setup-python icon indicating copy to clipboard operation
setup-python copied to clipboard

Unable to use asdf-vm based version-file

Open hjpotter92 opened this issue 2 years ago • 3 comments

I was using setup-node action, and didn't face this problem when using .tool-versions file; so i was surprised hitting this error in setup-python action.

Description: When using the action, I expected it to work seamlessly with .tool-versions file that asdf-vm generates.

Action version: Using @v4

Platform:

  • [x] Ubuntu

Runner type:

  • Github's runner

Tools version:

Repro steps:

  • Create a asdf based version file:

    asdf local python 3.10.9
    asdf local poetry 1.3.1
    
  • Use the generated .tool-versions file in github action:

    
    - uses: actions/setup-python@v4
      with:
        python-version-file: .tool-versions
        cache: poetry
    
  • Fails to install python.

Expected behavior:

Parser should be smart to also identify other version managers

Actual behavior:

Resolved architecture/.tool-versions as python 3.10.9
poetry 1.3.1

Version python 3.10.[9](https://github.com/XXXXXXXXXXXXXXXX/actions/runs/3738XXXXXX/jobs/63453738XXXXXX#step:4:10)
poetry 1.3.1
 was not found in the local cache
Error: The version 'python 3.[10](https://github.com/XXXXXXXXXXXXXXXX/actions/runs/3738XXXXXX/jobs/63453738XXXXXX#step:4:11).9
poetry 1.3.1
' with architecture 'x64' was not found for Ubuntu 22.04.

hjpotter92 avatar Dec 21 '22 12:12 hjpotter92

Hello @hjpotter92 ! Thank you for reporting this! We'll consider updating the parsing logic for the python-version-file input.

MaksimZhukov avatar Dec 21 '22 13:12 MaksimZhukov

As a workaround you can add a small intermediate step:

    - name: Determine versions
      shell: bash -leo pipefail {0}
      id: get_versions
      run: |
        python="$(grep -v '#' .tool-versions | grep python | awk '{print $2}')"
        echo "python=${python}" >> $GITHUB_OUTPUT

    - name: Install Python
      uses: actions/setup-python@v4
      with:
        python-version: ${{ steps.get_versions.outputs.python }}

goetzc avatar Oct 03 '23 18:10 goetzc

You can even parse the Python version in a single step:

python_version="$(grep --perl-regexp --only-matching '(?<=python )(\d+\.){2}\d+' .tool-versions)"

Kurt-von-Laven avatar Oct 18 '23 04:10 Kurt-von-Laven