-
Notifications
You must be signed in to change notification settings - Fork 934
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
Best practices for requires-python
#7429
Comments
Using |
@zanieb So this actually overlaps with a topic that affects us quite a bit (both in general, and it's also come up again with the recent addition of Poetry support). For libraries (or tools/software that is going to be distributed to a variety of end-user machines that needs to support multiple Python versions, such as CLIs, ...) supporting a range of Python versions in However, there are a large number of projects (and I would posit a much larger group than the library/... case), for which the project only needs to support, and will likely only ever be capable of supporting (due to lack of CI coverage of all Python versions in a CI matrix), a single major Python version. For example, when deploying a Django app to a PaaS, the build system needs to pick a single version of Python for the project to install into the container and use to boot the app at launch. But what version should be picked if there is no
Plus for all of the above apart from (4), there is no guarantee that the Python version picked by the build system will match the end users machine - or even that two developers from the same team are using the same Python version. This then leads to "well it works for me locally, but not on your platform" type support tickets. The fact that However, I imagine there will still be a number of uv-using projects that didn't use As such, it would be great to either:
Lastly, imagine the scenario where:
In that scenario, it seems using a wide-version-range value for (See also heroku/buildpacks-python#260 and python-poetry/poetry#9668) |
requires-python
I have a related issue, and I'm not sure what's the best approach. I have a modular monolith, where the same Python package/code can run as multiple roles - webserver or worker for example. Each role has different dependencies, and I'm using [project]
requires-python = ">=3.11"
dependencies = [
"prometheus-client>=0.20.0",
]
[project.optional-dependencies]
webserver = [
"aiohttp>=3.9.5",
]
worker = [
"orjson>=3.10.7",
] If I want to run a particular checkout using the The two pain points I encountered:
So I'm wondering if there are some best practices on how to work with separate sets of somewhat incompatible optional dependencies. |
I have a similar issue with the usage of the following type of command: uv python install '>=3.11' With the latest pre-release Python version 3.13.0rc2 being available, if no other version is installed, uv will install 3.13.0rc2. Would it not be better if uv installed the latest stable version (3.12.6) in that scenario? As explained in PEP440, section Handling of pre-release, Also, I am new to creating issues or requests, so let me know if I am doing something wrong. |
Hi! I have a similar issue. When developing libraries, I prefer to use minimal supported Python version. It's easier to control that I'm not using features of newer Python versions. I also use tox with tox-uv to test libraries against all supported Python versions. When I use .python-version with minimal supported version, tox-uv stops working properly. As I can see from the logs, uv recreates test environment because it doesn't match the pinned python version. |
Hi @tkukushkin perhaps that's a tox-uv bug? It sounds like they should be supplying an explicit Python version to use during testing? |
I saw the tox-uv issue about it (tox-dev/tox-uv#110) but I just decided to show my use case here as well. Ideally I would not like to have .python-version at all. It just duplicates |
Except it doesn't duplicate it — it serves a distinct purpose, e.g., see discussion in #8247 You don't need to have a |
I meant it duplicates in my use case. I never want them to be different. Also I don't really understand what "first" means. Could you please clarify it? I've seen it in documentation, but it's not clear for me. |
#5609 looks like what I need. |
I had some thoughts about version handling and documentation in #7352, but that was out of scope, so I created this issue.
I used the wrong version identifier in the first place which resulted to-> Warn when project defines a3.12.0
requires-python
that pins to a.0
patch version #7426uv
to be stuck at3.12.0
when definingrequires-python = "==3.12"
and changing it to~=3.12
~=3.12
(or==3.12.*
?) and describing what that means instead of using>=3.12
which could lead to3.13.x
Version specifier
documentation?The text was updated successfully, but these errors were encountered: