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

v3.1's default poetry example uses wrong python version #374

Closed
2 of 5 tasks
tony opened this issue Apr 3, 2022 · 18 comments
Closed
2 of 5 tasks

v3.1's default poetry example uses wrong python version #374

tony opened this issue Apr 3, 2022 · 18 comments
Assignees
Labels
bug Something isn't working

Comments

@tony
Copy link

tony commented Apr 3, 2022

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:

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

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.

@tony tony added bug Something isn't working needs triage labels Apr 3, 2022
@tony tony 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 Apr 3, 2022
@dmitry-shibanov dmitry-shibanov self-assigned this Apr 3, 2022
@matthew-mcallister
Copy link

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

@dhvcc
Copy link
Contributor

dhvcc commented Apr 5, 2022

@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 poetry

@falkben
Copy link

falkben commented Apr 5, 2022

You can get around this problem by telling poetry to use the same version of python as installed by setup-python with the poetry env use command

This 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

tony added a commit to vcs-python/libvcs that referenced this issue Apr 9, 2022
@dogweather
Copy link

Really weird: I do not get this error on a feature branch / PR:

Screen Shot 2022-04-10 at 1 25 53 PM

But I do get the wrong Python version after merged to master:

Screen Shot 2022-04-10 at 1 25 28 PM

@dogweather
Copy link

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

@dogweather
Copy link

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.

@dhvcc
Copy link
Contributor

dhvcc commented Apr 10, 2022

@dogweather, for me it seems like poetry's ignoring your poetry env use because 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 end

gmsantos added a commit to gmsantos/cruft that referenced this issue May 28, 2022
gmsantos added a commit to gmsantos/cruft that referenced this issue May 28, 2022
gmsantos added a commit to gmsantos/cruft that referenced this issue May 28, 2022
see actions/setup-python#374 (comment)

windows hosts cannot find python3.x in $PATH, but after
setup-python the python executable uses the correct version
sambhav pushed a commit to cruft/cruft that referenced this issue May 28, 2022
* 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

* Rename run-tests workflow to run_tests (consistency)

* Bump workflow actions, refactor python setup and cache

Based on https://github.com/actions/setup-python#caching-packages-dependencies

* Disable fast-fail

* Make poetry use the correct python version

see actions/setup-python#374 (comment)

windows hosts cannot find python3.x in $PATH, but after
setup-python the python executable uses the correct version

* Bump poetry deps

some builds are complainig about the lock file

Make it compatible with python 3.10
poetry update in python 3.10, macOS M1
@shelper
Copy link

shelper commented Jun 10, 2022

same for windows, see #425
and the workaround here does not work 'cus poetry env use 3.x does not work, see python-poetry/poetry#2117

@srittau
Copy link

srittau commented Jun 13, 2022

Unfortunately, poetry is still broken with v4.

@IvanZosimov
Copy link
Contributor

IvanZosimov commented Jun 29, 2022

Hello, everyone 👋 It's a well-known issue of the poetry. Poetry tends to use the system's version of the python. Workarounds from the comments above can be helpful.

@psychobolt
Copy link

psychobolt commented Jul 2, 2022

Somehow poetry will try to resolve the correct version after install, if project has a specific version

2022-07-02T22:52:39.4923852Z ##[group]Run poetry install
2022-07-02T22:52:39.4924106Z �[36;1mpoetry install�[0m
2022-07-02T22:52:39.4978618Z shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
2022-07-02T22:52:39.4978872Z env:
2022-07-02T22:52:39.4979142Z   pythonLocation: /opt/hostedtoolcache/Python/3.10.5/x64
2022-07-02T22:52:39.4979489Z   LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.10.5/x64/lib
2022-07-02T22:52:39.4979743Z ##[endgroup]
2022-07-02T22:52:39.8768892Z The currently activated Python version 3.8.10 is not supported by the project (^3.9).
2022-07-02T22:52:39.8769599Z Trying to find and use a compatible version. 
2022-07-02T22:52:39.9175522Z Using python3 (3.10.5)

@IvanZosimov
Copy link
Contributor

Hi, @psychobolt 👋 ! Thanks for the comment. but in that case, poetry just writes that it uses python 3.10.5, in fact, it proceeds to use 3.8.10 and because of that, your workflow can be failed later.

donfiguerres added a commit to donfiguerres/COVID-19-Tracker-PH that referenced this issue Jul 13, 2022
donfiguerres added a commit to donfiguerres/COVID-19-Tracker-PH that referenced this issue Jul 17, 2022
donfiguerres added a commit to donfiguerres/COVID-19-Tracker-PH that referenced this issue Jul 18, 2022
donfiguerres added a commit to donfiguerres/COVID-19-Tracker-PH that referenced this issue Jul 25, 2022
Using the workaround posted here:
actions/setup-python#374 (comment)

Former-commit-id: 184c35e
Former-commit-id: abea5f5cf51c765f090077e953d202ba9b875fe3
donfiguerres added a commit to donfiguerres/COVID-19-Tracker-PH that referenced this issue Jul 25, 2022
Using the workaround posted here:
actions/setup-python#374 (comment)

Former-commit-id: ddf90f7
Former-commit-id: 5ea8accbda113ec7612db6c8443a1876304e32d2
donfiguerres added a commit to donfiguerres/COVID-19-Tracker-PH that referenced this issue Jul 25, 2022
Using the workaround posted here:
actions/setup-python#374 (comment)

Former-commit-id: 184c35e
Former-commit-id: abea5f5cf51c765f090077e953d202ba9b875fe3
Former-commit-id: 5efaaef
@dmitry-shibanov
Copy link
Contributor

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.

@Tenzer
Copy link

Tenzer commented Aug 11, 2022

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!

@dmitry-shibanov
Copy link
Contributor

Hello @Tenzer. Thank you for your response. For now I'm going to close the issue.

tony added a commit to vcs-python/libvcs that referenced this issue Aug 16, 2022
This was originally added in #316 but retracted due to actions/setup-python#374. In recent versions this python version issue has apparently been fixed.
caarlos0 pushed a commit to goreleaser/goreleaser that referenced this issue Aug 19, 2022
⚠️  Dependabot is rebasing this PR ⚠️
Rebasing might not happen immediately, so don't worry if this takes some time.
Note: if you make any changes to this PR yourself, they will take precedence over the rebase.

Bumps github/codeql-action from 2.1.18 to 2.1.19.

Changelog
Sourced from github/codeql-action's changelog.

CodeQL Action Changelog
[UNRELEASED]
No user facing changes.
2.1.19 - 17 Aug 2022

Add the ability to filter queries from a code scanning run by using the query-filters option in the code scanning configuration file. #1098
In debug mode, debug artifacts are now uploaded even if a step in the Actions workflow fails. #1159
Update default CodeQL bundle version to 2.10.3. #1178
The combination of python2 and Pipenv is no longer supported. #1181

2.1.18 - 03 Aug 2022

Update default CodeQL bundle version to 2.10.2.  #1156

2.1.17 - 28 Jul 2022

Update default CodeQL bundle version to 2.10.1.  #1143

2.1.16 - 13 Jul 2022

You can now quickly debug a job that uses the CodeQL Action by re-running the job from the GitHub UI and selecting the "Enable debug logging" option. #1132
You can now see diagnostic messages produced by the analysis in the logs of the analyze Action by enabling debug mode. To enable debug mode, pass debug: true to the init Action, or enable step debug logging. This feature is available for CodeQL CLI version 2.10.0 and later. #1133

2.1.15 - 28 Jun 2022

CodeQL query packs listed in the packs configuration field will be skipped if their target language is not being analyzed in the current Actions job. Previously, this would throw an error. #1116
The combination of python2 and poetry is no longer supported. See actions/setup-python#374 for more details. #1124
Update default CodeQL bundle version to 2.10.0. #1123

2.1.14 - 22 Jun 2022
No user facing changes.
2.1.13 - 21 Jun 2022

Update default CodeQL bundle version to 2.9.4. #1100

2.1.12 - 01 Jun 2022

Update default CodeQL bundle version to 2.9.3. #1084

2.1.11 - 17 May 2022

Update default CodeQL bundle version to 2.9.2. #1074

2.1.10 - 10 May 2022


... (truncated)


Commits

f5d217b Merge pull request #1192 from github/update-v2.1.19-5502fefd
7c3d74c Move changelog note to right release
04ea3b1 Update changelog for v2.1.19
5502fef Merge pull request #1191 from github/edoardo/fix-upload-times
0349bb0 Fix TRAP cache upload timing
3154c4f Merge pull request #1190 from github/henrymercer/fix-debug-artifact-tests-on-...
b21cab9 Mock expect-error input to avoid errors in Action integration tests
219a937 Require test mode to be set to use expect-error input
ff9d53b Dump GitHub event in debug artifacts failure workflow
5f4cfb0 Merge pull request #1188 from github/edoardo/round-fields
Additional commits viewable in compare view




Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options

You can trigger Dependabot actions by commenting on this PR:

@dependabot rebase will rebase this PR
@dependabot recreate will recreate this PR, overwriting any edits that have been made to it
@dependabot merge will merge this PR after your CI passes on it
@dependabot squash and merge will squash and merge this PR after your CI passes on it
@dependabot cancel merge will cancel a previously requested merge and block automerging
@dependabot reopen will reopen this PR if it is closed
@dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
@dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
@dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
@dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@omBratteng
Copy link

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.

@dogweather
Copy link

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?

@omBratteng
Copy link

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/caches

Then 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_ID

More information available here: https://docs.github.com/en/rest/actions/cache

ian-noaa added a commit to NOAA-GSL/unified-graphics that referenced this issue Oct 14, 2022
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 run ...` commands as well. I hope it's unnecessary. Apparently
Poetry has some "well-known" issues with correctly detecting the
desired Python version. See:

* Poetry issue: python-poetry/poetry#655
* setup-python workaround: actions/setup-python#374 (comment)
ian-noaa added a commit to NOAA-GSL/unified-graphics that referenced this issue Oct 14, 2022
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: actions/setup-python#374 (comment)
alexdewar added a commit to ImperialCollegeLondon/FINESSE that referenced this issue May 30, 2024
Currently the poetry cache for the GitHub Actions appears not to be being used.

See: actions/setup-python#374
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests