Possible feature: Support .python-version
pyenv and Rye both use a .python-version file to define what version they use.
Pros
Hatch could use it as a default for hatch.envs.default.python, and it
- would simplify transition from Pyenv/Rye or interoperability with those projects.
- Could be used to implement #1097
Cons
- .python-version is not a standard
- It makes it a bit harder to reason about what version Hatch will default to (see below). I don’t know if this is a problem, as interrogating the used version is easy, and explicitly overriding it is easy, too.
Impact
It would make the fallback chain for the Python version look something like the following
hatch.envs.<env>.overrides.<matching condition>.pythonhatch.envs.<env>.pythonhatch.envs.default.python(assuminghatch.envs.<env>.template = 'default'or unspecified)- .python-version
- minimum version matching
project.requires_python
Thank you for expanding on how the resolution would work! I am open to this 🙂
Somewhat unrelated, but would this functionality be useful to you? https://github.com/pypa/hatch/discussions/1124#discussioncomment-7832642
Thank you for expanding on how the resolution would work! I am open to this 🙂
Let’s ask people if they want this. It was just an idea that I had to ease transition. I’m personally committed to Hatch lol
Somewhat unrelated, but would this functionality be useful to you? https://github.com/pypa/hatch/discussions/1124#discussioncomment-7832642
answered there
since the proposed feature adapts one of the many non-standard practices in the ecosystem, i propose to implement this in an Environment Collector plugin.
+1 My use case is that I have an application project which requires everyone on the team to be on the same Python version as the one deployed in production. However, my team has not adopted Hatch.
Having .python-version along side hatch.toml would let us enforce a Python version without enforcing Hatch.
project.requires_python can be an alternative, but pyproject.toml is not ideal for project-manager-agnostic application projects (yet).