astral-sh / uv

An extremely fast Python package and project manager, written in Rust.
https://docs.astral.sh/uv
Apache License 2.0
23.87k stars 683 forks source link

Docs: Mention that `.python-version` is obsolete if `project.requires-python` is present in `pyproject.toml`? #8247

Open jnussbaum opened 6 days ago

jnussbaum commented 6 days ago

First a big thumbs up for the great work you're doing with ruff and uv! We have adopted both in our company, and we're overwhelmed!

I have just a quick request for clarification: https://docs.astral.sh/uv/guides/projects/ implies that it is always necessary (or at least best practice) to have the file .python-version checked in. But for standards-compliant projects that define project.requires-python in pyproject.toml, this seems obsolete. I tried it out, and in fact, uv correctly detects project.requires-python and installs the intended python version, even without .python-version.

In our project, I wanted to remove .python-version, so that we don't have the python version defined in 2 separate places. But then I became insecure because of the documentation.

Therefore, I think it would be helpful to add a remark to https://docs.astral.sh/uv/guides/projects/, mentioning that .python-version is obsolete in this case. WDYT?

charliermarsh commented 6 days ago

The .python-version file is not quite obsolete with requires-python -- they're subtly different. requires-python is the range of versions supported by your project. .python-version is the exact version you want to use when developing. For example, if you're working on a library, your requires-python might be >= "3.10". But when developing on your machine, you might want to use 3.12.4 by default -- so you'd set that in a .python-version.

jnussbaum commented 6 days ago

Thanks for this information, that makes sense 👍