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

environment type "system" ignores "python" setting #1820

Open
sumpfralle opened this issue Nov 23, 2024 · 0 comments
Open

environment type "system" ignores "python" setting #1820

sumpfralle opened this issue Nov 23, 2024 · 0 comments

Comments

@sumpfralle
Copy link

  1. minimal pyproject.toml file:
    [tool.hatch.envs.default]
    python = "/usr/bin/python3"
    type = "system"
  2. create environment: hatch --verbose env create default:
    Finished creating environment: default
    /usr/bin/python: No module named pip
    Finished installing project in development mode
    

I think, there are three issues here:

  • A) I guess, hatch should break with an error, if pip is unavailable.
  • B) hatch.env.system does not use the python setting of the environment.
    • Maybe this is intended? Only the virtual environment is documented at the moment. Thus, it is unclear, whether the python setting should be supported by the system environment, too. I just expected it here.
  • C) hatch prefers /usr/bin/python over /usr/bin/python3
    • Here on my Debian system /bin/bin/python is still pointing to Python2. This is a valid setup according to PEP-394.

This issue is related to #583. Maybe not all aspects of that issue were fixed by 90a77ef.

Regarding (C): I would suggest to reverse the order of search paths in env.plugin.interface (system_python).

sumpfralle added a commit to sumpfralle/hatch that referenced this issue Nov 24, 2024
Previously hatch used `python` as the default name of the interpreter.
This was not in line with PEP-394 [1], since `python` is still allowed
to point to a Python 2.x interpreter.
PEP-394 recommends to use `python3` in a system context and `python` in
the context of a virtual environment.

This change should not affect existing setups, since `python3` is
expected to exist under all circumstances (according to PEP-394).

The change will relieve users from the burden of adding
`python = /usr/bin/python3` to their environment configuration for hatch
in order to support setups, where a Python 2.x interpreter is
reachable via `python` (as specified in PEP-394).

The other occurrences of `python` within hatch's code seem to be used
within virtual environments (i.e. `python` is suitable here).

See pypa#583

See pypa#1820

[1] https://peps.python.org/pep-0394/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant