-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Windows Chocolatey package #80
Changes from 3 commits
d82790e
e92e21c
ad2633a
1d48a24
b567d2b
93a79cf
6e48c0e
e8ce2c8
9407bad
21a4536
4126965
a71593f
c9f8c8b
ef8e2b6
4d0ffa6
8b22a89
872a493
eff5c22
25c4738
8250358
f40609d
8a92467
baf75e3
9efa805
a4d6682
074620f
310655e
f5f0d33
0697b75
ea49e5a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- Do not remove this test for UTF-8: if “Ω” doesn’t appear as greek uppercase omega letter enclosed in quotation marks, you should use an editor that supports UTF-8, not this one. --> | ||
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd"> | ||
<metadata> | ||
<id>algokit</id> | ||
<version></version> <!-- note, no semantic version 2.0 support. So beta.17 needs to be beta17 https://github.com/chocolatey/choco/issues/1610 --> | ||
<packageSourceUrl>https://github.com/algorandfoundation/algokit-cli/blob/main/scripts/chocolatey</packageSourceUrl> | ||
<owners>wilsonwaters</owners> | ||
<title>algokit</title> | ||
<authors>Algorand Foundation</authors> | ||
<projectUrl>https://www.algorand.foundation/developers</projectUrl> | ||
<!-- <iconUrl>http://rawcdn.githack.com/__REPLACE_YOUR_REPO__/master/icons/algokit.png</iconUrl> --> | ||
<licenseUrl>https://github.com/algorandfoundation/algokit-cli/blob/main/LICENSE</licenseUrl> | ||
<requireLicenseAcceptance>false</requireLicenseAcceptance> | ||
<projectSourceUrl>https://github.com/algorandfoundation/algokit-cli</projectSourceUrl> | ||
<!-- <docsUrl>At what url are the software docs located?</docsUrl> --> | ||
<bugTrackerUrl>https://github.com/algorandfoundation/algokit-cli/issues</bugTrackerUrl> | ||
<tags>algokit algorand developers python typescript hello-world smart-contract beaker</tags> | ||
<summary>The Algorand AlgoKit CLI is the one-stop shop tool for developers building on the Algorand network.</summary> | ||
<description><![CDATA[AlgoKit gets developers of all levels up and running with a familiar, fun and productive development environment in minutes. | ||
The goal of AlgoKit is to help developers build and launch secure, automated production-ready applications rapidly. | ||
]]></description> | ||
<!-- <releaseNotes>__REPLACE_OR_REMOVE__MarkDown_Okay</releaseNotes> --> | ||
<dependencies> | ||
<dependency id="python3" version="3.10" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is interesting. It means that if you already have python installed globally then god knows what this will do (worth testing?). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right. Python version hell. For me, it installed a new version and added it at the beginning of my path. Everything still worked, but yea, that might annoy people who already have a specific version of python installed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think for some chocolatey packages it will try to determine if it's already been installed manually and "take over". But doesn't seem to do this for python (fortunately?) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we depend on >=3.10.0 here instead? |
||
</dependencies> | ||
</metadata> | ||
<files> | ||
<file src="tools\**" target="tools" /> | ||
<file src="..\..\..\dist\algokit*.whl" target="tools" /> | ||
</files> | ||
</package> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 Algorand Foundation | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
VERIFICATION | ||
Verification is intended to assist the Chocolatey moderators and community | ||
in verifying that this package's contents are trustworthy. | ||
|
||
Official algokit releases can be found on the Githib project page | ||
https://github.com/algorandfoundation/algokit-cli/releases/ | ||
A checksum can be generated from corresponding .whl file and compared with the checksum | ||
specified in the chocolatey release. | ||
|
||
Algorand Foundation are the authors of this software and maintainers of the Chocolatey package. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)" | ||
|
||
# run refreshenv to ensure python is on path. If it was just installed | ||
$ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1" | ||
if (Test-Path($ChocolateyProfile)) { | ||
Import-Module "$ChocolateyProfile" | ||
} | ||
else { | ||
Write-Output "couldn't find chocolatey profile script" | ||
} | ||
RefreshEnv.cmd | ||
|
||
# ensure pipx is installed | ||
python -m pip --disable-pip-version-check install --user pipx | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we assume There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If python has been installed successfully as a dependency, then I can't see why not? Do you think I should do a test and print a useful error message (rather than a slightly obscure "command not found" error). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand the logic here, but this makes our package not idempotent due to also requiring pipe for uninstall. Can we make There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's no pipx package for chocolatey. |
||
if ($LASTEXITCODE -ne 0) { | ||
Throw "Error installing pipx" | ||
} | ||
|
||
# work out the wheel name and make sure there wasn't a packaging error | ||
$wheelFileName = Get-ChildItem -File -Filter $env:ChocolateyPackageName*.whl $toolsDir | ||
if ($wheelFileName.count -ne 1) { | ||
Throw "Packaging error. nupkg contained $($wheelFile.count) wheel files" | ||
} | ||
|
||
# determine if the package is already installed. In which case, uninstall it first | ||
# Note - pipx upgrade does not work with local files | ||
$pipxListOutput = pipx list | ||
wilsonwaters marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if ($LASTEXITCODE -ne 0) { | ||
Throw "Error searching for existing packages" | ||
} | ||
if ($pipxListOutput -match "algokit.*") { | ||
wilsonwaters marked this conversation as resolved.
Show resolved
Hide resolved
|
||
pipx uninstall $env:ChocolateyPackageName | ||
if ($LASTEXITCODE -ne 0) { | ||
Throw "Error removing existing version" | ||
} | ||
} | ||
|
||
# install the bundled wheel file. | ||
# For some reason pipx outputs normal messages to stderr, which causes choco to complain. Redirect stderr to stdout and rely on return value for errors | ||
pipx install $wheelFileName[0].FullName 2>&1 | ||
if ($LASTEXITCODE -ne 0) { | ||
Throw "Error installing $($wheelFileName[0].FullName)" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# ensure pipx is installed. Just in case someone has removed it manually | ||
python -m pip --disable-pip-version-check install --user pipx | ||
if ($LASTEXITCODE -ne 0) { | ||
Throw "Error configuring pipx for uninstalling" | ||
} | ||
|
||
# zap it | ||
pipx uninstall $env:ChocolateyPackageName | Tee-Object -Variable cmdOutput | ||
wilsonwaters marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if ($LASTEXITCODE -ne 0) { | ||
if ($cmdOutput -match "Nothing to uninstall" ) { | ||
Write-Output "$($env:ChocolateyPackageName) already uninstalled by pipx. Ignoring" | ||
} | ||
else { | ||
Throw "Error running pipx uninstall $($env:ChocolateyPackageName)" | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we switch to the fixed version of copier while we're waiting for copier-org/copier#890 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep