setup-python: v3.1's default poetry example uses wrong python version
Description:
The default configuration example for #281’s new example installs poetry before actions/setup-python
is ran.
This can run into some funky issues in poetry itself since poetry may stick to use the python version it was installed in.
This may be on the poetry side. I’m not sure:
- Oldest post I could find (closed): https://github.com/python-poetry/poetry/issues/655
- https://github.com/python-poetry/poetry/issues/4101
- ~~See if in 1.2.x prerelease PR helps: https://github.com/python-poetry/poetry/pull/4852~~: Seems not to https://github.com/tony/setup-python-poetry-version-example/blob/main/.github/workflows/experiment-with-poetry-prerelease.yml
Action version: v3.1
Platform:
- Ubuntu
- macOS
- Windows
Runner type:
- Hosted
- Self-hosted
Tools version:
Repro steps:
Reproduction repo: https://github.com/tony/setup-python-poetry-version-example
-
https://github.com/tony/setup-python-poetry-version-example/tree/main/.github/workflows
- default-example.yml
- default-example-install-poetry.yml
- experiment-with-poetry-prerelease.yml
- workaround.yml by trigger
poetry env use <version>
to force version
Runs: https://github.com/tony/setup-python-poetry-version-example/actions
Expected behavior:
poetry
should respect the version in actions/setup-python
Actual behavior:
It uses the python version poetry
was installed with before actions/setup-python
was ran.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 16
- Comments: 18 (6 by maintainers)
Commits related to this issue
- ci(docs): fix poetry (temporarily) See also: https://github.com/actions/setup-python/issues/374 — committed to vcs-python/libvcs by tony 2 years ago
- Try to fix poetry python version to use see https://github.com/actions/setup-python/issues/374#issuecomment-1088938718 — committed to gmsantos/cruft by gmsantos 2 years ago
- Try to fix poetry python version to use see https://github.com/actions/setup-python/issues/374#issuecomment-1088938718 — committed to gmsantos/cruft by gmsantos 2 years ago
- Make poetry use the correct python version see https://github.com/actions/setup-python/issues/374#issuecomment-1088938718 windows hosts cannot find python3.x in $PATH, but after setup-python the pyt... — committed to gmsantos/cruft by gmsantos 2 years ago
- Add Python 3.10 to CI (#161) * Run tests in python 3.10 * Set python version as string if someone tries to update to 3.10, it will fail and try to install pyhton 3.1 because integer * Renam... — committed to cruft/cruft by gmsantos 2 years ago
- Trying workaround with Poetry caching issue. Using the workaround posted here: https://github.com/actions/setup-python/issues/374#issuecomment-1088938718 — committed to donfiguerres/COVID-19-Tracker-PH by donfiguerres 2 years ago
- Trying workaround with Poetry caching issue. Using the workaround posted here: https://github.com/actions/setup-python/issues/374#issuecomment-1088938718 — committed to donfiguerres/COVID-19-Tracker-PH by donfiguerres 2 years ago
- Trying workaround with Poetry caching issue. Using the workaround posted here: https://github.com/actions/setup-python/issues/374#issuecomment-1088938718 — committed to donfiguerres/COVID-19-Tracker-PH by donfiguerres 2 years ago
- Trying workaround with Poetry caching issue. Using the workaround posted here: https://github.com/actions/setup-python/issues/374#issuecomment-1088938718 Former-commit-id: 184c35e224256ea76110e100f3... — committed to donfiguerres/COVID-19-Tracker-PH by donfiguerres 2 years ago
- Trying workaround with Poetry caching issue. Using the workaround posted here: https://github.com/actions/setup-python/issues/374#issuecomment-1088938718 Former-commit-id: ddf90f7076f8f5cd1191cc8182... — committed to donfiguerres/COVID-19-Tracker-PH by donfiguerres 2 years ago
- Trying workaround with Poetry caching issue. Using the workaround posted here: https://github.com/actions/setup-python/issues/374#issuecomment-1088938718 Former-commit-id: 184c35e224256ea76110e100f3... — committed to donfiguerres/COVID-19-Tracker-PH by donfiguerres 2 years ago
- build,ci: Python 3.10.6, setup-python@v4 This was originally added in #316 but retracted due to https://github.com/actions/setup-python/issues/374. In recent versions this python version issue has ap... — committed to vcs-python/libvcs by tony 2 years ago
- chore(deps): bump github/codeql-action from 2.1.18 to 2.1.19 (#3325) ⚠️ Dependabot is rebasing this PR ⚠️ Rebasing might not happen immediately, so don't worry if this takes some time. Note: if yo... — committed to goreleaser/goreleaser by dependabot[bot] 2 years ago
- Change the poetry env within the poetry install step Each step runs in its own process in GitHub Actions so environment changes are not preserved between steps. I may need to add this to the `poetry ... — committed to NOAA-GSL/unified-graphics by ian-noaa 2 years ago
- Disable Python installation caching It sounds like Poetry will grab the Python env from the cache. The cached python is incorrect so hopefully this will result in the correct Python version. See: ht... — committed to NOAA-GSL/unified-graphics by ian-noaa 2 years ago
You can get around this problem by telling
poetry
to use the same version of python as installed bysetup-python
with thepoetry env use
commandThis has been working for me:
Unfortunately, poetry is still broken with v4.
First I ran this, to get a list of the caches, in this case, there was only one.
Then I ran this, to delete the cache, based off of the cache ID in the previous command.
More information available here: https://docs.github.com/en/rest/actions/cache
I encountered this issue as well, and spent some time trying to figure out why this was still happening after upgrading the action to v4.2.0. It is cache, it had the wrong python version cached.
To solve it, I used the GitHub API to get a list of caches, and then delete it. Once done, I re-ran the workflow, and it rebuilt the cache and had the correct python version.
Hello everyone. Sorry for the late response. We released a new version of the action and updated the major tag with possible fix. Could you please confirm that everything works as expected.
I can confirm the latest version (4.2.0) fixes the problem in the places I’ve previously had to add the
poetry env use 3.10
workaround. Thanks!How hard would it be to defer caching to a later step? Then you wouldn’t have to rely on the system version of Python. I’m thinking something like this: