-
Notifications
You must be signed in to change notification settings - Fork 803
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
Determine Python requirement boundary based on supported Requires-Python
range
#4071
Comments
I'm now somewhat uncertain that this makes sense, because we include the project itself in the lockfile, and so the range will be at most the range of the project itself. |
I think that's okay; the goal is to write the narrowest bound, right? That it's "at most the range of the project" makes a ton of sense i.e. you can constrain project's Python requirement more narrowly than its dependencies. |
I think it will always end up being exactly the bound of the project, right? |
Because we require that all dependencies have bounds that are >= the bound of the project. So the project is already the narrowest bound, by definition. |
Ah I was thinking we'd drop the requirement that the project's python bound is narrower than all its dependencies'. It feels incorrect to require that a project's Python requirement is narrower than all of its dependencies unless they're all pinned (i.e. in a lockfile) because otherwise you're overly constraining against future versions of the dependencies. Imagine if I'm developing a library and a new version of a dependency gets published with a relaxed Python requirement. If that new dependency version is within my published constraints, the supported Python range should expand but uv will have forced me to narrow my published supported Python range to the previous value. |
Sorry, can you give a concrete example? |
Henry's comment gives a concrete example, I'll modify it here. Say your project has one dependency |
Ahh, I don't think that's solved by the thing in this issue, though. I thought that was solved by other things:
When locking, we do need some user-defined range of "Python versions you want to lock for"; and then when solving, we do need to ensure that all the packages we include are supported on all of those versions. I think the critical thing, though, is that the "Python versions you want to lock for" should not be coupled to the |
Like, maybe the code in the project itself only requires Python 3.7. Great. So you put But when locking, that might too permissive. You might want to lock against a narrower range, so that you're not required to use versions that support Python 3.7. This suggests that you want some other control that isn't |
Yes this sounds good to me. I think we're on the same page. I don't think we should suggest constraining |
Are you suggesting "enforce |
I'm thinking about that error case we raise saying to narrow your I think this is different than both of the options you presented. Though, I am confused by:
Isn't the failure case that the constraint of your dependencies is more strict than |
Yeah. In that case, I was suggesting that you have a successful resolve, and then we try to figure out how broad the |
What you've described above makes sense, though. If we fail, tell the user, "Hey, we could only create a universal environment for Python 3.10 and later, so set that as your lock constraint." And critically "your lock constraint" is not |
If you'd lock for let's say >=3.8, it means ou can't run test for python 3.7 with the lockfile. The lockfile would lose a part of it's universally by breaking down for a section of possible environments. If we want to achieve higher versions with more recent python versions, we'd need to apply fork-and-merge when encounter a requires-python bound splitting our supported range. When we lock for >=3.7 and encounter a python >=3.9 numpy, we resolve once for >=3.9 and once for <3.9,>=3.7, locking two different numpy versions depending on the python you install on. These would be two resolver modes: A python-universal mode that enforces >=3.7 support for all your dependencies, and a python-specific mode that gives you the highest version per python version. While problems with using features from newer versions that will not be supported on older versions could be irritating when working on more complex projects, i believe the main problem is performance, we potentially get a lot of splits. |
Rather than writing the user's
Requires-Python
to the lockfile, we could instead write the minimum boundingRequires-Python
of all the requirements. Or we could even omit it and use theRequires-Python
of each package.The text was updated successfully, but these errors were encountered: