Skip to content
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

Merged
merged 30 commits into from
Jan 4, 2023
Merged

feat: Windows Chocolatey package #80

merged 30 commits into from
Jan 4, 2023

Conversation

wilsonwaters
Copy link
Contributor

@wilsonwaters wilsonwaters commented Dec 12, 2022

closes #79

Windows users can choco install algokit and get the latest production version of algokit installed to their machine

TODO

  • Create package .nuspec file
  • Create python 3.10 as a dependency
  • write chocolateyinstall.ps1 to install algokit from bundled wheel file using pipx
  • write chocolateyuninstall.ps1 to remove algokit using pipx
  • Github actions to upload new package on manual release
  • Github actions to upload new prelease package continuous deployment (automatic based on version slash notation x.y.x-beta)
  • bundle pre-built wheel file as part of github actions
  • determine wheel file version and pass to choco pack
  • set .nuspec Project URL and documentation URLs (when known) (used https://github.com/algorandfoundation/algokit-cli) for now
  • set icon (png, transparent, 128x or higher) and host it somewhere (used https://www.algorand.com/assets/media-kit/logos/logo-marks/png/algorand_logo_mark_black.png for now)
  • Create https://community.chocolatey.org/ API key used to publish package (Alessandro? Add key to Github secrets) (requested from Shane McGovern)
  • Confirm choco upgrade algokit to upgrade to latest available version
  • Confirm choco uninstall algokit to remove algokit cli from a system
  • Add comments to install docs indicting that using chocolatey will install a new python and add it to start of your path (potentially clobbering any pre-installed python version). If you already have python installed, suggest to use the pipx method. Alternatively, run choco install --ignoredependencies algokit to use existing python (use at own risk)
  • remove dependency on crazy-max/ghaction-chocolatey. Call chocolatey directly in a windows again (it should even be pre-installed!)

@github-actions
Copy link

github-actions bot commented Dec 12, 2022

Coverage

Coverage Report
FileStmtsMissCoverMissing
src/algokit
   __init__.py15753%6–13, 17–24, 32–34
   __main__.py220%1–3
src/algokit/cli
   completions.py103199%91
   init.py1651690%57, 204–205, 236, 239–241, 252, 290, 327, 336–338, 341–346, 361
   sandbox.py84199%155
src/algokit/core
   bootstrap.py1331688%109, 129, 201, 204, 210–224
   click_extensions.py472057%40–43, 50, 56, 67–68, 73–74, 79–80, 91, 104–114
   conf.py30487%13, 17, 25, 27
   doctor.py54394%63–65
   log_handlers.py68987%44–45, 50–51, 63, 112–116, 125
   proc.py44198%95
   sandbox.py112794%86, 151, 167, 182–184, 199
   version_prompt.py70987%27–28, 33, 52–55, 66, 76, 105
TOTAL11149691% 

Tests Skipped Failures Errors Time
156 0 💤 0 ❌ 0 🔥 9.393s ⏱️

@wilsonwaters
Copy link
Contributor Author

Building locally

  • ensure wheel file is built poetry build (make sure there's only a single file in dist)
  • update version in algokit.nuspec
  • cd .\scripts\chocolatey\algokit
  • choco pack
  • choco apikey --api-key [API_KEY_HERE] -source https://push.chocolatey.org/
  • choco push --source https://push.chocolatey.org/

Installing/testing locally

  • choco install algokit -pre --source "'.;https://community.chocolatey.org/api/v2/'" -y
  • choco uninstall algokit -y
  • choco upgrade algokit -pre --source "'.;https://community.chocolatey.org/api/v2/'" -y

@@ -10,7 +10,7 @@ readme = "README.md"
python = "^3.10"
click = "^8.1.3"
httpx = "^0.23.1"
copier = "^7.0.1"
Copy link
Contributor Author

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 ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep

]]></description>
<!-- <releaseNotes>__REPLACE_OR_REMOVE__MarkDown_Okay</releaseNotes> -->
<dependencies>
<dependency id="python3" version="3.10" />
Copy link
Contributor

Choose a reason for hiding this comment

The 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?).

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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?)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we depend on >=3.10.0 here instead?

RefreshEnv.cmd

# ensure pipx is installed
python -m pip --disable-pip-version-check install --user pipx
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we assume python will work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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).

Copy link
Contributor

Choose a reason for hiding this comment

The 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 pipx a dependency instead? This would mirror our home-brew package, and pipx is actually an (optional) runtime dependency (for installing poetry if not already installed during bootstrap)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no pipx package for chocolatey.

if ($wheelFileName.count -ne 1) {
Throw "Packaging error. build artifact contained $($wheelFileName.count) normally named wheel files"
}
if ($wheelFileName[0].Name -Match '-([0-9]+\.[0-9]+\.[0-9]+)b?([0-9]*)-') {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shamelessly stolen from @daniel-makerx here

@@ -105,3 +105,12 @@ jobs:
name: algokit-cli
path: dist/algokit-*-py3-none-any.whl
if-no-files-found: error

cd-publish-release-packages:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I gathered having a separate job (and yaml file) for packages makes sense? We could potentially publish all our packages from the publish-release-packages.yaml files (i.e. brew and chocolatey. And potentially pypi). Keeps all package publishing together and allows us to trigger them all based on a single condition.

Otherwise I'm happy to move the whole publish-release-packages.yaml here into cd.yaml

@wilsonwaters wilsonwaters changed the title WIP: Windows Chocolatey package Windows Chocolatey package Dec 20, 2022
@wilsonwaters
Copy link
Contributor Author

Seems the Chocolaty community repo automated tests failed due to the copier package not installing. The image they use to test installing the packages does not have git, so it couldn't use our hacky fix in pyproject.toml pointing to my github fork of copier.

We'll need to wait until copier release an alpha package to pypi...

2022-12-20 18:01:46,878 5092 [INFO ] - pip seemed to fail to build package:
2022-12-20 18:01:46,894 5092 [INFO ] -     copier@
2022-12-20 18:01:46,894 5092 [INFO ] - System.Management.Automation.RemoteException
2022-12-20 18:01:46,910 5092 [INFO ] - Some possibly relevant errors from pip install:
2022-12-20 18:01:46,910 5092 [INFO ] -     ERROR: Error [WinError 2] The system cannot find the file specified while executing command git version
2022-12-20 18:01:46,925 5092 [INFO ] -     ERROR: Cannot find command 'git' - do you have 'git' installed and in your PATH?

https://gist.github.com/choco-bot/f7f5353bab35c18811de2a2843516c18

@robdmoore robdmoore changed the title Windows Chocolatey package feat: Windows Chocolatey package Jan 4, 2023
@robdmoore robdmoore merged commit 3f4bb04 into main Jan 4, 2023
@robdmoore robdmoore deleted the chocolatey-package branch January 4, 2023 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Set up Windows Chocolatey installation
3 participants