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

Purpose of .python-version? #8920

Closed
denkasyanov opened this issue Nov 8, 2024 · 2 comments
Closed

Purpose of .python-version? #8920

denkasyanov opened this issue Nov 8, 2024 · 2 comments

Comments

@denkasyanov
Copy link
Contributor

Currently on uv init a project boilerplate created includes the file .python-version.

What is the purpose of this file, if there are constraints in pyproject.toml and uv.lock?

Is it just for compatibility with tools like pyenv or is there more to it?

I really like how clean project directory became after moving a lot of stuff (like requirements.*) to pyproject.toml. So wonder, if .python-version is really required in two senses:

  1. Is it required for the projects now? I tested by deleting .python-version, and everything works as expected and this file is not recreated with commands like uv run, uv sync and uv lock
  2. Since a lot of constraints/pinned versions of things are now in pyproject.toml and uv.lock, maybe if .python-version still plays some important role, its function can be moved to pyproject.toml or uv.lock in future?

Asking as a 5-year user of pyenv and .python-version. They are great, but I don't really miss them.

Also, couldn't find peps related to this file.

@my1e5
Copy link
Contributor

my1e5 commented Nov 8, 2024

Related - #8247

A .python-version file is not strictly required, but it's useful to have it when developing a project as it allows you to specify the exact Python version you are using to do development. It's different to the requires-python field - that is the range of Python versions supported by your project.

@denkasyanov
Copy link
Contributor Author

Thanks!

It matches my intuition and #8247 indeed provides useful context!

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

2 participants