Repository navigation
v3.1's default poetry example uses wrong python version #374
Description
Activity
- changed the title
[-]actions/setup-python v3.1's default poetry configuration example uses wrong python version[/-][+]v3.1's default poetry example uses wrong python version[/+]on Apr 3, 2022 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:
- name: Install Python uses: actions/setup-python@v3 with: # Install Python, skip caching python-version: ${{ matrix.python-version }} - name: Install poetry run: python -m pip install poetry - name: Cache Poetry deps uses: actions/setup-python@v3 with: # Restore cache, skip Python installation cache: poetry
Reacted by Junpei Kawamoto@matthew-mcallister @tony this action relies on poetry to tell it's config values. The problem with locking poetry onto 1 version can be solved by installing poetry with curl. This action wil help you https://github.com/snok/install-poetry. However, take note, that it's significantly slower than
pipx install poetryYou can get around this problem by telling
poetryto use the same version of python as installed bysetup-pythonwith thepoetry env usecommandThis has been working for me:
- uses: actions/checkout@v3 - name: Install poetry run: pipx install poetry - name: Setup Python uses: actions/setup-python@v3 with: python-version: "3.10" cache: "poetry" - name: Install dependencies run: | poetry env use "3.10" poetry install --no-interaction
Reacted by Lenon, Sam Thomson, Marco Aguiar, Mikael Briolet, Kazuya Takei, Mahmoud Hanafy, rinat715, Miyar, Stephen Fuqua, Sylvain Lesage and 14 more- added a commit that references this issue
on Apr 9, 2022 @falkben Your recipe works for me if I disable caching. Otherwise, it still uses the wrong Python. I introduced caching in the latest PR. I'm thinking I might need to delete the cache for some reason.
Well, I can't find a way to delete the cache, so I've disabled it for now, and the correct Python is used again on
master.@dogweather, for me it seems like poetry's ignoring your
poetry env usebecause it thinks that your're already using this env (since config/env values are retrieved from cache). While this behaviour is ok, the strange part is why does it execute the wrong version in the endsame for windows, see #425
and the workaround here does not work 'cuspoetry env use 3.xdoes not work, see python-poetry/poetry#21177 remaining items
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.
Reacted by Alexey and Robson PiereReacted by Mikko OhtamaaI 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.10workaround. Thanks!Reacted by vs and ShelperHello @Tenzer. Thank you for your response. For now I'm going to close the issue.
- added a commit that references this issue
on Aug 16, 2022 - added a commit that references this issue
on Aug 19, 2022 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.
Reacted by Robert Shecter, call and Abraham BriñezTo solve it, I used the GitHub API to get a list of caches, and then delete it.
How did you delete it? Where did you delete it from?
To solve it, I used the GitHub API to get a list of caches, and then delete it.
How did you delete it? Where did you delete it from?
First I ran this, to get a list of the caches, in this case, there was only one.
gh api \ -H "Accept: application/vnd.github+json" \ /repos/OWNER/REPO/actions/cachesThen I ran this, to delete the cache, based off of the cache ID in the previous command.
gh api \ --method DELETE \ -H "Accept: application/vnd.github+json" \ /repos/OWNER/REPO/actions/caches/CACHE_IDMore information available here: https://docs.github.com/en/rest/actions/cache
Reacted by Robert Shecter, call and Abraham BriñezReacted by Robert Shecter and call- added 2 commits that reference this issue
on Oct 14, 2022 - added a commit that references this issue
on May 30, 2024


Description:
The default configuration example for #281's new example installs poetry before
actions/setup-pythonis 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:
See if in 1.2.x prerelease PR helps: Add (experimental) option to use current active python to create venv ("pyenv way") python-poetry/poetry#4852: Seems not to https://github.com/tony/setup-python-poetry-version-example/blob/main/.github/workflows/experiment-with-poetry-prerelease.ymlAction version:
v3.1
Platform:
Runner type:
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
poetry env use <version>to force versionRuns: https://github.com/tony/setup-python-poetry-version-example/actions
Expected behavior:
poetryshould respect the version inactions/setup-pythonActual behavior:
It uses the python version
poetrywas installed with beforeactions/setup-pythonwas ran.