pypa / hatch

Modern, extensible Python project management
https://hatch.pypa.io/latest/
MIT License
6.1k stars 309 forks source link

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

Open sumpfralle opened 2 days ago

sumpfralle commented 2 days ago

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/

ofek commented 2 days ago

That doesn't exist on Windows

image

sumpfralle commented 22 hours ago

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:

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