GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — v3.1's default poetry example uses wrong python version · Issue #374 · actions/setup-python

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

New issue
Copy link
New issue
Copy link
Closed
Closed
v3.1's default poetry example uses wrong python version#374
Copy link
Assignees
dmitry-shibanov
Labels
bugSomething isn't working

Description

@tony
tony
opened on Apr 3, 2022
Issue body actions

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): Poetry using the wrong Python version (not related to pyenv) python-poetry/poetry#655
  • Poetry uses wrong Python version python-poetry/poetry#4101
  • 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.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.

Reacted by Olli Paakkunainen, Junpei Kawamoto, Ben Falk, Lenon, Sam Thomson, Mikael Briolet, Robert Shecter, Thorben Dahl, Takahiro Ueda, Carlos Pereira Atencio and 5 more
Reacted by Mikko Ohtamaa

Activity

Next
  1. tony
    added
    bugSomething isn't working
    needs triage
    on Apr 3, 2022
  2. 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[/+] on Apr 3, 2022
  3. dmitry-shibanov
    self-assigned this
    on Apr 3, 2022
  4. dmitry-shibanov
    removed
    needs triage
    on Apr 3, 2022
  5. matthew-mcallister commented on Apr 4, 2022

    @matthew-mcallister
    matthew-mcallister
    on Apr 4, 2022
    More actions

    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
  6. dhvcc commented on Apr 5, 2022

    @dhvcc
    dhvcc
    on Apr 5, 2022
    Contributor
    More actions

    @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

  7. falkben commented on Apr 5, 2022

    @falkben
    falkben
    on Apr 5, 2022
    More actions

    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
    Reacted by Lenon, Sam Thomson, Marco Aguiar, Mikael Briolet, Kazuya Takei, Mahmoud Hanafy, rinat715, Miyar, Stephen Fuqua, Sylvain Lesage and 14 more
  8. tony
    added a commit that references this issue on Apr 9, 2022

    ci(docs): fix poetry (temporarily)

    e5d6cf3
  9. dogweather commented on Apr 10, 2022

    @dogweather
    dogweather
    on Apr 10, 2022
    More actions

    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

  10. dogweather commented on Apr 10, 2022

    @dogweather
    dogweather
    on Apr 10, 2022
    More actions

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

  11. dogweather commented on Apr 10, 2022

    @dogweather
    dogweather
    on Apr 10, 2022
    More actions

    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.

  12. dhvcc commented on Apr 10, 2022

    @dhvcc
    dhvcc
    on Apr 10, 2022
    Contributor
    More actions

    @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

  13. sambhav
    added a commit that references this issue on May 28, 2022

    Add Python 3.10 to CI (#161)

    48531b1
  14. shelper commented on Jun 10, 2022

    @shelper
    shelper
    on Jun 10, 2022
    More actions

    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

  15. 7 remaining items

  16. donfiguerres
    added 3 commits that reference this issue on Jul 25, 2022

    Trying workaround with Poetry caching issue.

    5efaaef

    Trying workaround with Poetry caching issue.

    5403a30

    Trying workaround with Poetry caching issue.

    a1d961c
  17. dmitry-shibanov commented on Aug 10, 2022

    @dmitry-shibanov
    dmitry-shibanov
    on Aug 10, 2022
    Contributor
    More actions

    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 Piere
    Reacted by Mikko Ohtamaa
  18. Tenzer commented on Aug 11, 2022

    @Tenzer
    Tenzer
    on Aug 11, 2022
    More actions

    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!

    Reacted by vs and Shelper
  19. dmitry-shibanov commented on Aug 15, 2022

    @dmitry-shibanov
    dmitry-shibanov
    on Aug 15, 2022
    Contributor
    More actions

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

  20. dmitry-shibanov
    closed this as completedon Aug 15, 2022
  21. tony
    added a commit that references this issue on Aug 16, 2022

    build,ci: Python 3.10.6, setup-python@v4

    ae5c23c
  22. caarlos0
    added a commit that references this issue on Aug 19, 2022

    chore(deps): bump github/codeql-action from 2.1.18 to 2.1.19 (#3325)

    9d2206f
  23. omBratteng commented on Aug 31, 2022

    @omBratteng
    omBratteng
    on Aug 31, 2022
    More actions

    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ñez
  24. dogweather commented on Aug 31, 2022

    @dogweather
    dogweather
    on Aug 31, 2022
    More actions

    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?

  25. omBratteng commented on Aug 31, 2022

    @omBratteng
    omBratteng
    on Aug 31, 2022
    More actions

    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

    Reacted by Robert Shecter, call and Abraham Briñez
    Reacted by Robert Shecter and call
  26. ian-noaa
    added 2 commits that reference this issue on Oct 14, 2022

    Change the poetry env within the poetry install step

    940d49b

    Disable Python installation caching

    4106228
  27. alexdewar
    added a commit that references this issue on May 30, 2024

    Fix: Force poetry to use specific environment

    99fb6e0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @dmitry-shibanov
    dmitry-shibanov

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.