mirror of
https://github.com/astral-sh/uv.git
synced 2025-11-25 21:37:51 +00:00
Remove uses of Option<MarkerTreeContents> in PubGrubPackage (#9541)
Some checks are pending
CI / check system | python on ubuntu (push) Blocked by required conditions
CI / cargo dev generate-all (push) Blocked by required conditions
CI / cargo shear (push) Waiting to run
CI / Determine changes (push) Waiting to run
CI / lint (push) Waiting to run
CI / cargo clippy | ubuntu (push) Blocked by required conditions
CI / cargo clippy | windows (push) Blocked by required conditions
CI / cargo test | ubuntu (push) Blocked by required conditions
CI / cargo test | macos (push) Blocked by required conditions
CI / cargo test | windows (push) Blocked by required conditions
CI / check windows trampoline | aarch64 (push) Blocked by required conditions
CI / check windows trampoline | i686 (push) Blocked by required conditions
CI / check windows trampoline | x86_64 (push) Blocked by required conditions
CI / test windows trampoline | i686 (push) Blocked by required conditions
CI / test windows trampoline | x86_64 (push) Blocked by required conditions
CI / typos (push) Waiting to run
CI / mkdocs (push) Waiting to run
CI / build binary | linux (push) Blocked by required conditions
CI / build binary | macos aarch64 (push) Blocked by required conditions
CI / build binary | macos x86_64 (push) Blocked by required conditions
CI / build binary | windows (push) Blocked by required conditions
CI / cargo build (msrv) (push) Blocked by required conditions
CI / build binary | freebsd (push) Blocked by required conditions
CI / ecosystem test | prefecthq/prefect (push) Blocked by required conditions
CI / ecosystem test | pallets/flask (push) Blocked by required conditions
CI / integration test | conda on ubuntu (push) Blocked by required conditions
CI / integration test | free-threaded on linux (push) Blocked by required conditions
CI / check system | python on fedora (push) Blocked by required conditions
CI / integration test | free-threaded on windows (push) Blocked by required conditions
CI / integration test | pypy on ubuntu (push) Blocked by required conditions
CI / integration test | pypy on windows (push) Blocked by required conditions
CI / integration test | graalpy on ubuntu (push) Blocked by required conditions
CI / integration test | graalpy on windows (push) Blocked by required conditions
CI / integration test | github actions (push) Blocked by required conditions
CI / integration test | determine publish changes (push) Blocked by required conditions
CI / integration test | uv publish (push) Blocked by required conditions
CI / check cache | ubuntu (push) Blocked by required conditions
CI / check cache | macos aarch64 (push) Blocked by required conditions
CI / check system | python on debian (push) Blocked by required conditions
CI / check system | python on opensuse (push) Blocked by required conditions
CI / check system | python on rocky linux 8 (push) Blocked by required conditions
CI / check system | python on rocky linux 9 (push) Blocked by required conditions
CI / check system | pypy on ubuntu (push) Blocked by required conditions
CI / check system | pyston (push) Blocked by required conditions
CI / check system | alpine (push) Blocked by required conditions
CI / check system | python on macos aarch64 (push) Blocked by required conditions
CI / check system | homebrew python on macos aarch64 (push) Blocked by required conditions
CI / check system | python on macos x86_64 (push) Blocked by required conditions
CI / check system | python3.10 on windows (push) Blocked by required conditions
CI / check system | python3.10 on windows x86 (push) Blocked by required conditions
CI / check system | python3.13 on windows (push) Blocked by required conditions
CI / check system | python3.12 via chocolatey (push) Blocked by required conditions
CI / check system | python3.9 via pyenv (push) Blocked by required conditions
CI / check system | python3.13 (push) Blocked by required conditions
CI / check system | conda3.11 on linux (push) Blocked by required conditions
CI / check system | conda3.8 on linux (push) Blocked by required conditions
CI / check system | conda3.11 on macos (push) Blocked by required conditions
CI / check system | conda3.8 on macos (push) Blocked by required conditions
CI / check system | conda3.11 on windows (push) Blocked by required conditions
CI / check system | conda3.8 on windows (push) Blocked by required conditions
CI / check system | amazonlinux (push) Blocked by required conditions
CI / check system | embedded python3.10 on windows (push) Blocked by required conditions
CI / benchmarks (push) Blocked by required conditions
Some checks are pending
CI / check system | python on ubuntu (push) Blocked by required conditions
CI / cargo dev generate-all (push) Blocked by required conditions
CI / cargo shear (push) Waiting to run
CI / Determine changes (push) Waiting to run
CI / lint (push) Waiting to run
CI / cargo clippy | ubuntu (push) Blocked by required conditions
CI / cargo clippy | windows (push) Blocked by required conditions
CI / cargo test | ubuntu (push) Blocked by required conditions
CI / cargo test | macos (push) Blocked by required conditions
CI / cargo test | windows (push) Blocked by required conditions
CI / check windows trampoline | aarch64 (push) Blocked by required conditions
CI / check windows trampoline | i686 (push) Blocked by required conditions
CI / check windows trampoline | x86_64 (push) Blocked by required conditions
CI / test windows trampoline | i686 (push) Blocked by required conditions
CI / test windows trampoline | x86_64 (push) Blocked by required conditions
CI / typos (push) Waiting to run
CI / mkdocs (push) Waiting to run
CI / build binary | linux (push) Blocked by required conditions
CI / build binary | macos aarch64 (push) Blocked by required conditions
CI / build binary | macos x86_64 (push) Blocked by required conditions
CI / build binary | windows (push) Blocked by required conditions
CI / cargo build (msrv) (push) Blocked by required conditions
CI / build binary | freebsd (push) Blocked by required conditions
CI / ecosystem test | prefecthq/prefect (push) Blocked by required conditions
CI / ecosystem test | pallets/flask (push) Blocked by required conditions
CI / integration test | conda on ubuntu (push) Blocked by required conditions
CI / integration test | free-threaded on linux (push) Blocked by required conditions
CI / check system | python on fedora (push) Blocked by required conditions
CI / integration test | free-threaded on windows (push) Blocked by required conditions
CI / integration test | pypy on ubuntu (push) Blocked by required conditions
CI / integration test | pypy on windows (push) Blocked by required conditions
CI / integration test | graalpy on ubuntu (push) Blocked by required conditions
CI / integration test | graalpy on windows (push) Blocked by required conditions
CI / integration test | github actions (push) Blocked by required conditions
CI / integration test | determine publish changes (push) Blocked by required conditions
CI / integration test | uv publish (push) Blocked by required conditions
CI / check cache | ubuntu (push) Blocked by required conditions
CI / check cache | macos aarch64 (push) Blocked by required conditions
CI / check system | python on debian (push) Blocked by required conditions
CI / check system | python on opensuse (push) Blocked by required conditions
CI / check system | python on rocky linux 8 (push) Blocked by required conditions
CI / check system | python on rocky linux 9 (push) Blocked by required conditions
CI / check system | pypy on ubuntu (push) Blocked by required conditions
CI / check system | pyston (push) Blocked by required conditions
CI / check system | alpine (push) Blocked by required conditions
CI / check system | python on macos aarch64 (push) Blocked by required conditions
CI / check system | homebrew python on macos aarch64 (push) Blocked by required conditions
CI / check system | python on macos x86_64 (push) Blocked by required conditions
CI / check system | python3.10 on windows (push) Blocked by required conditions
CI / check system | python3.10 on windows x86 (push) Blocked by required conditions
CI / check system | python3.13 on windows (push) Blocked by required conditions
CI / check system | python3.12 via chocolatey (push) Blocked by required conditions
CI / check system | python3.9 via pyenv (push) Blocked by required conditions
CI / check system | python3.13 (push) Blocked by required conditions
CI / check system | conda3.11 on linux (push) Blocked by required conditions
CI / check system | conda3.8 on linux (push) Blocked by required conditions
CI / check system | conda3.11 on macos (push) Blocked by required conditions
CI / check system | conda3.8 on macos (push) Blocked by required conditions
CI / check system | conda3.11 on windows (push) Blocked by required conditions
CI / check system | conda3.8 on windows (push) Blocked by required conditions
CI / check system | amazonlinux (push) Blocked by required conditions
CI / check system | embedded python3.10 on windows (push) Blocked by required conditions
CI / benchmarks (push) Blocked by required conditions
## Summary Just use `MarkerTree::TRUE` instead of `None`.
This commit is contained in:
parent
22fd9f7ff1
commit
6bebf79ac3
3 changed files with 45 additions and 59 deletions
|
|
@ -2,7 +2,7 @@ use std::ops::Deref;
|
|||
use std::sync::Arc;
|
||||
|
||||
use uv_normalize::{ExtraName, GroupName, PackageName};
|
||||
use uv_pep508::{MarkerTree, MarkerTreeContents};
|
||||
use uv_pep508::MarkerTree;
|
||||
use uv_pypi_types::ConflictItemRef;
|
||||
|
||||
use crate::python_requirement::PythonRequirement;
|
||||
|
|
@ -52,7 +52,7 @@ pub(crate) enum PubGrubPackageInner {
|
|||
name: PackageName,
|
||||
extra: Option<ExtraName>,
|
||||
dev: Option<GroupName>,
|
||||
marker: Option<MarkerTreeContents>,
|
||||
marker: MarkerTree,
|
||||
},
|
||||
/// A proxy package to represent a dependency with an extra (e.g., `black[colorama]`).
|
||||
///
|
||||
|
|
@ -70,7 +70,7 @@ pub(crate) enum PubGrubPackageInner {
|
|||
Extra {
|
||||
name: PackageName,
|
||||
extra: ExtraName,
|
||||
marker: Option<MarkerTreeContents>,
|
||||
marker: MarkerTree,
|
||||
},
|
||||
/// A proxy package to represent an enabled "dependency group" (e.g., development dependencies).
|
||||
///
|
||||
|
|
@ -80,7 +80,7 @@ pub(crate) enum PubGrubPackageInner {
|
|||
Dev {
|
||||
name: PackageName,
|
||||
dev: GroupName,
|
||||
marker: Option<MarkerTreeContents>,
|
||||
marker: MarkerTree,
|
||||
},
|
||||
/// A proxy package for a base package with a marker (e.g., `black; python_version >= "3.6"`).
|
||||
///
|
||||
|
|
@ -105,23 +105,22 @@ impl PubGrubPackage {
|
|||
// extras end up having two distinct marker expressions, which in turn
|
||||
// makes them two distinct packages. This results in PubGrub being
|
||||
// unable to unify version constraints across such packages.
|
||||
let tree = marker.simplify_extras_with(|_| true);
|
||||
let marker = tree.contents();
|
||||
let marker = marker.simplify_extras_with(|_| true);
|
||||
if let Some(extra) = extra {
|
||||
Self(Arc::new(PubGrubPackageInner::Extra {
|
||||
name,
|
||||
extra,
|
||||
marker,
|
||||
}))
|
||||
} else if marker.is_some() {
|
||||
Self(Arc::new(PubGrubPackageInner::Marker { name, marker: tree }))
|
||||
} else {
|
||||
} else if marker.is_true() {
|
||||
Self(Arc::new(PubGrubPackageInner::Package {
|
||||
name,
|
||||
extra,
|
||||
dev: None,
|
||||
marker,
|
||||
}))
|
||||
} else {
|
||||
Self(Arc::new(PubGrubPackageInner::Marker { name, marker }))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -160,9 +159,7 @@ impl PubGrubPackage {
|
|||
PubGrubPackageInner::Root(_) | PubGrubPackageInner::Python(_) => None,
|
||||
PubGrubPackageInner::Package { marker, .. }
|
||||
| PubGrubPackageInner::Extra { marker, .. }
|
||||
| PubGrubPackageInner::Dev { marker, .. } => {
|
||||
marker.as_ref().map(MarkerTreeContents::as_ref)
|
||||
}
|
||||
| PubGrubPackageInner::Dev { marker, .. } => Some(marker),
|
||||
PubGrubPackageInner::Marker { marker, .. } => Some(marker),
|
||||
}
|
||||
}
|
||||
|
|
@ -254,14 +251,8 @@ impl PubGrubPackage {
|
|||
PubGrubPackageInner::Root(_) | PubGrubPackageInner::Python(_) => {}
|
||||
PubGrubPackageInner::Package { ref mut marker, .. }
|
||||
| PubGrubPackageInner::Extra { ref mut marker, .. }
|
||||
| PubGrubPackageInner::Dev { ref mut marker, .. } => {
|
||||
let Some(contents) = marker.as_mut() else {
|
||||
return;
|
||||
};
|
||||
let tree = MarkerTree::from(contents.clone());
|
||||
*marker = python_requirement.simplify_markers(tree).contents();
|
||||
}
|
||||
PubGrubPackageInner::Marker { ref mut marker, .. } => {
|
||||
| PubGrubPackageInner::Dev { ref mut marker, .. }
|
||||
| PubGrubPackageInner::Marker { ref mut marker, .. } => {
|
||||
*marker = python_requirement.simplify_markers(marker.clone());
|
||||
}
|
||||
}
|
||||
|
|
@ -303,44 +294,38 @@ impl std::fmt::Display for PubGrubPackageInner {
|
|||
Self::Package {
|
||||
name,
|
||||
extra: None,
|
||||
marker: None,
|
||||
marker,
|
||||
dev: None,
|
||||
} => write!(f, "{name}"),
|
||||
} => {
|
||||
if let Some(marker) = marker.contents() {
|
||||
write!(f, "{name}{{{marker}}}")
|
||||
} else {
|
||||
write!(f, "{name}")
|
||||
}
|
||||
}
|
||||
Self::Package {
|
||||
name,
|
||||
extra: Some(extra),
|
||||
marker: None,
|
||||
marker,
|
||||
dev: None,
|
||||
} => {
|
||||
write!(f, "{name}[{extra}]")
|
||||
if let Some(marker) = marker.contents() {
|
||||
write!(f, "{name}[{extra}]{{{marker}}}")
|
||||
} else {
|
||||
write!(f, "{name}[{extra}]")
|
||||
}
|
||||
}
|
||||
Self::Package {
|
||||
name,
|
||||
extra: None,
|
||||
marker: Some(marker),
|
||||
dev: None,
|
||||
} => write!(f, "{name}{{{marker}}}"),
|
||||
Self::Package {
|
||||
name,
|
||||
extra: Some(extra),
|
||||
marker: Some(marker),
|
||||
dev: None,
|
||||
} => {
|
||||
write!(f, "{name}[{extra}]{{{marker}}}")
|
||||
}
|
||||
Self::Package {
|
||||
name,
|
||||
extra: None,
|
||||
marker: None,
|
||||
dev: Some(dev),
|
||||
} => write!(f, "{name}:{dev}"),
|
||||
Self::Package {
|
||||
name,
|
||||
extra: None,
|
||||
marker: Some(marker),
|
||||
marker,
|
||||
dev: Some(dev),
|
||||
} => {
|
||||
write!(f, "{name}[{dev}]{{{marker}}}")
|
||||
if let Some(marker) = marker.contents() {
|
||||
write!(f, "{name}:{dev}{{{marker}}}")
|
||||
} else {
|
||||
write!(f, "{name}:{dev}")
|
||||
}
|
||||
}
|
||||
Self::Marker { name, marker, .. } => {
|
||||
if let Some(marker) = marker.contents() {
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ use crate::{
|
|||
use uv_distribution_types::{CompatibleDist, DistributionMetadata, IndexCapabilities, IndexUrl};
|
||||
use uv_normalize::PackageName;
|
||||
use uv_pep440::Version;
|
||||
use uv_pep508::MarkerTree;
|
||||
|
||||
enum BatchPrefetchStrategy {
|
||||
/// Go through the next versions assuming the existing selection and its constraints
|
||||
|
|
@ -64,7 +65,7 @@ impl BatchPrefetcher {
|
|||
name,
|
||||
extra: None,
|
||||
dev: None,
|
||||
marker: None,
|
||||
marker: MarkerTree::TRUE,
|
||||
} = &**next
|
||||
else {
|
||||
return Ok(());
|
||||
|
|
@ -232,7 +233,7 @@ impl BatchPrefetcher {
|
|||
name,
|
||||
extra: None,
|
||||
dev: None,
|
||||
marker: None,
|
||||
marker: MarkerTree::TRUE,
|
||||
} = &**package
|
||||
else {
|
||||
return;
|
||||
|
|
@ -248,7 +249,7 @@ impl BatchPrefetcher {
|
|||
name,
|
||||
extra: None,
|
||||
dev: None,
|
||||
marker: None,
|
||||
marker: MarkerTree::TRUE,
|
||||
} = &**next
|
||||
else {
|
||||
return (0, false);
|
||||
|
|
|
|||
|
|
@ -822,7 +822,7 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag
|
|||
name,
|
||||
extra: None,
|
||||
dev: None,
|
||||
marker: None,
|
||||
marker: MarkerTree::TRUE,
|
||||
} = &**package
|
||||
else {
|
||||
continue;
|
||||
|
|
@ -1490,14 +1490,14 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag
|
|||
// Add a dependency on both the marker and base package.
|
||||
PubGrubPackageInner::Marker { name, marker } => {
|
||||
return Ok(Dependencies::Unforkable(
|
||||
[None, Some(marker)]
|
||||
[MarkerTree::TRUE, marker.clone()]
|
||||
.into_iter()
|
||||
.map(move |marker| PubGrubDependency {
|
||||
package: PubGrubPackage::from(PubGrubPackageInner::Package {
|
||||
name: name.clone(),
|
||||
extra: None,
|
||||
dev: None,
|
||||
marker: marker.and_then(MarkerTree::contents),
|
||||
marker,
|
||||
}),
|
||||
version: Range::singleton(version.clone()),
|
||||
url: None,
|
||||
|
|
@ -1513,7 +1513,7 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag
|
|||
marker,
|
||||
} => {
|
||||
return Ok(Dependencies::Unforkable(
|
||||
[None, marker.as_ref()]
|
||||
[&MarkerTree::TRUE, marker]
|
||||
.into_iter()
|
||||
.dedup()
|
||||
.flat_map(move |marker| {
|
||||
|
|
@ -1524,7 +1524,7 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag
|
|||
name: name.clone(),
|
||||
extra: extra.cloned(),
|
||||
dev: None,
|
||||
marker: marker.cloned(),
|
||||
marker: marker.clone(),
|
||||
}),
|
||||
version: Range::singleton(version.clone()),
|
||||
url: None,
|
||||
|
|
@ -1538,7 +1538,7 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag
|
|||
// without the marker.
|
||||
PubGrubPackageInner::Dev { name, dev, marker } => {
|
||||
return Ok(Dependencies::Unforkable(
|
||||
[None, marker.as_ref()]
|
||||
[&MarkerTree::TRUE, marker]
|
||||
.into_iter()
|
||||
.dedup()
|
||||
.flat_map(move |marker| {
|
||||
|
|
@ -1549,7 +1549,7 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag
|
|||
name: name.clone(),
|
||||
extra: None,
|
||||
dev: dev.cloned(),
|
||||
marker: marker.cloned(),
|
||||
marker: marker.clone(),
|
||||
}),
|
||||
version: Range::singleton(version.clone()),
|
||||
url: None,
|
||||
|
|
@ -2555,7 +2555,7 @@ impl ForkState {
|
|||
to_index: to_index.cloned(),
|
||||
to_extra: Some(dependency_extra.clone()),
|
||||
to_dev: None,
|
||||
marker: MarkerTree::from(dependency_marker.clone()),
|
||||
marker: dependency_marker.clone(),
|
||||
};
|
||||
edges.insert(edge);
|
||||
}
|
||||
|
|
@ -2586,7 +2586,7 @@ impl ForkState {
|
|||
to_index: to_index.cloned(),
|
||||
to_extra: None,
|
||||
to_dev: Some(dependency_dev.clone()),
|
||||
marker: MarkerTree::from(dependency_marker.clone()),
|
||||
marker: dependency_marker.clone(),
|
||||
};
|
||||
edges.insert(edge);
|
||||
}
|
||||
|
|
@ -2603,7 +2603,7 @@ impl ForkState {
|
|||
name,
|
||||
extra,
|
||||
dev,
|
||||
marker: None,
|
||||
marker: MarkerTree::TRUE,
|
||||
} = &*self.pubgrub.package_store[package]
|
||||
{
|
||||
Some((
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue