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

Possible feature: Support .python-version #1126

Open
flying-sheep opened this issue Dec 12, 2023 · 5 comments · May be fixed by #1607
Open

Possible feature: Support .python-version #1126

flying-sheep opened this issue Dec 12, 2023 · 5 comments · May be fixed by #1607

Comments

@flying-sheep
Copy link
Contributor

flying-sheep commented Dec 12, 2023

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

  1. would simplify transition from Pyenv/Rye or interoperability with those projects.
  2. Could be used to implement Option to change hatch env python version #1097

Cons

  1. .python-version is not a standard
  2. 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

  1. hatch.envs.<env>.overrides.<matching condition>.python
  2. hatch.envs.<env>.python
  3. hatch.envs.default.python (assuming hatch.envs.<env>.template = 'default' or unspecified)
  4. .python-version
  5. minimum version matching project.requires_python
@ofek
Copy link
Collaborator

ofek commented Dec 12, 2023

Thank you for expanding on how the resolution would work! I am open to this 🙂

@ofek
Copy link
Collaborator

ofek commented Dec 12, 2023

Somewhat unrelated, but would this functionality be useful to you? #1124 (comment)

@flying-sheep
Copy link
Contributor Author

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? #1124 (comment)

answered there

@funkyfuture
Copy link
Contributor

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.

@ketozhang
Copy link

+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).

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 a pull request may close this issue.

4 participants