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

Trim injected python_version marker to (major, minor) #2395

Merged
merged 3 commits into from
Mar 13, 2024

Conversation

charliermarsh
Copy link
Member

Summary

Per PEP 508, python_version is just major and minor:

Screenshot 2024-03-12 at 5 15 09 PM

Right now, we're using the provided version directly, so if it's, e.g., -p 3.11.8, we'll inject the wrong marker. This was causing pandas to omit numpy when -p 3.11.8 was provided, since its markers look like:

Requires-Dist: numpy<2,>=1.22.4; python_version < "3.11"
Requires-Dist: numpy<2,>=1.23.2; python_version == "3.11"
Requires-Dist: numpy<2,>=1.26.0; python_version >= "3.12"

Closes #2392.

@charliermarsh charliermarsh requested a review from zanieb March 12, 2024 21:16
@charliermarsh charliermarsh added the bug Something isn't working label Mar 12, 2024
}
if version.is_pre() {
return Err(format!("Python version {s} is a pre-release"));
}
Copy link
Member Author

Choose a reason for hiding this comment

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

I guess we can support this, but it makes the code below simpler because we can construct markers.python_full_version by just looking at the releases. Otherwise, I need to add some more handling to it.

@charliermarsh charliermarsh marked this pull request as ready for review March 12, 2024 21:17
Comment on lines 80 to 81
self.release()[0],
self.release()[1],
Copy link
Member

Choose a reason for hiding this comment

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

Mildly confused that we use .get(...).unwrap... elsewhere but not here?

@charliermarsh charliermarsh force-pushed the charlie/marker branch 4 times, most recently from 731bc82 to 937bb86 Compare March 12, 2024 23:07
}

impl PythonRequirement {
pub fn new(interpreter: &Interpreter, markers: &MarkerEnvironment) -> Self {
Self {
installed: interpreter.python_version().clone(),
target: markers.python_full_version.version.clone(),
installed: interpreter.python_full_version().clone(),
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the same value, I just renamed the method because it's the python_full_version marker.

@charliermarsh charliermarsh enabled auto-merge (squash) March 13, 2024 00:02
@charliermarsh charliermarsh merged commit 3799862 into main Mar 13, 2024
26 checks passed
@charliermarsh charliermarsh deleted the charlie/marker branch March 13, 2024 00:11
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 pip compile uses overly specific python_version with -p markers
2 participants