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

fix: prefer python3 over python when discovering the interpreter #1821

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sumpfralle
Copy link

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 #583

See #1820

[1] https://peps.python.org/pep-0394/

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/
@ofek
Copy link
Collaborator

ofek commented Nov 24, 2024

That doesn't exist on Windows

image

@sumpfralle
Copy link
Author

sumpfralle commented Nov 25, 2024

Indeed. This is also mentioned in PEP-394:

This PEP deliberately excludes any proposals relating to Microsoft Windows [..]

In light of this detail, I would suggest the following:

  • A) the proposed change of the order of preference (prefer python3 over python) in system_python is still valid
  • B) the other substitutions of python with python3 should be replaced with a global default value, I guess (based on the operating system: either python or python3)

Does that sound reasonable to you? If yes, then I could implement (B) within this PR.

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

Successfully merging this pull request may close these issues.

2 participants