mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 10:58:28 +00:00
parent
89bef7bf09
commit
d7f195fdc9
3 changed files with 72 additions and 76 deletions
|
@ -132,6 +132,18 @@ impl PubGrubPackage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the name of this PubGrub package, if it is not the root package or a Python version
|
||||||
|
/// constraint.
|
||||||
|
pub(crate) fn name_no_root(&self) -> Option<&PackageName> {
|
||||||
|
match &**self {
|
||||||
|
PubGrubPackageInner::Root(_) | PubGrubPackageInner::Python(_) => None,
|
||||||
|
PubGrubPackageInner::Package { name, .. }
|
||||||
|
| PubGrubPackageInner::Extra { name, .. }
|
||||||
|
| PubGrubPackageInner::Dev { name, .. }
|
||||||
|
| PubGrubPackageInner::Marker { name, .. } => Some(name),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns the marker expression associated with this PubGrub package, if
|
/// Returns the marker expression associated with this PubGrub package, if
|
||||||
/// it has one.
|
/// it has one.
|
||||||
pub(crate) fn marker(&self) -> Option<&MarkerTree> {
|
pub(crate) fn marker(&self) -> Option<&MarkerTree> {
|
||||||
|
|
|
@ -31,14 +31,12 @@ impl PubGrubPriorities {
|
||||||
urls: &ForkUrls,
|
urls: &ForkUrls,
|
||||||
) {
|
) {
|
||||||
let next = self.0.len();
|
let next = self.0.len();
|
||||||
match &**package {
|
// The root package and Python constraints have no explicit priority, the root package is
|
||||||
PubGrubPackageInner::Root(_) => {}
|
// always first and the Python version (range) is fixed.
|
||||||
PubGrubPackageInner::Python(_) => {}
|
let Some(name) = package.name_no_root() else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
PubGrubPackageInner::Marker { name, .. }
|
|
||||||
| PubGrubPackageInner::Extra { name, .. }
|
|
||||||
| PubGrubPackageInner::Dev { name, .. }
|
|
||||||
| PubGrubPackageInner::Package { name, .. } => {
|
|
||||||
match self.0.entry(name.clone()) {
|
match self.0.entry(name.clone()) {
|
||||||
std::collections::hash_map::Entry::Occupied(mut entry) => {
|
std::collections::hash_map::Entry::Occupied(mut entry) => {
|
||||||
// Preserve the original index.
|
// Preserve the original index.
|
||||||
|
@ -78,8 +76,6 @@ impl PubGrubPriorities {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Return the [`PubGrubPriority`] of the given package, if it exists.
|
/// Return the [`PubGrubPriority`] of the given package, if it exists.
|
||||||
pub(crate) fn get(&self, package: &PubGrubPackage) -> Option<PubGrubPriority> {
|
pub(crate) fn get(&self, package: &PubGrubPackage) -> Option<PubGrubPriority> {
|
||||||
|
|
|
@ -667,33 +667,12 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag
|
||||||
url: Option<&VerbatimParsedUrl>,
|
url: Option<&VerbatimParsedUrl>,
|
||||||
request_sink: &Sender<Request>,
|
request_sink: &Sender<Request>,
|
||||||
) -> Result<(), ResolveError> {
|
) -> Result<(), ResolveError> {
|
||||||
match (&**package, url) {
|
// Only request real package
|
||||||
(PubGrubPackageInner::Root(_), _) => {}
|
let Some(name) = package.name_no_root() else {
|
||||||
(PubGrubPackageInner::Python(_), _) => {}
|
return Ok(());
|
||||||
(
|
};
|
||||||
PubGrubPackageInner::Marker { name, .. }
|
|
||||||
| PubGrubPackageInner::Extra { name, .. }
|
|
||||||
| PubGrubPackageInner::Dev { name, .. }
|
|
||||||
| PubGrubPackageInner::Package { name, .. },
|
|
||||||
None,
|
|
||||||
) => {
|
|
||||||
// Verify that the package is allowed under the hash-checking policy.
|
|
||||||
if !self.hasher.allows_package(name) {
|
|
||||||
return Err(ResolveError::UnhashedPackage(name.clone()));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Emit a request to fetch the metadata for this package.
|
if let Some(url) = url {
|
||||||
if self.index.packages().register(name.clone()) {
|
|
||||||
request_sink.blocking_send(Request::Package(name.clone()))?;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
(
|
|
||||||
PubGrubPackageInner::Marker { name, .. }
|
|
||||||
| PubGrubPackageInner::Extra { name, .. }
|
|
||||||
| PubGrubPackageInner::Dev { name, .. }
|
|
||||||
| PubGrubPackageInner::Package { name, .. },
|
|
||||||
Some(url),
|
|
||||||
) => {
|
|
||||||
// Verify that the package is allowed under the hash-checking policy.
|
// Verify that the package is allowed under the hash-checking policy.
|
||||||
if !self.hasher.allows_url(&url.verbatim) {
|
if !self.hasher.allows_url(&url.verbatim) {
|
||||||
return Err(ResolveError::UnhashedPackage(name.clone()));
|
return Err(ResolveError::UnhashedPackage(name.clone()));
|
||||||
|
@ -704,6 +683,15 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag
|
||||||
if self.index.distributions().register(dist.version_id()) {
|
if self.index.distributions().register(dist.version_id()) {
|
||||||
request_sink.blocking_send(Request::Dist(dist))?;
|
request_sink.blocking_send(Request::Dist(dist))?;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// Verify that the package is allowed under the hash-checking policy.
|
||||||
|
if !self.hasher.allows_package(name) {
|
||||||
|
return Err(ResolveError::UnhashedPackage(name.clone()));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Emit a request to fetch the metadata for this package.
|
||||||
|
if self.index.packages().register(name.clone()) {
|
||||||
|
request_sink.blocking_send(Request::Package(name.clone()))?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue