mirror of
https://github.com/astral-sh/uv.git
synced 2025-11-01 04:17:37 +00:00
Trim injected python_version marker to (major, minor) (#2395)
## Summary
Per [PEP 508](https://peps.python.org/pep-0508/), `python_version` is
just major and minor:

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 https://github.com/astral-sh/uv/issues/2392.
This commit is contained in:
parent
00ec99399a
commit
3799862f5d
6 changed files with 118 additions and 34 deletions
|
|
@ -11,7 +11,7 @@ use tracing::{debug, warn};
|
|||
use cache_key::digest;
|
||||
use install_wheel_rs::Layout;
|
||||
use pep440_rs::Version;
|
||||
use pep508_rs::MarkerEnvironment;
|
||||
use pep508_rs::{MarkerEnvironment, StringVersion};
|
||||
use platform_host::Platform;
|
||||
use platform_tags::{Tags, TagsError};
|
||||
use pypi_types::Scheme;
|
||||
|
|
@ -182,6 +182,12 @@ impl Interpreter {
|
|||
&self.markers.python_full_version.version
|
||||
}
|
||||
|
||||
/// Returns the `python_full_version` marker corresponding to this Python version.
|
||||
#[inline]
|
||||
pub const fn python_full_version(&self) -> &StringVersion {
|
||||
&self.markers.python_full_version
|
||||
}
|
||||
|
||||
/// Return the major version of this Python version.
|
||||
pub fn python_major(&self) -> u8 {
|
||||
let major = self.markers.python_full_version.version.release()[0];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue