Skip to content

pre-commitu-uv decides to use unexpected python version #28

@ssbarnea

Description

@ssbarnea

Initially raised on tox-dev/tox#3428 but the more I dig into it, the more I believe that is caused by pre-commitu-uv itself, and I will explain why:

  • default python on system is not using 3.8
  • tox environment is not using python 3.8
  • asdf is not configured to use python 3.8
  • uv is not configured to pin python 3.8

Still, at runtime it decides to use python3.9 for a pre-commit hook that does not really supports python3.8 and fails to install it.

AFAIK, pre-commit itself defaults to prefer current (default) python version.

❯ which -a python3
/Users/ssbarnea/.asdf/shims/python3
/usr/local/bin/python3
/Library/Frameworks/Python.framework/Versions/3.12/bin/python3
/opt/homebrew/bin/python3
/usr/bin/python3
❯ uv  python list
cpython-3.13.0+freethreaded-macos-aarch64-none    /Users/ssbarnea/.asdf/installs/python/3.13.0t/bin/python3.13t
cpython-3.13.0+freethreaded-macos-aarch64-none    <download available>
cpython-3.13.0-macos-aarch64-none                 /opt/homebrew/opt/python@3.13/bin/python3.13 -> ../Frameworks/Python.framework/Versions/3.13/bin/python3.13
cpython-3.13.0-macos-aarch64-none                 /Users/ssbarnea/.asdf/installs/python/3.13.0/bin/python3.13
cpython-3.13.0-macos-aarch64-none                 /Users/ssbarnea/.config/uv/python/cpython-3.13.0-macos-aarch64-none/bin/python3 -> python3.13
cpython-3.12.7-macos-aarch64-none                 /opt/homebrew/opt/python@3.12/bin/python3.12 -> ../Frameworks/Python.framework/Versions/3.12/bin/python3.12
cpython-3.12.7-macos-aarch64-none                 /Users/ssbarnea/.asdf/installs/python/3.12.7/bin/python3.12
cpython-3.12.7-macos-aarch64-none                 /Users/ssbarnea/.asdf/installs/python/3.12.7/bin/python3 -> python3.12
cpython-3.12.7-macos-aarch64-none                 /Users/ssbarnea/.asdf/installs/python/3.12.7/bin/python -> python3.12
cpython-3.12.7-macos-aarch64-none                 /Users/ssbarnea/.config/uv/python/cpython-3.12.7-macos-aarch64-none/bin/python3 -> python3.12
cpython-3.12.0a4-macos-aarch64-none               /usr/local/bin/python3.12 -> ../../../Library/Frameworks/Python.framework/Versions/3.12/bin/python3.12
cpython-3.12.0a4-macos-aarch64-none               /usr/local/bin/python3 -> ../../../Library/Frameworks/Python.framework/Versions/3.12/bin/python3
cpython-3.12.0a4-macos-aarch64-none               /Library/Frameworks/Python.framework/Versions/3.12/bin/python3.12
cpython-3.12.0a4-macos-aarch64-none               /Library/Frameworks/Python.framework/Versions/3.12/bin/python3 -> python3.12
cpython-3.11.10-macos-aarch64-none                /opt/homebrew/opt/python@3.11/bin/python3.11 -> ../Frameworks/Python.framework/Versions/3.11/bin/python3.11
cpython-3.11.10-macos-aarch64-none                /Users/ssbarnea/.config/uv/python/cpython-3.11.10-macos-aarch64-none/bin/python3 -> python3.11
cpython-3.10.15-macos-aarch64-none                /opt/homebrew/opt/python@3.10/bin/python3.10 -> ../Frameworks/Python.framework/Versions/3.10/bin/python3.10
cpython-3.10.15-macos-aarch64-none                /Users/ssbarnea/.config/uv/python/cpython-3.10.15-macos-aarch64-none/bin/python3 -> python3.10
cpython-3.9.20-macos-aarch64-none                 /Users/ssbarnea/.config/uv/python/cpython-3.9.20-macos-aarch64-none/bin/python3 -> python3.9
cpython-3.9.6-macos-aarch64-none                  /Applications/Xcode.app/Contents/Developer/usr/bin/python3 -> ../../Library/Frameworks/Python3.framework/Versions/3.9/bin/python3
cpython-3.8.20-macos-aarch64-none                 /Users/ssbarnea/.config/uv/python/cpython-3.8.20-macos-aarch64-none/bin/python3 -> python3.8
pypy-3.10.14-macos-aarch64-none                   <download available>
pypy-3.9.19-macos-aarch64-none                    <download available>
pypy-3.8.16-macos-aarch64-none                    <download available>
$ tox -e fix   
fix: recreate env because python changed version_info=[3, 12, 7, 'final', 0]->[3, 9, None, '', 0]
fix: remove tox env folder /Volumes/code/os/tox/.tox/fix
fix: venv> /Users/ssbarnea/.asdf/installs/python/3.12.7/bin/uv venv -p 3.9 --allow-existing /Volumes/code/os/tox/.tox/fix
fix: install_dependency-groups> /Users/ssbarnea/.asdf/installs/python/3.12.7/bin/uv pip install 'pre-commit-uv>=4.1.3'
fix: commands[0]> pre-commit run --all-files --show-diff-on-failure
[INFO] Installing environment for https://github.com/tox-dev/pyproject-fmt.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Using pre-commit with uv 0.4.28 via pre-commit-uv 4.1.3
An unexpected error has occurred: CalledProcessError: command: ('/Volumes/code/os/tox/.tox/fix/bin/uv', 'pip', 'install', '.')
return code: 1
stdout: (none)
stderr:
    Using Python 3.8.20 environment at py_env-python3
      × No solution found when resolving dependencies:
      ╰─▶ Because the current Python version (3.8.20) does not satisfy Python>=3.9
          and pyproject-fmt==2.4.3 depends on Python>=3.9, we can conclude that
          pyproject-fmt==2.4.3 cannot be used.
          And because pre-commit-placeholder-package==0.0.0
          depends on pyproject-fmt==2.4.3, we can conclude that
          pre-commit-placeholder-package==0.0.0 cannot be used.
          And because only pre-commit-placeholder-package==0.0.0 is available and
          you require pre-commit-placeholder-package, we can conclude that your
          requirements are unsatisfiable.
Check the log at /Users/ssbarnea/.cache/pre-commit/pre-commit.log
``

Metadata

Metadata

Assignees

No one assigned

    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