-
Notifications
You must be signed in to change notification settings - Fork 605
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
Use intersection rather than union for requires-python
#5644
Conversation
91465a9
to
235e560
Compare
@@ -101,7 +101,7 @@ pub(crate) enum ProjectError { | |||
pub(crate) fn find_requires_python( | |||
workspace: &Workspace, | |||
) -> Result<Option<RequiresPython>, uv_resolver::RequiresPythonError> { | |||
RequiresPython::union(workspace.packages().values().filter_map(|member| { | |||
RequiresPython::intersection(workspace.packages().values().filter_map(|member| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can warn here, if people feel strongly. I'm not sure that we should, though, since users will see it every time without any way to resolve it.
CodSpeed Performance ReportMerging #5644 will not alter performanceComparing Summary
|
----- stderr ----- | ||
warning: `uv sync` is experimental and may change without warning | ||
Using Python 3.8.[X] interpreter at: [PYTHON-3.8] | ||
error: The requested Python interpreter (3.8.[X]) is incompatible with the project Python requirement: `>=3.12` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add a specific error message for this case that tells you how to run something on 3.8 with only bird-feeder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@konstin -- What's the recommended workflow? Can we even support it right now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say we check if the request version is in the union, but not in the intersection, and if so, recommend uv pip install -p 3.8 -e . <older-python-version-project>
, which should work, i can test this after #5644 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now i checked the right way and cargo run venv -p 3.8 && cargo run pip install -e packages/foo_lib/
indeed works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do separately.
Those codspeed numbers are dubious |
I just tried the following project layout:
bar: [project]
name = "bar"
version = "0.1.0"
requires-python = ">=3.12"
dependencies = []
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build" foo_lib: [project]
name = "foo-lib"
version = "0.1.0"
requires-python = ">=3.8"
dependencies = []
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build" When trying to
It seems that the PR currently forces the same requires-python across the workspace. |
You must be running from |
version = 1
requires-python = ">=3.12"
[[distribution]]
name = "bar"
version = "0.1.0"
source = { editable = "packages/bar" }
[[distribution]]
name = "foo-lib"
version = "0.1.0"
source = { editable = "packages/foo_lib" }
[[distribution]]
name = "root"
version = "0.1.0"
source = { editable = "." } |
Right branch but it was using |
Haha yeah. That's the exact problem this was designed to fix 😂 |
235e560
to
1e5b02d
Compare
1e5b02d
to
7c2db70
Compare
7c2db70
to
1566081
Compare
Summary
As-is, if you have a workspace with mixed
requires-python
requirements, resolution will never succeed, since we'll use the union as therequires-python
bound (i.e., take the lowest value), and fail when we see the package that only supports some more narrow range.This PR modifies the behavior to take the intersection (i.e., the highest value), so if you have one package that supports Python 3.12 and later, and another that supports Python 3.8 and later, we lock for Python 3.12. If you try to sync or run with Python 3.8, we raise an error, since the lockfile will be incompatible with that request.
Konsti has a write-up in #5594 that outlines what could be a longer-term strategy.
Closes #5578.