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

Avoid narrowing requires-python marker with disjunctions #10704

Merged
merged 3 commits into from
Jan 17, 2025

Conversation

charliermarsh
Copy link
Member

@charliermarsh charliermarsh commented Jan 17, 2025

Summary

A bug in requires_python (which infers the Python requirement from a marker) was leading us to break an invariant around the relationship between the marker environment and the Python requirement. This, in turn, was leading us to drop parts of the environment space when solving.

Specifically, in the linked example, we generated a fork for python_full_version < '3.10' or platform_python_implementation != 'CPython', which was later split into python_full_version == '3.8.*' and python_full_version == '3.9.*', losing the platform_python_implementation != 'CPython' portion.

Closes #10669.

@charliermarsh charliermarsh added the bug Something isn't working label Jan 17, 2025
@charliermarsh charliermarsh marked this pull request as ready for review January 17, 2025 04:34
@charliermarsh charliermarsh force-pushed the charlie/pypy-req-python branch 2 times, most recently from 1b83917 to 9c22987 Compare January 17, 2025 04:35
@charliermarsh charliermarsh force-pushed the charlie/pypy-req-python branch 3 times, most recently from ef5c8f0 to 59ff621 Compare January 17, 2025 04:56
@charliermarsh charliermarsh force-pushed the charlie/pypy-req-python branch from 59ff621 to 08878b0 Compare January 17, 2025 05:01
Copy link
Member

@ibraheemdev ibraheemdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than the potential simplification I pointed out this looks good to me! A little surprised that we didn't notice this bug sooner.

/// `MarkerTreeKind::True` node.
fn collect_python_markers(
tree: MarkerTree,
markers: &mut Vec<Vec<Ranges<Version>>>,
Copy link
Member

@ibraheemdev ibraheemdev Jan 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The search here only cares about a single type of node (CanonicalMarkerValueVersion::PythonFullVersion), and importantly that node can only show up once on a given solution path in the decision diagram. I believe this means that you shouldn't need an inner Vec here, and you can default to Ranges::full() for a solution that does not have an explicit python version requirement. That should simplify this a little bit — there is no list of versions to take the intersection of for a given solution.

@charliermarsh charliermarsh force-pushed the charlie/pypy-req-python branch from fd49e53 to 6cbcccf Compare January 17, 2025 15:47
@charliermarsh charliermarsh enabled auto-merge (squash) January 17, 2025 15:56
@charliermarsh charliermarsh force-pushed the charlie/pypy-req-python branch from 6cbcccf to e5e8e8f Compare January 17, 2025 15:58
@charliermarsh charliermarsh enabled auto-merge (squash) January 17, 2025 15:58
@charliermarsh charliermarsh merged commit bc8002e into main Jan 17, 2025
81 checks passed
@charliermarsh charliermarsh deleted the charlie/pypy-req-python branch January 17, 2025 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

uv sync x dependency groups doesn't work with PyPy
4 participants