Skip to content

Hatch doesn’t find Python versions other than its own and …/python{,3} on Linux #1395

@flying-sheep

Description

@flying-sheep

If I configure a project with requires_python '>=3.12', on my system I see this error:

else 'no compatible Python distribution available'

I don’t understand what the code is supposed to do. It requires either an env variable or one of two functions to not return None:

  1. _get_available_distribution seems to call hatch.python.resolve.get_compatible_distributions, and then it removes the “installed distribution”

    compatible_distributions = get_compatible_distributions()
    for installed_distribution in self.python_manager.get_installed():
    compatible_distributions.pop(installed_distribution, None)

    get_compatible_distributions() returns everything hatch can download:

    $ ~/.local/pipx/venvs/hatch/bin/python -c 'from hatch.python.resolve import get_compatible_distributionsprint(get_compatible_distributions().keys())'
    dict_keys(['3.7', '3.8', '3.9', '3.10', '3.11', '3.12', 'pypy2.7', 'pypy3.9', 'pypy3.10'])

    In my case self.python_manager.get_installed().keys() == {'3.12'}, so _get_available_distribution returns None

  2. _find_existing_interpreter calls virtualenv.discovery.builtin.propose_interpreters, which yields this on my system:

    PythonInfo(spec=CPython3.11.8.final.0-64, system=/usr/bin/python3.11, exe=/home/phil/.local/pipx/venvs/hatch/bin/python, platform=linux, version='3.11.8 (main, Feb 12 2024, 14:50:05) [GCC 13.2.1 20230801]', encoding_fs_io=utf-8-utf-8)
    PathPythonInfo(spec=CPython3.11.8.final.0-64, exe=/usr/bin/python, platform=linux, version='3.11.8 (main, Feb 12 2024, 14:50:05) [GCC 13.2.1 20230801]', encoding_fs_io=utf-8-utf-8)

    so that function also returns None.

I can work around this using

pipx install --python=python3.12 hatch

but this should still be fixed. I’d be happy to help, but I don’t know what the intended semantics of _get_available_distribution and _find_existing_interpreter are: Which one of these is supposed to return /usr/bin/python3.12?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions