mirror of https://github.com/astral-sh/uv
Make the use of `Self` consistent. (#15074)
## Summary Make the use of `Self` consistent. Mostly done by running `cargo clippy --fix -- -A clippy::all -W clippy::use_self`. ## Test Plan <!-- How was it tested? --> No need.
This commit is contained in:
parent
57f900ad0d
commit
3f83390e34
|
|
@ -250,6 +250,7 @@ rc_buffer = "warn"
|
||||||
rc_mutex = "warn"
|
rc_mutex = "warn"
|
||||||
rest_pat_in_fully_bound_structs = "warn"
|
rest_pat_in_fully_bound_structs = "warn"
|
||||||
if_not_else = "allow"
|
if_not_else = "allow"
|
||||||
|
use_self = "warn"
|
||||||
|
|
||||||
# Diagnostics are not actionable: Enable once https://github.com/rust-lang/rust-clippy/issues/13774 is resolved.
|
# Diagnostics are not actionable: Enable once https://github.com/rust-lang/rust-clippy/issues/13774 is resolved.
|
||||||
large_stack_arrays = "allow"
|
large_stack_arrays = "allow"
|
||||||
|
|
|
||||||
|
|
@ -177,8 +177,8 @@ struct TrieState {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UrlTrie {
|
impl UrlTrie {
|
||||||
fn new() -> UrlTrie {
|
fn new() -> Self {
|
||||||
let mut trie = UrlTrie { states: vec![] };
|
let mut trie = Self { states: vec![] };
|
||||||
trie.alloc();
|
trie.alloc();
|
||||||
trie
|
trie
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -158,7 +158,7 @@ impl Credentials {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(Credentials::Basic {
|
Some(Self::Basic {
|
||||||
username: Username::new(Some(entry.login.clone())),
|
username: Username::new(Some(entry.login.clone())),
|
||||||
password: Some(Password(entry.password.clone())),
|
password: Some(Password(entry.password.clone())),
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -42,9 +42,9 @@ pub enum AuthPolicy {
|
||||||
impl Display for AuthPolicy {
|
impl Display for AuthPolicy {
|
||||||
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
AuthPolicy::Auto => write!(f, "auto"),
|
Self::Auto => write!(f, "auto"),
|
||||||
AuthPolicy::Always => write!(f, "always"),
|
Self::Always => write!(f, "always"),
|
||||||
AuthPolicy::Never => write!(f, "never"),
|
Self::Never => write!(f, "never"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ enum NetrcMode {
|
||||||
|
|
||||||
impl Default for NetrcMode {
|
impl Default for NetrcMode {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
NetrcMode::Automatic(LazyLock::new(|| match Netrc::new() {
|
Self::Automatic(LazyLock::new(|| match Netrc::new() {
|
||||||
Ok(netrc) => Some(netrc),
|
Ok(netrc) => Some(netrc),
|
||||||
Err(netrc::Error::Io(err)) if err.kind() == std::io::ErrorKind::NotFound => {
|
Err(netrc::Error::Io(err)) if err.kind() == std::io::ErrorKind::NotFound => {
|
||||||
debug!("No netrc file found");
|
debug!("No netrc file found");
|
||||||
|
|
@ -44,9 +44,9 @@ impl NetrcMode {
|
||||||
/// Get the parsed netrc file if enabled.
|
/// Get the parsed netrc file if enabled.
|
||||||
fn get(&self) -> Option<&Netrc> {
|
fn get(&self) -> Option<&Netrc> {
|
||||||
match self {
|
match self {
|
||||||
NetrcMode::Automatic(lock) => lock.as_ref(),
|
Self::Automatic(lock) => lock.as_ref(),
|
||||||
NetrcMode::Enabled(netrc) => Some(netrc),
|
Self::Enabled(netrc) => Some(netrc),
|
||||||
NetrcMode::Disabled => None,
|
Self::Disabled => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -129,7 +129,7 @@ impl AuthMiddleware {
|
||||||
|
|
||||||
impl Default for AuthMiddleware {
|
impl Default for AuthMiddleware {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
AuthMiddleware::new()
|
Self::new()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -723,9 +723,9 @@ impl Readme {
|
||||||
/// If the readme is a file, return the path to the file.
|
/// If the readme is a file, return the path to the file.
|
||||||
pub(crate) fn path(&self) -> Option<&Path> {
|
pub(crate) fn path(&self) -> Option<&Path> {
|
||||||
match self {
|
match self {
|
||||||
Readme::String(path) => Some(path),
|
Self::String(path) => Some(path),
|
||||||
Readme::File { file, .. } => Some(file),
|
Self::File { file, .. } => Some(file),
|
||||||
Readme::Text { .. } => None,
|
Self::Text { .. } => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ impl TryFrom<CacheArgs> for Cache {
|
||||||
type Error = io::Error;
|
type Error = io::Error;
|
||||||
|
|
||||||
fn try_from(value: CacheArgs) -> Result<Self, Self::Error> {
|
fn try_from(value: CacheArgs) -> Result<Self, Self::Error> {
|
||||||
Cache::from_settings(value.no_cache, value.cache_dir)
|
Self::from_settings(value.no_cache, value.cache_dir)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1211,7 +1211,7 @@ impl Refresh {
|
||||||
|
|
||||||
/// Combine two [`Refresh`] policies, taking the "max" of the two policies.
|
/// Combine two [`Refresh`] policies, taking the "max" of the two policies.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn combine(self, other: Refresh) -> Self {
|
pub fn combine(self, other: Self) -> Self {
|
||||||
/// Return the maximum of two timestamps.
|
/// Return the maximum of two timestamps.
|
||||||
fn max(a: Timestamp, b: Timestamp) -> Timestamp {
|
fn max(a: Timestamp, b: Timestamp) -> Timestamp {
|
||||||
if a > b { a } else { b }
|
if a > b { a } else { b }
|
||||||
|
|
@ -1220,24 +1220,24 @@ impl Refresh {
|
||||||
match (self, other) {
|
match (self, other) {
|
||||||
// If the policy is `None`, return the existing refresh policy.
|
// If the policy is `None`, return the existing refresh policy.
|
||||||
// Take the `max` of the two timestamps.
|
// Take the `max` of the two timestamps.
|
||||||
(Self::None(t1), Refresh::None(t2)) => Refresh::None(max(t1, t2)),
|
(Self::None(t1), Self::None(t2)) => Self::None(max(t1, t2)),
|
||||||
(Self::None(t1), Refresh::All(t2)) => Refresh::All(max(t1, t2)),
|
(Self::None(t1), Self::All(t2)) => Self::All(max(t1, t2)),
|
||||||
(Self::None(t1), Refresh::Packages(packages, paths, t2)) => {
|
(Self::None(t1), Self::Packages(packages, paths, t2)) => {
|
||||||
Refresh::Packages(packages, paths, max(t1, t2))
|
Self::Packages(packages, paths, max(t1, t2))
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the policy is `All`, refresh all packages.
|
// If the policy is `All`, refresh all packages.
|
||||||
(Self::All(t1), Refresh::None(t2)) => Refresh::All(max(t1, t2)),
|
(Self::All(t1), Self::None(t2)) => Self::All(max(t1, t2)),
|
||||||
(Self::All(t1), Refresh::All(t2)) => Refresh::All(max(t1, t2)),
|
(Self::All(t1), Self::All(t2)) => Self::All(max(t1, t2)),
|
||||||
(Self::All(t1), Refresh::Packages(.., t2)) => Refresh::All(max(t1, t2)),
|
(Self::All(t1), Self::Packages(.., t2)) => Self::All(max(t1, t2)),
|
||||||
|
|
||||||
// If the policy is `Packages`, take the "max" of the two policies.
|
// If the policy is `Packages`, take the "max" of the two policies.
|
||||||
(Self::Packages(packages, paths, t1), Refresh::None(t2)) => {
|
(Self::Packages(packages, paths, t1), Self::None(t2)) => {
|
||||||
Refresh::Packages(packages, paths, max(t1, t2))
|
Self::Packages(packages, paths, max(t1, t2))
|
||||||
}
|
}
|
||||||
(Self::Packages(.., t1), Refresh::All(t2)) => Refresh::All(max(t1, t2)),
|
(Self::Packages(.., t1), Self::All(t2)) => Self::All(max(t1, t2)),
|
||||||
(Self::Packages(packages1, paths1, t1), Refresh::Packages(packages2, paths2, t2)) => {
|
(Self::Packages(packages1, paths1, t1), Self::Packages(packages2, paths2, t2)) => {
|
||||||
Refresh::Packages(
|
Self::Packages(
|
||||||
packages1.into_iter().chain(packages2).collect(),
|
packages1.into_iter().chain(packages2).collect(),
|
||||||
paths1.into_iter().chain(paths2).collect(),
|
paths1.into_iter().chain(paths2).collect(),
|
||||||
max(t1, t2),
|
max(t1, t2),
|
||||||
|
|
|
||||||
|
|
@ -26,20 +26,20 @@ impl WheelCache<'_> {
|
||||||
/// The root directory for a cache bucket.
|
/// The root directory for a cache bucket.
|
||||||
pub fn root(&self) -> PathBuf {
|
pub fn root(&self) -> PathBuf {
|
||||||
match self {
|
match self {
|
||||||
WheelCache::Index(IndexUrl::Pypi(_)) => WheelCacheKind::Pypi.root(),
|
Self::Index(IndexUrl::Pypi(_)) => WheelCacheKind::Pypi.root(),
|
||||||
WheelCache::Index(url) => WheelCacheKind::Index
|
Self::Index(url) => WheelCacheKind::Index
|
||||||
.root()
|
.root()
|
||||||
.join(cache_digest(&CanonicalUrl::new(url.url()))),
|
.join(cache_digest(&CanonicalUrl::new(url.url()))),
|
||||||
WheelCache::Url(url) => WheelCacheKind::Url
|
Self::Url(url) => WheelCacheKind::Url
|
||||||
.root()
|
.root()
|
||||||
.join(cache_digest(&CanonicalUrl::new(url))),
|
.join(cache_digest(&CanonicalUrl::new(url))),
|
||||||
WheelCache::Path(url) => WheelCacheKind::Path
|
Self::Path(url) => WheelCacheKind::Path
|
||||||
.root()
|
.root()
|
||||||
.join(cache_digest(&CanonicalUrl::new(url))),
|
.join(cache_digest(&CanonicalUrl::new(url))),
|
||||||
WheelCache::Editable(url) => WheelCacheKind::Editable
|
Self::Editable(url) => WheelCacheKind::Editable
|
||||||
.root()
|
.root()
|
||||||
.join(cache_digest(&CanonicalUrl::new(url))),
|
.join(cache_digest(&CanonicalUrl::new(url))),
|
||||||
WheelCache::Git(url, sha) => WheelCacheKind::Git
|
Self::Git(url, sha) => WheelCacheKind::Git
|
||||||
.root()
|
.root()
|
||||||
.join(cache_digest(&CanonicalUrl::new(url)))
|
.join(cache_digest(&CanonicalUrl::new(url)))
|
||||||
.join(sha),
|
.join(sha),
|
||||||
|
|
|
||||||
|
|
@ -680,15 +680,15 @@ pub enum VersionBump {
|
||||||
impl std::fmt::Display for VersionBump {
|
impl std::fmt::Display for VersionBump {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
let string = match self {
|
let string = match self {
|
||||||
VersionBump::Major => "major",
|
Self::Major => "major",
|
||||||
VersionBump::Minor => "minor",
|
Self::Minor => "minor",
|
||||||
VersionBump::Patch => "patch",
|
Self::Patch => "patch",
|
||||||
VersionBump::Stable => "stable",
|
Self::Stable => "stable",
|
||||||
VersionBump::Alpha => "alpha",
|
Self::Alpha => "alpha",
|
||||||
VersionBump::Beta => "beta",
|
Self::Beta => "beta",
|
||||||
VersionBump::Rc => "rc",
|
Self::Rc => "rc",
|
||||||
VersionBump::Post => "post",
|
Self::Post => "post",
|
||||||
VersionBump::Dev => "dev",
|
Self::Dev => "dev",
|
||||||
};
|
};
|
||||||
string.fmt(f)
|
string.fmt(f)
|
||||||
}
|
}
|
||||||
|
|
@ -1017,13 +1017,13 @@ pub enum Maybe<T> {
|
||||||
impl<T> Maybe<T> {
|
impl<T> Maybe<T> {
|
||||||
pub fn into_option(self) -> Option<T> {
|
pub fn into_option(self) -> Option<T> {
|
||||||
match self {
|
match self {
|
||||||
Maybe::Some(value) => Some(value),
|
Self::Some(value) => Some(value),
|
||||||
Maybe::None => None,
|
Self::None => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_some(&self) -> bool {
|
pub fn is_some(&self) -> bool {
|
||||||
matches!(self, Maybe::Some(_))
|
matches!(self, Self::Some(_))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ impl From<ResolverArgs> for PipOptions {
|
||||||
exclude_newer_package: exclude_newer_package.map(ExcludeNewerPackage::from_iter),
|
exclude_newer_package: exclude_newer_package.map(ExcludeNewerPackage::from_iter),
|
||||||
link_mode,
|
link_mode,
|
||||||
no_sources: if no_sources { Some(true) } else { None },
|
no_sources: if no_sources { Some(true) } else { None },
|
||||||
..PipOptions::from(index_args)
|
..Self::from(index_args)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -141,7 +141,7 @@ impl From<InstallerArgs> for PipOptions {
|
||||||
link_mode,
|
link_mode,
|
||||||
compile_bytecode: flag(compile_bytecode, no_compile_bytecode, "compile-bytecode"),
|
compile_bytecode: flag(compile_bytecode, no_compile_bytecode, "compile-bytecode"),
|
||||||
no_sources: if no_sources { Some(true) } else { None },
|
no_sources: if no_sources { Some(true) } else { None },
|
||||||
..PipOptions::from(index_args)
|
..Self::from(index_args)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -203,7 +203,7 @@ impl From<ResolverInstallerArgs> for PipOptions {
|
||||||
link_mode,
|
link_mode,
|
||||||
compile_bytecode: flag(compile_bytecode, no_compile_bytecode, "compile-bytecode"),
|
compile_bytecode: flag(compile_bytecode, no_compile_bytecode, "compile-bytecode"),
|
||||||
no_sources: if no_sources { Some(true) } else { None },
|
no_sources: if no_sources { Some(true) } else { None },
|
||||||
..PipOptions::from(index_args)
|
..Self::from(index_args)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -221,7 +221,7 @@ impl From<FetchArgs> for PipOptions {
|
||||||
index_strategy,
|
index_strategy,
|
||||||
keyring_provider,
|
keyring_provider,
|
||||||
exclude_newer,
|
exclude_newer,
|
||||||
..PipOptions::from(index_args)
|
..Self::from(index_args)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -262,7 +262,7 @@ impl From<IndexArgs> for PipOptions {
|
||||||
.filter_map(Maybe::into_option)
|
.filter_map(Maybe::into_option)
|
||||||
.collect()
|
.collect()
|
||||||
}),
|
}),
|
||||||
..PipOptions::default()
|
..Self::default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -98,8 +98,8 @@ pub enum RedirectPolicy {
|
||||||
impl RedirectPolicy {
|
impl RedirectPolicy {
|
||||||
pub fn reqwest_policy(self) -> reqwest::redirect::Policy {
|
pub fn reqwest_policy(self) -> reqwest::redirect::Policy {
|
||||||
match self {
|
match self {
|
||||||
RedirectPolicy::BypassMiddleware => reqwest::redirect::Policy::default(),
|
Self::BypassMiddleware => reqwest::redirect::Policy::default(),
|
||||||
RedirectPolicy::RetriggerMiddleware => reqwest::redirect::Policy::none(),
|
Self::RetriggerMiddleware => reqwest::redirect::Policy::none(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -640,7 +640,7 @@ impl RedirectClientWithMiddleware {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<RedirectClientWithMiddleware> for ClientWithMiddleware {
|
impl From<RedirectClientWithMiddleware> for ClientWithMiddleware {
|
||||||
fn from(item: RedirectClientWithMiddleware) -> ClientWithMiddleware {
|
fn from(item: RedirectClientWithMiddleware) -> Self {
|
||||||
item.client
|
item.client
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -117,17 +117,17 @@ impl<CallbackError: std::error::Error + 'static> CachedClientError<CallbackError
|
||||||
/// Adds to existing errors if any, in case different layers retried.
|
/// Adds to existing errors if any, in case different layers retried.
|
||||||
fn with_retries(self, retries: u32) -> Self {
|
fn with_retries(self, retries: u32) -> Self {
|
||||||
match self {
|
match self {
|
||||||
CachedClientError::Client {
|
Self::Client {
|
||||||
retries: existing_retries,
|
retries: existing_retries,
|
||||||
err,
|
err,
|
||||||
} => CachedClientError::Client {
|
} => Self::Client {
|
||||||
retries: Some(existing_retries.unwrap_or_default() + retries),
|
retries: Some(existing_retries.unwrap_or_default() + retries),
|
||||||
err,
|
err,
|
||||||
},
|
},
|
||||||
CachedClientError::Callback {
|
Self::Callback {
|
||||||
retries: existing_retries,
|
retries: existing_retries,
|
||||||
err,
|
err,
|
||||||
} => CachedClientError::Callback {
|
} => Self::Callback {
|
||||||
retries: Some(existing_retries.unwrap_or_default() + retries),
|
retries: Some(existing_retries.unwrap_or_default() + retries),
|
||||||
err,
|
err,
|
||||||
},
|
},
|
||||||
|
|
@ -136,15 +136,15 @@ impl<CallbackError: std::error::Error + 'static> CachedClientError<CallbackError
|
||||||
|
|
||||||
fn retries(&self) -> Option<u32> {
|
fn retries(&self) -> Option<u32> {
|
||||||
match self {
|
match self {
|
||||||
CachedClientError::Client { retries, .. } => *retries,
|
Self::Client { retries, .. } => *retries,
|
||||||
CachedClientError::Callback { retries, .. } => *retries,
|
Self::Callback { retries, .. } => *retries,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn error(&self) -> &dyn std::error::Error {
|
fn error(&self) -> &dyn std::error::Error {
|
||||||
match self {
|
match self {
|
||||||
CachedClientError::Client { err, .. } => err,
|
Self::Client { err, .. } => err,
|
||||||
CachedClientError::Callback { err, .. } => err,
|
Self::Callback { err, .. } => err,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -176,12 +176,12 @@ impl<E: Into<Self> + std::error::Error + 'static> From<CachedClientError<E>> for
|
||||||
CachedClientError::Client {
|
CachedClientError::Client {
|
||||||
retries: Some(retries),
|
retries: Some(retries),
|
||||||
err,
|
err,
|
||||||
} => Error::new(err.into_kind(), retries),
|
} => Self::new(err.into_kind(), retries),
|
||||||
CachedClientError::Client { retries: None, err } => err,
|
CachedClientError::Client { retries: None, err } => err,
|
||||||
CachedClientError::Callback {
|
CachedClientError::Callback {
|
||||||
retries: Some(retries),
|
retries: Some(retries),
|
||||||
err,
|
err,
|
||||||
} => Error::new(err.into().into_kind(), retries),
|
} => Self::new(err.into().into_kind(), retries),
|
||||||
CachedClientError::Callback { retries: None, err } => err.into(),
|
CachedClientError::Callback { retries: None, err } => err.into(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -179,7 +179,7 @@ struct CacheControlParser<'b, I> {
|
||||||
impl<'b, B: 'b + ?Sized + AsRef<[u8]>, I: Iterator<Item = &'b B>> CacheControlParser<'b, I> {
|
impl<'b, B: 'b + ?Sized + AsRef<[u8]>, I: Iterator<Item = &'b B>> CacheControlParser<'b, I> {
|
||||||
/// Create a new parser of zero or more `Cache-Control` header values. The
|
/// Create a new parser of zero or more `Cache-Control` header values. The
|
||||||
/// given iterator should yield elements that satisfy `AsRef<[u8]>`.
|
/// given iterator should yield elements that satisfy `AsRef<[u8]>`.
|
||||||
fn new<II: IntoIterator<IntoIter = I>>(headers: II) -> CacheControlParser<'b, I> {
|
fn new<II: IntoIterator<IntoIter = I>>(headers: II) -> Self {
|
||||||
let mut directives = headers.into_iter();
|
let mut directives = headers.into_iter();
|
||||||
let cur = directives.next().map(AsRef::as_ref).unwrap_or(b"");
|
let cur = directives.next().map(AsRef::as_ref).unwrap_or(b"");
|
||||||
CacheControlParser {
|
CacheControlParser {
|
||||||
|
|
|
||||||
|
|
@ -1179,11 +1179,7 @@ impl SimpleMetadata {
|
||||||
let SimpleHtml { base, files } =
|
let SimpleHtml { base, files } =
|
||||||
SimpleHtml::parse(text, url).map_err(|err| Error::from_html_err(err, url.clone()))?;
|
SimpleHtml::parse(text, url).map_err(|err| Error::from_html_err(err, url.clone()))?;
|
||||||
|
|
||||||
Ok(SimpleMetadata::from_files(
|
Ok(Self::from_files(files, package_name, base.as_url()))
|
||||||
files,
|
|
||||||
package_name,
|
|
||||||
base.as_url(),
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,10 +19,10 @@ pub struct Concurrency {
|
||||||
|
|
||||||
impl Default for Concurrency {
|
impl Default for Concurrency {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Concurrency {
|
Self {
|
||||||
downloads: Concurrency::DEFAULT_DOWNLOADS,
|
downloads: Self::DEFAULT_DOWNLOADS,
|
||||||
builds: Concurrency::threads(),
|
builds: Self::threads(),
|
||||||
installs: Concurrency::threads(),
|
installs: Self::threads(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -67,8 +67,8 @@ enum ConfigSettingValue {
|
||||||
impl serde::Serialize for ConfigSettingValue {
|
impl serde::Serialize for ConfigSettingValue {
|
||||||
fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
|
fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
|
||||||
match self {
|
match self {
|
||||||
ConfigSettingValue::String(value) => serializer.serialize_str(value),
|
Self::String(value) => serializer.serialize_str(value),
|
||||||
ConfigSettingValue::List(values) => serializer.collect_seq(values.iter()),
|
Self::List(values) => serializer.collect_seq(values.iter()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -153,7 +153,7 @@ impl ConfigSettings {
|
||||||
|
|
||||||
/// Merge two sets of config settings, with the values in `self` taking precedence.
|
/// Merge two sets of config settings, with the values in `self` taking precedence.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn merge(self, other: ConfigSettings) -> ConfigSettings {
|
pub fn merge(self, other: Self) -> Self {
|
||||||
let mut config = self.0;
|
let mut config = self.0;
|
||||||
for (key, value) in other.0 {
|
for (key, value) in other.0 {
|
||||||
match config.entry(key) {
|
match config.entry(key) {
|
||||||
|
|
@ -277,7 +277,7 @@ impl PackageConfigSettings {
|
||||||
|
|
||||||
/// Merge two sets of package config settings, with the values in `self` taking precedence.
|
/// Merge two sets of package config settings, with the values in `self` taking precedence.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn merge(mut self, other: PackageConfigSettings) -> PackageConfigSettings {
|
pub fn merge(mut self, other: Self) -> Self {
|
||||||
for (package, settings) in other.0 {
|
for (package, settings) in other.0 {
|
||||||
match self.0.entry(package) {
|
match self.0.entry(package) {
|
||||||
Entry::Vacant(vacant) => {
|
Entry::Vacant(vacant) => {
|
||||||
|
|
|
||||||
|
|
@ -253,7 +253,7 @@ impl DependencyGroupsHistory {
|
||||||
/// [`DependencyGroups::is_empty`][] when there aren't any defaults set.
|
/// [`DependencyGroups::is_empty`][] when there aren't any defaults set.
|
||||||
/// When there are defaults the two will disagree, and rightfully so!
|
/// When there are defaults the two will disagree, and rightfully so!
|
||||||
pub fn as_flags_pretty(&self) -> Vec<Cow<str>> {
|
pub fn as_flags_pretty(&self) -> Vec<Cow<str>> {
|
||||||
let DependencyGroupsHistory {
|
let Self {
|
||||||
dev_mode,
|
dev_mode,
|
||||||
group,
|
group,
|
||||||
only_group,
|
only_group,
|
||||||
|
|
@ -362,26 +362,26 @@ impl IncludeGroups {
|
||||||
/// Returns `true` if the specification includes the given group.
|
/// Returns `true` if the specification includes the given group.
|
||||||
pub fn contains(&self, group: &GroupName) -> bool {
|
pub fn contains(&self, group: &GroupName) -> bool {
|
||||||
match self {
|
match self {
|
||||||
IncludeGroups::Some(groups) => groups.contains(group),
|
Self::Some(groups) => groups.contains(group),
|
||||||
IncludeGroups::All => true,
|
Self::All => true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns `true` if the specification will have no effect.
|
/// Returns `true` if the specification will have no effect.
|
||||||
pub fn is_empty(&self) -> bool {
|
pub fn is_empty(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
IncludeGroups::Some(groups) => groups.is_empty(),
|
Self::Some(groups) => groups.is_empty(),
|
||||||
// Although technically this is a noop if they have no groups,
|
// Although technically this is a noop if they have no groups,
|
||||||
// conceptually they're *trying* to have an effect, so treat it as one.
|
// conceptually they're *trying* to have an effect, so treat it as one.
|
||||||
IncludeGroups::All => false,
|
Self::All => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Iterate over all groups referenced in the [`IncludeGroups`].
|
/// Iterate over all groups referenced in the [`IncludeGroups`].
|
||||||
pub fn names(&self) -> std::slice::Iter<GroupName> {
|
pub fn names(&self) -> std::slice::Iter<GroupName> {
|
||||||
match self {
|
match self {
|
||||||
IncludeGroups::Some(groups) => groups.iter(),
|
Self::Some(groups) => groups.iter(),
|
||||||
IncludeGroups::All => [].iter(),
|
Self::All => [].iter(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,14 +14,14 @@ impl DryRun {
|
||||||
/// Determine the [`DryRun`] setting based on the command-line arguments.
|
/// Determine the [`DryRun`] setting based on the command-line arguments.
|
||||||
pub fn from_args(dry_run: bool) -> Self {
|
pub fn from_args(dry_run: bool) -> Self {
|
||||||
if dry_run {
|
if dry_run {
|
||||||
DryRun::Enabled
|
Self::Enabled
|
||||||
} else {
|
} else {
|
||||||
DryRun::Disabled
|
Self::Disabled
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns `true` if dry run mode is enabled.
|
/// Returns `true` if dry run mode is enabled.
|
||||||
pub const fn enabled(&self) -> bool {
|
pub const fn enabled(&self) -> bool {
|
||||||
matches!(self, DryRun::Enabled) || matches!(self, DryRun::Check)
|
matches!(self, Self::Enabled) || matches!(self, Self::Check)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -214,7 +214,7 @@ impl ExtrasSpecificationHistory {
|
||||||
/// [`ExtrasSpecification::is_empty`][] when there aren't any defaults set.
|
/// [`ExtrasSpecification::is_empty`][] when there aren't any defaults set.
|
||||||
/// When there are defaults the two will disagree, and rightfully so!
|
/// When there are defaults the two will disagree, and rightfully so!
|
||||||
pub fn as_flags_pretty(&self) -> Vec<Cow<str>> {
|
pub fn as_flags_pretty(&self) -> Vec<Cow<str>> {
|
||||||
let ExtrasSpecificationHistory {
|
let Self {
|
||||||
extra,
|
extra,
|
||||||
no_extra,
|
no_extra,
|
||||||
all_extras,
|
all_extras,
|
||||||
|
|
@ -296,26 +296,26 @@ impl IncludeExtras {
|
||||||
/// Returns `true` if the specification includes the given extra.
|
/// Returns `true` if the specification includes the given extra.
|
||||||
pub fn contains(&self, extra: &ExtraName) -> bool {
|
pub fn contains(&self, extra: &ExtraName) -> bool {
|
||||||
match self {
|
match self {
|
||||||
IncludeExtras::Some(extras) => extras.contains(extra),
|
Self::Some(extras) => extras.contains(extra),
|
||||||
IncludeExtras::All => true,
|
Self::All => true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns `true` if the specification will have no effect.
|
/// Returns `true` if the specification will have no effect.
|
||||||
pub fn is_empty(&self) -> bool {
|
pub fn is_empty(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
IncludeExtras::Some(extras) => extras.is_empty(),
|
Self::Some(extras) => extras.is_empty(),
|
||||||
// Although technically this is a noop if they have no extras,
|
// Although technically this is a noop if they have no extras,
|
||||||
// conceptually they're *trying* to have an effect, so treat it as one.
|
// conceptually they're *trying* to have an effect, so treat it as one.
|
||||||
IncludeExtras::All => false,
|
Self::All => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Iterate over all extras referenced in the [`IncludeExtras`].
|
/// Iterate over all extras referenced in the [`IncludeExtras`].
|
||||||
pub fn names(&self) -> std::slice::Iter<ExtraName> {
|
pub fn names(&self) -> std::slice::Iter<ExtraName> {
|
||||||
match self {
|
match self {
|
||||||
IncludeExtras::Some(extras) => extras.iter(),
|
Self::Some(extras) => extras.iter(),
|
||||||
IncludeExtras::All => [].iter(),
|
Self::All => [].iter(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ impl Display for PreviewFeatures {
|
||||||
if self.is_empty() {
|
if self.is_empty() {
|
||||||
write!(f, "none")
|
write!(f, "none")
|
||||||
} else {
|
} else {
|
||||||
let features: Vec<&str> = self.iter().map(PreviewFeatures::flag_as_str).collect();
|
let features: Vec<&str> = self.iter().map(Self::flag_as_str).collect();
|
||||||
write!(f, "{}", features.join(","))
|
write!(f, "{}", features.join(","))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -56,7 +56,7 @@ impl FromStr for PreviewFeatures {
|
||||||
type Err = PreviewFeaturesParseError;
|
type Err = PreviewFeaturesParseError;
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
let mut flags = PreviewFeatures::empty();
|
let mut flags = Self::empty();
|
||||||
|
|
||||||
for part in s.split(',') {
|
for part in s.split(',') {
|
||||||
let part = part.trim();
|
let part = part.trim();
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,8 @@ impl TrustedHost {
|
||||||
/// Returns `true` if the [`Url`] matches this trusted host.
|
/// Returns `true` if the [`Url`] matches this trusted host.
|
||||||
pub fn matches(&self, url: &Url) -> bool {
|
pub fn matches(&self, url: &Url) -> bool {
|
||||||
match self {
|
match self {
|
||||||
TrustedHost::Wildcard => true,
|
Self::Wildcard => true,
|
||||||
TrustedHost::Host { scheme, host, port } => {
|
Self::Host { scheme, host, port } => {
|
||||||
if scheme.as_ref().is_some_and(|scheme| scheme != url.scheme()) {
|
if scheme.as_ref().is_some_and(|scheme| scheme != url.scheme()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -53,9 +53,9 @@ impl<'de> Deserialize<'de> for TrustedHost {
|
||||||
}
|
}
|
||||||
|
|
||||||
serde_untagged::UntaggedEnumVisitor::new()
|
serde_untagged::UntaggedEnumVisitor::new()
|
||||||
.string(|string| TrustedHost::from_str(string).map_err(serde::de::Error::custom))
|
.string(|string| Self::from_str(string).map_err(serde::de::Error::custom))
|
||||||
.map(|map| {
|
.map(|map| {
|
||||||
map.deserialize::<Inner>().map(|inner| TrustedHost::Host {
|
map.deserialize::<Inner>().map(|inner| Self::Host {
|
||||||
scheme: inner.scheme,
|
scheme: inner.scheme,
|
||||||
host: inner.host,
|
host: inner.host,
|
||||||
port: inner.port,
|
port: inner.port,
|
||||||
|
|
@ -123,10 +123,10 @@ impl FromStr for TrustedHost {
|
||||||
impl std::fmt::Display for TrustedHost {
|
impl std::fmt::Display for TrustedHost {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
TrustedHost::Wildcard => {
|
Self::Wildcard => {
|
||||||
write!(f, "*")?;
|
write!(f, "*")?;
|
||||||
}
|
}
|
||||||
TrustedHost::Host { scheme, host, port } => {
|
Self::Host { scheme, host, port } => {
|
||||||
if let Some(scheme) = &scheme {
|
if let Some(scheme) = &scheme {
|
||||||
write!(f, "{scheme}://{host}")?;
|
write!(f, "{scheme}://{host}")?;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -193,15 +193,15 @@ enum Set {
|
||||||
impl Set {
|
impl Set {
|
||||||
fn name(&self) -> Option<&str> {
|
fn name(&self) -> Option<&str> {
|
||||||
match self {
|
match self {
|
||||||
Set::Global { .. } => None,
|
Self::Global { .. } => None,
|
||||||
Set::Named { name, .. } => Some(name),
|
Self::Named { name, .. } => Some(name),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn metadata(&self) -> &OptionSet {
|
fn metadata(&self) -> &OptionSet {
|
||||||
match self {
|
match self {
|
||||||
Set::Global { set, .. } => set,
|
Self::Global { set, .. } => set,
|
||||||
Set::Named { set, .. } => set,
|
Self::Named { set, .. } => set,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -66,12 +66,12 @@ pub enum BuildDispatchError {
|
||||||
impl IsBuildBackendError for BuildDispatchError {
|
impl IsBuildBackendError for BuildDispatchError {
|
||||||
fn is_build_backend_error(&self) -> bool {
|
fn is_build_backend_error(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
BuildDispatchError::Tags(_)
|
Self::Tags(_)
|
||||||
| BuildDispatchError::Resolve(_)
|
| Self::Resolve(_)
|
||||||
| BuildDispatchError::Join(_)
|
| Self::Join(_)
|
||||||
| BuildDispatchError::Anyhow(_)
|
| Self::Anyhow(_)
|
||||||
| BuildDispatchError::Prepare(_) => false,
|
| Self::Prepare(_) => false,
|
||||||
BuildDispatchError::BuildFrontend(err) => err.is_build_backend_error(),
|
Self::BuildFrontend(err) => err.is_build_backend_error(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,10 +58,7 @@ impl FromStr for BuildTag {
|
||||||
None => (s, None),
|
None => (s, None),
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(BuildTag(
|
Ok(Self(prefix.parse::<u64>()?, suffix.map(SmallString::from)))
|
||||||
prefix.parse::<u64>()?,
|
|
||||||
suffix.map(SmallString::from),
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,26 +32,24 @@ pub enum DistErrorKind {
|
||||||
impl DistErrorKind {
|
impl DistErrorKind {
|
||||||
pub fn from_requested_dist(dist: &RequestedDist, err: &impl IsBuildBackendError) -> Self {
|
pub fn from_requested_dist(dist: &RequestedDist, err: &impl IsBuildBackendError) -> Self {
|
||||||
match dist {
|
match dist {
|
||||||
RequestedDist::Installed(_) => DistErrorKind::Read,
|
RequestedDist::Installed(_) => Self::Read,
|
||||||
RequestedDist::Installable(dist) => Self::from_dist(dist, err),
|
RequestedDist::Installable(dist) => Self::from_dist(dist, err),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_dist(dist: &Dist, err: &impl IsBuildBackendError) -> Self {
|
pub fn from_dist(dist: &Dist, err: &impl IsBuildBackendError) -> Self {
|
||||||
if err.is_build_backend_error() {
|
if err.is_build_backend_error() {
|
||||||
DistErrorKind::BuildBackend
|
Self::BuildBackend
|
||||||
} else {
|
} else {
|
||||||
match dist {
|
match dist {
|
||||||
Dist::Built(BuiltDist::Path(_)) => DistErrorKind::Read,
|
Dist::Built(BuiltDist::Path(_)) => Self::Read,
|
||||||
Dist::Source(SourceDist::Path(_) | SourceDist::Directory(_)) => {
|
Dist::Source(SourceDist::Path(_) | SourceDist::Directory(_)) => Self::Build,
|
||||||
DistErrorKind::Build
|
Dist::Built(_) => Self::Download,
|
||||||
}
|
|
||||||
Dist::Built(_) => DistErrorKind::Download,
|
|
||||||
Dist::Source(source_dist) => {
|
Dist::Source(source_dist) => {
|
||||||
if source_dist.is_local() {
|
if source_dist.is_local() {
|
||||||
DistErrorKind::Build
|
Self::Build
|
||||||
} else {
|
} else {
|
||||||
DistErrorKind::DownloadAndBuild
|
Self::DownloadAndBuild
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -62,11 +60,11 @@ impl DistErrorKind {
|
||||||
impl Display for DistErrorKind {
|
impl Display for DistErrorKind {
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
DistErrorKind::Download => f.write_str("Failed to download"),
|
Self::Download => f.write_str("Failed to download"),
|
||||||
DistErrorKind::DownloadAndBuild => f.write_str("Failed to download and build"),
|
Self::DownloadAndBuild => f.write_str("Failed to download and build"),
|
||||||
DistErrorKind::Build => f.write_str("Failed to build"),
|
Self::Build => f.write_str("Failed to build"),
|
||||||
DistErrorKind::BuildBackend => f.write_str("Failed to build"),
|
Self::BuildBackend => f.write_str("Failed to build"),
|
||||||
DistErrorKind::Read => f.write_str("Failed to read"),
|
Self::Read => f.write_str("Failed to read"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -87,10 +85,7 @@ impl DerivationChain {
|
||||||
///
|
///
|
||||||
/// This is used to construct a derivation chain upon install failure in the `uv pip` context,
|
/// This is used to construct a derivation chain upon install failure in the `uv pip` context,
|
||||||
/// where we don't have a lockfile describing the resolution.
|
/// where we don't have a lockfile describing the resolution.
|
||||||
pub fn from_resolution(
|
pub fn from_resolution(resolution: &Resolution, target: DistRef<'_>) -> Option<Self> {
|
||||||
resolution: &Resolution,
|
|
||||||
target: DistRef<'_>,
|
|
||||||
) -> Option<DerivationChain> {
|
|
||||||
// Find the target distribution in the resolution graph.
|
// Find the target distribution in the resolution graph.
|
||||||
let target = resolution.graph().node_indices().find(|node| {
|
let target = resolution.graph().node_indices().find(|node| {
|
||||||
let Node::Dist {
|
let Node::Dist {
|
||||||
|
|
@ -117,7 +112,7 @@ impl DerivationChain {
|
||||||
Node::Root => {
|
Node::Root => {
|
||||||
path.reverse();
|
path.reverse();
|
||||||
path.pop();
|
path.pop();
|
||||||
return Some(DerivationChain::from_iter(path));
|
return Some(Self::from_iter(path));
|
||||||
}
|
}
|
||||||
Node::Dist { dist, .. } => {
|
Node::Dist { dist, .. } => {
|
||||||
for edge in resolution.graph().edges_directed(node, Direction::Incoming) {
|
for edge in resolution.graph().edges_directed(node, Direction::Incoming) {
|
||||||
|
|
|
||||||
|
|
@ -80,8 +80,8 @@ impl FileLocation {
|
||||||
/// that page.
|
/// that page.
|
||||||
pub fn new(url: SmallString, base: &SmallString) -> Self {
|
pub fn new(url: SmallString, base: &SmallString) -> Self {
|
||||||
match split_scheme(&url) {
|
match split_scheme(&url) {
|
||||||
Some(..) => FileLocation::AbsoluteUrl(UrlString::new(url)),
|
Some(..) => Self::AbsoluteUrl(UrlString::new(url)),
|
||||||
None => FileLocation::RelativeUrl(base.clone(), url),
|
None => Self::RelativeUrl(base.clone(), url),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -98,7 +98,7 @@ impl FileLocation {
|
||||||
/// (Because URLs must be valid UTF-8.)
|
/// (Because URLs must be valid UTF-8.)
|
||||||
pub fn to_url(&self) -> Result<DisplaySafeUrl, ToUrlError> {
|
pub fn to_url(&self) -> Result<DisplaySafeUrl, ToUrlError> {
|
||||||
match *self {
|
match *self {
|
||||||
FileLocation::RelativeUrl(ref base, ref path) => {
|
Self::RelativeUrl(ref base, ref path) => {
|
||||||
let base_url =
|
let base_url =
|
||||||
DisplaySafeUrl::parse(base).map_err(|err| ToUrlError::InvalidBase {
|
DisplaySafeUrl::parse(base).map_err(|err| ToUrlError::InvalidBase {
|
||||||
base: base.to_string(),
|
base: base.to_string(),
|
||||||
|
|
@ -111,7 +111,7 @@ impl FileLocation {
|
||||||
})?;
|
})?;
|
||||||
Ok(joined)
|
Ok(joined)
|
||||||
}
|
}
|
||||||
FileLocation::AbsoluteUrl(ref absolute) => absolute.to_url(),
|
Self::AbsoluteUrl(ref absolute) => absolute.to_url(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -174,7 +174,7 @@ impl UrlString {
|
||||||
pub fn without_fragment(&self) -> Cow<'_, Self> {
|
pub fn without_fragment(&self) -> Cow<'_, Self> {
|
||||||
self.as_ref()
|
self.as_ref()
|
||||||
.split_once('#')
|
.split_once('#')
|
||||||
.map(|(path, _)| Cow::Owned(UrlString(SmallString::from(path))))
|
.map(|(path, _)| Cow::Owned(Self(SmallString::from(path))))
|
||||||
.unwrap_or(Cow::Borrowed(self))
|
.unwrap_or(Cow::Borrowed(self))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,12 +25,12 @@ impl HashPolicy<'_> {
|
||||||
/// Returns `true` if the hash policy indicates that hashes should be generated.
|
/// Returns `true` if the hash policy indicates that hashes should be generated.
|
||||||
pub fn is_generate(&self, dist: &crate::BuiltDist) -> bool {
|
pub fn is_generate(&self, dist: &crate::BuiltDist) -> bool {
|
||||||
match self {
|
match self {
|
||||||
HashPolicy::Generate(HashGeneration::Url) => dist.file().is_none(),
|
Self::Generate(HashGeneration::Url) => dist.file().is_none(),
|
||||||
HashPolicy::Generate(HashGeneration::All) => {
|
Self::Generate(HashGeneration::All) => {
|
||||||
dist.file().is_none_or(|file| file.hashes.is_empty())
|
dist.file().is_none_or(|file| file.hashes.is_empty())
|
||||||
}
|
}
|
||||||
HashPolicy::Validate(_) => false,
|
Self::Validate(_) => false,
|
||||||
HashPolicy::None => false,
|
Self::None => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ impl<'de> serde::de::Deserialize<'de> for IndexName {
|
||||||
D: serde::de::Deserializer<'de>,
|
D: serde::de::Deserializer<'de>,
|
||||||
{
|
{
|
||||||
let s = Cow::<'_, str>::deserialize(deserializer)?;
|
let s = Cow::<'_, str>::deserialize(deserializer)?;
|
||||||
IndexName::new(&s).map_err(serde::de::Error::custom)
|
Self::new(&s).map_err(serde::de::Error::custom)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -212,7 +212,7 @@ impl serde::ser::Serialize for IndexUrl {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'de> serde::de::Deserialize<'de> for IndexUrl {
|
impl<'de> serde::de::Deserialize<'de> for IndexUrl {
|
||||||
fn deserialize<D>(deserializer: D) -> Result<IndexUrl, D::Error>
|
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||||
where
|
where
|
||||||
D: serde::de::Deserializer<'de>,
|
D: serde::de::Deserializer<'de>,
|
||||||
{
|
{
|
||||||
|
|
@ -488,8 +488,8 @@ impl<'a> IndexLocations {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<&IndexLocations> for uv_auth::Indexes {
|
impl From<&IndexLocations> for uv_auth::Indexes {
|
||||||
fn from(index_locations: &IndexLocations) -> uv_auth::Indexes {
|
fn from(index_locations: &IndexLocations) -> Self {
|
||||||
uv_auth::Indexes::from_indexes(index_locations.allowed_indexes().into_iter().map(|index| {
|
Self::from_indexes(index_locations.allowed_indexes().into_iter().map(|index| {
|
||||||
let mut url = index.url().url().clone();
|
let mut url = index.url().url().clone();
|
||||||
url.set_username("").ok();
|
url.set_username("").ok();
|
||||||
url.set_password(None).ok();
|
url.set_password(None).ok();
|
||||||
|
|
|
||||||
|
|
@ -14,9 +14,9 @@ impl KnownPlatform {
|
||||||
/// Return the platform's `sys.platform` value.
|
/// Return the platform's `sys.platform` value.
|
||||||
pub fn sys_platform(self) -> &'static str {
|
pub fn sys_platform(self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
KnownPlatform::Linux => "linux",
|
Self::Linux => "linux",
|
||||||
KnownPlatform::Windows => "win32",
|
Self::Windows => "win32",
|
||||||
KnownPlatform::MacOS => "darwin",
|
Self::MacOS => "darwin",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -26,21 +26,21 @@ impl KnownPlatform {
|
||||||
key: MarkerValueString::SysPlatform,
|
key: MarkerValueString::SysPlatform,
|
||||||
operator: MarkerOperator::Equal,
|
operator: MarkerOperator::Equal,
|
||||||
value: match self {
|
value: match self {
|
||||||
KnownPlatform::Linux => arcstr::literal!("linux"),
|
Self::Linux => arcstr::literal!("linux"),
|
||||||
KnownPlatform::Windows => arcstr::literal!("win32"),
|
Self::Windows => arcstr::literal!("win32"),
|
||||||
KnownPlatform::MacOS => arcstr::literal!("darwin"),
|
Self::MacOS => arcstr::literal!("darwin"),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Determine the [`KnownPlatform`] from a marker tree.
|
/// Determine the [`KnownPlatform`] from a marker tree.
|
||||||
pub fn from_marker(marker: MarkerTree) -> Option<KnownPlatform> {
|
pub fn from_marker(marker: MarkerTree) -> Option<Self> {
|
||||||
if marker == KnownPlatform::Linux.marker() {
|
if marker == Self::Linux.marker() {
|
||||||
Some(KnownPlatform::Linux)
|
Some(Self::Linux)
|
||||||
} else if marker == KnownPlatform::Windows.marker() {
|
} else if marker == Self::Windows.marker() {
|
||||||
Some(KnownPlatform::Windows)
|
Some(Self::Windows)
|
||||||
} else if marker == KnownPlatform::MacOS.marker() {
|
} else if marker == Self::MacOS.marker() {
|
||||||
Some(KnownPlatform::MacOS)
|
Some(Self::MacOS)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
@ -50,9 +50,9 @@ impl KnownPlatform {
|
||||||
impl Display for KnownPlatform {
|
impl Display for KnownPlatform {
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
KnownPlatform::Linux => write!(f, "Linux"),
|
Self::Linux => write!(f, "Linux"),
|
||||||
KnownPlatform::Windows => write!(f, "Windows"),
|
Self::Windows => write!(f, "Windows"),
|
||||||
KnownPlatform::MacOS => write!(f, "macOS"),
|
Self::MacOS => write!(f, "macOS"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -122,8 +122,8 @@ impl<T: Pep508Url> VersionOrUrlRef<'_, T> {
|
||||||
/// If it is a URL, return its value.
|
/// If it is a URL, return its value.
|
||||||
pub fn url(&self) -> Option<&T> {
|
pub fn url(&self) -> Option<&T> {
|
||||||
match self {
|
match self {
|
||||||
VersionOrUrlRef::Version(_) => None,
|
Self::Version(_) => None,
|
||||||
VersionOrUrlRef::Url(url) => Some(url),
|
Self::Url(url) => Some(url),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -131,8 +131,8 @@ impl<T: Pep508Url> VersionOrUrlRef<'_, T> {
|
||||||
impl Verbatim for VersionOrUrlRef<'_> {
|
impl Verbatim for VersionOrUrlRef<'_> {
|
||||||
fn verbatim(&self) -> Cow<'_, str> {
|
fn verbatim(&self) -> Cow<'_, str> {
|
||||||
match self {
|
match self {
|
||||||
VersionOrUrlRef::Version(version) => Cow::Owned(format!("=={version}")),
|
Self::Version(version) => Cow::Owned(format!("=={version}")),
|
||||||
VersionOrUrlRef::Url(url) => Cow::Owned(format!(" @ {}", url.verbatim())),
|
Self::Url(url) => Cow::Owned(format!(" @ {}", url.verbatim())),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -140,8 +140,8 @@ impl Verbatim for VersionOrUrlRef<'_> {
|
||||||
impl std::fmt::Display for VersionOrUrlRef<'_> {
|
impl std::fmt::Display for VersionOrUrlRef<'_> {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
VersionOrUrlRef::Version(version) => write!(f, "=={version}"),
|
Self::Version(version) => write!(f, "=={version}"),
|
||||||
VersionOrUrlRef::Url(url) => write!(f, " @ {url}"),
|
Self::Url(url) => write!(f, " @ {url}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -159,16 +159,16 @@ impl InstalledVersion<'_> {
|
||||||
/// If it is a URL, return its value.
|
/// If it is a URL, return its value.
|
||||||
pub fn url(&self) -> Option<&DisplaySafeUrl> {
|
pub fn url(&self) -> Option<&DisplaySafeUrl> {
|
||||||
match self {
|
match self {
|
||||||
InstalledVersion::Version(_) => None,
|
Self::Version(_) => None,
|
||||||
InstalledVersion::Url(url, _) => Some(url),
|
Self::Url(url, _) => Some(url),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// If it is a version, return its value.
|
/// If it is a version, return its value.
|
||||||
pub fn version(&self) -> &Version {
|
pub fn version(&self) -> &Version {
|
||||||
match self {
|
match self {
|
||||||
InstalledVersion::Version(version) => version,
|
Self::Version(version) => version,
|
||||||
InstalledVersion::Url(_, version) => version,
|
Self::Url(_, version) => version,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -176,8 +176,8 @@ impl InstalledVersion<'_> {
|
||||||
impl std::fmt::Display for InstalledVersion<'_> {
|
impl std::fmt::Display for InstalledVersion<'_> {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
InstalledVersion::Version(version) => write!(f, "=={version}"),
|
Self::Version(version) => write!(f, "=={version}"),
|
||||||
InstalledVersion::Url(url, version) => write!(f, "=={version} (from {url})"),
|
Self::Url(url, version) => write!(f, "=={version} (from {url})"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -361,7 +361,7 @@ impl Dist {
|
||||||
location: DisplaySafeUrl,
|
location: DisplaySafeUrl,
|
||||||
subdirectory: Option<Box<Path>>,
|
subdirectory: Option<Box<Path>>,
|
||||||
ext: DistExtension,
|
ext: DistExtension,
|
||||||
) -> Result<Dist, Error> {
|
) -> Result<Self, Error> {
|
||||||
match ext {
|
match ext {
|
||||||
DistExtension::Wheel => {
|
DistExtension::Wheel => {
|
||||||
// Validate that the name in the wheel matches that of the requirement.
|
// Validate that the name in the wheel matches that of the requirement.
|
||||||
|
|
@ -398,7 +398,7 @@ impl Dist {
|
||||||
url: VerbatimUrl,
|
url: VerbatimUrl,
|
||||||
install_path: &Path,
|
install_path: &Path,
|
||||||
ext: DistExtension,
|
ext: DistExtension,
|
||||||
) -> Result<Dist, Error> {
|
) -> Result<Self, Error> {
|
||||||
// Convert to an absolute path.
|
// Convert to an absolute path.
|
||||||
let install_path = path::absolute(install_path)?;
|
let install_path = path::absolute(install_path)?;
|
||||||
|
|
||||||
|
|
@ -456,7 +456,7 @@ impl Dist {
|
||||||
install_path: &Path,
|
install_path: &Path,
|
||||||
editable: Option<bool>,
|
editable: Option<bool>,
|
||||||
r#virtual: Option<bool>,
|
r#virtual: Option<bool>,
|
||||||
) -> Result<Dist, Error> {
|
) -> Result<Self, Error> {
|
||||||
// Convert to an absolute path.
|
// Convert to an absolute path.
|
||||||
let install_path = path::absolute(install_path)?;
|
let install_path = path::absolute(install_path)?;
|
||||||
|
|
||||||
|
|
@ -484,7 +484,7 @@ impl Dist {
|
||||||
url: VerbatimUrl,
|
url: VerbatimUrl,
|
||||||
git: GitUrl,
|
git: GitUrl,
|
||||||
subdirectory: Option<Box<Path>>,
|
subdirectory: Option<Box<Path>>,
|
||||||
) -> Result<Dist, Error> {
|
) -> Result<Self, Error> {
|
||||||
Ok(Self::Source(SourceDist::Git(GitSourceDist {
|
Ok(Self::Source(SourceDist::Git(GitSourceDist {
|
||||||
name,
|
name,
|
||||||
git: Box::new(git),
|
git: Box::new(git),
|
||||||
|
|
@ -854,17 +854,17 @@ impl Name for Dist {
|
||||||
impl Name for CompatibleDist<'_> {
|
impl Name for CompatibleDist<'_> {
|
||||||
fn name(&self) -> &PackageName {
|
fn name(&self) -> &PackageName {
|
||||||
match self {
|
match self {
|
||||||
CompatibleDist::InstalledDist(dist) => dist.name(),
|
Self::InstalledDist(dist) => dist.name(),
|
||||||
CompatibleDist::SourceDist {
|
Self::SourceDist {
|
||||||
sdist,
|
sdist,
|
||||||
prioritized: _,
|
prioritized: _,
|
||||||
} => sdist.name(),
|
} => sdist.name(),
|
||||||
CompatibleDist::CompatibleWheel {
|
Self::CompatibleWheel {
|
||||||
wheel,
|
wheel,
|
||||||
priority: _,
|
priority: _,
|
||||||
prioritized: _,
|
prioritized: _,
|
||||||
} => wheel.name(),
|
} => wheel.name(),
|
||||||
CompatibleDist::IncompatibleWheel {
|
Self::IncompatibleWheel {
|
||||||
sdist,
|
sdist,
|
||||||
wheel: _,
|
wheel: _,
|
||||||
prioritized: _,
|
prioritized: _,
|
||||||
|
|
@ -1450,15 +1450,15 @@ impl Identifier for SourceUrl<'_> {
|
||||||
impl Identifier for BuildableSource<'_> {
|
impl Identifier for BuildableSource<'_> {
|
||||||
fn distribution_id(&self) -> DistributionId {
|
fn distribution_id(&self) -> DistributionId {
|
||||||
match self {
|
match self {
|
||||||
BuildableSource::Dist(source) => source.distribution_id(),
|
Self::Dist(source) => source.distribution_id(),
|
||||||
BuildableSource::Url(source) => source.distribution_id(),
|
Self::Url(source) => source.distribution_id(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn resource_id(&self) -> ResourceId {
|
fn resource_id(&self) -> ResourceId {
|
||||||
match self {
|
match self {
|
||||||
BuildableSource::Dist(source) => source.resource_id(),
|
Self::Dist(source) => source.resource_id(),
|
||||||
BuildableSource::Url(source) => source.resource_id(),
|
Self::Url(source) => source.resource_id(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -84,20 +84,20 @@ impl CompatibleDist<'_> {
|
||||||
/// Return the `requires-python` specifier for the distribution, if any.
|
/// Return the `requires-python` specifier for the distribution, if any.
|
||||||
pub fn requires_python(&self) -> Option<&VersionSpecifiers> {
|
pub fn requires_python(&self) -> Option<&VersionSpecifiers> {
|
||||||
match self {
|
match self {
|
||||||
CompatibleDist::InstalledDist(_) => None,
|
Self::InstalledDist(_) => None,
|
||||||
CompatibleDist::SourceDist { sdist, .. } => sdist.file.requires_python.as_ref(),
|
Self::SourceDist { sdist, .. } => sdist.file.requires_python.as_ref(),
|
||||||
CompatibleDist::CompatibleWheel { wheel, .. } => wheel.file.requires_python.as_ref(),
|
Self::CompatibleWheel { wheel, .. } => wheel.file.requires_python.as_ref(),
|
||||||
CompatibleDist::IncompatibleWheel { sdist, .. } => sdist.file.requires_python.as_ref(),
|
Self::IncompatibleWheel { sdist, .. } => sdist.file.requires_python.as_ref(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// For installable distributions, return the prioritized distribution it was derived from.
|
// For installable distributions, return the prioritized distribution it was derived from.
|
||||||
pub fn prioritized(&self) -> Option<&PrioritizedDist> {
|
pub fn prioritized(&self) -> Option<&PrioritizedDist> {
|
||||||
match self {
|
match self {
|
||||||
CompatibleDist::InstalledDist(_) => None,
|
Self::InstalledDist(_) => None,
|
||||||
CompatibleDist::SourceDist { prioritized, .. }
|
Self::SourceDist { prioritized, .. }
|
||||||
| CompatibleDist::CompatibleWheel { prioritized, .. }
|
| Self::CompatibleWheel { prioritized, .. }
|
||||||
| CompatibleDist::IncompatibleWheel { prioritized, .. } => Some(prioritized),
|
| Self::IncompatibleWheel { prioritized, .. } => Some(prioritized),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -654,10 +654,10 @@ impl<'a> CompatibleDist<'a> {
|
||||||
/// wheel.
|
/// wheel.
|
||||||
pub fn wheel(&self) -> Option<&RegistryBuiltWheel> {
|
pub fn wheel(&self) -> Option<&RegistryBuiltWheel> {
|
||||||
match self {
|
match self {
|
||||||
CompatibleDist::InstalledDist(_) => None,
|
Self::InstalledDist(_) => None,
|
||||||
CompatibleDist::SourceDist { .. } => None,
|
Self::SourceDist { .. } => None,
|
||||||
CompatibleDist::CompatibleWheel { wheel, .. } => Some(wheel),
|
Self::CompatibleWheel { wheel, .. } => Some(wheel),
|
||||||
CompatibleDist::IncompatibleWheel { wheel, .. } => Some(wheel),
|
Self::IncompatibleWheel { wheel, .. } => Some(wheel),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -195,7 +195,7 @@ impl PartialOrd for Requirement {
|
||||||
impl From<Requirement> for uv_pep508::Requirement<VerbatimUrl> {
|
impl From<Requirement> for uv_pep508::Requirement<VerbatimUrl> {
|
||||||
/// Convert a [`Requirement`] to a [`uv_pep508::Requirement`].
|
/// Convert a [`Requirement`] to a [`uv_pep508::Requirement`].
|
||||||
fn from(requirement: Requirement) -> Self {
|
fn from(requirement: Requirement) -> Self {
|
||||||
uv_pep508::Requirement {
|
Self {
|
||||||
name: requirement.name,
|
name: requirement.name,
|
||||||
extras: requirement.extras,
|
extras: requirement.extras,
|
||||||
marker: requirement.marker,
|
marker: requirement.marker,
|
||||||
|
|
@ -216,7 +216,7 @@ impl From<Requirement> for uv_pep508::Requirement<VerbatimUrl> {
|
||||||
impl From<Requirement> for uv_pep508::Requirement<VerbatimParsedUrl> {
|
impl From<Requirement> for uv_pep508::Requirement<VerbatimParsedUrl> {
|
||||||
/// Convert a [`Requirement`] to a [`uv_pep508::Requirement`].
|
/// Convert a [`Requirement`] to a [`uv_pep508::Requirement`].
|
||||||
fn from(requirement: Requirement) -> Self {
|
fn from(requirement: Requirement) -> Self {
|
||||||
uv_pep508::Requirement {
|
Self {
|
||||||
name: requirement.name,
|
name: requirement.name,
|
||||||
extras: requirement.extras,
|
extras: requirement.extras,
|
||||||
marker: requirement.marker,
|
marker: requirement.marker,
|
||||||
|
|
@ -299,7 +299,7 @@ impl From<uv_pep508::Requirement<VerbatimParsedUrl>> for Requirement {
|
||||||
RequirementSource::from_parsed_url(url.parsed_url, url.verbatim)
|
RequirementSource::from_parsed_url(url.parsed_url, url.verbatim)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Requirement {
|
Self {
|
||||||
name: requirement.name,
|
name: requirement.name,
|
||||||
groups: Box::new([]),
|
groups: Box::new([]),
|
||||||
extras: requirement.extras,
|
extras: requirement.extras,
|
||||||
|
|
@ -544,23 +544,23 @@ impl RequirementSource {
|
||||||
/// the PEP 508 string (after the `@`) as [`VerbatimUrl`].
|
/// the PEP 508 string (after the `@`) as [`VerbatimUrl`].
|
||||||
pub fn from_parsed_url(parsed_url: ParsedUrl, url: VerbatimUrl) -> Self {
|
pub fn from_parsed_url(parsed_url: ParsedUrl, url: VerbatimUrl) -> Self {
|
||||||
match parsed_url {
|
match parsed_url {
|
||||||
ParsedUrl::Path(local_file) => RequirementSource::Path {
|
ParsedUrl::Path(local_file) => Self::Path {
|
||||||
install_path: local_file.install_path.clone(),
|
install_path: local_file.install_path.clone(),
|
||||||
ext: local_file.ext,
|
ext: local_file.ext,
|
||||||
url,
|
url,
|
||||||
},
|
},
|
||||||
ParsedUrl::Directory(directory) => RequirementSource::Directory {
|
ParsedUrl::Directory(directory) => Self::Directory {
|
||||||
install_path: directory.install_path.clone(),
|
install_path: directory.install_path.clone(),
|
||||||
editable: directory.editable,
|
editable: directory.editable,
|
||||||
r#virtual: directory.r#virtual,
|
r#virtual: directory.r#virtual,
|
||||||
url,
|
url,
|
||||||
},
|
},
|
||||||
ParsedUrl::Git(git) => RequirementSource::Git {
|
ParsedUrl::Git(git) => Self::Git {
|
||||||
git: git.url.clone(),
|
git: git.url.clone(),
|
||||||
url,
|
url,
|
||||||
subdirectory: git.subdirectory,
|
subdirectory: git.subdirectory,
|
||||||
},
|
},
|
||||||
ParsedUrl::Archive(archive) => RequirementSource::Url {
|
ParsedUrl::Archive(archive) => Self::Url {
|
||||||
url,
|
url,
|
||||||
location: archive.url,
|
location: archive.url,
|
||||||
subdirectory: archive.subdirectory,
|
subdirectory: archive.subdirectory,
|
||||||
|
|
@ -668,21 +668,18 @@ impl RequirementSource {
|
||||||
/// If the source is the registry, return the version specifiers
|
/// If the source is the registry, return the version specifiers
|
||||||
pub fn version_specifiers(&self) -> Option<&VersionSpecifiers> {
|
pub fn version_specifiers(&self) -> Option<&VersionSpecifiers> {
|
||||||
match self {
|
match self {
|
||||||
RequirementSource::Registry { specifier, .. } => Some(specifier),
|
Self::Registry { specifier, .. } => Some(specifier),
|
||||||
RequirementSource::Url { .. }
|
Self::Url { .. } | Self::Git { .. } | Self::Path { .. } | Self::Directory { .. } => {
|
||||||
| RequirementSource::Git { .. }
|
None
|
||||||
| RequirementSource::Path { .. }
|
}
|
||||||
| RequirementSource::Directory { .. } => None,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert the source to a [`RequirementSource`] relative to the given path.
|
/// Convert the source to a [`RequirementSource`] relative to the given path.
|
||||||
pub fn relative_to(self, path: &Path) -> Result<Self, io::Error> {
|
pub fn relative_to(self, path: &Path) -> Result<Self, io::Error> {
|
||||||
match self {
|
match self {
|
||||||
RequirementSource::Registry { .. }
|
Self::Registry { .. } | Self::Url { .. } | Self::Git { .. } => Ok(self),
|
||||||
| RequirementSource::Url { .. }
|
Self::Path {
|
||||||
| RequirementSource::Git { .. } => Ok(self),
|
|
||||||
RequirementSource::Path {
|
|
||||||
install_path,
|
install_path,
|
||||||
ext,
|
ext,
|
||||||
url,
|
url,
|
||||||
|
|
@ -693,7 +690,7 @@ impl RequirementSource {
|
||||||
ext,
|
ext,
|
||||||
url,
|
url,
|
||||||
}),
|
}),
|
||||||
RequirementSource::Directory {
|
Self::Directory {
|
||||||
install_path,
|
install_path,
|
||||||
editable,
|
editable,
|
||||||
r#virtual,
|
r#virtual,
|
||||||
|
|
@ -714,10 +711,8 @@ impl RequirementSource {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn to_absolute(self, root: &Path) -> Self {
|
pub fn to_absolute(self, root: &Path) -> Self {
|
||||||
match self {
|
match self {
|
||||||
RequirementSource::Registry { .. }
|
Self::Registry { .. } | Self::Url { .. } | Self::Git { .. } => self,
|
||||||
| RequirementSource::Url { .. }
|
Self::Path {
|
||||||
| RequirementSource::Git { .. } => self,
|
|
||||||
RequirementSource::Path {
|
|
||||||
install_path,
|
install_path,
|
||||||
ext,
|
ext,
|
||||||
url,
|
url,
|
||||||
|
|
@ -726,7 +721,7 @@ impl RequirementSource {
|
||||||
ext,
|
ext,
|
||||||
url,
|
url,
|
||||||
},
|
},
|
||||||
RequirementSource::Directory {
|
Self::Directory {
|
||||||
install_path,
|
install_path,
|
||||||
editable,
|
editable,
|
||||||
r#virtual,
|
r#virtual,
|
||||||
|
|
@ -920,7 +915,7 @@ impl From<RequirementSource> for RequirementSourceWire {
|
||||||
impl TryFrom<RequirementSourceWire> for RequirementSource {
|
impl TryFrom<RequirementSourceWire> for RequirementSource {
|
||||||
type Error = RequirementError;
|
type Error = RequirementError;
|
||||||
|
|
||||||
fn try_from(wire: RequirementSourceWire) -> Result<RequirementSource, RequirementError> {
|
fn try_from(wire: RequirementSourceWire) -> Result<Self, RequirementError> {
|
||||||
match wire {
|
match wire {
|
||||||
RequirementSourceWire::Registry {
|
RequirementSourceWire::Registry {
|
||||||
specifier,
|
specifier,
|
||||||
|
|
|
||||||
|
|
@ -570,7 +570,7 @@ impl Default for RequiresPythonRange {
|
||||||
|
|
||||||
impl From<RequiresPythonRange> for Ranges<Version> {
|
impl From<RequiresPythonRange> for Ranges<Version> {
|
||||||
fn from(value: RequiresPythonRange) -> Self {
|
fn from(value: RequiresPythonRange) -> Self {
|
||||||
Ranges::from_range_bounds::<(Bound<Version>, Bound<Version>), _>((
|
Self::from_range_bounds::<(Bound<Version>, Bound<Version>), _>((
|
||||||
value.0.into(),
|
value.0.into(),
|
||||||
value.1.into(),
|
value.1.into(),
|
||||||
))
|
))
|
||||||
|
|
@ -590,8 +590,8 @@ pub struct SimplifiedMarkerTree(MarkerTree);
|
||||||
impl SimplifiedMarkerTree {
|
impl SimplifiedMarkerTree {
|
||||||
/// Simplifies the given markers by assuming the given `requires-python`
|
/// Simplifies the given markers by assuming the given `requires-python`
|
||||||
/// bound is true.
|
/// bound is true.
|
||||||
pub fn new(requires_python: &RequiresPython, marker: MarkerTree) -> SimplifiedMarkerTree {
|
pub fn new(requires_python: &RequiresPython, marker: MarkerTree) -> Self {
|
||||||
SimplifiedMarkerTree(requires_python.simplify_markers(marker))
|
Self(requires_python.simplify_markers(marker))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Complexifies the given markers by adding the given `requires-python` as
|
/// Complexifies the given markers by adding the given `requires-python` as
|
||||||
|
|
|
||||||
|
|
@ -215,7 +215,7 @@ impl From<&ResolvedDist> for RequirementSource {
|
||||||
ResolvedDist::Installable { dist, .. } => match dist.as_ref() {
|
ResolvedDist::Installable { dist, .. } => match dist.as_ref() {
|
||||||
Dist::Built(BuiltDist::Registry(wheels)) => {
|
Dist::Built(BuiltDist::Registry(wheels)) => {
|
||||||
let wheel = wheels.best_wheel();
|
let wheel = wheels.best_wheel();
|
||||||
RequirementSource::Registry {
|
Self::Registry {
|
||||||
specifier: uv_pep440::VersionSpecifiers::from(
|
specifier: uv_pep440::VersionSpecifiers::from(
|
||||||
uv_pep440::VersionSpecifier::equals_version(
|
uv_pep440::VersionSpecifier::equals_version(
|
||||||
wheel.filename.version.clone(),
|
wheel.filename.version.clone(),
|
||||||
|
|
@ -228,19 +228,19 @@ impl From<&ResolvedDist> for RequirementSource {
|
||||||
Dist::Built(BuiltDist::DirectUrl(wheel)) => {
|
Dist::Built(BuiltDist::DirectUrl(wheel)) => {
|
||||||
let mut location = wheel.url.to_url();
|
let mut location = wheel.url.to_url();
|
||||||
location.set_fragment(None);
|
location.set_fragment(None);
|
||||||
RequirementSource::Url {
|
Self::Url {
|
||||||
url: wheel.url.clone(),
|
url: wheel.url.clone(),
|
||||||
location,
|
location,
|
||||||
subdirectory: None,
|
subdirectory: None,
|
||||||
ext: DistExtension::Wheel,
|
ext: DistExtension::Wheel,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Dist::Built(BuiltDist::Path(wheel)) => RequirementSource::Path {
|
Dist::Built(BuiltDist::Path(wheel)) => Self::Path {
|
||||||
install_path: wheel.install_path.clone(),
|
install_path: wheel.install_path.clone(),
|
||||||
url: wheel.url.clone(),
|
url: wheel.url.clone(),
|
||||||
ext: DistExtension::Wheel,
|
ext: DistExtension::Wheel,
|
||||||
},
|
},
|
||||||
Dist::Source(SourceDist::Registry(sdist)) => RequirementSource::Registry {
|
Dist::Source(SourceDist::Registry(sdist)) => Self::Registry {
|
||||||
specifier: uv_pep440::VersionSpecifiers::from(
|
specifier: uv_pep440::VersionSpecifiers::from(
|
||||||
uv_pep440::VersionSpecifier::equals_version(sdist.version.clone()),
|
uv_pep440::VersionSpecifier::equals_version(sdist.version.clone()),
|
||||||
),
|
),
|
||||||
|
|
@ -250,31 +250,31 @@ impl From<&ResolvedDist> for RequirementSource {
|
||||||
Dist::Source(SourceDist::DirectUrl(sdist)) => {
|
Dist::Source(SourceDist::DirectUrl(sdist)) => {
|
||||||
let mut location = sdist.url.to_url();
|
let mut location = sdist.url.to_url();
|
||||||
location.set_fragment(None);
|
location.set_fragment(None);
|
||||||
RequirementSource::Url {
|
Self::Url {
|
||||||
url: sdist.url.clone(),
|
url: sdist.url.clone(),
|
||||||
location,
|
location,
|
||||||
subdirectory: sdist.subdirectory.clone(),
|
subdirectory: sdist.subdirectory.clone(),
|
||||||
ext: DistExtension::Source(sdist.ext),
|
ext: DistExtension::Source(sdist.ext),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Dist::Source(SourceDist::Git(sdist)) => RequirementSource::Git {
|
Dist::Source(SourceDist::Git(sdist)) => Self::Git {
|
||||||
git: (*sdist.git).clone(),
|
git: (*sdist.git).clone(),
|
||||||
url: sdist.url.clone(),
|
url: sdist.url.clone(),
|
||||||
subdirectory: sdist.subdirectory.clone(),
|
subdirectory: sdist.subdirectory.clone(),
|
||||||
},
|
},
|
||||||
Dist::Source(SourceDist::Path(sdist)) => RequirementSource::Path {
|
Dist::Source(SourceDist::Path(sdist)) => Self::Path {
|
||||||
install_path: sdist.install_path.clone(),
|
install_path: sdist.install_path.clone(),
|
||||||
url: sdist.url.clone(),
|
url: sdist.url.clone(),
|
||||||
ext: DistExtension::Source(sdist.ext),
|
ext: DistExtension::Source(sdist.ext),
|
||||||
},
|
},
|
||||||
Dist::Source(SourceDist::Directory(sdist)) => RequirementSource::Directory {
|
Dist::Source(SourceDist::Directory(sdist)) => Self::Directory {
|
||||||
install_path: sdist.install_path.clone(),
|
install_path: sdist.install_path.clone(),
|
||||||
url: sdist.url.clone(),
|
url: sdist.url.clone(),
|
||||||
editable: sdist.editable,
|
editable: sdist.editable,
|
||||||
r#virtual: sdist.r#virtual,
|
r#virtual: sdist.r#virtual,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
ResolvedDist::Installed { dist } => RequirementSource::Registry {
|
ResolvedDist::Installed { dist } => Self::Registry {
|
||||||
specifier: uv_pep440::VersionSpecifiers::from(
|
specifier: uv_pep440::VersionSpecifiers::from(
|
||||||
uv_pep440::VersionSpecifier::equals_version(dist.version().clone()),
|
uv_pep440::VersionSpecifier::equals_version(dist.version().clone()),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ impl IndexStatusCodeStrategy {
|
||||||
capabilities: &IndexCapabilities,
|
capabilities: &IndexCapabilities,
|
||||||
) -> IndexStatusCodeDecision {
|
) -> IndexStatusCodeDecision {
|
||||||
match self {
|
match self {
|
||||||
IndexStatusCodeStrategy::Default => match status_code {
|
Self::Default => match status_code {
|
||||||
StatusCode::NOT_FOUND => IndexStatusCodeDecision::Ignore,
|
StatusCode::NOT_FOUND => IndexStatusCodeDecision::Ignore,
|
||||||
StatusCode::UNAUTHORIZED => {
|
StatusCode::UNAUTHORIZED => {
|
||||||
capabilities.set_unauthorized(index_url.clone());
|
capabilities.set_unauthorized(index_url.clone());
|
||||||
|
|
@ -80,15 +80,11 @@ impl IndexStatusCodeStrategy {
|
||||||
}
|
}
|
||||||
_ => IndexStatusCodeDecision::Fail(status_code),
|
_ => IndexStatusCodeDecision::Fail(status_code),
|
||||||
},
|
},
|
||||||
IndexStatusCodeStrategy::IgnoreErrorCodes { status_codes } => {
|
Self::IgnoreErrorCodes { status_codes } => {
|
||||||
if status_codes.contains(&status_code) {
|
if status_codes.contains(&status_code) {
|
||||||
IndexStatusCodeDecision::Ignore
|
IndexStatusCodeDecision::Ignore
|
||||||
} else {
|
} else {
|
||||||
IndexStatusCodeStrategy::Default.handle_status_code(
|
Self::Default.handle_status_code(status_code, index_url, capabilities)
|
||||||
status_code,
|
|
||||||
index_url,
|
|
||||||
capabilities,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1051,7 +1051,7 @@ pub struct ManagedClient<'a> {
|
||||||
|
|
||||||
impl<'a> ManagedClient<'a> {
|
impl<'a> ManagedClient<'a> {
|
||||||
/// Create a new `ManagedClient` using the given client and concurrency limit.
|
/// Create a new `ManagedClient` using the given client and concurrency limit.
|
||||||
fn new(client: &'a RegistryClient, concurrency: usize) -> ManagedClient<'a> {
|
fn new(client: &'a RegistryClient, concurrency: usize) -> Self {
|
||||||
ManagedClient {
|
ManagedClient {
|
||||||
unmanaged: client,
|
unmanaged: client,
|
||||||
control: Semaphore::new(concurrency),
|
control: Semaphore::new(concurrency),
|
||||||
|
|
@ -1176,7 +1176,7 @@ impl LocalArchivePointer {
|
||||||
/// Read an [`LocalArchivePointer`] from the cache.
|
/// Read an [`LocalArchivePointer`] from the cache.
|
||||||
pub fn read_from(path: impl AsRef<Path>) -> Result<Option<Self>, Error> {
|
pub fn read_from(path: impl AsRef<Path>) -> Result<Option<Self>, Error> {
|
||||||
match fs_err::read(path) {
|
match fs_err::read(path) {
|
||||||
Ok(cached) => Ok(Some(rmp_serde::from_slice::<LocalArchivePointer>(&cached)?)),
|
Ok(cached) => Ok(Some(rmp_serde::from_slice::<Self>(&cached)?)),
|
||||||
Err(err) if err.kind() == io::ErrorKind::NotFound => Ok(None),
|
Err(err) if err.kind() == io::ErrorKind::NotFound => Ok(None),
|
||||||
Err(err) => Err(Error::CacheRead(err)),
|
Err(err) => Err(Error::CacheRead(err)),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -55,8 +55,8 @@ impl Hashed for LocalWheel {
|
||||||
|
|
||||||
/// Convert a [`LocalWheel`] into a [`CachedDist`].
|
/// Convert a [`LocalWheel`] into a [`CachedDist`].
|
||||||
impl From<LocalWheel> for CachedDist {
|
impl From<LocalWheel> for CachedDist {
|
||||||
fn from(wheel: LocalWheel) -> CachedDist {
|
fn from(wheel: LocalWheel) -> Self {
|
||||||
CachedDist::from_remote(
|
Self::from_remote(
|
||||||
wheel.dist,
|
wheel.dist,
|
||||||
wheel.filename,
|
wheel.filename,
|
||||||
wheel.hashes,
|
wheel.hashes,
|
||||||
|
|
|
||||||
|
|
@ -189,7 +189,7 @@ impl Error {
|
||||||
distribution: String,
|
distribution: String,
|
||||||
expected: &[HashDigest],
|
expected: &[HashDigest],
|
||||||
actual: &[HashDigest],
|
actual: &[HashDigest],
|
||||||
) -> Error {
|
) -> Self {
|
||||||
match (expected.is_empty(), actual.is_empty()) {
|
match (expected.is_empty(), actual.is_empty()) {
|
||||||
(true, true) => Self::MissingHashes { distribution },
|
(true, true) => Self::MissingHashes { distribution },
|
||||||
(true, false) => {
|
(true, false) => {
|
||||||
|
|
|
||||||
|
|
@ -149,7 +149,7 @@ impl LoweredRequirement {
|
||||||
let mut remaining = total.negate();
|
let mut remaining = total.negate();
|
||||||
remaining.and(requirement.marker);
|
remaining.and(requirement.marker);
|
||||||
|
|
||||||
LoweredRequirement(Requirement {
|
Self(Requirement {
|
||||||
marker: remaining,
|
marker: remaining,
|
||||||
..Requirement::from(requirement.clone())
|
..Requirement::from(requirement.clone())
|
||||||
})
|
})
|
||||||
|
|
@ -389,7 +389,7 @@ impl LoweredRequirement {
|
||||||
let mut remaining = total.negate();
|
let mut remaining = total.negate();
|
||||||
remaining.and(requirement.marker);
|
remaining.and(requirement.marker);
|
||||||
|
|
||||||
LoweredRequirement(Requirement {
|
Self(Requirement {
|
||||||
marker: remaining,
|
marker: remaining,
|
||||||
..Requirement::from(requirement.clone())
|
..Requirement::from(requirement.clone())
|
||||||
})
|
})
|
||||||
|
|
@ -565,10 +565,10 @@ pub enum SourceKind {
|
||||||
impl std::fmt::Display for SourceKind {
|
impl std::fmt::Display for SourceKind {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
SourceKind::Path => write!(f, "path"),
|
Self::Path => write!(f, "path"),
|
||||||
SourceKind::Url => write!(f, "URL"),
|
Self::Url => write!(f, "URL"),
|
||||||
SourceKind::Git => write!(f, "Git"),
|
Self::Git => write!(f, "Git"),
|
||||||
SourceKind::Registry => write!(f, "registry"),
|
Self::Registry => write!(f, "registry"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2889,9 +2889,7 @@ impl LocalRevisionPointer {
|
||||||
/// Read an [`LocalRevisionPointer`] from the cache.
|
/// Read an [`LocalRevisionPointer`] from the cache.
|
||||||
pub(crate) fn read_from(path: impl AsRef<Path>) -> Result<Option<Self>, Error> {
|
pub(crate) fn read_from(path: impl AsRef<Path>) -> Result<Option<Self>, Error> {
|
||||||
match fs_err::read(path) {
|
match fs_err::read(path) {
|
||||||
Ok(cached) => Ok(Some(rmp_serde::from_slice::<LocalRevisionPointer>(
|
Ok(cached) => Ok(Some(rmp_serde::from_slice::<Self>(&cached)?)),
|
||||||
&cached,
|
|
||||||
)?)),
|
|
||||||
Err(err) if err.kind() == std::io::ErrorKind::NotFound => Ok(None),
|
Err(err) if err.kind() == std::io::ErrorKind::NotFound => Ok(None),
|
||||||
Err(err) => Err(Error::CacheRead(err)),
|
Err(err) => Err(Error::CacheRead(err)),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,11 +18,11 @@ pub enum Hasher {
|
||||||
impl Hasher {
|
impl Hasher {
|
||||||
pub fn update(&mut self, data: &[u8]) {
|
pub fn update(&mut self, data: &[u8]) {
|
||||||
match self {
|
match self {
|
||||||
Hasher::Md5(hasher) => hasher.update(data),
|
Self::Md5(hasher) => hasher.update(data),
|
||||||
Hasher::Sha256(hasher) => hasher.update(data),
|
Self::Sha256(hasher) => hasher.update(data),
|
||||||
Hasher::Sha384(hasher) => hasher.update(data),
|
Self::Sha384(hasher) => hasher.update(data),
|
||||||
Hasher::Sha512(hasher) => hasher.update(data),
|
Self::Sha512(hasher) => hasher.update(data),
|
||||||
Hasher::Blake2b(hasher) => hasher.update(data),
|
Self::Blake2b(hasher) => hasher.update(data),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -30,11 +30,11 @@ impl Hasher {
|
||||||
impl From<HashAlgorithm> for Hasher {
|
impl From<HashAlgorithm> for Hasher {
|
||||||
fn from(algorithm: HashAlgorithm) -> Self {
|
fn from(algorithm: HashAlgorithm) -> Self {
|
||||||
match algorithm {
|
match algorithm {
|
||||||
HashAlgorithm::Md5 => Hasher::Md5(md5::Md5::new()),
|
HashAlgorithm::Md5 => Self::Md5(md5::Md5::new()),
|
||||||
HashAlgorithm::Sha256 => Hasher::Sha256(sha2::Sha256::new()),
|
HashAlgorithm::Sha256 => Self::Sha256(sha2::Sha256::new()),
|
||||||
HashAlgorithm::Sha384 => Hasher::Sha384(sha2::Sha384::new()),
|
HashAlgorithm::Sha384 => Self::Sha384(sha2::Sha384::new()),
|
||||||
HashAlgorithm::Sha512 => Hasher::Sha512(sha2::Sha512::new()),
|
HashAlgorithm::Sha512 => Self::Sha512(sha2::Sha512::new()),
|
||||||
HashAlgorithm::Blake2b => Hasher::Blake2b(blake2::Blake2b::new()),
|
HashAlgorithm::Blake2b => Self::Blake2b(blake2::Blake2b::new()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -42,23 +42,23 @@ impl From<HashAlgorithm> for Hasher {
|
||||||
impl From<Hasher> for HashDigest {
|
impl From<Hasher> for HashDigest {
|
||||||
fn from(hasher: Hasher) -> Self {
|
fn from(hasher: Hasher) -> Self {
|
||||||
match hasher {
|
match hasher {
|
||||||
Hasher::Md5(hasher) => HashDigest {
|
Hasher::Md5(hasher) => Self {
|
||||||
algorithm: HashAlgorithm::Md5,
|
algorithm: HashAlgorithm::Md5,
|
||||||
digest: format!("{:x}", hasher.finalize()).into(),
|
digest: format!("{:x}", hasher.finalize()).into(),
|
||||||
},
|
},
|
||||||
Hasher::Sha256(hasher) => HashDigest {
|
Hasher::Sha256(hasher) => Self {
|
||||||
algorithm: HashAlgorithm::Sha256,
|
algorithm: HashAlgorithm::Sha256,
|
||||||
digest: format!("{:x}", hasher.finalize()).into(),
|
digest: format!("{:x}", hasher.finalize()).into(),
|
||||||
},
|
},
|
||||||
Hasher::Sha384(hasher) => HashDigest {
|
Hasher::Sha384(hasher) => Self {
|
||||||
algorithm: HashAlgorithm::Sha384,
|
algorithm: HashAlgorithm::Sha384,
|
||||||
digest: format!("{:x}", hasher.finalize()).into(),
|
digest: format!("{:x}", hasher.finalize()).into(),
|
||||||
},
|
},
|
||||||
Hasher::Sha512(hasher) => HashDigest {
|
Hasher::Sha512(hasher) => Self {
|
||||||
algorithm: HashAlgorithm::Sha512,
|
algorithm: HashAlgorithm::Sha512,
|
||||||
digest: format!("{:x}", hasher.finalize()).into(),
|
digest: format!("{:x}", hasher.finalize()).into(),
|
||||||
},
|
},
|
||||||
Hasher::Blake2b(hasher) => HashDigest {
|
Hasher::Blake2b(hasher) => Self {
|
||||||
algorithm: HashAlgorithm::Blake2b,
|
algorithm: HashAlgorithm::Blake2b,
|
||||||
digest: format!("{:x}", hasher.finalize()).into(),
|
digest: format!("{:x}", hasher.finalize()).into(),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ impl FromStr for GitOid {
|
||||||
|
|
||||||
let mut bytes = [0; 40];
|
let mut bytes = [0; 40];
|
||||||
bytes.copy_from_slice(s.as_bytes());
|
bytes.copy_from_slice(s.as_bytes());
|
||||||
Ok(GitOid { bytes })
|
Ok(Self { bytes })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -75,7 +75,7 @@ impl serde::Serialize for GitOid {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'de> serde::Deserialize<'de> for GitOid {
|
impl<'de> serde::Deserialize<'de> for GitOid {
|
||||||
fn deserialize<D>(deserializer: D) -> Result<GitOid, D::Error>
|
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||||
where
|
where
|
||||||
D: serde::Deserializer<'de>,
|
D: serde::Deserializer<'de>,
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -161,20 +161,20 @@ pub(crate) struct GitRepository {
|
||||||
|
|
||||||
impl GitRepository {
|
impl GitRepository {
|
||||||
/// Opens an existing Git repository at `path`.
|
/// Opens an existing Git repository at `path`.
|
||||||
pub(crate) fn open(path: &Path) -> Result<GitRepository> {
|
pub(crate) fn open(path: &Path) -> Result<Self> {
|
||||||
// Make sure there is a Git repository at the specified path.
|
// Make sure there is a Git repository at the specified path.
|
||||||
ProcessBuilder::new(GIT.as_ref()?)
|
ProcessBuilder::new(GIT.as_ref()?)
|
||||||
.arg("rev-parse")
|
.arg("rev-parse")
|
||||||
.cwd(path)
|
.cwd(path)
|
||||||
.exec_with_output()?;
|
.exec_with_output()?;
|
||||||
|
|
||||||
Ok(GitRepository {
|
Ok(Self {
|
||||||
path: path.to_path_buf(),
|
path: path.to_path_buf(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Initializes a Git repository at `path`.
|
/// Initializes a Git repository at `path`.
|
||||||
fn init(path: &Path) -> Result<GitRepository> {
|
fn init(path: &Path) -> Result<Self> {
|
||||||
// TODO(ibraheem): see if this still necessary now that we no longer use libgit2
|
// TODO(ibraheem): see if this still necessary now that we no longer use libgit2
|
||||||
// Skip anything related to templates, they just call all sorts of issues as
|
// Skip anything related to templates, they just call all sorts of issues as
|
||||||
// we really don't want to use them yet they insist on being used. See #6240
|
// we really don't want to use them yet they insist on being used. See #6240
|
||||||
|
|
@ -187,7 +187,7 @@ impl GitRepository {
|
||||||
.cwd(path)
|
.cwd(path)
|
||||||
.exec_with_output()?;
|
.exec_with_output()?;
|
||||||
|
|
||||||
Ok(GitRepository {
|
Ok(Self {
|
||||||
path: path.to_path_buf(),
|
path: path.to_path_buf(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -392,7 +392,7 @@ impl GitCheckout {
|
||||||
}
|
}
|
||||||
|
|
||||||
let repo = GitRepository::open(into)?;
|
let repo = GitRepository::open(into)?;
|
||||||
let checkout = GitCheckout::new(revision, repo);
|
let checkout = Self::new(revision, repo);
|
||||||
checkout.reset()?;
|
checkout.reset()?;
|
||||||
Ok(checkout)
|
Ok(checkout)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -69,8 +69,8 @@ pub enum PortableGlobParser {
|
||||||
impl PortableGlobParser {
|
impl PortableGlobParser {
|
||||||
fn backslash_escape(self) -> bool {
|
fn backslash_escape(self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
PortableGlobParser::Pep639 => false,
|
Self::Pep639 => false,
|
||||||
PortableGlobParser::Uv => true,
|
Self::Uv => true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -165,13 +165,13 @@ impl PortableGlobParser {
|
||||||
start_or_slash = false;
|
start_or_slash = false;
|
||||||
} else if c == '\\' {
|
} else if c == '\\' {
|
||||||
match *self {
|
match *self {
|
||||||
PortableGlobParser::Pep639 => {
|
Self::Pep639 => {
|
||||||
return Err(PortableGlobError::InvalidBackslash {
|
return Err(PortableGlobError::InvalidBackslash {
|
||||||
glob: glob.to_string(),
|
glob: glob.to_string(),
|
||||||
pos,
|
pos,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
PortableGlobParser::Uv => {
|
Self::Uv => {
|
||||||
match chars.next() {
|
match chars.next() {
|
||||||
Some((pos, '/' | '\\')) => {
|
Some((pos, '/' | '\\')) => {
|
||||||
// For cross-platform compatibility, we don't allow forward slashes or
|
// For cross-platform compatibility, we don't allow forward slashes or
|
||||||
|
|
@ -195,12 +195,12 @@ impl PortableGlobParser {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let err = match *self {
|
let err = match *self {
|
||||||
PortableGlobParser::Pep639 => PortableGlobError::InvalidCharacter {
|
Self::Pep639 => PortableGlobError::InvalidCharacter {
|
||||||
glob: glob.to_string(),
|
glob: glob.to_string(),
|
||||||
pos,
|
pos,
|
||||||
invalid: c,
|
invalid: c,
|
||||||
},
|
},
|
||||||
PortableGlobParser::Uv => PortableGlobError::InvalidCharacterUv {
|
Self::Uv => PortableGlobError::InvalidCharacterUv {
|
||||||
glob: glob.to_string(),
|
glob: glob.to_string(),
|
||||||
pos,
|
pos,
|
||||||
invalid: c,
|
invalid: c,
|
||||||
|
|
|
||||||
|
|
@ -904,7 +904,7 @@ impl RenameOrCopy {
|
||||||
Self::Rename => match fs_err::rename(from.as_ref(), to.as_ref()) {
|
Self::Rename => match fs_err::rename(from.as_ref(), to.as_ref()) {
|
||||||
Ok(()) => {}
|
Ok(()) => {}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
*self = RenameOrCopy::Copy;
|
*self = Self::Copy;
|
||||||
debug!("Failed to rename, falling back to copy: {err}");
|
debug!("Failed to rename, falling back to copy: {err}");
|
||||||
fs_err::copy(from.as_ref(), to.as_ref())?;
|
fs_err::copy(from.as_ref(), to.as_ref())?;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,8 @@ impl serde::Serialize for DefaultExtras {
|
||||||
S: serde::Serializer,
|
S: serde::Serializer,
|
||||||
{
|
{
|
||||||
match self {
|
match self {
|
||||||
DefaultExtras::All => serializer.serialize_str("all"),
|
Self::All => serializer.serialize_str("all"),
|
||||||
DefaultExtras::List(extras) => {
|
Self::List(extras) => {
|
||||||
let mut seq = serializer.serialize_seq(Some(extras.len()))?;
|
let mut seq = serializer.serialize_seq(Some(extras.len()))?;
|
||||||
for extra in extras {
|
for extra in extras {
|
||||||
seq.serialize_element(&extra)?;
|
seq.serialize_element(&extra)?;
|
||||||
|
|
@ -40,7 +40,7 @@ impl serde::Serialize for DefaultExtras {
|
||||||
|
|
||||||
/// Deserialize a "all" or list of [`ExtraName`] into a [`DefaultExtras`] enum.
|
/// Deserialize a "all" or list of [`ExtraName`] into a [`DefaultExtras`] enum.
|
||||||
impl<'de> serde::Deserialize<'de> for DefaultExtras {
|
impl<'de> serde::Deserialize<'de> for DefaultExtras {
|
||||||
fn deserialize<D>(deserializer: D) -> Result<DefaultExtras, D::Error>
|
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||||
where
|
where
|
||||||
D: serde::Deserializer<'de>,
|
D: serde::Deserializer<'de>,
|
||||||
{
|
{
|
||||||
|
|
@ -85,7 +85,7 @@ impl<'de> serde::Deserialize<'de> for DefaultExtras {
|
||||||
|
|
||||||
impl Default for DefaultExtras {
|
impl Default for DefaultExtras {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
DefaultExtras::List(Vec::new())
|
Self::List(Vec::new())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -176,8 +176,8 @@ impl serde::Serialize for DefaultGroups {
|
||||||
S: serde::Serializer,
|
S: serde::Serializer,
|
||||||
{
|
{
|
||||||
match self {
|
match self {
|
||||||
DefaultGroups::All => serializer.serialize_str("all"),
|
Self::All => serializer.serialize_str("all"),
|
||||||
DefaultGroups::List(groups) => {
|
Self::List(groups) => {
|
||||||
let mut seq = serializer.serialize_seq(Some(groups.len()))?;
|
let mut seq = serializer.serialize_seq(Some(groups.len()))?;
|
||||||
for group in groups {
|
for group in groups {
|
||||||
seq.serialize_element(&group)?;
|
seq.serialize_element(&group)?;
|
||||||
|
|
@ -190,7 +190,7 @@ impl serde::Serialize for DefaultGroups {
|
||||||
|
|
||||||
/// Deserialize a "all" or list of [`GroupName`] into a [`DefaultGroups`] enum.
|
/// Deserialize a "all" or list of [`GroupName`] into a [`DefaultGroups`] enum.
|
||||||
impl<'de> serde::Deserialize<'de> for DefaultGroups {
|
impl<'de> serde::Deserialize<'de> for DefaultGroups {
|
||||||
fn deserialize<D>(deserializer: D) -> Result<DefaultGroups, D::Error>
|
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||||
where
|
where
|
||||||
D: serde::Deserializer<'de>,
|
D: serde::Deserializer<'de>,
|
||||||
{
|
{
|
||||||
|
|
@ -236,7 +236,7 @@ impl<'de> serde::Deserialize<'de> for DefaultGroups {
|
||||||
impl Default for DefaultGroups {
|
impl Default for DefaultGroups {
|
||||||
/// Note this is an "empty" default unlike other contexts where `["dev"]` is the default
|
/// Note this is an "empty" default unlike other contexts where `["dev"]` is the default
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
DefaultGroups::List(Vec::new())
|
Self::List(Vec::new())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -153,8 +153,8 @@ pub enum InvalidPipGroupError {
|
||||||
impl Display for InvalidPipGroupError {
|
impl Display for InvalidPipGroupError {
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
InvalidPipGroupError::Name(e) => e.fmt(f),
|
Self::Name(e) => e.fmt(f),
|
||||||
InvalidPipGroupError::Path(e) => e.fmt(f),
|
Self::Path(e) => e.fmt(f),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,15 +21,15 @@ pub struct OnceMap<K, V, S = RandomState> {
|
||||||
|
|
||||||
impl<K: Eq + Hash, V: Clone, H: BuildHasher + Clone> OnceMap<K, V, H> {
|
impl<K: Eq + Hash, V: Clone, H: BuildHasher + Clone> OnceMap<K, V, H> {
|
||||||
/// Create a [`OnceMap`] with the specified hasher.
|
/// Create a [`OnceMap`] with the specified hasher.
|
||||||
pub fn with_hasher(hasher: H) -> OnceMap<K, V, H> {
|
pub fn with_hasher(hasher: H) -> Self {
|
||||||
OnceMap {
|
Self {
|
||||||
items: DashMap::with_hasher(hasher),
|
items: DashMap::with_hasher(hasher),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a [`OnceMap`] with the specified capacity and hasher.
|
/// Create a [`OnceMap`] with the specified capacity and hasher.
|
||||||
pub fn with_capacity_and_hasher(capacity: usize, hasher: H) -> OnceMap<K, V, H> {
|
pub fn with_capacity_and_hasher(capacity: usize, hasher: H) -> Self {
|
||||||
OnceMap {
|
Self {
|
||||||
items: DashMap::with_capacity_and_hasher(capacity, hasher),
|
items: DashMap::with_capacity_and_hasher(capacity, hasher),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -133,7 +133,7 @@ where
|
||||||
H: Default + Clone + BuildHasher,
|
H: Default + Clone + BuildHasher,
|
||||||
{
|
{
|
||||||
fn from_iter<T: IntoIterator<Item = (K, V)>>(iter: T) -> Self {
|
fn from_iter<T: IntoIterator<Item = (K, V)>>(iter: T) -> Self {
|
||||||
OnceMap {
|
Self {
|
||||||
items: iter
|
items: iter
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|(k, v)| (k, Value::Filled(v)))
|
.map(|(k, v)| (k, Value::Filled(v)))
|
||||||
|
|
|
||||||
|
|
@ -59,8 +59,8 @@ pub enum OptionEntry {
|
||||||
impl Display for OptionEntry {
|
impl Display for OptionEntry {
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
OptionEntry::Set(set) => std::fmt::Display::fmt(set, f),
|
Self::Set(set) => std::fmt::Display::fmt(set, f),
|
||||||
OptionEntry::Field(field) => std::fmt::Display::fmt(&field, f),
|
Self::Field(field) => std::fmt::Display::fmt(&field, f),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -63,18 +63,18 @@ impl Operator {
|
||||||
/// Note that this routine is not reversible in all cases. For example
|
/// Note that this routine is not reversible in all cases. For example
|
||||||
/// `Operator::ExactEqual` negates to `Operator::NotEqual`, and
|
/// `Operator::ExactEqual` negates to `Operator::NotEqual`, and
|
||||||
/// `Operator::NotEqual` in turn negates to `Operator::Equal`.
|
/// `Operator::NotEqual` in turn negates to `Operator::Equal`.
|
||||||
pub fn negate(self) -> Option<Operator> {
|
pub fn negate(self) -> Option<Self> {
|
||||||
Some(match self {
|
Some(match self {
|
||||||
Operator::Equal => Operator::NotEqual,
|
Self::Equal => Self::NotEqual,
|
||||||
Operator::EqualStar => Operator::NotEqualStar,
|
Self::EqualStar => Self::NotEqualStar,
|
||||||
Operator::ExactEqual => Operator::NotEqual,
|
Self::ExactEqual => Self::NotEqual,
|
||||||
Operator::NotEqual => Operator::Equal,
|
Self::NotEqual => Self::Equal,
|
||||||
Operator::NotEqualStar => Operator::EqualStar,
|
Self::NotEqualStar => Self::EqualStar,
|
||||||
Operator::TildeEqual => return None,
|
Self::TildeEqual => return None,
|
||||||
Operator::LessThan => Operator::GreaterThanEqual,
|
Self::LessThan => Self::GreaterThanEqual,
|
||||||
Operator::LessThanEqual => Operator::GreaterThan,
|
Self::LessThanEqual => Self::GreaterThan,
|
||||||
Operator::GreaterThan => Operator::LessThanEqual,
|
Self::GreaterThan => Self::LessThanEqual,
|
||||||
Operator::GreaterThanEqual => Operator::LessThan,
|
Self::GreaterThanEqual => Self::LessThan,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1721,8 +1721,8 @@ impl LocalVersion {
|
||||||
/// Convert the local version segments into a slice.
|
/// Convert the local version segments into a slice.
|
||||||
pub fn as_slice(&self) -> LocalVersionSlice<'_> {
|
pub fn as_slice(&self) -> LocalVersionSlice<'_> {
|
||||||
match self {
|
match self {
|
||||||
LocalVersion::Segments(segments) => LocalVersionSlice::Segments(segments),
|
Self::Segments(segments) => LocalVersionSlice::Segments(segments),
|
||||||
LocalVersion::Max => LocalVersionSlice::Max,
|
Self::Max => LocalVersionSlice::Max,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1742,7 +1742,7 @@ impl LocalVersion {
|
||||||
impl std::fmt::Display for LocalVersionSlice<'_> {
|
impl std::fmt::Display for LocalVersionSlice<'_> {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
LocalVersionSlice::Segments(segments) => {
|
Self::Segments(segments) => {
|
||||||
for (i, segment) in segments.iter().enumerate() {
|
for (i, segment) in segments.iter().enumerate() {
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
write!(f, ".")?;
|
write!(f, ".")?;
|
||||||
|
|
@ -1751,7 +1751,7 @@ impl std::fmt::Display for LocalVersionSlice<'_> {
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
LocalVersionSlice::Max => write!(f, "[max]"),
|
Self::Max => write!(f, "[max]"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1759,14 +1759,14 @@ impl std::fmt::Display for LocalVersionSlice<'_> {
|
||||||
impl CacheKey for LocalVersionSlice<'_> {
|
impl CacheKey for LocalVersionSlice<'_> {
|
||||||
fn cache_key(&self, state: &mut CacheKeyHasher) {
|
fn cache_key(&self, state: &mut CacheKeyHasher) {
|
||||||
match self {
|
match self {
|
||||||
LocalVersionSlice::Segments(segments) => {
|
Self::Segments(segments) => {
|
||||||
0u8.cache_key(state);
|
0u8.cache_key(state);
|
||||||
segments.len().cache_key(state);
|
segments.len().cache_key(state);
|
||||||
for segment in *segments {
|
for segment in *segments {
|
||||||
segment.cache_key(state);
|
segment.cache_key(state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LocalVersionSlice::Max => {
|
Self::Max => {
|
||||||
1u8.cache_key(state);
|
1u8.cache_key(state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1912,7 +1912,7 @@ impl<'a> Parser<'a> {
|
||||||
const SEPARATOR: ByteSet = ByteSet::new(&[b'.', b'_', b'-']);
|
const SEPARATOR: ByteSet = ByteSet::new(&[b'.', b'_', b'-']);
|
||||||
|
|
||||||
/// Create a new `Parser` for parsing the version in the given byte string.
|
/// Create a new `Parser` for parsing the version in the given byte string.
|
||||||
fn new(version: &'a [u8]) -> Parser<'a> {
|
fn new(version: &'a [u8]) -> Self {
|
||||||
Parser {
|
Parser {
|
||||||
v: version,
|
v: version,
|
||||||
i: 0,
|
i: 0,
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ impl From<VersionSpecifiers> for Ranges<Version> {
|
||||||
/// Convert [`VersionSpecifiers`] to a PubGrub-compatible version range, using PEP 440
|
/// Convert [`VersionSpecifiers`] to a PubGrub-compatible version range, using PEP 440
|
||||||
/// semantics.
|
/// semantics.
|
||||||
fn from(specifiers: VersionSpecifiers) -> Self {
|
fn from(specifiers: VersionSpecifiers) -> Self {
|
||||||
let mut range = Ranges::full();
|
let mut range = Self::full();
|
||||||
for specifier in specifiers {
|
for specifier in specifiers {
|
||||||
range = range.intersection(&Self::from(specifier));
|
range = range.intersection(&Self::from(specifier));
|
||||||
}
|
}
|
||||||
|
|
@ -32,15 +32,15 @@ impl From<VersionSpecifier> for Ranges<Version> {
|
||||||
LocalVersionSlice::Segments(&[]) => {
|
LocalVersionSlice::Segments(&[]) => {
|
||||||
let low = version;
|
let low = version;
|
||||||
let high = low.clone().with_local(LocalVersion::Max);
|
let high = low.clone().with_local(LocalVersion::Max);
|
||||||
Ranges::between(low, high)
|
Self::between(low, high)
|
||||||
}
|
}
|
||||||
LocalVersionSlice::Segments(_) => Ranges::singleton(version),
|
LocalVersionSlice::Segments(_) => Self::singleton(version),
|
||||||
LocalVersionSlice::Max => unreachable!(
|
LocalVersionSlice::Max => unreachable!(
|
||||||
"found `LocalVersionSlice::Sentinel`, which should be an internal-only value"
|
"found `LocalVersionSlice::Sentinel`, which should be an internal-only value"
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
Operator::ExactEqual => Ranges::singleton(version),
|
Operator::ExactEqual => Self::singleton(version),
|
||||||
Operator::NotEqual => Ranges::from(VersionSpecifier {
|
Operator::NotEqual => Self::from(VersionSpecifier {
|
||||||
operator: Operator::Equal,
|
operator: Operator::Equal,
|
||||||
version,
|
version,
|
||||||
})
|
})
|
||||||
|
|
@ -54,32 +54,32 @@ impl From<VersionSpecifier> for Ranges<Version> {
|
||||||
.with_epoch(version.epoch())
|
.with_epoch(version.epoch())
|
||||||
.with_dev(Some(0));
|
.with_dev(Some(0));
|
||||||
|
|
||||||
Ranges::from_range_bounds(version..upper)
|
Self::from_range_bounds(version..upper)
|
||||||
}
|
}
|
||||||
Operator::LessThan => {
|
Operator::LessThan => {
|
||||||
if version.any_prerelease() {
|
if version.any_prerelease() {
|
||||||
Ranges::strictly_lower_than(version)
|
Self::strictly_lower_than(version)
|
||||||
} else {
|
} else {
|
||||||
// Per PEP 440: "The exclusive ordered comparison <V MUST NOT allow a
|
// Per PEP 440: "The exclusive ordered comparison <V MUST NOT allow a
|
||||||
// pre-release of the specified version unless the specified version is itself a
|
// pre-release of the specified version unless the specified version is itself a
|
||||||
// pre-release."
|
// pre-release."
|
||||||
Ranges::strictly_lower_than(version.with_min(Some(0)))
|
Self::strictly_lower_than(version.with_min(Some(0)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Operator::LessThanEqual => Ranges::lower_than(version.with_local(LocalVersion::Max)),
|
Operator::LessThanEqual => Self::lower_than(version.with_local(LocalVersion::Max)),
|
||||||
Operator::GreaterThan => {
|
Operator::GreaterThan => {
|
||||||
// Per PEP 440: "The exclusive ordered comparison >V MUST NOT allow a post-release of
|
// Per PEP 440: "The exclusive ordered comparison >V MUST NOT allow a post-release of
|
||||||
// the given version unless V itself is a post release."
|
// the given version unless V itself is a post release."
|
||||||
|
|
||||||
if let Some(dev) = version.dev() {
|
if let Some(dev) = version.dev() {
|
||||||
Ranges::higher_than(version.with_dev(Some(dev + 1)))
|
Self::higher_than(version.with_dev(Some(dev + 1)))
|
||||||
} else if let Some(post) = version.post() {
|
} else if let Some(post) = version.post() {
|
||||||
Ranges::higher_than(version.with_post(Some(post + 1)))
|
Self::higher_than(version.with_post(Some(post + 1)))
|
||||||
} else {
|
} else {
|
||||||
Ranges::strictly_higher_than(version.with_max(Some(0)))
|
Self::strictly_higher_than(version.with_max(Some(0)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Operator::GreaterThanEqual => Ranges::higher_than(version),
|
Operator::GreaterThanEqual => Self::higher_than(version),
|
||||||
Operator::EqualStar => {
|
Operator::EqualStar => {
|
||||||
let low = version.with_dev(Some(0));
|
let low = version.with_dev(Some(0));
|
||||||
let mut high = low.clone();
|
let mut high = low.clone();
|
||||||
|
|
@ -95,7 +95,7 @@ impl From<VersionSpecifier> for Ranges<Version> {
|
||||||
*release.last_mut().unwrap() += 1;
|
*release.last_mut().unwrap() += 1;
|
||||||
high = high.with_release(release);
|
high = high.with_release(release);
|
||||||
}
|
}
|
||||||
Ranges::from_range_bounds(low..high)
|
Self::from_range_bounds(low..high)
|
||||||
}
|
}
|
||||||
Operator::NotEqualStar => {
|
Operator::NotEqualStar => {
|
||||||
let low = version.with_dev(Some(0));
|
let low = version.with_dev(Some(0));
|
||||||
|
|
@ -112,7 +112,7 @@ impl From<VersionSpecifier> for Ranges<Version> {
|
||||||
*release.last_mut().unwrap() += 1;
|
*release.last_mut().unwrap() += 1;
|
||||||
high = high.with_release(release);
|
high = high.with_release(release);
|
||||||
}
|
}
|
||||||
Ranges::from_range_bounds(low..high).complement()
|
Self::from_range_bounds(low..high).complement()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -482,61 +482,57 @@ impl VersionSpecifier {
|
||||||
/// This function is not applicable to ranges involving pre-release versions.
|
/// This function is not applicable to ranges involving pre-release versions.
|
||||||
pub fn from_release_only_bounds(
|
pub fn from_release_only_bounds(
|
||||||
bounds: (&Bound<Version>, &Bound<Version>),
|
bounds: (&Bound<Version>, &Bound<Version>),
|
||||||
) -> impl Iterator<Item = VersionSpecifier> {
|
) -> impl Iterator<Item = Self> {
|
||||||
let (b1, b2) = match bounds {
|
let (b1, b2) = match bounds {
|
||||||
(Bound::Included(v1), Bound::Included(v2)) if v1 == v2 => {
|
(Bound::Included(v1), Bound::Included(v2)) if v1 == v2 => {
|
||||||
(Some(VersionSpecifier::equals_version(v1.clone())), None)
|
(Some(Self::equals_version(v1.clone())), None)
|
||||||
}
|
}
|
||||||
// `v >= 3.7 && v < 3.8` is equivalent to `v == 3.7.*`
|
// `v >= 3.7 && v < 3.8` is equivalent to `v == 3.7.*`
|
||||||
(Bound::Included(v1), Bound::Excluded(v2)) => {
|
(Bound::Included(v1), Bound::Excluded(v2)) => {
|
||||||
match *v1.only_release_trimmed().release() {
|
match *v1.only_release_trimmed().release() {
|
||||||
[major] if *v2.only_release_trimmed().release() == [major, 1] => {
|
[major] if *v2.only_release_trimmed().release() == [major, 1] => {
|
||||||
let version = Version::new([major, 0]);
|
let version = Version::new([major, 0]);
|
||||||
(Some(VersionSpecifier::equals_star_version(version)), None)
|
(Some(Self::equals_star_version(version)), None)
|
||||||
}
|
}
|
||||||
[major, minor]
|
[major, minor]
|
||||||
if *v2.only_release_trimmed().release() == [major, minor + 1] =>
|
if *v2.only_release_trimmed().release() == [major, minor + 1] =>
|
||||||
{
|
{
|
||||||
let version = Version::new([major, minor]);
|
let version = Version::new([major, minor]);
|
||||||
(Some(VersionSpecifier::equals_star_version(version)), None)
|
(Some(Self::equals_star_version(version)), None)
|
||||||
}
|
}
|
||||||
_ => (
|
_ => (
|
||||||
VersionSpecifier::from_lower_bound(&Bound::Included(v1.clone())),
|
Self::from_lower_bound(&Bound::Included(v1.clone())),
|
||||||
VersionSpecifier::from_upper_bound(&Bound::Excluded(v2.clone())),
|
Self::from_upper_bound(&Bound::Excluded(v2.clone())),
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(lower, upper) => (
|
(lower, upper) => (Self::from_lower_bound(lower), Self::from_upper_bound(upper)),
|
||||||
VersionSpecifier::from_lower_bound(lower),
|
|
||||||
VersionSpecifier::from_upper_bound(upper),
|
|
||||||
),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
b1.into_iter().chain(b2)
|
b1.into_iter().chain(b2)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a version specifier representing the given lower bound.
|
/// Returns a version specifier representing the given lower bound.
|
||||||
pub fn from_lower_bound(bound: &Bound<Version>) -> Option<VersionSpecifier> {
|
pub fn from_lower_bound(bound: &Bound<Version>) -> Option<Self> {
|
||||||
match bound {
|
match bound {
|
||||||
Bound::Included(version) => Some(
|
Bound::Included(version) => {
|
||||||
VersionSpecifier::from_version(Operator::GreaterThanEqual, version.clone())
|
Some(Self::from_version(Operator::GreaterThanEqual, version.clone()).unwrap())
|
||||||
.unwrap(),
|
}
|
||||||
),
|
Bound::Excluded(version) => {
|
||||||
Bound::Excluded(version) => Some(
|
Some(Self::from_version(Operator::GreaterThan, version.clone()).unwrap())
|
||||||
VersionSpecifier::from_version(Operator::GreaterThan, version.clone()).unwrap(),
|
}
|
||||||
),
|
|
||||||
Bound::Unbounded => None,
|
Bound::Unbounded => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a version specifier representing the given upper bound.
|
/// Returns a version specifier representing the given upper bound.
|
||||||
pub fn from_upper_bound(bound: &Bound<Version>) -> Option<VersionSpecifier> {
|
pub fn from_upper_bound(bound: &Bound<Version>) -> Option<Self> {
|
||||||
match bound {
|
match bound {
|
||||||
Bound::Included(version) => Some(
|
Bound::Included(version) => {
|
||||||
VersionSpecifier::from_version(Operator::LessThanEqual, version.clone()).unwrap(),
|
Some(Self::from_version(Operator::LessThanEqual, version.clone()).unwrap())
|
||||||
),
|
}
|
||||||
Bound::Excluded(version) => {
|
Bound::Excluded(version) => {
|
||||||
Some(VersionSpecifier::from_version(Operator::LessThan, version.clone()).unwrap())
|
Some(Self::from_version(Operator::LessThan, version.clone()).unwrap())
|
||||||
}
|
}
|
||||||
Bound::Unbounded => None,
|
Bound::Unbounded => None,
|
||||||
}
|
}
|
||||||
|
|
@ -905,16 +901,14 @@ impl<'a> TildeVersionSpecifier<'a> {
|
||||||
///
|
///
|
||||||
/// If a [`Operator::TildeEqual`] is not used, or the version includes more than minor and patch
|
/// If a [`Operator::TildeEqual`] is not used, or the version includes more than minor and patch
|
||||||
/// segments, this will return [`None`].
|
/// segments, this will return [`None`].
|
||||||
pub fn from_specifier(specifier: VersionSpecifier) -> Option<TildeVersionSpecifier<'a>> {
|
pub fn from_specifier(specifier: VersionSpecifier) -> Option<Self> {
|
||||||
TildeVersionSpecifier::new(Cow::Owned(specifier))
|
TildeVersionSpecifier::new(Cow::Owned(specifier))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a new [`TildeVersionSpecifier`] from a [`VersionSpecifier`] reference.
|
/// Create a new [`TildeVersionSpecifier`] from a [`VersionSpecifier`] reference.
|
||||||
///
|
///
|
||||||
/// See [`TildeVersionSpecifier::from_specifier`].
|
/// See [`TildeVersionSpecifier::from_specifier`].
|
||||||
pub fn from_specifier_ref(
|
pub fn from_specifier_ref(specifier: &'a VersionSpecifier) -> Option<Self> {
|
||||||
specifier: &'a VersionSpecifier,
|
|
||||||
) -> Option<TildeVersionSpecifier<'a>> {
|
|
||||||
TildeVersionSpecifier::new(Cow::Borrowed(specifier))
|
TildeVersionSpecifier::new(Cow::Borrowed(specifier))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -342,7 +342,7 @@ impl Pep508Url for Url {
|
||||||
type Err = url::ParseError;
|
type Err = url::ParseError;
|
||||||
|
|
||||||
fn parse_url(url: &str, _working_dir: Option<&Path>) -> Result<Self, Self::Err> {
|
fn parse_url(url: &str, _working_dir: Option<&Path>) -> Result<Self, Self::Err> {
|
||||||
Url::parse(url)
|
Self::parse(url)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn displayable_with_credentials(&self) -> impl Display {
|
fn displayable_with_credentials(&self) -> impl Display {
|
||||||
|
|
|
||||||
|
|
@ -1067,7 +1067,7 @@ impl Variable {
|
||||||
/// For example, `sys_platform == 'win32'` and `platform_system == 'Darwin'` are known to
|
/// For example, `sys_platform == 'win32'` and `platform_system == 'Darwin'` are known to
|
||||||
/// never be true at the same time.
|
/// never be true at the same time.
|
||||||
fn is_conflicting_variable(&self) -> bool {
|
fn is_conflicting_variable(&self) -> bool {
|
||||||
let Variable::String(marker) = self else {
|
let Self::String(marker) = self else {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
marker.is_conflicting()
|
marker.is_conflicting()
|
||||||
|
|
@ -1086,8 +1086,8 @@ pub(crate) struct Node {
|
||||||
|
|
||||||
impl Node {
|
impl Node {
|
||||||
/// Return the complement of this node, flipping all children IDs.
|
/// Return the complement of this node, flipping all children IDs.
|
||||||
fn not(self) -> Node {
|
fn not(self) -> Self {
|
||||||
Node {
|
Self {
|
||||||
var: self.var,
|
var: self.var,
|
||||||
children: self.children.not(),
|
children: self.children.not(),
|
||||||
}
|
}
|
||||||
|
|
@ -1102,16 +1102,16 @@ pub(crate) struct NodeId(usize);
|
||||||
|
|
||||||
impl NodeId {
|
impl NodeId {
|
||||||
// The terminal node representing `true`, or a trivially `true` node.
|
// The terminal node representing `true`, or a trivially `true` node.
|
||||||
pub(crate) const TRUE: NodeId = NodeId(0);
|
pub(crate) const TRUE: Self = Self(0);
|
||||||
|
|
||||||
// The terminal node representing `false`, or an unsatisifable node.
|
// The terminal node representing `false`, or an unsatisifable node.
|
||||||
pub(crate) const FALSE: NodeId = NodeId(1);
|
pub(crate) const FALSE: Self = Self(1);
|
||||||
|
|
||||||
/// Create a new, optionally complemented, [`NodeId`] with the given index.
|
/// Create a new, optionally complemented, [`NodeId`] with the given index.
|
||||||
fn new(index: usize, complement: bool) -> NodeId {
|
fn new(index: usize, complement: bool) -> Self {
|
||||||
// Ensure the index does not interfere with the lowest complement bit.
|
// Ensure the index does not interfere with the lowest complement bit.
|
||||||
let index = (index + 1) << 1;
|
let index = (index + 1) << 1;
|
||||||
NodeId(index | usize::from(complement))
|
Self(index | usize::from(complement))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the index of this ID, ignoring the complemented edge.
|
/// Returns the index of this ID, ignoring the complemented edge.
|
||||||
|
|
@ -1127,16 +1127,16 @@ impl NodeId {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the complement of this node.
|
/// Returns the complement of this node.
|
||||||
pub(crate) fn not(self) -> NodeId {
|
pub(crate) fn not(self) -> Self {
|
||||||
// Toggle the lowest bit.
|
// Toggle the lowest bit.
|
||||||
NodeId(self.0 ^ 1)
|
Self(self.0 ^ 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the complement of this node, if it's parent is complemented.
|
/// Returns the complement of this node, if it's parent is complemented.
|
||||||
///
|
///
|
||||||
/// This method is useful to restore the complemented state of children nodes
|
/// This method is useful to restore the complemented state of children nodes
|
||||||
/// when traversing the tree.
|
/// when traversing the tree.
|
||||||
pub(crate) fn negate(self, parent: NodeId) -> NodeId {
|
pub(crate) fn negate(self, parent: Self) -> Self {
|
||||||
if parent.is_complement() {
|
if parent.is_complement() {
|
||||||
self.not()
|
self.not()
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1146,12 +1146,12 @@ impl NodeId {
|
||||||
|
|
||||||
/// Returns `true` if this node represents an unsatisfiable node.
|
/// Returns `true` if this node represents an unsatisfiable node.
|
||||||
pub(crate) fn is_false(self) -> bool {
|
pub(crate) fn is_false(self) -> bool {
|
||||||
self == NodeId::FALSE
|
self == Self::FALSE
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns `true` if this node represents a trivially `true` node.
|
/// Returns `true` if this node represents a trivially `true` node.
|
||||||
pub(crate) fn is_true(self) -> bool {
|
pub(crate) fn is_true(self) -> bool {
|
||||||
self == NodeId::TRUE
|
self == Self::TRUE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1189,14 +1189,14 @@ pub(crate) enum Edges {
|
||||||
|
|
||||||
impl Edges {
|
impl Edges {
|
||||||
/// Returns the [`Edges`] for a boolean variable.
|
/// Returns the [`Edges`] for a boolean variable.
|
||||||
fn from_bool(complemented: bool) -> Edges {
|
fn from_bool(complemented: bool) -> Self {
|
||||||
if complemented {
|
if complemented {
|
||||||
Edges::Boolean {
|
Self::Boolean {
|
||||||
high: NodeId::TRUE,
|
high: NodeId::TRUE,
|
||||||
low: NodeId::FALSE,
|
low: NodeId::FALSE,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Edges::Boolean {
|
Self::Boolean {
|
||||||
high: NodeId::FALSE,
|
high: NodeId::FALSE,
|
||||||
low: NodeId::TRUE,
|
low: NodeId::TRUE,
|
||||||
}
|
}
|
||||||
|
|
@ -1207,7 +1207,7 @@ impl Edges {
|
||||||
///
|
///
|
||||||
/// This function will panic for the `In` and `Contains` marker operators, which
|
/// This function will panic for the `In` and `Contains` marker operators, which
|
||||||
/// should be represented as separate boolean variables.
|
/// should be represented as separate boolean variables.
|
||||||
fn from_string(operator: MarkerOperator, value: ArcStr) -> Edges {
|
fn from_string(operator: MarkerOperator, value: ArcStr) -> Self {
|
||||||
let range: Ranges<ArcStr> = match operator {
|
let range: Ranges<ArcStr> = match operator {
|
||||||
MarkerOperator::Equal => Ranges::singleton(value),
|
MarkerOperator::Equal => Ranges::singleton(value),
|
||||||
MarkerOperator::NotEqual => Ranges::singleton(value).complement(),
|
MarkerOperator::NotEqual => Ranges::singleton(value).complement(),
|
||||||
|
|
@ -1219,16 +1219,16 @@ impl Edges {
|
||||||
_ => unreachable!("`in` and `contains` are treated as boolean variables"),
|
_ => unreachable!("`in` and `contains` are treated as boolean variables"),
|
||||||
};
|
};
|
||||||
|
|
||||||
Edges::String {
|
Self::String {
|
||||||
edges: Edges::from_range(&range),
|
edges: Self::from_range(&range),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the [`Edges`] for a version specifier.
|
/// Returns the [`Edges`] for a version specifier.
|
||||||
fn from_specifier(specifier: VersionSpecifier) -> Edges {
|
fn from_specifier(specifier: VersionSpecifier) -> Self {
|
||||||
let specifier = release_specifier_to_range(specifier.only_release(), true);
|
let specifier = release_specifier_to_range(specifier.only_release(), true);
|
||||||
Edges::Version {
|
Self::Version {
|
||||||
edges: Edges::from_range(&specifier),
|
edges: Self::from_range(&specifier),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1238,7 +1238,7 @@ impl Edges {
|
||||||
fn from_python_versions(
|
fn from_python_versions(
|
||||||
versions: Vec<Version>,
|
versions: Vec<Version>,
|
||||||
operator: ContainerOperator,
|
operator: ContainerOperator,
|
||||||
) -> Result<Edges, NodeId> {
|
) -> Result<Self, NodeId> {
|
||||||
let mut range: Ranges<Version> = versions
|
let mut range: Ranges<Version> = versions
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|version| {
|
.map(|version| {
|
||||||
|
|
@ -1253,13 +1253,13 @@ impl Edges {
|
||||||
range = range.complement();
|
range = range.complement();
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(Edges::Version {
|
Ok(Self::Version {
|
||||||
edges: Edges::from_range(&range),
|
edges: Self::from_range(&range),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns an [`Edges`] where values in the given range are `true`.
|
/// Returns an [`Edges`] where values in the given range are `true`.
|
||||||
fn from_versions(versions: &[Version], operator: ContainerOperator) -> Edges {
|
fn from_versions(versions: &[Version], operator: ContainerOperator) -> Self {
|
||||||
let mut range: Ranges<Version> = versions
|
let mut range: Ranges<Version> = versions
|
||||||
.iter()
|
.iter()
|
||||||
.map(|version| {
|
.map(|version| {
|
||||||
|
|
@ -1274,8 +1274,8 @@ impl Edges {
|
||||||
range = range.complement();
|
range = range.complement();
|
||||||
}
|
}
|
||||||
|
|
||||||
Edges::Version {
|
Self::Version {
|
||||||
edges: Edges::from_range(&range),
|
edges: Self::from_range(&range),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1323,26 +1323,26 @@ impl Edges {
|
||||||
fn apply(
|
fn apply(
|
||||||
&self,
|
&self,
|
||||||
parent: NodeId,
|
parent: NodeId,
|
||||||
right_edges: &Edges,
|
right_edges: &Self,
|
||||||
right_parent: NodeId,
|
right_parent: NodeId,
|
||||||
mut apply: impl FnMut(NodeId, NodeId) -> NodeId,
|
mut apply: impl FnMut(NodeId, NodeId) -> NodeId,
|
||||||
) -> Edges {
|
) -> Self {
|
||||||
match (self, right_edges) {
|
match (self, right_edges) {
|
||||||
// For version or string variables, we have to split and merge the overlapping ranges.
|
// For version or string variables, we have to split and merge the overlapping ranges.
|
||||||
(Edges::Version { edges }, Edges::Version { edges: right_edges }) => Edges::Version {
|
(Self::Version { edges }, Self::Version { edges: right_edges }) => Self::Version {
|
||||||
edges: Edges::apply_ranges(edges, parent, right_edges, right_parent, apply),
|
edges: Self::apply_ranges(edges, parent, right_edges, right_parent, apply),
|
||||||
},
|
},
|
||||||
(Edges::String { edges }, Edges::String { edges: right_edges }) => Edges::String {
|
(Self::String { edges }, Self::String { edges: right_edges }) => Self::String {
|
||||||
edges: Edges::apply_ranges(edges, parent, right_edges, right_parent, apply),
|
edges: Self::apply_ranges(edges, parent, right_edges, right_parent, apply),
|
||||||
},
|
},
|
||||||
// For boolean variables, we simply merge the low and high edges.
|
// For boolean variables, we simply merge the low and high edges.
|
||||||
(
|
(
|
||||||
Edges::Boolean { high, low },
|
Self::Boolean { high, low },
|
||||||
Edges::Boolean {
|
Self::Boolean {
|
||||||
high: right_high,
|
high: right_high,
|
||||||
low: right_low,
|
low: right_low,
|
||||||
},
|
},
|
||||||
) => Edges::Boolean {
|
) => Self::Boolean {
|
||||||
high: apply(high.negate(parent), right_high.negate(right_parent)),
|
high: apply(high.negate(parent), right_high.negate(right_parent)),
|
||||||
low: apply(low.negate(parent), right_low.negate(right_parent)),
|
low: apply(low.negate(parent), right_low.negate(right_parent)),
|
||||||
},
|
},
|
||||||
|
|
@ -1422,22 +1422,22 @@ impl Edges {
|
||||||
fn is_disjoint(
|
fn is_disjoint(
|
||||||
&self,
|
&self,
|
||||||
parent: NodeId,
|
parent: NodeId,
|
||||||
right_edges: &Edges,
|
right_edges: &Self,
|
||||||
right_parent: NodeId,
|
right_parent: NodeId,
|
||||||
interner: &mut InternerGuard<'_>,
|
interner: &mut InternerGuard<'_>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
match (self, right_edges) {
|
match (self, right_edges) {
|
||||||
// For version or string variables, we have to split and check the overlapping ranges.
|
// For version or string variables, we have to split and check the overlapping ranges.
|
||||||
(Edges::Version { edges }, Edges::Version { edges: right_edges }) => {
|
(Self::Version { edges }, Self::Version { edges: right_edges }) => {
|
||||||
Edges::is_disjoint_ranges(edges, parent, right_edges, right_parent, interner)
|
Self::is_disjoint_ranges(edges, parent, right_edges, right_parent, interner)
|
||||||
}
|
}
|
||||||
(Edges::String { edges }, Edges::String { edges: right_edges }) => {
|
(Self::String { edges }, Self::String { edges: right_edges }) => {
|
||||||
Edges::is_disjoint_ranges(edges, parent, right_edges, right_parent, interner)
|
Self::is_disjoint_ranges(edges, parent, right_edges, right_parent, interner)
|
||||||
}
|
}
|
||||||
// For boolean variables, we simply check the low and high edges.
|
// For boolean variables, we simply check the low and high edges.
|
||||||
(
|
(
|
||||||
Edges::Boolean { high, low },
|
Self::Boolean { high, low },
|
||||||
Edges::Boolean {
|
Self::Boolean {
|
||||||
high: right_high,
|
high: right_high,
|
||||||
low: right_low,
|
low: right_low,
|
||||||
},
|
},
|
||||||
|
|
@ -1482,23 +1482,23 @@ impl Edges {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply the given function to all direct children of this node.
|
// Apply the given function to all direct children of this node.
|
||||||
fn map(&self, parent: NodeId, mut f: impl FnMut(NodeId) -> NodeId) -> Edges {
|
fn map(&self, parent: NodeId, mut f: impl FnMut(NodeId) -> NodeId) -> Self {
|
||||||
match self {
|
match self {
|
||||||
Edges::Version { edges: map } => Edges::Version {
|
Self::Version { edges: map } => Self::Version {
|
||||||
edges: map
|
edges: map
|
||||||
.iter()
|
.iter()
|
||||||
.cloned()
|
.cloned()
|
||||||
.map(|(range, node)| (range, f(node.negate(parent))))
|
.map(|(range, node)| (range, f(node.negate(parent))))
|
||||||
.collect(),
|
.collect(),
|
||||||
},
|
},
|
||||||
Edges::String { edges: map } => Edges::String {
|
Self::String { edges: map } => Self::String {
|
||||||
edges: map
|
edges: map
|
||||||
.iter()
|
.iter()
|
||||||
.cloned()
|
.cloned()
|
||||||
.map(|(range, node)| (range, f(node.negate(parent))))
|
.map(|(range, node)| (range, f(node.negate(parent))))
|
||||||
.collect(),
|
.collect(),
|
||||||
},
|
},
|
||||||
Edges::Boolean { high, low } => Edges::Boolean {
|
Self::Boolean { high, low } => Self::Boolean {
|
||||||
low: f(low.negate(parent)),
|
low: f(low.negate(parent)),
|
||||||
high: f(high.negate(parent)),
|
high: f(high.negate(parent)),
|
||||||
},
|
},
|
||||||
|
|
@ -1508,32 +1508,32 @@ impl Edges {
|
||||||
// Returns an iterator over all direct children of this node.
|
// Returns an iterator over all direct children of this node.
|
||||||
fn nodes(&self) -> impl Iterator<Item = NodeId> + '_ {
|
fn nodes(&self) -> impl Iterator<Item = NodeId> + '_ {
|
||||||
match self {
|
match self {
|
||||||
Edges::Version { edges: map } => {
|
Self::Version { edges: map } => {
|
||||||
Either::Left(Either::Left(map.iter().map(|(_, node)| *node)))
|
Either::Left(Either::Left(map.iter().map(|(_, node)| *node)))
|
||||||
}
|
}
|
||||||
Edges::String { edges: map } => {
|
Self::String { edges: map } => {
|
||||||
Either::Left(Either::Right(map.iter().map(|(_, node)| *node)))
|
Either::Left(Either::Right(map.iter().map(|(_, node)| *node)))
|
||||||
}
|
}
|
||||||
Edges::Boolean { high, low } => Either::Right([*high, *low].into_iter()),
|
Self::Boolean { high, low } => Either::Right([*high, *low].into_iter()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the complement of this [`Edges`].
|
// Returns the complement of this [`Edges`].
|
||||||
fn not(self) -> Edges {
|
fn not(self) -> Self {
|
||||||
match self {
|
match self {
|
||||||
Edges::Version { edges: map } => Edges::Version {
|
Self::Version { edges: map } => Self::Version {
|
||||||
edges: map
|
edges: map
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|(range, node)| (range, node.not()))
|
.map(|(range, node)| (range, node.not()))
|
||||||
.collect(),
|
.collect(),
|
||||||
},
|
},
|
||||||
Edges::String { edges: map } => Edges::String {
|
Self::String { edges: map } => Self::String {
|
||||||
edges: map
|
edges: map
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|(range, node)| (range, node.not()))
|
.map(|(range, node)| (range, node.not()))
|
||||||
.collect(),
|
.collect(),
|
||||||
},
|
},
|
||||||
Edges::Boolean { high, low } => Edges::Boolean {
|
Self::Boolean { high, low } => Self::Boolean {
|
||||||
high: high.not(),
|
high: high.not(),
|
||||||
low: low.not(),
|
low: low.not(),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -187,7 +187,7 @@ impl MarkerEnvironment {
|
||||||
/// See also [`MarkerEnvironment::implementation_name`].
|
/// See also [`MarkerEnvironment::implementation_name`].
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn with_implementation_name(mut self, value: impl Into<String>) -> MarkerEnvironment {
|
pub fn with_implementation_name(mut self, value: impl Into<String>) -> Self {
|
||||||
Arc::make_mut(&mut self.inner).implementation_name = value.into();
|
Arc::make_mut(&mut self.inner).implementation_name = value.into();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
@ -197,10 +197,7 @@ impl MarkerEnvironment {
|
||||||
/// See also [`MarkerEnvironment::implementation_version`].
|
/// See also [`MarkerEnvironment::implementation_version`].
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn with_implementation_version(
|
pub fn with_implementation_version(mut self, value: impl Into<StringVersion>) -> Self {
|
||||||
mut self,
|
|
||||||
value: impl Into<StringVersion>,
|
|
||||||
) -> MarkerEnvironment {
|
|
||||||
Arc::make_mut(&mut self.inner).implementation_version = value.into();
|
Arc::make_mut(&mut self.inner).implementation_version = value.into();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
@ -210,7 +207,7 @@ impl MarkerEnvironment {
|
||||||
/// See also [`MarkerEnvironment::os_name`].
|
/// See also [`MarkerEnvironment::os_name`].
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn with_os_name(mut self, value: impl Into<String>) -> MarkerEnvironment {
|
pub fn with_os_name(mut self, value: impl Into<String>) -> Self {
|
||||||
Arc::make_mut(&mut self.inner).os_name = value.into();
|
Arc::make_mut(&mut self.inner).os_name = value.into();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
@ -220,7 +217,7 @@ impl MarkerEnvironment {
|
||||||
/// See also [`MarkerEnvironment::platform_machine`].
|
/// See also [`MarkerEnvironment::platform_machine`].
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn with_platform_machine(mut self, value: impl Into<String>) -> MarkerEnvironment {
|
pub fn with_platform_machine(mut self, value: impl Into<String>) -> Self {
|
||||||
Arc::make_mut(&mut self.inner).platform_machine = value.into();
|
Arc::make_mut(&mut self.inner).platform_machine = value.into();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
@ -231,10 +228,7 @@ impl MarkerEnvironment {
|
||||||
/// See also [`MarkerEnvironment::platform_python_implementation`].
|
/// See also [`MarkerEnvironment::platform_python_implementation`].
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn with_platform_python_implementation(
|
pub fn with_platform_python_implementation(mut self, value: impl Into<String>) -> Self {
|
||||||
mut self,
|
|
||||||
value: impl Into<String>,
|
|
||||||
) -> MarkerEnvironment {
|
|
||||||
Arc::make_mut(&mut self.inner).platform_python_implementation = value.into();
|
Arc::make_mut(&mut self.inner).platform_python_implementation = value.into();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
@ -244,7 +238,7 @@ impl MarkerEnvironment {
|
||||||
/// See also [`MarkerEnvironment::platform_release`].
|
/// See also [`MarkerEnvironment::platform_release`].
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn with_platform_release(mut self, value: impl Into<String>) -> MarkerEnvironment {
|
pub fn with_platform_release(mut self, value: impl Into<String>) -> Self {
|
||||||
Arc::make_mut(&mut self.inner).platform_release = value.into();
|
Arc::make_mut(&mut self.inner).platform_release = value.into();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
@ -254,7 +248,7 @@ impl MarkerEnvironment {
|
||||||
/// See also [`MarkerEnvironment::platform_system`].
|
/// See also [`MarkerEnvironment::platform_system`].
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn with_platform_system(mut self, value: impl Into<String>) -> MarkerEnvironment {
|
pub fn with_platform_system(mut self, value: impl Into<String>) -> Self {
|
||||||
Arc::make_mut(&mut self.inner).platform_system = value.into();
|
Arc::make_mut(&mut self.inner).platform_system = value.into();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
@ -264,7 +258,7 @@ impl MarkerEnvironment {
|
||||||
/// See also [`MarkerEnvironment::platform_version`].
|
/// See also [`MarkerEnvironment::platform_version`].
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn with_platform_version(mut self, value: impl Into<String>) -> MarkerEnvironment {
|
pub fn with_platform_version(mut self, value: impl Into<String>) -> Self {
|
||||||
Arc::make_mut(&mut self.inner).platform_version = value.into();
|
Arc::make_mut(&mut self.inner).platform_version = value.into();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
@ -274,10 +268,7 @@ impl MarkerEnvironment {
|
||||||
/// See also [`MarkerEnvironment::python_full_version`].
|
/// See also [`MarkerEnvironment::python_full_version`].
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn with_python_full_version(
|
pub fn with_python_full_version(mut self, value: impl Into<StringVersion>) -> Self {
|
||||||
mut self,
|
|
||||||
value: impl Into<StringVersion>,
|
|
||||||
) -> MarkerEnvironment {
|
|
||||||
Arc::make_mut(&mut self.inner).python_full_version = value.into();
|
Arc::make_mut(&mut self.inner).python_full_version = value.into();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
@ -287,7 +278,7 @@ impl MarkerEnvironment {
|
||||||
/// See also [`MarkerEnvironment::python_full_version`].
|
/// See also [`MarkerEnvironment::python_full_version`].
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn with_python_version(mut self, value: impl Into<StringVersion>) -> MarkerEnvironment {
|
pub fn with_python_version(mut self, value: impl Into<StringVersion>) -> Self {
|
||||||
Arc::make_mut(&mut self.inner).python_version = value.into();
|
Arc::make_mut(&mut self.inner).python_version = value.into();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
@ -297,7 +288,7 @@ impl MarkerEnvironment {
|
||||||
/// See also [`MarkerEnvironment::sys_platform`].
|
/// See also [`MarkerEnvironment::sys_platform`].
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn with_sys_platform(mut self, value: impl Into<String>) -> MarkerEnvironment {
|
pub fn with_sys_platform(mut self, value: impl Into<String>) -> Self {
|
||||||
Arc::make_mut(&mut self.inner).sys_platform = value.into();
|
Arc::make_mut(&mut self.inner).sys_platform = value.into();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
@ -331,7 +322,7 @@ impl<'a> TryFrom<MarkerEnvironmentBuilder<'a>> for MarkerEnvironment {
|
||||||
type Error = VersionParseError;
|
type Error = VersionParseError;
|
||||||
|
|
||||||
fn try_from(builder: MarkerEnvironmentBuilder<'a>) -> Result<Self, Self::Error> {
|
fn try_from(builder: MarkerEnvironmentBuilder<'a>) -> Result<Self, Self::Error> {
|
||||||
Ok(MarkerEnvironment {
|
Ok(Self {
|
||||||
inner: Arc::new(MarkerEnvironmentInner {
|
inner: Arc::new(MarkerEnvironmentInner {
|
||||||
implementation_name: builder.implementation_name.to_string(),
|
implementation_name: builder.implementation_name.to_string(),
|
||||||
implementation_version: builder.implementation_version.parse()?,
|
implementation_version: builder.implementation_version.parse()?,
|
||||||
|
|
|
||||||
|
|
@ -268,7 +268,7 @@ impl MarkerOperator {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Inverts this marker operator.
|
/// Inverts this marker operator.
|
||||||
pub(crate) fn invert(self) -> MarkerOperator {
|
pub(crate) fn invert(self) -> Self {
|
||||||
match self {
|
match self {
|
||||||
Self::LessThan => Self::GreaterThan,
|
Self::LessThan => Self::GreaterThan,
|
||||||
Self::LessEqual => Self::GreaterEqual,
|
Self::LessEqual => Self::GreaterEqual,
|
||||||
|
|
@ -288,7 +288,7 @@ impl MarkerOperator {
|
||||||
///
|
///
|
||||||
/// If a negation doesn't exist, which is only the case for ~=, then this
|
/// If a negation doesn't exist, which is only the case for ~=, then this
|
||||||
/// returns `None`.
|
/// returns `None`.
|
||||||
pub(crate) fn negate(self) -> Option<MarkerOperator> {
|
pub(crate) fn negate(self) -> Option<Self> {
|
||||||
Some(match self {
|
Some(match self {
|
||||||
Self::Equal => Self::NotEqual,
|
Self::Equal => Self::NotEqual,
|
||||||
Self::NotEqual => Self::Equal,
|
Self::NotEqual => Self::Equal,
|
||||||
|
|
@ -307,37 +307,34 @@ impl MarkerOperator {
|
||||||
/// Returns the marker operator and value whose union represents the given range.
|
/// Returns the marker operator and value whose union represents the given range.
|
||||||
pub fn from_bounds(
|
pub fn from_bounds(
|
||||||
bounds: (&Bound<ArcStr>, &Bound<ArcStr>),
|
bounds: (&Bound<ArcStr>, &Bound<ArcStr>),
|
||||||
) -> impl Iterator<Item = (MarkerOperator, ArcStr)> {
|
) -> impl Iterator<Item = (Self, ArcStr)> {
|
||||||
let (b1, b2) = match bounds {
|
let (b1, b2) = match bounds {
|
||||||
(Bound::Included(v1), Bound::Included(v2)) if v1 == v2 => {
|
(Bound::Included(v1), Bound::Included(v2)) if v1 == v2 => {
|
||||||
(Some((MarkerOperator::Equal, v1.clone())), None)
|
(Some((Self::Equal, v1.clone())), None)
|
||||||
}
|
}
|
||||||
(Bound::Excluded(v1), Bound::Excluded(v2)) if v1 == v2 => {
|
(Bound::Excluded(v1), Bound::Excluded(v2)) if v1 == v2 => {
|
||||||
(Some((MarkerOperator::NotEqual, v1.clone())), None)
|
(Some((Self::NotEqual, v1.clone())), None)
|
||||||
}
|
}
|
||||||
(lower, upper) => (
|
(lower, upper) => (Self::from_lower_bound(lower), Self::from_upper_bound(upper)),
|
||||||
MarkerOperator::from_lower_bound(lower),
|
|
||||||
MarkerOperator::from_upper_bound(upper),
|
|
||||||
),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
b1.into_iter().chain(b2)
|
b1.into_iter().chain(b2)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a value specifier representing the given lower bound.
|
/// Returns a value specifier representing the given lower bound.
|
||||||
pub fn from_lower_bound(bound: &Bound<ArcStr>) -> Option<(MarkerOperator, ArcStr)> {
|
pub fn from_lower_bound(bound: &Bound<ArcStr>) -> Option<(Self, ArcStr)> {
|
||||||
match bound {
|
match bound {
|
||||||
Bound::Included(value) => Some((MarkerOperator::GreaterEqual, value.clone())),
|
Bound::Included(value) => Some((Self::GreaterEqual, value.clone())),
|
||||||
Bound::Excluded(value) => Some((MarkerOperator::GreaterThan, value.clone())),
|
Bound::Excluded(value) => Some((Self::GreaterThan, value.clone())),
|
||||||
Bound::Unbounded => None,
|
Bound::Unbounded => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a value specifier representing the given upper bound.
|
/// Returns a value specifier representing the given upper bound.
|
||||||
pub fn from_upper_bound(bound: &Bound<ArcStr>) -> Option<(MarkerOperator, ArcStr)> {
|
pub fn from_upper_bound(bound: &Bound<ArcStr>) -> Option<(Self, ArcStr)> {
|
||||||
match bound {
|
match bound {
|
||||||
Bound::Included(value) => Some((MarkerOperator::LessEqual, value.clone())),
|
Bound::Included(value) => Some((Self::LessEqual, value.clone())),
|
||||||
Bound::Excluded(value) => Some((MarkerOperator::LessThan, value.clone())),
|
Bound::Excluded(value) => Some((Self::LessThan, value.clone())),
|
||||||
Bound::Unbounded => None,
|
Bound::Unbounded => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -574,19 +571,19 @@ impl ExtraOperator {
|
||||||
/// Creates a [`ExtraOperator`] from an equivalent [`MarkerOperator`].
|
/// Creates a [`ExtraOperator`] from an equivalent [`MarkerOperator`].
|
||||||
///
|
///
|
||||||
/// Returns `None` if the operator is not supported for extras.
|
/// Returns `None` if the operator is not supported for extras.
|
||||||
pub(crate) fn from_marker_operator(operator: MarkerOperator) -> Option<ExtraOperator> {
|
pub(crate) fn from_marker_operator(operator: MarkerOperator) -> Option<Self> {
|
||||||
match operator {
|
match operator {
|
||||||
MarkerOperator::Equal => Some(ExtraOperator::Equal),
|
MarkerOperator::Equal => Some(Self::Equal),
|
||||||
MarkerOperator::NotEqual => Some(ExtraOperator::NotEqual),
|
MarkerOperator::NotEqual => Some(Self::NotEqual),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Negates this operator.
|
/// Negates this operator.
|
||||||
pub(crate) fn negate(&self) -> ExtraOperator {
|
pub(crate) fn negate(&self) -> Self {
|
||||||
match *self {
|
match *self {
|
||||||
ExtraOperator::Equal => ExtraOperator::NotEqual,
|
Self::Equal => Self::NotEqual,
|
||||||
ExtraOperator::NotEqual => ExtraOperator::Equal,
|
Self::NotEqual => Self::Equal,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -613,10 +610,10 @@ impl ContainerOperator {
|
||||||
/// Creates a [`ContainerOperator`] from an equivalent [`MarkerOperator`].
|
/// Creates a [`ContainerOperator`] from an equivalent [`MarkerOperator`].
|
||||||
///
|
///
|
||||||
/// Returns `None` if the operator is not supported for containers.
|
/// Returns `None` if the operator is not supported for containers.
|
||||||
pub(crate) fn from_marker_operator(operator: MarkerOperator) -> Option<ContainerOperator> {
|
pub(crate) fn from_marker_operator(operator: MarkerOperator) -> Option<Self> {
|
||||||
match operator {
|
match operator {
|
||||||
MarkerOperator::In => Some(ContainerOperator::In),
|
MarkerOperator::In => Some(Self::In),
|
||||||
MarkerOperator::NotIn => Some(ContainerOperator::NotIn),
|
MarkerOperator::NotIn => Some(Self::NotIn),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -660,17 +657,17 @@ impl MarkerExpression {
|
||||||
/// that are ignored, such as `os_name ~= 'foo'`.
|
/// that are ignored, such as `os_name ~= 'foo'`.
|
||||||
#[allow(clippy::should_implement_trait)]
|
#[allow(clippy::should_implement_trait)]
|
||||||
pub fn from_str(s: &str) -> Result<Option<Self>, Pep508Error> {
|
pub fn from_str(s: &str) -> Result<Option<Self>, Pep508Error> {
|
||||||
MarkerExpression::parse_reporter(s, &mut TracingReporter)
|
Self::parse_reporter(s, &mut TracingReporter)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the kind of this marker expression.
|
/// Return the kind of this marker expression.
|
||||||
pub(crate) fn kind(&self) -> MarkerExpressionKind {
|
pub(crate) fn kind(&self) -> MarkerExpressionKind {
|
||||||
match self {
|
match self {
|
||||||
MarkerExpression::Version { key, .. } => MarkerExpressionKind::Version(*key),
|
Self::Version { key, .. } => MarkerExpressionKind::Version(*key),
|
||||||
MarkerExpression::VersionIn { key, .. } => MarkerExpressionKind::VersionIn(*key),
|
Self::VersionIn { key, .. } => MarkerExpressionKind::VersionIn(*key),
|
||||||
MarkerExpression::String { key, .. } => MarkerExpressionKind::String(*key),
|
Self::String { key, .. } => MarkerExpressionKind::String(*key),
|
||||||
MarkerExpression::List { pair, .. } => MarkerExpressionKind::List(pair.key()),
|
Self::List { pair, .. } => MarkerExpressionKind::List(pair.key()),
|
||||||
MarkerExpression::Extra { .. } => MarkerExpressionKind::Extra,
|
Self::Extra { .. } => MarkerExpressionKind::Extra,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -678,7 +675,7 @@ impl MarkerExpression {
|
||||||
impl Display for MarkerExpression {
|
impl Display for MarkerExpression {
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
MarkerExpression::Version { key, specifier } => {
|
Self::Version { key, specifier } => {
|
||||||
let (op, version) = (specifier.operator(), specifier.version());
|
let (op, version) = (specifier.operator(), specifier.version());
|
||||||
if op == &uv_pep440::Operator::EqualStar || op == &uv_pep440::Operator::NotEqualStar
|
if op == &uv_pep440::Operator::EqualStar || op == &uv_pep440::Operator::NotEqualStar
|
||||||
{
|
{
|
||||||
|
|
@ -686,7 +683,7 @@ impl Display for MarkerExpression {
|
||||||
}
|
}
|
||||||
write!(f, "{key} {op} '{version}'")
|
write!(f, "{key} {op} '{version}'")
|
||||||
}
|
}
|
||||||
MarkerExpression::VersionIn {
|
Self::VersionIn {
|
||||||
key,
|
key,
|
||||||
versions,
|
versions,
|
||||||
operator,
|
operator,
|
||||||
|
|
@ -694,7 +691,7 @@ impl Display for MarkerExpression {
|
||||||
let versions = versions.iter().map(ToString::to_string).join(" ");
|
let versions = versions.iter().map(ToString::to_string).join(" ");
|
||||||
write!(f, "{key} {operator} '{versions}'")
|
write!(f, "{key} {operator} '{versions}'")
|
||||||
}
|
}
|
||||||
MarkerExpression::String {
|
Self::String {
|
||||||
key,
|
key,
|
||||||
operator,
|
operator,
|
||||||
value,
|
value,
|
||||||
|
|
@ -708,10 +705,10 @@ impl Display for MarkerExpression {
|
||||||
|
|
||||||
write!(f, "{key} {operator} '{value}'")
|
write!(f, "{key} {operator} '{value}'")
|
||||||
}
|
}
|
||||||
MarkerExpression::List { pair, operator } => {
|
Self::List { pair, operator } => {
|
||||||
write!(f, "'{}' {} {}", pair.value(), operator, pair.key())
|
write!(f, "'{}' {} {}", pair.value(), operator, pair.key())
|
||||||
}
|
}
|
||||||
MarkerExpression::Extra { operator, name } => {
|
Self::Extra { operator, name } => {
|
||||||
write!(f, "extra {operator} '{name}'")
|
write!(f, "extra {operator} '{name}'")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -773,7 +770,7 @@ pub struct MarkerTree(NodeId);
|
||||||
|
|
||||||
impl Default for MarkerTree {
|
impl Default for MarkerTree {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
MarkerTree::TRUE
|
Self::TRUE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -823,14 +820,14 @@ impl MarkerTree {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An empty marker that always evaluates to `true`.
|
/// An empty marker that always evaluates to `true`.
|
||||||
pub const TRUE: MarkerTree = MarkerTree(NodeId::TRUE);
|
pub const TRUE: Self = Self(NodeId::TRUE);
|
||||||
|
|
||||||
/// An unsatisfiable marker that always evaluates to `false`.
|
/// An unsatisfiable marker that always evaluates to `false`.
|
||||||
pub const FALSE: MarkerTree = MarkerTree(NodeId::FALSE);
|
pub const FALSE: Self = Self(NodeId::FALSE);
|
||||||
|
|
||||||
/// Returns a marker tree for a single expression.
|
/// Returns a marker tree for a single expression.
|
||||||
pub fn expression(expr: MarkerExpression) -> MarkerTree {
|
pub fn expression(expr: MarkerExpression) -> Self {
|
||||||
MarkerTree(INTERNER.lock().expression(expr))
|
Self(INTERNER.lock().expression(expr))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Whether the marker always evaluates to `true`.
|
/// Whether the marker always evaluates to `true`.
|
||||||
|
|
@ -856,17 +853,17 @@ impl MarkerTree {
|
||||||
|
|
||||||
/// Returns a new marker tree that is the negation of this one.
|
/// Returns a new marker tree that is the negation of this one.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn negate(self) -> MarkerTree {
|
pub fn negate(self) -> Self {
|
||||||
MarkerTree(self.0.not())
|
Self(self.0.not())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Combine this marker tree with the one given via a conjunction.
|
/// Combine this marker tree with the one given via a conjunction.
|
||||||
pub fn and(&mut self, tree: MarkerTree) {
|
pub fn and(&mut self, tree: Self) {
|
||||||
self.0 = INTERNER.lock().and(self.0, tree.0);
|
self.0 = INTERNER.lock().and(self.0, tree.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Combine this marker tree with the one given via a disjunction.
|
/// Combine this marker tree with the one given via a disjunction.
|
||||||
pub fn or(&mut self, tree: MarkerTree) {
|
pub fn or(&mut self, tree: Self) {
|
||||||
self.0 = INTERNER.lock().or(self.0, tree.0);
|
self.0 = INTERNER.lock().or(self.0, tree.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -875,7 +872,7 @@ impl MarkerTree {
|
||||||
///
|
///
|
||||||
/// If the marker set is always `true`, then it can be said that `self`
|
/// If the marker set is always `true`, then it can be said that `self`
|
||||||
/// implies `consequent`.
|
/// implies `consequent`.
|
||||||
pub fn implies(&mut self, consequent: MarkerTree) {
|
pub fn implies(&mut self, consequent: Self) {
|
||||||
// This could probably be optimized, but is clearly
|
// This could probably be optimized, but is clearly
|
||||||
// correct, since logical implication is `-P or Q`.
|
// correct, since logical implication is `-P or Q`.
|
||||||
*self = self.negate();
|
*self = self.negate();
|
||||||
|
|
@ -889,7 +886,7 @@ impl MarkerTree {
|
||||||
/// never both evaluate to `true` in a given environment. However, this method may return
|
/// never both evaluate to `true` in a given environment. However, this method may return
|
||||||
/// false negatives, i.e. it may not be able to detect that two markers are disjoint for
|
/// false negatives, i.e. it may not be able to detect that two markers are disjoint for
|
||||||
/// complex expressions.
|
/// complex expressions.
|
||||||
pub fn is_disjoint(self, other: MarkerTree) -> bool {
|
pub fn is_disjoint(self, other: Self) -> bool {
|
||||||
INTERNER.lock().is_disjoint(self.0, other.0)
|
INTERNER.lock().is_disjoint(self.0, other.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1240,12 +1237,8 @@ impl MarkerTree {
|
||||||
/// results of that simplification. (If `requires-python` changes, then one
|
/// results of that simplification. (If `requires-python` changes, then one
|
||||||
/// should reconstitute all relevant markers from the source data.)
|
/// should reconstitute all relevant markers from the source data.)
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn simplify_python_versions(
|
pub fn simplify_python_versions(self, lower: Bound<&Version>, upper: Bound<&Version>) -> Self {
|
||||||
self,
|
Self(
|
||||||
lower: Bound<&Version>,
|
|
||||||
upper: Bound<&Version>,
|
|
||||||
) -> MarkerTree {
|
|
||||||
MarkerTree(
|
|
||||||
INTERNER
|
INTERNER
|
||||||
.lock()
|
.lock()
|
||||||
.simplify_python_versions(self.0, lower, upper),
|
.simplify_python_versions(self.0, lower, upper),
|
||||||
|
|
@ -1264,8 +1257,8 @@ impl MarkerTree {
|
||||||
self,
|
self,
|
||||||
lower: Bound<&Version>,
|
lower: Bound<&Version>,
|
||||||
upper: Bound<&Version>,
|
upper: Bound<&Version>,
|
||||||
) -> MarkerTree {
|
) -> Self {
|
||||||
MarkerTree(
|
Self(
|
||||||
INTERNER
|
INTERNER
|
||||||
.lock()
|
.lock()
|
||||||
.complexify_python_versions(self.0, lower, upper),
|
.complexify_python_versions(self.0, lower, upper),
|
||||||
|
|
@ -1281,7 +1274,7 @@ impl MarkerTree {
|
||||||
/// For example, if `dev` is a provided extra, given `sys_platform == 'linux' and extra == 'dev'`,
|
/// For example, if `dev` is a provided extra, given `sys_platform == 'linux' and extra == 'dev'`,
|
||||||
/// the marker will be simplified to `sys_platform == 'linux'`.
|
/// the marker will be simplified to `sys_platform == 'linux'`.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn simplify_extras(self, extras: &[ExtraName]) -> MarkerTree {
|
pub fn simplify_extras(self, extras: &[ExtraName]) -> Self {
|
||||||
self.simplify_extras_with(|name| extras.contains(name))
|
self.simplify_extras_with(|name| extras.contains(name))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1296,7 +1289,7 @@ impl MarkerTree {
|
||||||
/// == 'linux' and extra != 'dev'`, the marker will be simplified to
|
/// == 'linux' and extra != 'dev'`, the marker will be simplified to
|
||||||
/// `sys_platform == 'linux'`.
|
/// `sys_platform == 'linux'`.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn simplify_not_extras(self, extras: &[ExtraName]) -> MarkerTree {
|
pub fn simplify_not_extras(self, extras: &[ExtraName]) -> Self {
|
||||||
self.simplify_not_extras_with(|name| extras.contains(name))
|
self.simplify_not_extras_with(|name| extras.contains(name))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1310,7 +1303,7 @@ impl MarkerTree {
|
||||||
/// `sys_platform == 'linux' and extra == 'dev'`, the marker will be simplified to
|
/// `sys_platform == 'linux' and extra == 'dev'`, the marker will be simplified to
|
||||||
/// `sys_platform == 'linux'`.
|
/// `sys_platform == 'linux'`.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn simplify_extras_with(self, is_extra: impl Fn(&ExtraName) -> bool) -> MarkerTree {
|
pub fn simplify_extras_with(self, is_extra: impl Fn(&ExtraName) -> bool) -> Self {
|
||||||
// Because `simplify_extras_with_impl` is recursive, and we need to use
|
// Because `simplify_extras_with_impl` is recursive, and we need to use
|
||||||
// our predicate in recursive calls, we need the predicate itself to
|
// our predicate in recursive calls, we need the predicate itself to
|
||||||
// have some indirection (or else we'd have to clone it). To avoid a
|
// have some indirection (or else we'd have to clone it). To avoid a
|
||||||
|
|
@ -1330,7 +1323,7 @@ impl MarkerTree {
|
||||||
/// `sys_platform == 'linux' and extra != 'dev'`, the marker will be simplified to
|
/// `sys_platform == 'linux' and extra != 'dev'`, the marker will be simplified to
|
||||||
/// `sys_platform == 'linux'`.
|
/// `sys_platform == 'linux'`.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn simplify_not_extras_with(self, is_extra: impl Fn(&ExtraName) -> bool) -> MarkerTree {
|
pub fn simplify_not_extras_with(self, is_extra: impl Fn(&ExtraName) -> bool) -> Self {
|
||||||
// Because `simplify_extras_with_impl` is recursive, and we need to use
|
// Because `simplify_extras_with_impl` is recursive, and we need to use
|
||||||
// our predicate in recursive calls, we need the predicate itself to
|
// our predicate in recursive calls, we need the predicate itself to
|
||||||
// have some indirection (or else we'd have to clone it). To avoid a
|
// have some indirection (or else we'd have to clone it). To avoid a
|
||||||
|
|
@ -1344,8 +1337,8 @@ impl MarkerTree {
|
||||||
/// If the marker only consisted of `extra` expressions, then a marker that
|
/// If the marker only consisted of `extra` expressions, then a marker that
|
||||||
/// is always true is returned.
|
/// is always true is returned.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn without_extras(self) -> MarkerTree {
|
pub fn without_extras(self) -> Self {
|
||||||
MarkerTree(INTERNER.lock().without_extras(self.0))
|
Self(INTERNER.lock().without_extras(self.0))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a new `MarkerTree` where only `extra` expressions are removed.
|
/// Returns a new `MarkerTree` where only `extra` expressions are removed.
|
||||||
|
|
@ -1353,8 +1346,8 @@ impl MarkerTree {
|
||||||
/// If the marker did not contain any `extra` expressions, then a marker
|
/// If the marker did not contain any `extra` expressions, then a marker
|
||||||
/// that is always true is returned.
|
/// that is always true is returned.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn only_extras(self) -> MarkerTree {
|
pub fn only_extras(self) -> Self {
|
||||||
MarkerTree(INTERNER.lock().only_extras(self.0))
|
Self(INTERNER.lock().only_extras(self.0))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Calls the provided function on every `extra` in this tree.
|
/// Calls the provided function on every `extra` in this tree.
|
||||||
|
|
@ -1405,15 +1398,15 @@ impl MarkerTree {
|
||||||
imp(self, &mut f);
|
imp(self, &mut f);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn simplify_extras_with_impl(self, is_extra: &impl Fn(&ExtraName) -> bool) -> MarkerTree {
|
fn simplify_extras_with_impl(self, is_extra: &impl Fn(&ExtraName) -> bool) -> Self {
|
||||||
MarkerTree(INTERNER.lock().restrict(self.0, &|var| match var {
|
Self(INTERNER.lock().restrict(self.0, &|var| match var {
|
||||||
Variable::Extra(name) => is_extra(name.extra()).then_some(true),
|
Variable::Extra(name) => is_extra(name.extra()).then_some(true),
|
||||||
_ => None,
|
_ => None,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn simplify_not_extras_with_impl(self, is_extra: &impl Fn(&ExtraName) -> bool) -> MarkerTree {
|
fn simplify_not_extras_with_impl(self, is_extra: &impl Fn(&ExtraName) -> bool) -> Self {
|
||||||
MarkerTree(INTERNER.lock().restrict(self.0, &|var| match var {
|
Self(INTERNER.lock().restrict(self.0, &|var| match var {
|
||||||
Variable::Extra(name) => is_extra(name.extra()).then_some(false),
|
Variable::Extra(name) => is_extra(name.extra()).then_some(false),
|
||||||
_ => None,
|
_ => None,
|
||||||
}))
|
}))
|
||||||
|
|
|
||||||
|
|
@ -22,11 +22,11 @@ impl RequirementOrigin {
|
||||||
/// Returns the path of the requirement origin.
|
/// Returns the path of the requirement origin.
|
||||||
pub fn path(&self) -> &Path {
|
pub fn path(&self) -> &Path {
|
||||||
match self {
|
match self {
|
||||||
RequirementOrigin::File(path) => path.as_path(),
|
Self::File(path) => path.as_path(),
|
||||||
RequirementOrigin::Project(path, _) => path.as_path(),
|
Self::Project(path, _) => path.as_path(),
|
||||||
RequirementOrigin::Group(path, _, _) => path.as_path(),
|
Self::Group(path, _, _) => path.as_path(),
|
||||||
// Multiple toml are merged and difficult to track files where Requirement is defined. Returns a dummy path instead.
|
// Multiple toml are merged and difficult to track files where Requirement is defined. Returns a dummy path instead.
|
||||||
RequirementOrigin::Workspace => Path::new("(workspace)"),
|
Self::Workspace => Path::new("(workspace)"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -276,19 +276,19 @@ impl Deref for VerbatimUrl {
|
||||||
|
|
||||||
impl From<Url> for VerbatimUrl {
|
impl From<Url> for VerbatimUrl {
|
||||||
fn from(url: Url) -> Self {
|
fn from(url: Url) -> Self {
|
||||||
VerbatimUrl::from_url(DisplaySafeUrl::from(url))
|
Self::from_url(DisplaySafeUrl::from(url))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<DisplaySafeUrl> for VerbatimUrl {
|
impl From<DisplaySafeUrl> for VerbatimUrl {
|
||||||
fn from(url: DisplaySafeUrl) -> Self {
|
fn from(url: DisplaySafeUrl) -> Self {
|
||||||
VerbatimUrl::from_url(url)
|
Self::from_url(url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<VerbatimUrl> for Url {
|
impl From<VerbatimUrl> for Url {
|
||||||
fn from(url: VerbatimUrl) -> Self {
|
fn from(url: VerbatimUrl) -> Self {
|
||||||
Url::from(url.url)
|
Self::from(url.url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -304,12 +304,12 @@ impl serde::Serialize for VerbatimUrl {
|
||||||
|
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
impl<'de> serde::Deserialize<'de> for VerbatimUrl {
|
impl<'de> serde::Deserialize<'de> for VerbatimUrl {
|
||||||
fn deserialize<D>(deserializer: D) -> Result<VerbatimUrl, D::Error>
|
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||||
where
|
where
|
||||||
D: serde::Deserializer<'de>,
|
D: serde::Deserializer<'de>,
|
||||||
{
|
{
|
||||||
let url = DisplaySafeUrl::deserialize(deserializer)?;
|
let url = DisplaySafeUrl::deserialize(deserializer)?;
|
||||||
Ok(VerbatimUrl::from_url(url))
|
Ok(Self::from_url(url))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -338,21 +338,19 @@ impl Pep508Url for VerbatimUrl {
|
||||||
let path = normalize_url_path(path);
|
let path = normalize_url_path(path);
|
||||||
|
|
||||||
if let Some(working_dir) = working_dir {
|
if let Some(working_dir) = working_dir {
|
||||||
return Ok(
|
return Ok(Self::from_path(path.as_ref(), working_dir)?.with_given(url));
|
||||||
VerbatimUrl::from_path(path.as_ref(), working_dir)?.with_given(url)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(VerbatimUrl::from_absolute_path(path.as_ref())?.with_given(url))
|
Ok(Self::from_absolute_path(path.as_ref())?.with_given(url))
|
||||||
}
|
}
|
||||||
#[cfg(not(feature = "non-pep508-extensions"))]
|
#[cfg(not(feature = "non-pep508-extensions"))]
|
||||||
Ok(VerbatimUrl::parse_url(expanded)?.with_given(url))
|
Ok(Self::parse_url(expanded)?.with_given(url))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ex) `https://download.pytorch.org/whl/torch_stable.html`
|
// Ex) `https://download.pytorch.org/whl/torch_stable.html`
|
||||||
Some(_) => {
|
Some(_) => {
|
||||||
// Ex) `https://download.pytorch.org/whl/torch_stable.html`
|
// Ex) `https://download.pytorch.org/whl/torch_stable.html`
|
||||||
Ok(VerbatimUrl::parse_url(expanded.as_ref())?.with_given(url))
|
Ok(Self::parse_url(expanded.as_ref())?.with_given(url))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ex) `C:\Users\ferris\wheel-0.42.0.tar.gz`
|
// Ex) `C:\Users\ferris\wheel-0.42.0.tar.gz`
|
||||||
|
|
@ -360,11 +358,12 @@ impl Pep508Url for VerbatimUrl {
|
||||||
#[cfg(feature = "non-pep508-extensions")]
|
#[cfg(feature = "non-pep508-extensions")]
|
||||||
{
|
{
|
||||||
if let Some(working_dir) = working_dir {
|
if let Some(working_dir) = working_dir {
|
||||||
return Ok(VerbatimUrl::from_path(expanded.as_ref(), working_dir)?
|
return Ok(
|
||||||
.with_given(url));
|
Self::from_path(expanded.as_ref(), working_dir)?.with_given(url)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(VerbatimUrl::from_absolute_path(expanded.as_ref())?.with_given(url))
|
Ok(Self::from_absolute_path(expanded.as_ref())?.with_given(url))
|
||||||
}
|
}
|
||||||
#[cfg(not(feature = "non-pep508-extensions"))]
|
#[cfg(not(feature = "non-pep508-extensions"))]
|
||||||
Err(Self::Err::NotAUrl(expanded.to_string()))
|
Err(Self::Err::NotAUrl(expanded.to_string()))
|
||||||
|
|
@ -375,12 +374,10 @@ impl Pep508Url for VerbatimUrl {
|
||||||
#[cfg(feature = "non-pep508-extensions")]
|
#[cfg(feature = "non-pep508-extensions")]
|
||||||
{
|
{
|
||||||
if let Some(working_dir) = working_dir {
|
if let Some(working_dir) = working_dir {
|
||||||
return Ok(
|
return Ok(Self::from_path(expanded.as_ref(), working_dir)?.with_given(url));
|
||||||
VerbatimUrl::from_path(expanded.as_ref(), working_dir)?.with_given(url)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(VerbatimUrl::from_absolute_path(expanded.as_ref())?.with_given(url))
|
Ok(Self::from_absolute_path(expanded.as_ref())?.with_given(url))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "non-pep508-extensions"))]
|
#[cfg(not(feature = "non-pep508-extensions"))]
|
||||||
|
|
|
||||||
|
|
@ -47,26 +47,26 @@ impl AbiTag {
|
||||||
/// Return a pretty string representation of the ABI tag.
|
/// Return a pretty string representation of the ABI tag.
|
||||||
pub fn pretty(self) -> Option<String> {
|
pub fn pretty(self) -> Option<String> {
|
||||||
match self {
|
match self {
|
||||||
AbiTag::None => None,
|
Self::None => None,
|
||||||
AbiTag::Abi3 => None,
|
Self::Abi3 => None,
|
||||||
AbiTag::CPython { python_version, .. } => {
|
Self::CPython { python_version, .. } => {
|
||||||
Some(format!("CPython {}.{}", python_version.0, python_version.1))
|
Some(format!("CPython {}.{}", python_version.0, python_version.1))
|
||||||
}
|
}
|
||||||
AbiTag::PyPy {
|
Self::PyPy {
|
||||||
implementation_version,
|
implementation_version,
|
||||||
..
|
..
|
||||||
} => Some(format!(
|
} => Some(format!(
|
||||||
"PyPy {}.{}",
|
"PyPy {}.{}",
|
||||||
implementation_version.0, implementation_version.1
|
implementation_version.0, implementation_version.1
|
||||||
)),
|
)),
|
||||||
AbiTag::GraalPy {
|
Self::GraalPy {
|
||||||
implementation_version,
|
implementation_version,
|
||||||
..
|
..
|
||||||
} => Some(format!(
|
} => Some(format!(
|
||||||
"GraalPy {}.{}",
|
"GraalPy {}.{}",
|
||||||
implementation_version.0, implementation_version.1
|
implementation_version.0, implementation_version.1
|
||||||
)),
|
)),
|
||||||
AbiTag::Pyston { .. } => Some("Pyston".to_string()),
|
Self::Pyston { .. } => Some("Pyston".to_string()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -79,27 +79,27 @@ impl PlatformTag {
|
||||||
/// Return a pretty string representation of the language tag.
|
/// Return a pretty string representation of the language tag.
|
||||||
pub fn pretty(&self) -> Option<&'static str> {
|
pub fn pretty(&self) -> Option<&'static str> {
|
||||||
match self {
|
match self {
|
||||||
PlatformTag::Any => None,
|
Self::Any => None,
|
||||||
PlatformTag::Manylinux { .. } => Some("Linux"),
|
Self::Manylinux { .. } => Some("Linux"),
|
||||||
PlatformTag::Manylinux1 { .. } => Some("Linux"),
|
Self::Manylinux1 { .. } => Some("Linux"),
|
||||||
PlatformTag::Manylinux2010 { .. } => Some("Linux"),
|
Self::Manylinux2010 { .. } => Some("Linux"),
|
||||||
PlatformTag::Manylinux2014 { .. } => Some("Linux"),
|
Self::Manylinux2014 { .. } => Some("Linux"),
|
||||||
PlatformTag::Linux { .. } => Some("Linux"),
|
Self::Linux { .. } => Some("Linux"),
|
||||||
PlatformTag::Musllinux { .. } => Some("Linux"),
|
Self::Musllinux { .. } => Some("Linux"),
|
||||||
PlatformTag::Macos { .. } => Some("macOS"),
|
Self::Macos { .. } => Some("macOS"),
|
||||||
PlatformTag::Win32 => Some("Windows"),
|
Self::Win32 => Some("Windows"),
|
||||||
PlatformTag::WinAmd64 => Some("Windows"),
|
Self::WinAmd64 => Some("Windows"),
|
||||||
PlatformTag::WinArm64 => Some("Windows"),
|
Self::WinArm64 => Some("Windows"),
|
||||||
PlatformTag::WinIa64 => Some("Windows"),
|
Self::WinIa64 => Some("Windows"),
|
||||||
PlatformTag::Android { .. } => Some("Android"),
|
Self::Android { .. } => Some("Android"),
|
||||||
PlatformTag::FreeBsd { .. } => Some("FreeBSD"),
|
Self::FreeBsd { .. } => Some("FreeBSD"),
|
||||||
PlatformTag::NetBsd { .. } => Some("NetBSD"),
|
Self::NetBsd { .. } => Some("NetBSD"),
|
||||||
PlatformTag::OpenBsd { .. } => Some("OpenBSD"),
|
Self::OpenBsd { .. } => Some("OpenBSD"),
|
||||||
PlatformTag::Dragonfly { .. } => Some("DragonFly"),
|
Self::Dragonfly { .. } => Some("DragonFly"),
|
||||||
PlatformTag::Haiku { .. } => Some("Haiku"),
|
Self::Haiku { .. } => Some("Haiku"),
|
||||||
PlatformTag::Illumos { .. } => Some("Illumos"),
|
Self::Illumos { .. } => Some("Illumos"),
|
||||||
PlatformTag::Solaris { .. } => Some("Solaris"),
|
Self::Solaris { .. } => Some("Solaris"),
|
||||||
PlatformTag::Pyodide { .. } => Some("Pyodide"),
|
Self::Pyodide { .. } => Some("Pyodide"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -719,7 +719,7 @@ impl BinaryFormat {
|
||||||
///
|
///
|
||||||
/// This is roughly the inverse of the above: given a binary format, which `platform_machine`
|
/// This is roughly the inverse of the above: given a binary format, which `platform_machine`
|
||||||
/// tags are supported?
|
/// tags are supported?
|
||||||
pub fn platform_machine(&self) -> &'static [BinaryFormat] {
|
pub fn platform_machine(&self) -> &'static [Self] {
|
||||||
match self {
|
match self {
|
||||||
Self::Arm64 => &[Self::Arm64],
|
Self::Arm64 => &[Self::Arm64],
|
||||||
Self::Fat => &[Self::X86_64, Self::Ppc],
|
Self::Fat => &[Self::X86_64, Self::Ppc],
|
||||||
|
|
|
||||||
|
|
@ -41,13 +41,13 @@ impl Ord for Arch {
|
||||||
// should respect that request (this is the way users should "override"
|
// should respect that request (this is the way users should "override"
|
||||||
// this behaviour).
|
// this behaviour).
|
||||||
let preferred = if cfg!(all(windows, target_arch = "aarch64")) {
|
let preferred = if cfg!(all(windows, target_arch = "aarch64")) {
|
||||||
Arch {
|
Self {
|
||||||
family: target_lexicon::Architecture::X86_64,
|
family: target_lexicon::Architecture::X86_64,
|
||||||
variant: None,
|
variant: None,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Prefer native architectures
|
// Prefer native architectures
|
||||||
Arch::from_env()
|
Self::from_env()
|
||||||
};
|
};
|
||||||
|
|
||||||
match (
|
match (
|
||||||
|
|
@ -205,45 +205,45 @@ impl Display for ArchVariant {
|
||||||
impl From<&uv_platform_tags::Arch> for Arch {
|
impl From<&uv_platform_tags::Arch> for Arch {
|
||||||
fn from(value: &uv_platform_tags::Arch) -> Self {
|
fn from(value: &uv_platform_tags::Arch) -> Self {
|
||||||
match value {
|
match value {
|
||||||
uv_platform_tags::Arch::Aarch64 => Arch::new(
|
uv_platform_tags::Arch::Aarch64 => Self::new(
|
||||||
target_lexicon::Architecture::Aarch64(target_lexicon::Aarch64Architecture::Aarch64),
|
target_lexicon::Architecture::Aarch64(target_lexicon::Aarch64Architecture::Aarch64),
|
||||||
None,
|
None,
|
||||||
),
|
),
|
||||||
uv_platform_tags::Arch::Armv5TEL => Arch::new(
|
uv_platform_tags::Arch::Armv5TEL => Self::new(
|
||||||
target_lexicon::Architecture::Arm(target_lexicon::ArmArchitecture::Armv5te),
|
target_lexicon::Architecture::Arm(target_lexicon::ArmArchitecture::Armv5te),
|
||||||
None,
|
None,
|
||||||
),
|
),
|
||||||
uv_platform_tags::Arch::Armv6L => Arch::new(
|
uv_platform_tags::Arch::Armv6L => Self::new(
|
||||||
target_lexicon::Architecture::Arm(target_lexicon::ArmArchitecture::Armv6),
|
target_lexicon::Architecture::Arm(target_lexicon::ArmArchitecture::Armv6),
|
||||||
None,
|
None,
|
||||||
),
|
),
|
||||||
uv_platform_tags::Arch::Armv7L => Arch::new(
|
uv_platform_tags::Arch::Armv7L => Self::new(
|
||||||
target_lexicon::Architecture::Arm(target_lexicon::ArmArchitecture::Armv7),
|
target_lexicon::Architecture::Arm(target_lexicon::ArmArchitecture::Armv7),
|
||||||
None,
|
None,
|
||||||
),
|
),
|
||||||
uv_platform_tags::Arch::S390X => Arch::new(target_lexicon::Architecture::S390x, None),
|
uv_platform_tags::Arch::S390X => Self::new(target_lexicon::Architecture::S390x, None),
|
||||||
uv_platform_tags::Arch::Powerpc => {
|
uv_platform_tags::Arch::Powerpc => {
|
||||||
Arch::new(target_lexicon::Architecture::Powerpc, None)
|
Self::new(target_lexicon::Architecture::Powerpc, None)
|
||||||
}
|
}
|
||||||
uv_platform_tags::Arch::Powerpc64 => {
|
uv_platform_tags::Arch::Powerpc64 => {
|
||||||
Arch::new(target_lexicon::Architecture::Powerpc64, None)
|
Self::new(target_lexicon::Architecture::Powerpc64, None)
|
||||||
}
|
}
|
||||||
uv_platform_tags::Arch::Powerpc64Le => {
|
uv_platform_tags::Arch::Powerpc64Le => {
|
||||||
Arch::new(target_lexicon::Architecture::Powerpc64le, None)
|
Self::new(target_lexicon::Architecture::Powerpc64le, None)
|
||||||
}
|
}
|
||||||
uv_platform_tags::Arch::X86 => Arch::new(
|
uv_platform_tags::Arch::X86 => Self::new(
|
||||||
target_lexicon::Architecture::X86_32(target_lexicon::X86_32Architecture::I686),
|
target_lexicon::Architecture::X86_32(target_lexicon::X86_32Architecture::I686),
|
||||||
None,
|
None,
|
||||||
),
|
),
|
||||||
uv_platform_tags::Arch::X86_64 => Arch::new(target_lexicon::Architecture::X86_64, None),
|
uv_platform_tags::Arch::X86_64 => Self::new(target_lexicon::Architecture::X86_64, None),
|
||||||
uv_platform_tags::Arch::LoongArch64 => {
|
uv_platform_tags::Arch::LoongArch64 => {
|
||||||
Arch::new(target_lexicon::Architecture::LoongArch64, None)
|
Self::new(target_lexicon::Architecture::LoongArch64, None)
|
||||||
}
|
}
|
||||||
uv_platform_tags::Arch::Riscv64 => Arch::new(
|
uv_platform_tags::Arch::Riscv64 => Self::new(
|
||||||
target_lexicon::Architecture::Riscv64(target_lexicon::Riscv64Architecture::Riscv64),
|
target_lexicon::Architecture::Riscv64(target_lexicon::Riscv64Architecture::Riscv64),
|
||||||
None,
|
None,
|
||||||
),
|
),
|
||||||
uv_platform_tags::Arch::Wasm32 => Arch::new(target_lexicon::Architecture::Wasm32, None),
|
uv_platform_tags::Arch::Wasm32 => Self::new(target_lexicon::Architecture::Wasm32, None),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -125,9 +125,9 @@ impl Display for Libc {
|
||||||
impl From<&uv_platform_tags::Os> for Libc {
|
impl From<&uv_platform_tags::Os> for Libc {
|
||||||
fn from(value: &uv_platform_tags::Os) -> Self {
|
fn from(value: &uv_platform_tags::Os) -> Self {
|
||||||
match value {
|
match value {
|
||||||
uv_platform_tags::Os::Manylinux { .. } => Libc::Some(target_lexicon::Environment::Gnu),
|
uv_platform_tags::Os::Manylinux { .. } => Self::Some(target_lexicon::Environment::Gnu),
|
||||||
uv_platform_tags::Os::Musllinux { .. } => Libc::Some(target_lexicon::Environment::Musl),
|
uv_platform_tags::Os::Musllinux { .. } => Self::Some(target_lexicon::Environment::Musl),
|
||||||
_ => Libc::None,
|
_ => Self::None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,30 +58,32 @@ impl From<&uv_platform_tags::Os> for Os {
|
||||||
fn from(value: &uv_platform_tags::Os) -> Self {
|
fn from(value: &uv_platform_tags::Os) -> Self {
|
||||||
match value {
|
match value {
|
||||||
uv_platform_tags::Os::Dragonfly { .. } => {
|
uv_platform_tags::Os::Dragonfly { .. } => {
|
||||||
Os::new(target_lexicon::OperatingSystem::Dragonfly)
|
Self::new(target_lexicon::OperatingSystem::Dragonfly)
|
||||||
}
|
}
|
||||||
uv_platform_tags::Os::FreeBsd { .. } => {
|
uv_platform_tags::Os::FreeBsd { .. } => {
|
||||||
Os::new(target_lexicon::OperatingSystem::Freebsd)
|
Self::new(target_lexicon::OperatingSystem::Freebsd)
|
||||||
}
|
}
|
||||||
uv_platform_tags::Os::Haiku { .. } => Os::new(target_lexicon::OperatingSystem::Haiku),
|
uv_platform_tags::Os::Haiku { .. } => Self::new(target_lexicon::OperatingSystem::Haiku),
|
||||||
uv_platform_tags::Os::Illumos { .. } => {
|
uv_platform_tags::Os::Illumos { .. } => {
|
||||||
Os::new(target_lexicon::OperatingSystem::Illumos)
|
Self::new(target_lexicon::OperatingSystem::Illumos)
|
||||||
}
|
}
|
||||||
uv_platform_tags::Os::Macos { .. } => {
|
uv_platform_tags::Os::Macos { .. } => {
|
||||||
Os::new(target_lexicon::OperatingSystem::Darwin(None))
|
Self::new(target_lexicon::OperatingSystem::Darwin(None))
|
||||||
}
|
}
|
||||||
uv_platform_tags::Os::Manylinux { .. }
|
uv_platform_tags::Os::Manylinux { .. }
|
||||||
| uv_platform_tags::Os::Musllinux { .. }
|
| uv_platform_tags::Os::Musllinux { .. }
|
||||||
| uv_platform_tags::Os::Android { .. } => {
|
| uv_platform_tags::Os::Android { .. } => {
|
||||||
Os::new(target_lexicon::OperatingSystem::Linux)
|
Self::new(target_lexicon::OperatingSystem::Linux)
|
||||||
|
}
|
||||||
|
uv_platform_tags::Os::NetBsd { .. } => {
|
||||||
|
Self::new(target_lexicon::OperatingSystem::Netbsd)
|
||||||
}
|
}
|
||||||
uv_platform_tags::Os::NetBsd { .. } => Os::new(target_lexicon::OperatingSystem::Netbsd),
|
|
||||||
uv_platform_tags::Os::OpenBsd { .. } => {
|
uv_platform_tags::Os::OpenBsd { .. } => {
|
||||||
Os::new(target_lexicon::OperatingSystem::Openbsd)
|
Self::new(target_lexicon::OperatingSystem::Openbsd)
|
||||||
}
|
}
|
||||||
uv_platform_tags::Os::Windows => Os::new(target_lexicon::OperatingSystem::Windows),
|
uv_platform_tags::Os::Windows => Self::new(target_lexicon::OperatingSystem::Windows),
|
||||||
uv_platform_tags::Os::Pyodide { .. } => {
|
uv_platform_tags::Os::Pyodide { .. } => {
|
||||||
Os::new(target_lexicon::OperatingSystem::Emscripten)
|
Self::new(target_lexicon::OperatingSystem::Emscripten)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,8 @@ impl Conflicts {
|
||||||
/// Returns no conflicts.
|
/// Returns no conflicts.
|
||||||
///
|
///
|
||||||
/// This results in no effect on resolution.
|
/// This results in no effect on resolution.
|
||||||
pub fn empty() -> Conflicts {
|
pub fn empty() -> Self {
|
||||||
Conflicts::default()
|
Self::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Push a single set of conflicts.
|
/// Push a single set of conflicts.
|
||||||
|
|
@ -54,7 +54,7 @@ impl Conflicts {
|
||||||
|
|
||||||
/// Appends the given conflicts to this one. This drains all sets from the
|
/// Appends the given conflicts to this one. This drains all sets from the
|
||||||
/// conflicts given, such that after this call, it is empty.
|
/// conflicts given, such that after this call, it is empty.
|
||||||
pub fn append(&mut self, other: &mut Conflicts) {
|
pub fn append(&mut self, other: &mut Self) {
|
||||||
self.0.append(&mut other.0);
|
self.0.append(&mut other.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -225,8 +225,8 @@ pub struct ConflictSet {
|
||||||
|
|
||||||
impl ConflictSet {
|
impl ConflictSet {
|
||||||
/// Create a pair of items that conflict with one another.
|
/// Create a pair of items that conflict with one another.
|
||||||
pub fn pair(item1: ConflictItem, item2: ConflictItem) -> ConflictSet {
|
pub fn pair(item1: ConflictItem, item2: ConflictItem) -> Self {
|
||||||
ConflictSet {
|
Self {
|
||||||
set: BTreeSet::from_iter(vec![item1, item2]),
|
set: BTreeSet::from_iter(vec![item1, item2]),
|
||||||
is_inferred_conflict: false,
|
is_inferred_conflict: false,
|
||||||
}
|
}
|
||||||
|
|
@ -287,7 +287,7 @@ impl ConflictSet {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'de> serde::Deserialize<'de> for ConflictSet {
|
impl<'de> serde::Deserialize<'de> for ConflictSet {
|
||||||
fn deserialize<D>(deserializer: D) -> Result<ConflictSet, D::Error>
|
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||||
where
|
where
|
||||||
D: serde::Deserializer<'de>,
|
D: serde::Deserializer<'de>,
|
||||||
{
|
{
|
||||||
|
|
@ -299,13 +299,13 @@ impl<'de> serde::Deserialize<'de> for ConflictSet {
|
||||||
impl TryFrom<Vec<ConflictItem>> for ConflictSet {
|
impl TryFrom<Vec<ConflictItem>> for ConflictSet {
|
||||||
type Error = ConflictError;
|
type Error = ConflictError;
|
||||||
|
|
||||||
fn try_from(items: Vec<ConflictItem>) -> Result<ConflictSet, ConflictError> {
|
fn try_from(items: Vec<ConflictItem>) -> Result<Self, ConflictError> {
|
||||||
match items.len() {
|
match items.len() {
|
||||||
0 => return Err(ConflictError::ZeroItems),
|
0 => return Err(ConflictError::ZeroItems),
|
||||||
1 => return Err(ConflictError::OneItem),
|
1 => return Err(ConflictError::OneItem),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
Ok(ConflictSet {
|
Ok(Self {
|
||||||
set: BTreeSet::from_iter(items),
|
set: BTreeSet::from_iter(items),
|
||||||
is_inferred_conflict: false,
|
is_inferred_conflict: false,
|
||||||
})
|
})
|
||||||
|
|
@ -362,16 +362,16 @@ impl ConflictItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<(PackageName, ExtraName)> for ConflictItem {
|
impl From<(PackageName, ExtraName)> for ConflictItem {
|
||||||
fn from((package, extra): (PackageName, ExtraName)) -> ConflictItem {
|
fn from((package, extra): (PackageName, ExtraName)) -> Self {
|
||||||
let conflict = ConflictPackage::Extra(extra);
|
let conflict = ConflictPackage::Extra(extra);
|
||||||
ConflictItem { package, conflict }
|
Self { package, conflict }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<(PackageName, GroupName)> for ConflictItem {
|
impl From<(PackageName, GroupName)> for ConflictItem {
|
||||||
fn from((package, group): (PackageName, GroupName)) -> ConflictItem {
|
fn from((package, group): (PackageName, GroupName)) -> Self {
|
||||||
let conflict = ConflictPackage::Group(group);
|
let conflict = ConflictPackage::Group(group);
|
||||||
ConflictItem { package, conflict }
|
Self { package, conflict }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -418,14 +418,14 @@ impl<'a> ConflictItemRef<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> From<(&'a PackageName, &'a ExtraName)> for ConflictItemRef<'a> {
|
impl<'a> From<(&'a PackageName, &'a ExtraName)> for ConflictItemRef<'a> {
|
||||||
fn from((package, extra): (&'a PackageName, &'a ExtraName)) -> ConflictItemRef<'a> {
|
fn from((package, extra): (&'a PackageName, &'a ExtraName)) -> Self {
|
||||||
let conflict = ConflictPackageRef::Extra(extra);
|
let conflict = ConflictPackageRef::Extra(extra);
|
||||||
ConflictItemRef { package, conflict }
|
ConflictItemRef { package, conflict }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> From<(&'a PackageName, &'a GroupName)> for ConflictItemRef<'a> {
|
impl<'a> From<(&'a PackageName, &'a GroupName)> for ConflictItemRef<'a> {
|
||||||
fn from((package, group): (&'a PackageName, &'a GroupName)) -> ConflictItemRef<'a> {
|
fn from((package, group): (&'a PackageName, &'a GroupName)) -> Self {
|
||||||
let conflict = ConflictPackageRef::Group(group);
|
let conflict = ConflictPackageRef::Group(group);
|
||||||
ConflictItemRef { package, conflict }
|
ConflictItemRef { package, conflict }
|
||||||
}
|
}
|
||||||
|
|
@ -451,8 +451,8 @@ impl ConflictPackage {
|
||||||
/// extra name.
|
/// extra name.
|
||||||
pub fn extra(&self) -> Option<&ExtraName> {
|
pub fn extra(&self) -> Option<&ExtraName> {
|
||||||
match *self {
|
match *self {
|
||||||
ConflictPackage::Extra(ref extra) => Some(extra),
|
Self::Extra(ref extra) => Some(extra),
|
||||||
ConflictPackage::Group(_) => None,
|
Self::Group(_) => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -460,16 +460,16 @@ impl ConflictPackage {
|
||||||
/// group name.
|
/// group name.
|
||||||
pub fn group(&self) -> Option<&GroupName> {
|
pub fn group(&self) -> Option<&GroupName> {
|
||||||
match *self {
|
match *self {
|
||||||
ConflictPackage::Group(ref group) => Some(group),
|
Self::Group(ref group) => Some(group),
|
||||||
ConflictPackage::Extra(_) => None,
|
Self::Extra(_) => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns this conflict as a new type with its fields borrowed.
|
/// Returns this conflict as a new type with its fields borrowed.
|
||||||
pub fn as_ref(&self) -> ConflictPackageRef<'_> {
|
pub fn as_ref(&self) -> ConflictPackageRef<'_> {
|
||||||
match *self {
|
match *self {
|
||||||
ConflictPackage::Extra(ref extra) => ConflictPackageRef::Extra(extra),
|
Self::Extra(ref extra) => ConflictPackageRef::Extra(extra),
|
||||||
ConflictPackage::Group(ref group) => ConflictPackageRef::Group(group),
|
Self::Group(ref group) => ConflictPackageRef::Group(group),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -512,13 +512,13 @@ impl<'a> ConflictPackageRef<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> From<&'a ExtraName> for ConflictPackageRef<'a> {
|
impl<'a> From<&'a ExtraName> for ConflictPackageRef<'a> {
|
||||||
fn from(extra: &'a ExtraName) -> ConflictPackageRef<'a> {
|
fn from(extra: &'a ExtraName) -> Self {
|
||||||
ConflictPackageRef::Extra(extra)
|
ConflictPackageRef::Extra(extra)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> From<&'a GroupName> for ConflictPackageRef<'a> {
|
impl<'a> From<&'a GroupName> for ConflictPackageRef<'a> {
|
||||||
fn from(group: &'a GroupName) -> ConflictPackageRef<'a> {
|
fn from(group: &'a GroupName) -> Self {
|
||||||
ConflictPackageRef::Group(group)
|
ConflictPackageRef::Group(group)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -650,7 +650,7 @@ impl schemars::JsonSchema for SchemaConflictItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'de> serde::Deserialize<'de> for SchemaConflictSet {
|
impl<'de> serde::Deserialize<'de> for SchemaConflictSet {
|
||||||
fn deserialize<D>(deserializer: D) -> Result<SchemaConflictSet, D::Error>
|
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||||
where
|
where
|
||||||
D: serde::Deserializer<'de>,
|
D: serde::Deserializer<'de>,
|
||||||
{
|
{
|
||||||
|
|
@ -662,13 +662,13 @@ impl<'de> serde::Deserialize<'de> for SchemaConflictSet {
|
||||||
impl TryFrom<Vec<SchemaConflictItem>> for SchemaConflictSet {
|
impl TryFrom<Vec<SchemaConflictItem>> for SchemaConflictSet {
|
||||||
type Error = ConflictError;
|
type Error = ConflictError;
|
||||||
|
|
||||||
fn try_from(items: Vec<SchemaConflictItem>) -> Result<SchemaConflictSet, ConflictError> {
|
fn try_from(items: Vec<SchemaConflictItem>) -> Result<Self, ConflictError> {
|
||||||
match items.len() {
|
match items.len() {
|
||||||
0 => return Err(ConflictError::ZeroItems),
|
0 => return Err(ConflictError::ZeroItems),
|
||||||
1 => return Err(ConflictError::OneItem),
|
1 => return Err(ConflictError::OneItem),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
Ok(SchemaConflictSet(items))
|
Ok(Self(items))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -690,28 +690,28 @@ struct ConflictItemWire {
|
||||||
impl TryFrom<ConflictItemWire> for ConflictItem {
|
impl TryFrom<ConflictItemWire> for ConflictItem {
|
||||||
type Error = ConflictError;
|
type Error = ConflictError;
|
||||||
|
|
||||||
fn try_from(wire: ConflictItemWire) -> Result<ConflictItem, ConflictError> {
|
fn try_from(wire: ConflictItemWire) -> Result<Self, ConflictError> {
|
||||||
let Some(package) = wire.package else {
|
let Some(package) = wire.package else {
|
||||||
return Err(ConflictError::MissingPackage);
|
return Err(ConflictError::MissingPackage);
|
||||||
};
|
};
|
||||||
match (wire.extra, wire.group) {
|
match (wire.extra, wire.group) {
|
||||||
(None, None) => Err(ConflictError::MissingExtraAndGroup),
|
(None, None) => Err(ConflictError::MissingExtraAndGroup),
|
||||||
(Some(_), Some(_)) => Err(ConflictError::FoundExtraAndGroup),
|
(Some(_), Some(_)) => Err(ConflictError::FoundExtraAndGroup),
|
||||||
(Some(extra), None) => Ok(ConflictItem::from((package, extra))),
|
(Some(extra), None) => Ok(Self::from((package, extra))),
|
||||||
(None, Some(group)) => Ok(ConflictItem::from((package, group))),
|
(None, Some(group)) => Ok(Self::from((package, group))),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ConflictItem> for ConflictItemWire {
|
impl From<ConflictItem> for ConflictItemWire {
|
||||||
fn from(item: ConflictItem) -> ConflictItemWire {
|
fn from(item: ConflictItem) -> Self {
|
||||||
match item.conflict {
|
match item.conflict {
|
||||||
ConflictPackage::Extra(extra) => ConflictItemWire {
|
ConflictPackage::Extra(extra) => Self {
|
||||||
package: Some(item.package),
|
package: Some(item.package),
|
||||||
extra: Some(extra),
|
extra: Some(extra),
|
||||||
group: None,
|
group: None,
|
||||||
},
|
},
|
||||||
ConflictPackage::Group(group) => ConflictItemWire {
|
ConflictPackage::Group(group) => Self {
|
||||||
package: Some(item.package),
|
package: Some(item.package),
|
||||||
extra: None,
|
extra: None,
|
||||||
group: Some(group),
|
group: Some(group),
|
||||||
|
|
@ -723,16 +723,16 @@ impl From<ConflictItem> for ConflictItemWire {
|
||||||
impl TryFrom<ConflictItemWire> for SchemaConflictItem {
|
impl TryFrom<ConflictItemWire> for SchemaConflictItem {
|
||||||
type Error = ConflictError;
|
type Error = ConflictError;
|
||||||
|
|
||||||
fn try_from(wire: ConflictItemWire) -> Result<SchemaConflictItem, ConflictError> {
|
fn try_from(wire: ConflictItemWire) -> Result<Self, ConflictError> {
|
||||||
let package = wire.package;
|
let package = wire.package;
|
||||||
match (wire.extra, wire.group) {
|
match (wire.extra, wire.group) {
|
||||||
(None, None) => Err(ConflictError::MissingExtraAndGroup),
|
(None, None) => Err(ConflictError::MissingExtraAndGroup),
|
||||||
(Some(_), Some(_)) => Err(ConflictError::FoundExtraAndGroup),
|
(Some(_), Some(_)) => Err(ConflictError::FoundExtraAndGroup),
|
||||||
(Some(extra), None) => Ok(SchemaConflictItem {
|
(Some(extra), None) => Ok(Self {
|
||||||
package,
|
package,
|
||||||
conflict: ConflictPackage::Extra(extra),
|
conflict: ConflictPackage::Extra(extra),
|
||||||
}),
|
}),
|
||||||
(None, Some(group)) => Ok(SchemaConflictItem {
|
(None, Some(group)) => Ok(Self {
|
||||||
package,
|
package,
|
||||||
conflict: ConflictPackage::Group(group),
|
conflict: ConflictPackage::Group(group),
|
||||||
}),
|
}),
|
||||||
|
|
@ -741,14 +741,14 @@ impl TryFrom<ConflictItemWire> for SchemaConflictItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<SchemaConflictItem> for ConflictItemWire {
|
impl From<SchemaConflictItem> for ConflictItemWire {
|
||||||
fn from(item: SchemaConflictItem) -> ConflictItemWire {
|
fn from(item: SchemaConflictItem) -> Self {
|
||||||
match item.conflict {
|
match item.conflict {
|
||||||
ConflictPackage::Extra(extra) => ConflictItemWire {
|
ConflictPackage::Extra(extra) => Self {
|
||||||
package: item.package,
|
package: item.package,
|
||||||
extra: Some(extra),
|
extra: Some(extra),
|
||||||
group: None,
|
group: None,
|
||||||
},
|
},
|
||||||
ConflictPackage::Group(group) => ConflictItemWire {
|
ConflictPackage::Group(group) => Self {
|
||||||
package: item.package,
|
package: item.package,
|
||||||
extra: None,
|
extra: None,
|
||||||
group: Some(group),
|
group: Some(group),
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ impl<'de> serde::de::Deserialize<'de> for Identifier {
|
||||||
D: serde::de::Deserializer<'de>,
|
D: serde::de::Deserializer<'de>,
|
||||||
{
|
{
|
||||||
let s = String::deserialize(deserializer)?;
|
let s = String::deserialize(deserializer)?;
|
||||||
Identifier::from_str(&s).map_err(serde::de::Error::custom)
|
Self::from_str(&s).map_err(serde::de::Error::custom)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -148,7 +148,7 @@ impl Metadata23 {
|
||||||
let provides_extras = headers.get_all_values("Provides-Extra").collect();
|
let provides_extras = headers.get_all_values("Provides-Extra").collect();
|
||||||
let description_content_type = headers.get_first_value("Description-Content-Type");
|
let description_content_type = headers.get_first_value("Description-Content-Type");
|
||||||
let dynamic = headers.get_all_values("Dynamic").collect();
|
let dynamic = headers.get_all_values("Dynamic").collect();
|
||||||
Ok(Metadata23 {
|
Ok(Self {
|
||||||
metadata_version,
|
metadata_version,
|
||||||
name,
|
name,
|
||||||
version,
|
version,
|
||||||
|
|
@ -284,7 +284,7 @@ impl FromStr for Metadata23 {
|
||||||
type Err = MetadataError;
|
type Err = MetadataError;
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
Metadata23::parse(s.as_bytes())
|
Self::parse(s.as_bytes())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ impl PyProjectToml {
|
||||||
pub fn from_toml(toml: &str) -> Result<Self, MetadataError> {
|
pub fn from_toml(toml: &str) -> Result<Self, MetadataError> {
|
||||||
let pyproject_toml = toml_edit::Document::from_str(toml)
|
let pyproject_toml = toml_edit::Document::from_str(toml)
|
||||||
.map_err(MetadataError::InvalidPyprojectTomlSyntax)?;
|
.map_err(MetadataError::InvalidPyprojectTomlSyntax)?;
|
||||||
let pyproject_toml = PyProjectToml::deserialize(pyproject_toml.into_deserializer())
|
let pyproject_toml = Self::deserialize(pyproject_toml.into_deserializer())
|
||||||
.map_err(MetadataError::InvalidPyprojectTomlSchema)?;
|
.map_err(MetadataError::InvalidPyprojectTomlSchema)?;
|
||||||
Ok(pyproject_toml)
|
Ok(pyproject_toml)
|
||||||
}
|
}
|
||||||
|
|
@ -67,7 +67,7 @@ impl TryFrom<PyprojectTomlWire> for Project {
|
||||||
|
|
||||||
fn try_from(wire: PyprojectTomlWire) -> Result<Self, Self::Error> {
|
fn try_from(wire: PyprojectTomlWire) -> Result<Self, Self::Error> {
|
||||||
let name = wire.name.ok_or(MetadataError::MissingName)?;
|
let name = wire.name.ok_or(MetadataError::MissingName)?;
|
||||||
Ok(Project {
|
Ok(Self {
|
||||||
name,
|
name,
|
||||||
version: wire.version,
|
version: wire.version,
|
||||||
requires_python: wire.requires_python,
|
requires_python: wire.requires_python,
|
||||||
|
|
|
||||||
|
|
@ -133,7 +133,7 @@ impl<'de> Deserialize<'de> for CoreMetadata {
|
||||||
D: Deserializer<'de>,
|
D: Deserializer<'de>,
|
||||||
{
|
{
|
||||||
serde_untagged::UntaggedEnumVisitor::new()
|
serde_untagged::UntaggedEnumVisitor::new()
|
||||||
.bool(|bool| Ok(CoreMetadata::Bool(bool)))
|
.bool(|bool| Ok(Self::Bool(bool)))
|
||||||
.map(|map| map.deserialize().map(CoreMetadata::Hashes))
|
.map(|map| map.deserialize().map(CoreMetadata::Hashes))
|
||||||
.deserialize(deserializer)
|
.deserialize(deserializer)
|
||||||
}
|
}
|
||||||
|
|
@ -161,8 +161,8 @@ impl<'de> Deserialize<'de> for Yanked {
|
||||||
D: Deserializer<'de>,
|
D: Deserializer<'de>,
|
||||||
{
|
{
|
||||||
serde_untagged::UntaggedEnumVisitor::new()
|
serde_untagged::UntaggedEnumVisitor::new()
|
||||||
.bool(|bool| Ok(Yanked::Bool(bool)))
|
.bool(|bool| Ok(Self::Bool(bool)))
|
||||||
.string(|string| Ok(Yanked::Reason(SmallString::from(string))))
|
.string(|string| Ok(Self::Reason(SmallString::from(string))))
|
||||||
.deserialize(deserializer)
|
.deserialize(deserializer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -218,35 +218,35 @@ impl Hashes {
|
||||||
}
|
}
|
||||||
|
|
||||||
match name {
|
match name {
|
||||||
"md5" => Ok(Hashes {
|
"md5" => Ok(Self {
|
||||||
md5: Some(SmallString::from(value)),
|
md5: Some(SmallString::from(value)),
|
||||||
sha256: None,
|
sha256: None,
|
||||||
sha384: None,
|
sha384: None,
|
||||||
sha512: None,
|
sha512: None,
|
||||||
blake2b: None,
|
blake2b: None,
|
||||||
}),
|
}),
|
||||||
"sha256" => Ok(Hashes {
|
"sha256" => Ok(Self {
|
||||||
md5: None,
|
md5: None,
|
||||||
sha256: Some(SmallString::from(value)),
|
sha256: Some(SmallString::from(value)),
|
||||||
sha384: None,
|
sha384: None,
|
||||||
sha512: None,
|
sha512: None,
|
||||||
blake2b: None,
|
blake2b: None,
|
||||||
}),
|
}),
|
||||||
"sha384" => Ok(Hashes {
|
"sha384" => Ok(Self {
|
||||||
md5: None,
|
md5: None,
|
||||||
sha256: None,
|
sha256: None,
|
||||||
sha384: Some(SmallString::from(value)),
|
sha384: Some(SmallString::from(value)),
|
||||||
sha512: None,
|
sha512: None,
|
||||||
blake2b: None,
|
blake2b: None,
|
||||||
}),
|
}),
|
||||||
"sha512" => Ok(Hashes {
|
"sha512" => Ok(Self {
|
||||||
md5: None,
|
md5: None,
|
||||||
sha256: None,
|
sha256: None,
|
||||||
sha384: None,
|
sha384: None,
|
||||||
sha512: Some(SmallString::from(value)),
|
sha512: Some(SmallString::from(value)),
|
||||||
blake2b: None,
|
blake2b: None,
|
||||||
}),
|
}),
|
||||||
"blake2b" => Ok(Hashes {
|
"blake2b" => Ok(Self {
|
||||||
md5: None,
|
md5: None,
|
||||||
sha256: None,
|
sha256: None,
|
||||||
sha384: None,
|
sha384: None,
|
||||||
|
|
@ -278,35 +278,35 @@ impl FromStr for Hashes {
|
||||||
}
|
}
|
||||||
|
|
||||||
match name {
|
match name {
|
||||||
"md5" => Ok(Hashes {
|
"md5" => Ok(Self {
|
||||||
md5: Some(SmallString::from(value)),
|
md5: Some(SmallString::from(value)),
|
||||||
sha256: None,
|
sha256: None,
|
||||||
sha384: None,
|
sha384: None,
|
||||||
sha512: None,
|
sha512: None,
|
||||||
blake2b: None,
|
blake2b: None,
|
||||||
}),
|
}),
|
||||||
"sha256" => Ok(Hashes {
|
"sha256" => Ok(Self {
|
||||||
md5: None,
|
md5: None,
|
||||||
sha256: Some(SmallString::from(value)),
|
sha256: Some(SmallString::from(value)),
|
||||||
sha384: None,
|
sha384: None,
|
||||||
sha512: None,
|
sha512: None,
|
||||||
blake2b: None,
|
blake2b: None,
|
||||||
}),
|
}),
|
||||||
"sha384" => Ok(Hashes {
|
"sha384" => Ok(Self {
|
||||||
md5: None,
|
md5: None,
|
||||||
sha256: None,
|
sha256: None,
|
||||||
sha384: Some(SmallString::from(value)),
|
sha384: Some(SmallString::from(value)),
|
||||||
sha512: None,
|
sha512: None,
|
||||||
blake2b: None,
|
blake2b: None,
|
||||||
}),
|
}),
|
||||||
"sha512" => Ok(Hashes {
|
"sha512" => Ok(Self {
|
||||||
md5: None,
|
md5: None,
|
||||||
sha256: None,
|
sha256: None,
|
||||||
sha384: None,
|
sha384: None,
|
||||||
sha512: Some(SmallString::from(value)),
|
sha512: Some(SmallString::from(value)),
|
||||||
blake2b: None,
|
blake2b: None,
|
||||||
}),
|
}),
|
||||||
"blake2b" => Ok(Hashes {
|
"blake2b" => Ok(Self {
|
||||||
md5: None,
|
md5: None,
|
||||||
sha256: None,
|
sha256: None,
|
||||||
sha384: None,
|
sha384: None,
|
||||||
|
|
@ -523,7 +523,7 @@ impl From<Hashes> for HashDigests {
|
||||||
|
|
||||||
impl From<HashDigests> for Hashes {
|
impl From<HashDigests> for Hashes {
|
||||||
fn from(value: HashDigests) -> Self {
|
fn from(value: HashDigests) -> Self {
|
||||||
let mut hashes = Hashes::default();
|
let mut hashes = Self::default();
|
||||||
for digest in value {
|
for digest in value {
|
||||||
match digest.algorithm() {
|
match digest.algorithm() {
|
||||||
HashAlgorithm::Md5 => hashes.md5 = Some(digest.digest),
|
HashAlgorithm::Md5 => hashes.md5 = Some(digest.digest),
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ pub struct SupportedEnvironments(Vec<MarkerTree>);
|
||||||
impl SupportedEnvironments {
|
impl SupportedEnvironments {
|
||||||
/// Create a new [`SupportedEnvironments`] struct from a list of marker trees.
|
/// Create a new [`SupportedEnvironments`] struct from a list of marker trees.
|
||||||
pub fn from_markers(markers: Vec<MarkerTree>) -> Self {
|
pub fn from_markers(markers: Vec<MarkerTree>) -> Self {
|
||||||
SupportedEnvironments(markers)
|
Self(markers)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the list of marker trees.
|
/// Return the list of marker trees.
|
||||||
|
|
@ -56,7 +56,7 @@ impl serde::Serialize for SupportedEnvironments {
|
||||||
|
|
||||||
/// Deserialize a marker string or list of marker strings into a [`SupportedEnvironments`] struct.
|
/// Deserialize a marker string or list of marker strings into a [`SupportedEnvironments`] struct.
|
||||||
impl<'de> serde::Deserialize<'de> for SupportedEnvironments {
|
impl<'de> serde::Deserialize<'de> for SupportedEnvironments {
|
||||||
fn deserialize<D>(deserializer: D) -> Result<SupportedEnvironments, D::Error>
|
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||||
where
|
where
|
||||||
D: serde::Deserializer<'de>,
|
D: serde::Deserializer<'de>,
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ impl<'a> serde::Deserialize<'a> for PythonRequest {
|
||||||
D: serde::Deserializer<'a>,
|
D: serde::Deserializer<'a>,
|
||||||
{
|
{
|
||||||
let s = String::deserialize(deserializer)?;
|
let s = String::deserialize(deserializer)?;
|
||||||
Ok(PythonRequest::parse(&s))
|
Ok(Self::parse(&s))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -129,9 +129,9 @@ impl FromStr for PythonDownloads {
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
match s.to_ascii_lowercase().as_str() {
|
match s.to_ascii_lowercase().as_str() {
|
||||||
"auto" | "automatic" | "true" | "1" => Ok(PythonDownloads::Automatic),
|
"auto" | "automatic" | "true" | "1" => Ok(Self::Automatic),
|
||||||
"manual" => Ok(PythonDownloads::Manual),
|
"manual" => Ok(Self::Manual),
|
||||||
"never" | "false" | "0" => Ok(PythonDownloads::Never),
|
"never" | "false" | "0" => Ok(Self::Never),
|
||||||
_ => Err(format!("Invalid value for `python-download`: '{s}'")),
|
_ => Err(format!("Invalid value for `python-download`: '{s}'")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -139,11 +139,7 @@ impl FromStr for PythonDownloads {
|
||||||
|
|
||||||
impl From<bool> for PythonDownloads {
|
impl From<bool> for PythonDownloads {
|
||||||
fn from(value: bool) -> Self {
|
fn from(value: bool) -> Self {
|
||||||
if value {
|
if value { Self::Automatic } else { Self::Never }
|
||||||
PythonDownloads::Automatic
|
|
||||||
} else {
|
|
||||||
PythonDownloads::Never
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -966,7 +962,7 @@ impl Error {
|
||||||
match self {
|
match self {
|
||||||
// When querying the Python interpreter fails, we will only raise errors that demonstrate that something is broken
|
// When querying the Python interpreter fails, we will only raise errors that demonstrate that something is broken
|
||||||
// If the Python interpreter returned a bad response, we'll continue searching for one that works
|
// If the Python interpreter returned a bad response, we'll continue searching for one that works
|
||||||
Error::Query(err, _, source) => match &**err {
|
Self::Query(err, _, source) => match &**err {
|
||||||
InterpreterError::Encode(_)
|
InterpreterError::Encode(_)
|
||||||
| InterpreterError::Io(_)
|
| InterpreterError::Io(_)
|
||||||
| InterpreterError::SpawnFailed { .. } => true,
|
| InterpreterError::SpawnFailed { .. } => true,
|
||||||
|
|
@ -1007,7 +1003,7 @@ impl Error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Error::VirtualEnv(VirtualEnvError::MissingPyVenvCfg(path)) => {
|
Self::VirtualEnv(VirtualEnvError::MissingPyVenvCfg(path)) => {
|
||||||
trace!("Skipping broken virtualenv at {}", path.display());
|
trace!("Skipping broken virtualenv at {}", path.display());
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
@ -1603,8 +1599,8 @@ fn is_windows_store_shim(_path: &Path) -> bool {
|
||||||
impl PythonVariant {
|
impl PythonVariant {
|
||||||
fn matches_interpreter(self, interpreter: &Interpreter) -> bool {
|
fn matches_interpreter(self, interpreter: &Interpreter) -> bool {
|
||||||
match self {
|
match self {
|
||||||
PythonVariant::Default => !interpreter.gil_disabled(),
|
Self::Default => !interpreter.gil_disabled(),
|
||||||
PythonVariant::Freethreaded => interpreter.gil_disabled(),
|
Self::Freethreaded => interpreter.gil_disabled(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1717,7 +1713,7 @@ impl PythonRequest {
|
||||||
///
|
///
|
||||||
/// This can only return `Err` if `@` is used. Otherwise, if no match is found, it returns
|
/// This can only return `Err` if `@` is used. Otherwise, if no match is found, it returns
|
||||||
/// `Ok(None)`.
|
/// `Ok(None)`.
|
||||||
pub fn try_from_tool_name(value: &str) -> Result<Option<PythonRequest>, Error> {
|
pub fn try_from_tool_name(value: &str) -> Result<Option<Self>, Error> {
|
||||||
let lowercase_value = &value.to_ascii_lowercase();
|
let lowercase_value = &value.to_ascii_lowercase();
|
||||||
// Omitting the empty string from these lists excludes bare versions like "39".
|
// Omitting the empty string from these lists excludes bare versions like "39".
|
||||||
let abstract_version_prefixes = if cfg!(windows) {
|
let abstract_version_prefixes = if cfg!(windows) {
|
||||||
|
|
@ -1751,7 +1747,7 @@ impl PythonRequest {
|
||||||
implementation_names: impl IntoIterator<Item = &'a str>,
|
implementation_names: impl IntoIterator<Item = &'a str>,
|
||||||
// the string to parse
|
// the string to parse
|
||||||
lowercase_value: &str,
|
lowercase_value: &str,
|
||||||
) -> Result<Option<PythonRequest>, Error> {
|
) -> Result<Option<Self>, Error> {
|
||||||
for prefix in abstract_version_prefixes {
|
for prefix in abstract_version_prefixes {
|
||||||
if let Some(version_request) =
|
if let Some(version_request) =
|
||||||
Self::try_split_prefix_and_version(prefix, lowercase_value)?
|
Self::try_split_prefix_and_version(prefix, lowercase_value)?
|
||||||
|
|
@ -1826,15 +1822,15 @@ impl PythonRequest {
|
||||||
/// Check if this request includes a specific patch version.
|
/// Check if this request includes a specific patch version.
|
||||||
pub fn includes_patch(&self) -> bool {
|
pub fn includes_patch(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
PythonRequest::Default => false,
|
Self::Default => false,
|
||||||
PythonRequest::Any => false,
|
Self::Any => false,
|
||||||
PythonRequest::Version(version_request) => version_request.patch().is_some(),
|
Self::Version(version_request) => version_request.patch().is_some(),
|
||||||
PythonRequest::Directory(..) => false,
|
Self::Directory(..) => false,
|
||||||
PythonRequest::File(..) => false,
|
Self::File(..) => false,
|
||||||
PythonRequest::ExecutableName(..) => false,
|
Self::ExecutableName(..) => false,
|
||||||
PythonRequest::Implementation(..) => false,
|
Self::Implementation(..) => false,
|
||||||
PythonRequest::ImplementationVersion(_, version) => version.patch().is_some(),
|
Self::ImplementationVersion(_, version) => version.patch().is_some(),
|
||||||
PythonRequest::Key(request) => request
|
Self::Key(request) => request
|
||||||
.version
|
.version
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.is_some_and(|request| request.patch().is_some()),
|
.is_some_and(|request| request.patch().is_some()),
|
||||||
|
|
@ -1849,11 +1845,9 @@ impl PythonRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
match self {
|
match self {
|
||||||
PythonRequest::Default | PythonRequest::Any => true,
|
Self::Default | Self::Any => true,
|
||||||
PythonRequest::Version(version_request) => {
|
Self::Version(version_request) => version_request.matches_interpreter(interpreter),
|
||||||
version_request.matches_interpreter(interpreter)
|
Self::Directory(directory) => {
|
||||||
}
|
|
||||||
PythonRequest::Directory(directory) => {
|
|
||||||
// `sys.prefix` points to the environment root or `sys.executable` is the same
|
// `sys.prefix` points to the environment root or `sys.executable` is the same
|
||||||
is_same_executable(directory, interpreter.sys_prefix())
|
is_same_executable(directory, interpreter.sys_prefix())
|
||||||
|| is_same_executable(
|
|| is_same_executable(
|
||||||
|
|
@ -1861,7 +1855,7 @@ impl PythonRequest {
|
||||||
interpreter.sys_executable(),
|
interpreter.sys_executable(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
PythonRequest::File(file) => {
|
Self::File(file) => {
|
||||||
// The interpreter satisfies the request both if it is the venv...
|
// The interpreter satisfies the request both if it is the venv...
|
||||||
if is_same_executable(interpreter.sys_executable(), file) {
|
if is_same_executable(interpreter.sys_executable(), file) {
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -1893,7 +1887,7 @@ impl PythonRequest {
|
||||||
}
|
}
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
PythonRequest::ExecutableName(name) => {
|
Self::ExecutableName(name) => {
|
||||||
// First, see if we have a match in the venv ...
|
// First, see if we have a match in the venv ...
|
||||||
if interpreter
|
if interpreter
|
||||||
.sys_executable()
|
.sys_executable()
|
||||||
|
|
@ -1922,16 +1916,16 @@ impl PythonRequest {
|
||||||
}
|
}
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
PythonRequest::Implementation(implementation) => interpreter
|
Self::Implementation(implementation) => interpreter
|
||||||
.implementation_name()
|
.implementation_name()
|
||||||
.eq_ignore_ascii_case(implementation.into()),
|
.eq_ignore_ascii_case(implementation.into()),
|
||||||
PythonRequest::ImplementationVersion(implementation, version) => {
|
Self::ImplementationVersion(implementation, version) => {
|
||||||
version.matches_interpreter(interpreter)
|
version.matches_interpreter(interpreter)
|
||||||
&& interpreter
|
&& interpreter
|
||||||
.implementation_name()
|
.implementation_name()
|
||||||
.eq_ignore_ascii_case(implementation.into())
|
.eq_ignore_ascii_case(implementation.into())
|
||||||
}
|
}
|
||||||
PythonRequest::Key(request) => request.satisfied_by_interpreter(interpreter),
|
Self::Key(request) => request.satisfied_by_interpreter(interpreter),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2076,12 +2070,12 @@ impl PythonPreference {
|
||||||
}
|
}
|
||||||
|
|
||||||
match self {
|
match self {
|
||||||
PythonPreference::OnlyManaged => matches!(source, PythonSource::Managed),
|
Self::OnlyManaged => matches!(source, PythonSource::Managed),
|
||||||
Self::Managed | Self::System => matches!(
|
Self::Managed | Self::System => matches!(
|
||||||
source,
|
source,
|
||||||
PythonSource::Managed | PythonSource::SearchPath | PythonSource::Registry
|
PythonSource::Managed | PythonSource::SearchPath | PythonSource::Registry
|
||||||
),
|
),
|
||||||
PythonPreference::OnlySystem => {
|
Self::OnlySystem => {
|
||||||
matches!(source, PythonSource::SearchPath | PythonSource::Registry)
|
matches!(source, PythonSource::SearchPath | PythonSource::Registry)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -121,12 +121,12 @@ impl Error {
|
||||||
// Unfortunately different variants of `Error` track retry counts in different ways. We
|
// Unfortunately different variants of `Error` track retry counts in different ways. We
|
||||||
// could consider unifying the variants we handle here in `Error::from_reqwest_middleware`
|
// could consider unifying the variants we handle here in `Error::from_reqwest_middleware`
|
||||||
// instead, but both approaches will be fragile as new variants get added over time.
|
// instead, but both approaches will be fragile as new variants get added over time.
|
||||||
if let Error::NetworkErrorWithRetries { retries, .. } = self {
|
if let Self::NetworkErrorWithRetries { retries, .. } = self {
|
||||||
return retries + 1;
|
return retries + 1;
|
||||||
}
|
}
|
||||||
// TODO(jack): let-chains are stable as of Rust 1.88. We should use them here as soon as
|
// TODO(jack): let-chains are stable as of Rust 1.88. We should use them here as soon as
|
||||||
// our rust-version is high enough.
|
// our rust-version is high enough.
|
||||||
if let Error::NetworkMiddlewareError(_, anyhow_error) = self {
|
if let Self::NetworkMiddlewareError(_, anyhow_error) = self {
|
||||||
if let Some(RetryError::WithRetries { retries, .. }) =
|
if let Some(RetryError::WithRetries { retries, .. }) =
|
||||||
anyhow_error.downcast_ref::<RetryError>()
|
anyhow_error.downcast_ref::<RetryError>()
|
||||||
{
|
{
|
||||||
|
|
@ -632,7 +632,7 @@ impl ManagedPythonDownload {
|
||||||
pub fn from_request(
|
pub fn from_request(
|
||||||
request: &PythonDownloadRequest,
|
request: &PythonDownloadRequest,
|
||||||
python_downloads_json_url: Option<&str>,
|
python_downloads_json_url: Option<&str>,
|
||||||
) -> Result<&'static ManagedPythonDownload, Error> {
|
) -> Result<&'static Self, Error> {
|
||||||
if let Some(download) = request.iter_downloads(python_downloads_json_url)?.next() {
|
if let Some(download) = request.iter_downloads(python_downloads_json_url)?.next() {
|
||||||
return Ok(download);
|
return Ok(download);
|
||||||
}
|
}
|
||||||
|
|
@ -658,7 +658,7 @@ impl ManagedPythonDownload {
|
||||||
/// so `python_downloads_json_url` is only used in the first call to this function.
|
/// so `python_downloads_json_url` is only used in the first call to this function.
|
||||||
pub fn iter_all(
|
pub fn iter_all(
|
||||||
python_downloads_json_url: Option<&str>,
|
python_downloads_json_url: Option<&str>,
|
||||||
) -> Result<impl Iterator<Item = &'static ManagedPythonDownload>, Error> {
|
) -> Result<impl Iterator<Item = &'static Self>, Error> {
|
||||||
let downloads = PYTHON_DOWNLOADS.get_or_try_init(|| {
|
let downloads = PYTHON_DOWNLOADS.get_or_try_init(|| {
|
||||||
let json_downloads: HashMap<String, JsonPythonDownload> = if let Some(json_source) =
|
let json_downloads: HashMap<String, JsonPythonDownload> = if let Some(json_source) =
|
||||||
python_downloads_json_url
|
python_downloads_json_url
|
||||||
|
|
@ -1244,8 +1244,8 @@ pub enum Direction {
|
||||||
impl Direction {
|
impl Direction {
|
||||||
fn as_str(&self) -> &str {
|
fn as_str(&self) -> &str {
|
||||||
match self {
|
match self {
|
||||||
Direction::Download => "download",
|
Self::Download => "download",
|
||||||
Direction::Extract => "extract",
|
Self::Extract => "extract",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -690,6 +690,6 @@ impl Hash for PythonInstallationMinorVersionKey {
|
||||||
|
|
||||||
impl From<PythonInstallationKey> for PythonInstallationMinorVersionKey {
|
impl From<PythonInstallationKey> for PythonInstallationMinorVersionKey {
|
||||||
fn from(key: PythonInstallationKey) -> Self {
|
fn from(key: PythonInstallationKey) -> Self {
|
||||||
PythonInstallationMinorVersionKey(key)
|
Self(key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ pub enum Error {
|
||||||
impl Error {
|
impl Error {
|
||||||
pub(crate) fn with_missing_python_hint(self, hint: String) -> Self {
|
pub(crate) fn with_missing_python_hint(self, hint: String) -> Self {
|
||||||
match self {
|
match self {
|
||||||
Error::MissingPython(err, _) => Error::MissingPython(err, Some(hint)),
|
Self::MissingPython(err, _) => Self::MissingPython(err, Some(hint)),
|
||||||
_ => self,
|
_ => self,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -112,7 +112,7 @@ impl Error {
|
||||||
|
|
||||||
impl From<PythonNotFound> for Error {
|
impl From<PythonNotFound> for Error {
|
||||||
fn from(err: PythonNotFound) -> Self {
|
fn from(err: PythonNotFound) -> Self {
|
||||||
Error::MissingPython(err, None)
|
Self::MissingPython(err, None)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -360,7 +360,7 @@ mod tests {
|
||||||
///
|
///
|
||||||
/// Adds them to the test context search path.
|
/// Adds them to the test context search path.
|
||||||
fn add_python_to_workdir(&self, name: &str, version: &str) -> Result<()> {
|
fn add_python_to_workdir(&self, name: &str, version: &str) -> Result<()> {
|
||||||
TestContext::create_mock_interpreter(
|
Self::create_mock_interpreter(
|
||||||
self.workdir.child(name).as_ref(),
|
self.workdir.child(name).as_ref(),
|
||||||
&PythonVersion::from_str(version).expect("Test uses valid version"),
|
&PythonVersion::from_str(version).expect("Test uses valid version"),
|
||||||
ImplementationName::default(),
|
ImplementationName::default(),
|
||||||
|
|
@ -419,7 +419,7 @@ mod tests {
|
||||||
.parent()
|
.parent()
|
||||||
.expect("A Python executable path should always have a parent"),
|
.expect("A Python executable path should always have a parent"),
|
||||||
)?;
|
)?;
|
||||||
TestContext::create_mock_interpreter(
|
Self::create_mock_interpreter(
|
||||||
&executable,
|
&executable,
|
||||||
&PythonVersion::from_str(version)
|
&PythonVersion::from_str(version)
|
||||||
.expect("A valid Python version is used for tests"),
|
.expect("A valid Python version is used for tests"),
|
||||||
|
|
@ -441,7 +441,7 @@ mod tests {
|
||||||
.parent()
|
.parent()
|
||||||
.expect("A Python executable path should always have a parent"),
|
.expect("A Python executable path should always have a parent"),
|
||||||
)?;
|
)?;
|
||||||
TestContext::create_mock_interpreter(
|
Self::create_mock_interpreter(
|
||||||
&executable,
|
&executable,
|
||||||
&PythonVersion::from_str(version)
|
&PythonVersion::from_str(version)
|
||||||
.expect("A valid Python version is used for tests"),
|
.expect("A valid Python version is used for tests"),
|
||||||
|
|
|
||||||
|
|
@ -263,7 +263,7 @@ impl ManagedPythonInstallations {
|
||||||
let arch = Arch::from_env();
|
let arch = Arch::from_env();
|
||||||
let libc = Libc::from_env()?;
|
let libc = Libc::from_env()?;
|
||||||
|
|
||||||
let iter = ManagedPythonInstallations::from_settings(None)?
|
let iter = Self::from_settings(None)?
|
||||||
.find_all()?
|
.find_all()?
|
||||||
.filter(move |installation| {
|
.filter(move |installation| {
|
||||||
installation.key.os == os
|
installation.key.os == os
|
||||||
|
|
@ -627,7 +627,7 @@ impl ManagedPythonInstallation {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns `true` if self is a suitable upgrade of other.
|
/// Returns `true` if self is a suitable upgrade of other.
|
||||||
pub fn is_upgrade_of(&self, other: &ManagedPythonInstallation) -> bool {
|
pub fn is_upgrade_of(&self, other: &Self) -> bool {
|
||||||
// Require matching implementation
|
// Require matching implementation
|
||||||
if self.key.implementation != other.key.implementation {
|
if self.key.implementation != other.key.implementation {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -764,7 +764,7 @@ impl PythonMinorVersionLink {
|
||||||
installation: &ManagedPythonInstallation,
|
installation: &ManagedPythonInstallation,
|
||||||
preview: Preview,
|
preview: Preview,
|
||||||
) -> Option<Self> {
|
) -> Option<Self> {
|
||||||
PythonMinorVersionLink::from_executable(
|
Self::from_executable(
|
||||||
installation.executable(false).as_path(),
|
installation.executable(false).as_path(),
|
||||||
installation.key(),
|
installation.key(),
|
||||||
preview,
|
preview,
|
||||||
|
|
|
||||||
|
|
@ -227,7 +227,7 @@ impl PythonVersionFile {
|
||||||
|
|
||||||
/// Returns `true` if the version file is a global version file.
|
/// Returns `true` if the version file is a global version file.
|
||||||
pub fn is_global(&self) -> bool {
|
pub fn is_global(&self) -> bool {
|
||||||
PythonVersionFile::global().is_some_and(|global| self.path() == global.path())
|
Self::global().is_some_and(|global| self.path() == global.path())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the first request declared in the file, if any.
|
/// Return the first request declared in the file, if any.
|
||||||
|
|
|
||||||
|
|
@ -85,22 +85,22 @@ impl CondaEnvironmentKind {
|
||||||
fn from_prefix_path(path: &Path) -> Self {
|
fn from_prefix_path(path: &Path) -> Self {
|
||||||
// If we cannot read `CONDA_DEFAULT_ENV`, there's no way to know if the base environment
|
// If we cannot read `CONDA_DEFAULT_ENV`, there's no way to know if the base environment
|
||||||
let Ok(default_env) = env::var(EnvVars::CONDA_DEFAULT_ENV) else {
|
let Ok(default_env) = env::var(EnvVars::CONDA_DEFAULT_ENV) else {
|
||||||
return CondaEnvironmentKind::Child;
|
return Self::Child;
|
||||||
};
|
};
|
||||||
|
|
||||||
// These are the expected names for the base environment
|
// These are the expected names for the base environment
|
||||||
if default_env != "base" && default_env != "root" {
|
if default_env != "base" && default_env != "root" {
|
||||||
return CondaEnvironmentKind::Child;
|
return Self::Child;
|
||||||
}
|
}
|
||||||
|
|
||||||
let Some(name) = path.file_name() else {
|
let Some(name) = path.file_name() else {
|
||||||
return CondaEnvironmentKind::Child;
|
return Self::Child;
|
||||||
};
|
};
|
||||||
|
|
||||||
if name.to_str().is_some_and(|name| name == default_env) {
|
if name.to_str().is_some_and(|name| name == default_env) {
|
||||||
CondaEnvironmentKind::Base
|
Self::Base
|
||||||
} else {
|
} else {
|
||||||
CondaEnvironmentKind::Child
|
Self::Child
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ impl DisplaySafeUrl {
|
||||||
/// Parse a string as an URL, with this URL as the base URL.
|
/// Parse a string as an URL, with this URL as the base URL.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn join(&self, input: &str) -> Result<Self, url::ParseError> {
|
pub fn join(&self, input: &str) -> Result<Self, url::ParseError> {
|
||||||
self.0.join(input).map(DisplaySafeUrl::from)
|
self.0.join(input).map(Self::from)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Serialize with Serde using the internal representation of the `Url` struct.
|
/// Serialize with Serde using the internal representation of the `Url` struct.
|
||||||
|
|
@ -78,12 +78,12 @@ impl DisplaySafeUrl {
|
||||||
where
|
where
|
||||||
D: serde::Deserializer<'de>,
|
D: serde::Deserializer<'de>,
|
||||||
{
|
{
|
||||||
Url::deserialize_internal(deserializer).map(DisplaySafeUrl::from)
|
Url::deserialize_internal(deserializer).map(Self::from)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::result_unit_err)]
|
#[allow(clippy::result_unit_err)]
|
||||||
pub fn from_file_path<P: AsRef<std::path::Path>>(path: P) -> Result<DisplaySafeUrl, ()> {
|
pub fn from_file_path<P: AsRef<std::path::Path>>(path: P) -> Result<Self, ()> {
|
||||||
Url::from_file_path(path).map(DisplaySafeUrl::from)
|
Url::from_file_path(path).map(Self::from)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Remove the credentials from a URL, allowing the generic `git` username (without a password)
|
/// Remove the credentials from a URL, allowing the generic `git` username (without a password)
|
||||||
|
|
@ -177,7 +177,7 @@ impl Debug for DisplaySafeUrl {
|
||||||
|
|
||||||
impl From<Url> for DisplaySafeUrl {
|
impl From<Url> for DisplaySafeUrl {
|
||||||
fn from(url: Url) -> Self {
|
fn from(url: Url) -> Self {
|
||||||
DisplaySafeUrl(url)
|
Self(url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -428,7 +428,7 @@ impl RequirementsTxt {
|
||||||
|
|
||||||
/// Merge the data from a nested `requirements` file (`other`) into this one.
|
/// Merge the data from a nested `requirements` file (`other`) into this one.
|
||||||
pub fn update_from(&mut self, other: Self) {
|
pub fn update_from(&mut self, other: Self) {
|
||||||
let RequirementsTxt {
|
let Self {
|
||||||
requirements,
|
requirements,
|
||||||
constraints,
|
constraints,
|
||||||
editables,
|
editables,
|
||||||
|
|
@ -469,33 +469,33 @@ impl UnsupportedOption {
|
||||||
/// The name of the unsupported option.
|
/// The name of the unsupported option.
|
||||||
fn name(self) -> &'static str {
|
fn name(self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
UnsupportedOption::PreferBinary => "--prefer-binary",
|
Self::PreferBinary => "--prefer-binary",
|
||||||
UnsupportedOption::RequireHashes => "--require-hashes",
|
Self::RequireHashes => "--require-hashes",
|
||||||
UnsupportedOption::Pre => "--pre",
|
Self::Pre => "--pre",
|
||||||
UnsupportedOption::TrustedHost => "--trusted-host",
|
Self::TrustedHost => "--trusted-host",
|
||||||
UnsupportedOption::UseFeature => "--use-feature",
|
Self::UseFeature => "--use-feature",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns `true` if the option is supported on the CLI.
|
/// Returns `true` if the option is supported on the CLI.
|
||||||
fn cli(self) -> bool {
|
fn cli(self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
UnsupportedOption::PreferBinary => false,
|
Self::PreferBinary => false,
|
||||||
UnsupportedOption::RequireHashes => true,
|
Self::RequireHashes => true,
|
||||||
UnsupportedOption::Pre => true,
|
Self::Pre => true,
|
||||||
UnsupportedOption::TrustedHost => true,
|
Self::TrustedHost => true,
|
||||||
UnsupportedOption::UseFeature => false,
|
Self::UseFeature => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns an iterator over all unsupported options.
|
/// Returns an iterator over all unsupported options.
|
||||||
fn iter() -> impl Iterator<Item = UnsupportedOption> {
|
fn iter() -> impl Iterator<Item = Self> {
|
||||||
[
|
[
|
||||||
UnsupportedOption::PreferBinary,
|
Self::PreferBinary,
|
||||||
UnsupportedOption::RequireHashes,
|
Self::RequireHashes,
|
||||||
UnsupportedOption::Pre,
|
Self::Pre,
|
||||||
UnsupportedOption::TrustedHost,
|
Self::TrustedHost,
|
||||||
UnsupportedOption::UseFeature,
|
Self::UseFeature,
|
||||||
]
|
]
|
||||||
.iter()
|
.iter()
|
||||||
.copied()
|
.copied()
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ impl RequirementsTxtRequirement {
|
||||||
/// Specifically, only local directory URLs are supported.
|
/// Specifically, only local directory URLs are supported.
|
||||||
pub fn into_editable(self) -> Result<Self, EditableError> {
|
pub fn into_editable(self) -> Result<Self, EditableError> {
|
||||||
match self {
|
match self {
|
||||||
RequirementsTxtRequirement::Named(requirement) => {
|
Self::Named(requirement) => {
|
||||||
let Some(version_or_url) = requirement.version_or_url else {
|
let Some(version_or_url) = requirement.version_or_url else {
|
||||||
return Err(EditableError::MissingVersion(requirement.name));
|
return Err(EditableError::MissingVersion(requirement.name));
|
||||||
};
|
};
|
||||||
|
|
@ -97,7 +97,7 @@ impl RequirementsTxtRequirement {
|
||||||
..requirement
|
..requirement
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
RequirementsTxtRequirement::Unnamed(requirement) => {
|
Self::Unnamed(requirement) => {
|
||||||
let parsed_url = match requirement.url.parsed_url {
|
let parsed_url = match requirement.url.parsed_url {
|
||||||
ParsedUrl::Directory(parsed_url) => parsed_url,
|
ParsedUrl::Directory(parsed_url) => parsed_url,
|
||||||
ParsedUrl::Path(_) => {
|
ParsedUrl::Path(_) => {
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ impl LockedRequirements {
|
||||||
pub fn from_preferences(preferences: Vec<Preference>) -> Self {
|
pub fn from_preferences(preferences: Vec<Preference>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
preferences,
|
preferences,
|
||||||
..LockedRequirements::default()
|
..Self::default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -616,8 +616,8 @@ impl CandidateDist<'_> {
|
||||||
/// For an installable dist, return the prioritized distribution.
|
/// For an installable dist, return the prioritized distribution.
|
||||||
fn prioritized(&self) -> Option<&PrioritizedDist> {
|
fn prioritized(&self) -> Option<&PrioritizedDist> {
|
||||||
match self {
|
match self {
|
||||||
CandidateDist::Compatible(dist) => dist.prioritized(),
|
Self::Compatible(dist) => dist.prioritized(),
|
||||||
CandidateDist::Incompatible {
|
Self::Incompatible {
|
||||||
incompatible_dist: _,
|
incompatible_dist: _,
|
||||||
prioritized_dist: prioritized,
|
prioritized_dist: prioritized,
|
||||||
} => Some(prioritized),
|
} => Some(prioritized),
|
||||||
|
|
@ -664,9 +664,9 @@ pub(crate) enum VersionChoiceKind {
|
||||||
impl Display for VersionChoiceKind {
|
impl Display for VersionChoiceKind {
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
VersionChoiceKind::Preference => f.write_str("preference"),
|
Self::Preference => f.write_str("preference"),
|
||||||
VersionChoiceKind::Installed => f.write_str("installed"),
|
Self::Installed => f.write_str("installed"),
|
||||||
VersionChoiceKind::Compatible => f.write_str("compatible"),
|
Self::Compatible => f.write_str("compatible"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -298,30 +298,30 @@ pub(crate) trait Reachable<T> {
|
||||||
fn marker(&self) -> T;
|
fn marker(&self) -> T;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Reachable<MarkerTree> for MarkerTree {
|
impl Reachable<Self> for MarkerTree {
|
||||||
fn true_marker() -> MarkerTree {
|
fn true_marker() -> Self {
|
||||||
MarkerTree::TRUE
|
Self::TRUE
|
||||||
}
|
}
|
||||||
|
|
||||||
fn false_marker() -> MarkerTree {
|
fn false_marker() -> Self {
|
||||||
MarkerTree::FALSE
|
Self::FALSE
|
||||||
}
|
}
|
||||||
|
|
||||||
fn marker(&self) -> MarkerTree {
|
fn marker(&self) -> Self {
|
||||||
*self
|
*self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Reachable<UniversalMarker> for UniversalMarker {
|
impl Reachable<Self> for UniversalMarker {
|
||||||
fn true_marker() -> UniversalMarker {
|
fn true_marker() -> Self {
|
||||||
UniversalMarker::TRUE
|
Self::TRUE
|
||||||
}
|
}
|
||||||
|
|
||||||
fn false_marker() -> UniversalMarker {
|
fn false_marker() -> Self {
|
||||||
UniversalMarker::FALSE
|
Self::FALSE
|
||||||
}
|
}
|
||||||
|
|
||||||
fn marker(&self) -> UniversalMarker {
|
fn marker(&self) -> Self {
|
||||||
*self
|
*self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -173,7 +173,7 @@ where
|
||||||
PylockTomlErrorKind: From<E>,
|
PylockTomlErrorKind: From<E>,
|
||||||
{
|
{
|
||||||
fn from(err: E) -> Self {
|
fn from(err: E) -> Self {
|
||||||
PylockTomlError {
|
Self {
|
||||||
kind: Box::new(PylockTomlErrorKind::from(err)),
|
kind: Box::new(PylockTomlErrorKind::from(err)),
|
||||||
hint: None,
|
hint: None,
|
||||||
}
|
}
|
||||||
|
|
@ -601,7 +601,7 @@ impl<'lock> PylockToml {
|
||||||
packages.sort_by(|a, b| a.name.cmp(&b.name).then(a.version.cmp(&b.version)));
|
packages.sort_by(|a, b| a.name.cmp(&b.name).then(a.version.cmp(&b.version)));
|
||||||
|
|
||||||
// Return the constructed `pylock.toml`.
|
// Return the constructed `pylock.toml`.
|
||||||
Ok(PylockToml {
|
Ok(Self {
|
||||||
lock_version,
|
lock_version,
|
||||||
created_by,
|
created_by,
|
||||||
requires_python: Some(requires_python),
|
requires_python: Some(requires_python),
|
||||||
|
|
|
||||||
|
|
@ -1980,7 +1980,7 @@ impl<'tags> TagPolicy<'tags> {
|
||||||
/// Returns the platform tags to consider.
|
/// Returns the platform tags to consider.
|
||||||
fn tags(&self) -> &'tags Tags {
|
fn tags(&self) -> &'tags Tags {
|
||||||
match self {
|
match self {
|
||||||
TagPolicy::Required(tags) | TagPolicy::Preferred(tags) => tags,
|
Self::Required(tags) | Self::Preferred(tags) => tags,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2207,7 +2207,7 @@ struct LockWire {
|
||||||
impl TryFrom<LockWire> for Lock {
|
impl TryFrom<LockWire> for Lock {
|
||||||
type Error = LockError;
|
type Error = LockError;
|
||||||
|
|
||||||
fn try_from(wire: LockWire) -> Result<Lock, LockError> {
|
fn try_from(wire: LockWire) -> Result<Self, LockError> {
|
||||||
// Count the number of sources for each package name. When
|
// Count the number of sources for each package name. When
|
||||||
// there's only one source for a particular package name (the
|
// there's only one source for a particular package name (the
|
||||||
// overwhelmingly common case), we can omit some data (like source and
|
// overwhelmingly common case), we can omit some data (like source and
|
||||||
|
|
@ -2246,7 +2246,7 @@ impl TryFrom<LockWire> for Lock {
|
||||||
.map(|simplified_marker| simplified_marker.into_marker(&wire.requires_python))
|
.map(|simplified_marker| simplified_marker.into_marker(&wire.requires_python))
|
||||||
.map(UniversalMarker::from_combined)
|
.map(UniversalMarker::from_combined)
|
||||||
.collect();
|
.collect();
|
||||||
let lock = Lock::new(
|
let lock = Self::new(
|
||||||
wire.version,
|
wire.version,
|
||||||
wire.revision.unwrap_or(0),
|
wire.revision.unwrap_or(0),
|
||||||
packages,
|
packages,
|
||||||
|
|
@ -2353,7 +2353,7 @@ impl Package {
|
||||||
})
|
})
|
||||||
.collect::<Result<_, _>>()?
|
.collect::<Result<_, _>>()?
|
||||||
};
|
};
|
||||||
Ok(Package {
|
Ok(Self {
|
||||||
id,
|
id,
|
||||||
sdist,
|
sdist,
|
||||||
wheels,
|
wheels,
|
||||||
|
|
@ -3159,7 +3159,7 @@ struct PackageMetadata {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PackageMetadata {
|
impl PackageMetadata {
|
||||||
fn unwire(self, requires_python: &RequiresPython) -> PackageMetadata {
|
fn unwire(self, requires_python: &RequiresPython) -> Self {
|
||||||
// We need to complexify these markers so things like
|
// We need to complexify these markers so things like
|
||||||
// `requires_python < '0'` get normalized to False
|
// `requires_python < '0'` get normalized to False
|
||||||
let unwire_requirements = |requirements: BTreeSet<Requirement>| -> BTreeSet<Requirement> {
|
let unwire_requirements = |requirements: BTreeSet<Requirement>| -> BTreeSet<Requirement> {
|
||||||
|
|
@ -3174,7 +3174,7 @@ impl PackageMetadata {
|
||||||
.collect()
|
.collect()
|
||||||
};
|
};
|
||||||
|
|
||||||
PackageMetadata {
|
Self {
|
||||||
requires_dist: unwire_requirements(self.requires_dist),
|
requires_dist: unwire_requirements(self.requires_dist),
|
||||||
provides_extras: self.provides_extras,
|
provides_extras: self.provides_extras,
|
||||||
dependency_groups: self
|
dependency_groups: self
|
||||||
|
|
@ -3252,10 +3252,7 @@ pub(crate) struct PackageId {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PackageId {
|
impl PackageId {
|
||||||
fn from_annotated_dist(
|
fn from_annotated_dist(annotated_dist: &AnnotatedDist, root: &Path) -> Result<Self, LockError> {
|
||||||
annotated_dist: &AnnotatedDist,
|
|
||||||
root: &Path,
|
|
||||||
) -> Result<PackageId, LockError> {
|
|
||||||
// Identify the source of the package.
|
// Identify the source of the package.
|
||||||
let source = Source::from_resolved_dist(&annotated_dist.dist, root)?;
|
let source = Source::from_resolved_dist(&annotated_dist.dist, root)?;
|
||||||
// Omit versions for dynamic source trees.
|
// Omit versions for dynamic source trees.
|
||||||
|
|
@ -3355,8 +3352,8 @@ impl PackageIdForDependency {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<PackageId> for PackageIdForDependency {
|
impl From<PackageId> for PackageIdForDependency {
|
||||||
fn from(id: PackageId) -> PackageIdForDependency {
|
fn from(id: PackageId) -> Self {
|
||||||
PackageIdForDependency {
|
Self {
|
||||||
name: id.name,
|
name: id.name,
|
||||||
version: id.version,
|
version: id.version,
|
||||||
source: Some(id.source),
|
source: Some(id.source),
|
||||||
|
|
@ -3391,50 +3388,48 @@ enum Source {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Source {
|
impl Source {
|
||||||
fn from_resolved_dist(resolved_dist: &ResolvedDist, root: &Path) -> Result<Source, LockError> {
|
fn from_resolved_dist(resolved_dist: &ResolvedDist, root: &Path) -> Result<Self, LockError> {
|
||||||
match *resolved_dist {
|
match *resolved_dist {
|
||||||
// We pass empty installed packages for locking.
|
// We pass empty installed packages for locking.
|
||||||
ResolvedDist::Installed { .. } => unreachable!(),
|
ResolvedDist::Installed { .. } => unreachable!(),
|
||||||
ResolvedDist::Installable { ref dist, .. } => Source::from_dist(dist, root),
|
ResolvedDist::Installable { ref dist, .. } => Self::from_dist(dist, root),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_dist(dist: &Dist, root: &Path) -> Result<Source, LockError> {
|
fn from_dist(dist: &Dist, root: &Path) -> Result<Self, LockError> {
|
||||||
match *dist {
|
match *dist {
|
||||||
Dist::Built(ref built_dist) => Source::from_built_dist(built_dist, root),
|
Dist::Built(ref built_dist) => Self::from_built_dist(built_dist, root),
|
||||||
Dist::Source(ref source_dist) => Source::from_source_dist(source_dist, root),
|
Dist::Source(ref source_dist) => Self::from_source_dist(source_dist, root),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_built_dist(built_dist: &BuiltDist, root: &Path) -> Result<Source, LockError> {
|
fn from_built_dist(built_dist: &BuiltDist, root: &Path) -> Result<Self, LockError> {
|
||||||
match *built_dist {
|
match *built_dist {
|
||||||
BuiltDist::Registry(ref reg_dist) => Source::from_registry_built_dist(reg_dist, root),
|
BuiltDist::Registry(ref reg_dist) => Self::from_registry_built_dist(reg_dist, root),
|
||||||
BuiltDist::DirectUrl(ref direct_dist) => {
|
BuiltDist::DirectUrl(ref direct_dist) => Ok(Self::from_direct_built_dist(direct_dist)),
|
||||||
Ok(Source::from_direct_built_dist(direct_dist))
|
BuiltDist::Path(ref path_dist) => Self::from_path_built_dist(path_dist, root),
|
||||||
}
|
|
||||||
BuiltDist::Path(ref path_dist) => Source::from_path_built_dist(path_dist, root),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_source_dist(
|
fn from_source_dist(
|
||||||
source_dist: &uv_distribution_types::SourceDist,
|
source_dist: &uv_distribution_types::SourceDist,
|
||||||
root: &Path,
|
root: &Path,
|
||||||
) -> Result<Source, LockError> {
|
) -> Result<Self, LockError> {
|
||||||
match *source_dist {
|
match *source_dist {
|
||||||
uv_distribution_types::SourceDist::Registry(ref reg_dist) => {
|
uv_distribution_types::SourceDist::Registry(ref reg_dist) => {
|
||||||
Source::from_registry_source_dist(reg_dist, root)
|
Self::from_registry_source_dist(reg_dist, root)
|
||||||
}
|
}
|
||||||
uv_distribution_types::SourceDist::DirectUrl(ref direct_dist) => {
|
uv_distribution_types::SourceDist::DirectUrl(ref direct_dist) => {
|
||||||
Ok(Source::from_direct_source_dist(direct_dist))
|
Ok(Self::from_direct_source_dist(direct_dist))
|
||||||
}
|
}
|
||||||
uv_distribution_types::SourceDist::Git(ref git_dist) => {
|
uv_distribution_types::SourceDist::Git(ref git_dist) => {
|
||||||
Ok(Source::from_git_dist(git_dist))
|
Ok(Self::from_git_dist(git_dist))
|
||||||
}
|
}
|
||||||
uv_distribution_types::SourceDist::Path(ref path_dist) => {
|
uv_distribution_types::SourceDist::Path(ref path_dist) => {
|
||||||
Source::from_path_source_dist(path_dist, root)
|
Self::from_path_source_dist(path_dist, root)
|
||||||
}
|
}
|
||||||
uv_distribution_types::SourceDist::Directory(ref directory) => {
|
uv_distribution_types::SourceDist::Directory(ref directory) => {
|
||||||
Source::from_directory_source_dist(directory, root)
|
Self::from_directory_source_dist(directory, root)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -3442,26 +3437,26 @@ impl Source {
|
||||||
fn from_registry_built_dist(
|
fn from_registry_built_dist(
|
||||||
reg_dist: &RegistryBuiltDist,
|
reg_dist: &RegistryBuiltDist,
|
||||||
root: &Path,
|
root: &Path,
|
||||||
) -> Result<Source, LockError> {
|
) -> Result<Self, LockError> {
|
||||||
Source::from_index_url(®_dist.best_wheel().index, root)
|
Self::from_index_url(®_dist.best_wheel().index, root)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_registry_source_dist(
|
fn from_registry_source_dist(
|
||||||
reg_dist: &RegistrySourceDist,
|
reg_dist: &RegistrySourceDist,
|
||||||
root: &Path,
|
root: &Path,
|
||||||
) -> Result<Source, LockError> {
|
) -> Result<Self, LockError> {
|
||||||
Source::from_index_url(®_dist.index, root)
|
Self::from_index_url(®_dist.index, root)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_direct_built_dist(direct_dist: &DirectUrlBuiltDist) -> Source {
|
fn from_direct_built_dist(direct_dist: &DirectUrlBuiltDist) -> Self {
|
||||||
Source::Direct(
|
Self::Direct(
|
||||||
normalize_url(direct_dist.url.to_url()),
|
normalize_url(direct_dist.url.to_url()),
|
||||||
DirectSource { subdirectory: None },
|
DirectSource { subdirectory: None },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_direct_source_dist(direct_dist: &DirectUrlSourceDist) -> Source {
|
fn from_direct_source_dist(direct_dist: &DirectUrlSourceDist) -> Self {
|
||||||
Source::Direct(
|
Self::Direct(
|
||||||
normalize_url(direct_dist.url.to_url()),
|
normalize_url(direct_dist.url.to_url()),
|
||||||
DirectSource {
|
DirectSource {
|
||||||
subdirectory: direct_dist.subdirectory.clone(),
|
subdirectory: direct_dist.subdirectory.clone(),
|
||||||
|
|
@ -3469,43 +3464,43 @@ impl Source {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_path_built_dist(path_dist: &PathBuiltDist, root: &Path) -> Result<Source, LockError> {
|
fn from_path_built_dist(path_dist: &PathBuiltDist, root: &Path) -> Result<Self, LockError> {
|
||||||
let path = relative_to(&path_dist.install_path, root)
|
let path = relative_to(&path_dist.install_path, root)
|
||||||
.or_else(|_| std::path::absolute(&path_dist.install_path))
|
.or_else(|_| std::path::absolute(&path_dist.install_path))
|
||||||
.map_err(LockErrorKind::DistributionRelativePath)?;
|
.map_err(LockErrorKind::DistributionRelativePath)?;
|
||||||
Ok(Source::Path(path.into_boxed_path()))
|
Ok(Self::Path(path.into_boxed_path()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_path_source_dist(path_dist: &PathSourceDist, root: &Path) -> Result<Source, LockError> {
|
fn from_path_source_dist(path_dist: &PathSourceDist, root: &Path) -> Result<Self, LockError> {
|
||||||
let path = relative_to(&path_dist.install_path, root)
|
let path = relative_to(&path_dist.install_path, root)
|
||||||
.or_else(|_| std::path::absolute(&path_dist.install_path))
|
.or_else(|_| std::path::absolute(&path_dist.install_path))
|
||||||
.map_err(LockErrorKind::DistributionRelativePath)?;
|
.map_err(LockErrorKind::DistributionRelativePath)?;
|
||||||
Ok(Source::Path(path.into_boxed_path()))
|
Ok(Self::Path(path.into_boxed_path()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_directory_source_dist(
|
fn from_directory_source_dist(
|
||||||
directory_dist: &DirectorySourceDist,
|
directory_dist: &DirectorySourceDist,
|
||||||
root: &Path,
|
root: &Path,
|
||||||
) -> Result<Source, LockError> {
|
) -> Result<Self, LockError> {
|
||||||
let path = relative_to(&directory_dist.install_path, root)
|
let path = relative_to(&directory_dist.install_path, root)
|
||||||
.or_else(|_| std::path::absolute(&directory_dist.install_path))
|
.or_else(|_| std::path::absolute(&directory_dist.install_path))
|
||||||
.map_err(LockErrorKind::DistributionRelativePath)?;
|
.map_err(LockErrorKind::DistributionRelativePath)?;
|
||||||
if directory_dist.editable.unwrap_or(false) {
|
if directory_dist.editable.unwrap_or(false) {
|
||||||
Ok(Source::Editable(path.into_boxed_path()))
|
Ok(Self::Editable(path.into_boxed_path()))
|
||||||
} else if directory_dist.r#virtual.unwrap_or(false) {
|
} else if directory_dist.r#virtual.unwrap_or(false) {
|
||||||
Ok(Source::Virtual(path.into_boxed_path()))
|
Ok(Self::Virtual(path.into_boxed_path()))
|
||||||
} else {
|
} else {
|
||||||
Ok(Source::Directory(path.into_boxed_path()))
|
Ok(Self::Directory(path.into_boxed_path()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_index_url(index_url: &IndexUrl, root: &Path) -> Result<Source, LockError> {
|
fn from_index_url(index_url: &IndexUrl, root: &Path) -> Result<Self, LockError> {
|
||||||
match index_url {
|
match index_url {
|
||||||
IndexUrl::Pypi(_) | IndexUrl::Url(_) => {
|
IndexUrl::Pypi(_) | IndexUrl::Url(_) => {
|
||||||
// Remove any sensitive credentials from the index URL.
|
// Remove any sensitive credentials from the index URL.
|
||||||
let redacted = index_url.without_credentials();
|
let redacted = index_url.without_credentials();
|
||||||
let source = RegistrySource::Url(UrlString::from(redacted.as_ref()));
|
let source = RegistrySource::Url(UrlString::from(redacted.as_ref()));
|
||||||
Ok(Source::Registry(source))
|
Ok(Self::Registry(source))
|
||||||
}
|
}
|
||||||
IndexUrl::Path(url) => {
|
IndexUrl::Path(url) => {
|
||||||
let path = url
|
let path = url
|
||||||
|
|
@ -3515,13 +3510,13 @@ impl Source {
|
||||||
.or_else(|_| std::path::absolute(&path))
|
.or_else(|_| std::path::absolute(&path))
|
||||||
.map_err(LockErrorKind::IndexRelativePath)?;
|
.map_err(LockErrorKind::IndexRelativePath)?;
|
||||||
let source = RegistrySource::Path(path.into_boxed_path());
|
let source = RegistrySource::Path(path.into_boxed_path());
|
||||||
Ok(Source::Registry(source))
|
Ok(Self::Registry(source))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_git_dist(git_dist: &GitSourceDist) -> Source {
|
fn from_git_dist(git_dist: &GitSourceDist) -> Self {
|
||||||
Source::Git(
|
Self::Git(
|
||||||
UrlString::from(locked_git_url(git_dist)),
|
UrlString::from(locked_git_url(git_dist)),
|
||||||
GitSource {
|
GitSource {
|
||||||
kind: GitSourceKind::from(git_dist.git.reference().clone()),
|
kind: GitSourceKind::from(git_dist.git.reference().clone()),
|
||||||
|
|
@ -3546,46 +3541,46 @@ impl Source {
|
||||||
/// Returns `true` if the source is that of a wheel.
|
/// Returns `true` if the source is that of a wheel.
|
||||||
fn is_wheel(&self) -> bool {
|
fn is_wheel(&self) -> bool {
|
||||||
match &self {
|
match &self {
|
||||||
Source::Path(path) => {
|
Self::Path(path) => {
|
||||||
matches!(
|
matches!(
|
||||||
DistExtension::from_path(path).ok(),
|
DistExtension::from_path(path).ok(),
|
||||||
Some(DistExtension::Wheel)
|
Some(DistExtension::Wheel)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Source::Direct(url, _) => {
|
Self::Direct(url, _) => {
|
||||||
matches!(
|
matches!(
|
||||||
DistExtension::from_path(url.as_ref()).ok(),
|
DistExtension::from_path(url.as_ref()).ok(),
|
||||||
Some(DistExtension::Wheel)
|
Some(DistExtension::Wheel)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Source::Directory(..) => false,
|
Self::Directory(..) => false,
|
||||||
Source::Editable(..) => false,
|
Self::Editable(..) => false,
|
||||||
Source::Virtual(..) => false,
|
Self::Virtual(..) => false,
|
||||||
Source::Git(..) => false,
|
Self::Git(..) => false,
|
||||||
Source::Registry(..) => false,
|
Self::Registry(..) => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns `true` if the source is that of a source tree.
|
/// Returns `true` if the source is that of a source tree.
|
||||||
fn is_source_tree(&self) -> bool {
|
fn is_source_tree(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
Source::Directory(..) | Source::Editable(..) | Source::Virtual(..) => true,
|
Self::Directory(..) | Self::Editable(..) | Self::Virtual(..) => true,
|
||||||
Source::Path(..) | Source::Git(..) | Source::Registry(..) | Source::Direct(..) => false,
|
Self::Path(..) | Self::Git(..) | Self::Registry(..) | Self::Direct(..) => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the path to the source tree, if the source is a source tree.
|
/// Returns the path to the source tree, if the source is a source tree.
|
||||||
fn as_source_tree(&self) -> Option<&Path> {
|
fn as_source_tree(&self) -> Option<&Path> {
|
||||||
match self {
|
match self {
|
||||||
Source::Directory(path) | Source::Editable(path) | Source::Virtual(path) => Some(path),
|
Self::Directory(path) | Self::Editable(path) | Self::Virtual(path) => Some(path),
|
||||||
Source::Path(..) | Source::Git(..) | Source::Registry(..) | Source::Direct(..) => None,
|
Self::Path(..) | Self::Git(..) | Self::Registry(..) | Self::Direct(..) => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_toml(&self, table: &mut Table) {
|
fn to_toml(&self, table: &mut Table) {
|
||||||
let mut source_table = InlineTable::new();
|
let mut source_table = InlineTable::new();
|
||||||
match *self {
|
match *self {
|
||||||
Source::Registry(ref source) => match source {
|
Self::Registry(ref source) => match source {
|
||||||
RegistrySource::Url(url) => {
|
RegistrySource::Url(url) => {
|
||||||
source_table.insert("registry", Value::from(url.as_ref()));
|
source_table.insert("registry", Value::from(url.as_ref()));
|
||||||
}
|
}
|
||||||
|
|
@ -3596,10 +3591,10 @@ impl Source {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Source::Git(ref url, _) => {
|
Self::Git(ref url, _) => {
|
||||||
source_table.insert("git", Value::from(url.as_ref()));
|
source_table.insert("git", Value::from(url.as_ref()));
|
||||||
}
|
}
|
||||||
Source::Direct(ref url, DirectSource { ref subdirectory }) => {
|
Self::Direct(ref url, DirectSource { ref subdirectory }) => {
|
||||||
source_table.insert("url", Value::from(url.as_ref()));
|
source_table.insert("url", Value::from(url.as_ref()));
|
||||||
if let Some(ref subdirectory) = *subdirectory {
|
if let Some(ref subdirectory) = *subdirectory {
|
||||||
source_table.insert(
|
source_table.insert(
|
||||||
|
|
@ -3608,22 +3603,22 @@ impl Source {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Source::Path(ref path) => {
|
Self::Path(ref path) => {
|
||||||
source_table.insert("path", Value::from(PortablePath::from(path).to_string()));
|
source_table.insert("path", Value::from(PortablePath::from(path).to_string()));
|
||||||
}
|
}
|
||||||
Source::Directory(ref path) => {
|
Self::Directory(ref path) => {
|
||||||
source_table.insert(
|
source_table.insert(
|
||||||
"directory",
|
"directory",
|
||||||
Value::from(PortablePath::from(path).to_string()),
|
Value::from(PortablePath::from(path).to_string()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Source::Editable(ref path) => {
|
Self::Editable(ref path) => {
|
||||||
source_table.insert(
|
source_table.insert(
|
||||||
"editable",
|
"editable",
|
||||||
Value::from(PortablePath::from(path).to_string()),
|
Value::from(PortablePath::from(path).to_string()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Source::Virtual(ref path) => {
|
Self::Virtual(ref path) => {
|
||||||
source_table.insert("virtual", Value::from(PortablePath::from(path).to_string()));
|
source_table.insert("virtual", Value::from(PortablePath::from(path).to_string()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -3634,16 +3629,14 @@ impl Source {
|
||||||
impl Display for Source {
|
impl Display for Source {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
Source::Registry(RegistrySource::Url(url))
|
Self::Registry(RegistrySource::Url(url)) | Self::Git(url, _) | Self::Direct(url, _) => {
|
||||||
| Source::Git(url, _)
|
|
||||||
| Source::Direct(url, _) => {
|
|
||||||
write!(f, "{}+{}", self.name(), url)
|
write!(f, "{}+{}", self.name(), url)
|
||||||
}
|
}
|
||||||
Source::Registry(RegistrySource::Path(path))
|
Self::Registry(RegistrySource::Path(path))
|
||||||
| Source::Path(path)
|
| Self::Path(path)
|
||||||
| Source::Directory(path)
|
| Self::Directory(path)
|
||||||
| Source::Editable(path)
|
| Self::Editable(path)
|
||||||
| Source::Virtual(path) => {
|
| Self::Virtual(path) => {
|
||||||
write!(f, "{}+{}", self.name(), PortablePath::from(path))
|
write!(f, "{}+{}", self.name(), PortablePath::from(path))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -3711,12 +3704,12 @@ enum SourceWire {
|
||||||
impl TryFrom<SourceWire> for Source {
|
impl TryFrom<SourceWire> for Source {
|
||||||
type Error = LockError;
|
type Error = LockError;
|
||||||
|
|
||||||
fn try_from(wire: SourceWire) -> Result<Source, LockError> {
|
fn try_from(wire: SourceWire) -> Result<Self, LockError> {
|
||||||
#[allow(clippy::enum_glob_use)]
|
#[allow(clippy::enum_glob_use)]
|
||||||
use self::SourceWire::*;
|
use self::SourceWire::*;
|
||||||
|
|
||||||
match wire {
|
match wire {
|
||||||
Registry { registry } => Ok(Source::Registry(registry.into())),
|
Registry { registry } => Ok(Self::Registry(registry.into())),
|
||||||
Git { git } => {
|
Git { git } => {
|
||||||
let url = DisplaySafeUrl::parse(&git)
|
let url = DisplaySafeUrl::parse(&git)
|
||||||
.map_err(|err| SourceParseError::InvalidUrl {
|
.map_err(|err| SourceParseError::InvalidUrl {
|
||||||
|
|
@ -3736,18 +3729,18 @@ impl TryFrom<SourceWire> for Source {
|
||||||
})
|
})
|
||||||
.map_err(LockErrorKind::InvalidGitSourceUrl)?;
|
.map_err(LockErrorKind::InvalidGitSourceUrl)?;
|
||||||
|
|
||||||
Ok(Source::Git(UrlString::from(url), git_source))
|
Ok(Self::Git(UrlString::from(url), git_source))
|
||||||
}
|
}
|
||||||
Direct { url, subdirectory } => Ok(Source::Direct(
|
Direct { url, subdirectory } => Ok(Self::Direct(
|
||||||
url,
|
url,
|
||||||
DirectSource {
|
DirectSource {
|
||||||
subdirectory: subdirectory.map(Box::<std::path::Path>::from),
|
subdirectory: subdirectory.map(Box::<std::path::Path>::from),
|
||||||
},
|
},
|
||||||
)),
|
)),
|
||||||
Path { path } => Ok(Source::Path(path.into())),
|
Path { path } => Ok(Self::Path(path.into())),
|
||||||
Directory { directory } => Ok(Source::Directory(directory.into())),
|
Directory { directory } => Ok(Self::Directory(directory.into())),
|
||||||
Editable { editable } => Ok(Source::Editable(editable.into())),
|
Editable { editable } => Ok(Self::Editable(editable.into())),
|
||||||
Virtual { r#virtual } => Ok(Source::Virtual(r#virtual.into())),
|
Virtual { r#virtual } => Ok(Self::Virtual(r#virtual.into())),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -3764,8 +3757,8 @@ enum RegistrySource {
|
||||||
impl Display for RegistrySource {
|
impl Display for RegistrySource {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
RegistrySource::Url(url) => write!(f, "{url}"),
|
Self::Url(url) => write!(f, "{url}"),
|
||||||
RegistrySource::Path(path) => write!(f, "{}", path.display()),
|
Self::Path(path) => write!(f, "{}", path.display()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -3854,7 +3847,7 @@ enum GitSourceError {
|
||||||
impl GitSource {
|
impl GitSource {
|
||||||
/// Extracts a Git source reference from the query pairs and the hash
|
/// Extracts a Git source reference from the query pairs and the hash
|
||||||
/// fragment in the given URL.
|
/// fragment in the given URL.
|
||||||
fn from_url(url: &Url) -> Result<GitSource, GitSourceError> {
|
fn from_url(url: &Url) -> Result<Self, GitSourceError> {
|
||||||
let mut kind = GitSourceKind::DefaultBranch;
|
let mut kind = GitSourceKind::DefaultBranch;
|
||||||
let mut subdirectory = None;
|
let mut subdirectory = None;
|
||||||
for (key, val) in url.query_pairs() {
|
for (key, val) in url.query_pairs() {
|
||||||
|
|
@ -3869,7 +3862,7 @@ impl GitSource {
|
||||||
let precise = GitOid::from_str(url.fragment().ok_or(GitSourceError::MissingSha)?)
|
let precise = GitOid::from_str(url.fragment().ok_or(GitSourceError::MissingSha)?)
|
||||||
.map_err(|_| GitSourceError::InvalidSha)?;
|
.map_err(|_| GitSourceError::InvalidSha)?;
|
||||||
|
|
||||||
Ok(GitSource {
|
Ok(Self {
|
||||||
precise,
|
precise,
|
||||||
subdirectory,
|
subdirectory,
|
||||||
kind,
|
kind,
|
||||||
|
|
@ -3927,43 +3920,41 @@ enum SourceDist {
|
||||||
impl SourceDist {
|
impl SourceDist {
|
||||||
fn filename(&self) -> Option<Cow<str>> {
|
fn filename(&self) -> Option<Cow<str>> {
|
||||||
match self {
|
match self {
|
||||||
SourceDist::Metadata { .. } => None,
|
Self::Metadata { .. } => None,
|
||||||
SourceDist::Url { url, .. } => url.filename().ok(),
|
Self::Url { url, .. } => url.filename().ok(),
|
||||||
SourceDist::Path { path, .. } => {
|
Self::Path { path, .. } => path.file_name().map(|filename| filename.to_string_lossy()),
|
||||||
path.file_name().map(|filename| filename.to_string_lossy())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn url(&self) -> Option<&UrlString> {
|
fn url(&self) -> Option<&UrlString> {
|
||||||
match &self {
|
match &self {
|
||||||
SourceDist::Metadata { .. } => None,
|
Self::Metadata { .. } => None,
|
||||||
SourceDist::Url { url, .. } => Some(url),
|
Self::Url { url, .. } => Some(url),
|
||||||
SourceDist::Path { .. } => None,
|
Self::Path { .. } => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn hash(&self) -> Option<&Hash> {
|
pub(crate) fn hash(&self) -> Option<&Hash> {
|
||||||
match &self {
|
match &self {
|
||||||
SourceDist::Metadata { metadata } => metadata.hash.as_ref(),
|
Self::Metadata { metadata } => metadata.hash.as_ref(),
|
||||||
SourceDist::Url { metadata, .. } => metadata.hash.as_ref(),
|
Self::Url { metadata, .. } => metadata.hash.as_ref(),
|
||||||
SourceDist::Path { metadata, .. } => metadata.hash.as_ref(),
|
Self::Path { metadata, .. } => metadata.hash.as_ref(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn size(&self) -> Option<u64> {
|
pub(crate) fn size(&self) -> Option<u64> {
|
||||||
match &self {
|
match &self {
|
||||||
SourceDist::Metadata { metadata } => metadata.size,
|
Self::Metadata { metadata } => metadata.size,
|
||||||
SourceDist::Url { metadata, .. } => metadata.size,
|
Self::Url { metadata, .. } => metadata.size,
|
||||||
SourceDist::Path { metadata, .. } => metadata.size,
|
Self::Path { metadata, .. } => metadata.size,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn upload_time(&self) -> Option<Timestamp> {
|
pub(crate) fn upload_time(&self) -> Option<Timestamp> {
|
||||||
match &self {
|
match &self {
|
||||||
SourceDist::Metadata { metadata } => metadata.upload_time,
|
Self::Metadata { metadata } => metadata.upload_time,
|
||||||
SourceDist::Url { metadata, .. } => metadata.upload_time,
|
Self::Url { metadata, .. } => metadata.upload_time,
|
||||||
SourceDist::Path { metadata, .. } => metadata.upload_time,
|
Self::Path { metadata, .. } => metadata.upload_time,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -3972,11 +3963,11 @@ impl SourceDist {
|
||||||
fn from_annotated_dist(
|
fn from_annotated_dist(
|
||||||
id: &PackageId,
|
id: &PackageId,
|
||||||
annotated_dist: &AnnotatedDist,
|
annotated_dist: &AnnotatedDist,
|
||||||
) -> Result<Option<SourceDist>, LockError> {
|
) -> Result<Option<Self>, LockError> {
|
||||||
match annotated_dist.dist {
|
match annotated_dist.dist {
|
||||||
// We pass empty installed packages for locking.
|
// We pass empty installed packages for locking.
|
||||||
ResolvedDist::Installed { .. } => unreachable!(),
|
ResolvedDist::Installed { .. } => unreachable!(),
|
||||||
ResolvedDist::Installable { ref dist, .. } => SourceDist::from_dist(
|
ResolvedDist::Installable { ref dist, .. } => Self::from_dist(
|
||||||
id,
|
id,
|
||||||
dist,
|
dist,
|
||||||
annotated_dist.hashes.as_slice(),
|
annotated_dist.hashes.as_slice(),
|
||||||
|
|
@ -3990,18 +3981,16 @@ impl SourceDist {
|
||||||
dist: &Dist,
|
dist: &Dist,
|
||||||
hashes: &[HashDigest],
|
hashes: &[HashDigest],
|
||||||
index: Option<&IndexUrl>,
|
index: Option<&IndexUrl>,
|
||||||
) -> Result<Option<SourceDist>, LockError> {
|
) -> Result<Option<Self>, LockError> {
|
||||||
match *dist {
|
match *dist {
|
||||||
Dist::Built(BuiltDist::Registry(ref built_dist)) => {
|
Dist::Built(BuiltDist::Registry(ref built_dist)) => {
|
||||||
let Some(sdist) = built_dist.sdist.as_ref() else {
|
let Some(sdist) = built_dist.sdist.as_ref() else {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
};
|
};
|
||||||
SourceDist::from_registry_dist(sdist, index)
|
Self::from_registry_dist(sdist, index)
|
||||||
}
|
}
|
||||||
Dist::Built(_) => Ok(None),
|
Dist::Built(_) => Ok(None),
|
||||||
Dist::Source(ref source_dist) => {
|
Dist::Source(ref source_dist) => Self::from_source_dist(id, source_dist, hashes, index),
|
||||||
SourceDist::from_source_dist(id, source_dist, hashes, index)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4010,16 +3999,16 @@ impl SourceDist {
|
||||||
source_dist: &uv_distribution_types::SourceDist,
|
source_dist: &uv_distribution_types::SourceDist,
|
||||||
hashes: &[HashDigest],
|
hashes: &[HashDigest],
|
||||||
index: Option<&IndexUrl>,
|
index: Option<&IndexUrl>,
|
||||||
) -> Result<Option<SourceDist>, LockError> {
|
) -> Result<Option<Self>, LockError> {
|
||||||
match *source_dist {
|
match *source_dist {
|
||||||
uv_distribution_types::SourceDist::Registry(ref reg_dist) => {
|
uv_distribution_types::SourceDist::Registry(ref reg_dist) => {
|
||||||
SourceDist::from_registry_dist(reg_dist, index)
|
Self::from_registry_dist(reg_dist, index)
|
||||||
}
|
}
|
||||||
uv_distribution_types::SourceDist::DirectUrl(_) => {
|
uv_distribution_types::SourceDist::DirectUrl(_) => {
|
||||||
SourceDist::from_direct_dist(id, hashes).map(Some)
|
Self::from_direct_dist(id, hashes).map(Some)
|
||||||
}
|
}
|
||||||
uv_distribution_types::SourceDist::Path(_) => {
|
uv_distribution_types::SourceDist::Path(_) => {
|
||||||
SourceDist::from_path_dist(id, hashes).map(Some)
|
Self::from_path_dist(id, hashes).map(Some)
|
||||||
}
|
}
|
||||||
// An actual sdist entry in the lockfile is only required when
|
// An actual sdist entry in the lockfile is only required when
|
||||||
// it's from a registry or a direct URL. Otherwise, it's strictly
|
// it's from a registry or a direct URL. Otherwise, it's strictly
|
||||||
|
|
@ -4032,7 +4021,7 @@ impl SourceDist {
|
||||||
fn from_registry_dist(
|
fn from_registry_dist(
|
||||||
reg_dist: &RegistrySourceDist,
|
reg_dist: &RegistrySourceDist,
|
||||||
index: Option<&IndexUrl>,
|
index: Option<&IndexUrl>,
|
||||||
) -> Result<Option<SourceDist>, LockError> {
|
) -> Result<Option<Self>, LockError> {
|
||||||
// Reject distributions from registries that don't match the index URL, as can occur with
|
// Reject distributions from registries that don't match the index URL, as can occur with
|
||||||
// `--find-links`.
|
// `--find-links`.
|
||||||
if index.is_none_or(|index| *index != reg_dist.index) {
|
if index.is_none_or(|index| *index != reg_dist.index) {
|
||||||
|
|
@ -4052,7 +4041,7 @@ impl SourceDist {
|
||||||
.map(Timestamp::from_millisecond)
|
.map(Timestamp::from_millisecond)
|
||||||
.transpose()
|
.transpose()
|
||||||
.map_err(LockErrorKind::InvalidTimestamp)?;
|
.map_err(LockErrorKind::InvalidTimestamp)?;
|
||||||
Ok(Some(SourceDist::Url {
|
Ok(Some(Self::Url {
|
||||||
url,
|
url,
|
||||||
metadata: SourceDistMetadata {
|
metadata: SourceDistMetadata {
|
||||||
hash,
|
hash,
|
||||||
|
|
@ -4087,7 +4076,7 @@ impl SourceDist {
|
||||||
.map(Timestamp::from_millisecond)
|
.map(Timestamp::from_millisecond)
|
||||||
.transpose()
|
.transpose()
|
||||||
.map_err(LockErrorKind::InvalidTimestamp)?;
|
.map_err(LockErrorKind::InvalidTimestamp)?;
|
||||||
Ok(Some(SourceDist::Path {
|
Ok(Some(Self::Path {
|
||||||
path,
|
path,
|
||||||
metadata: SourceDistMetadata {
|
metadata: SourceDistMetadata {
|
||||||
hash,
|
hash,
|
||||||
|
|
@ -4107,7 +4096,7 @@ impl SourceDist {
|
||||||
.map(Timestamp::from_millisecond)
|
.map(Timestamp::from_millisecond)
|
||||||
.transpose()
|
.transpose()
|
||||||
.map_err(LockErrorKind::InvalidTimestamp)?;
|
.map_err(LockErrorKind::InvalidTimestamp)?;
|
||||||
Ok(Some(SourceDist::Url {
|
Ok(Some(Self::Url {
|
||||||
url,
|
url,
|
||||||
metadata: SourceDistMetadata {
|
metadata: SourceDistMetadata {
|
||||||
hash,
|
hash,
|
||||||
|
|
@ -4120,7 +4109,7 @@ impl SourceDist {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_direct_dist(id: &PackageId, hashes: &[HashDigest]) -> Result<SourceDist, LockError> {
|
fn from_direct_dist(id: &PackageId, hashes: &[HashDigest]) -> Result<Self, LockError> {
|
||||||
let Some(hash) = hashes.iter().max().cloned().map(Hash::from) else {
|
let Some(hash) = hashes.iter().max().cloned().map(Hash::from) else {
|
||||||
let kind = LockErrorKind::Hash {
|
let kind = LockErrorKind::Hash {
|
||||||
id: id.clone(),
|
id: id.clone(),
|
||||||
|
|
@ -4129,7 +4118,7 @@ impl SourceDist {
|
||||||
};
|
};
|
||||||
return Err(kind.into());
|
return Err(kind.into());
|
||||||
};
|
};
|
||||||
Ok(SourceDist::Metadata {
|
Ok(Self::Metadata {
|
||||||
metadata: SourceDistMetadata {
|
metadata: SourceDistMetadata {
|
||||||
hash: Some(hash),
|
hash: Some(hash),
|
||||||
size: None,
|
size: None,
|
||||||
|
|
@ -4138,7 +4127,7 @@ impl SourceDist {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_path_dist(id: &PackageId, hashes: &[HashDigest]) -> Result<SourceDist, LockError> {
|
fn from_path_dist(id: &PackageId, hashes: &[HashDigest]) -> Result<Self, LockError> {
|
||||||
let Some(hash) = hashes.iter().max().cloned().map(Hash::from) else {
|
let Some(hash) = hashes.iter().max().cloned().map(Hash::from) else {
|
||||||
let kind = LockErrorKind::Hash {
|
let kind = LockErrorKind::Hash {
|
||||||
id: id.clone(),
|
id: id.clone(),
|
||||||
|
|
@ -4147,7 +4136,7 @@ impl SourceDist {
|
||||||
};
|
};
|
||||||
return Err(kind.into());
|
return Err(kind.into());
|
||||||
};
|
};
|
||||||
Ok(SourceDist::Metadata {
|
Ok(Self::Metadata {
|
||||||
metadata: SourceDistMetadata {
|
metadata: SourceDistMetadata {
|
||||||
hash: Some(hash),
|
hash: Some(hash),
|
||||||
size: None,
|
size: None,
|
||||||
|
|
@ -4181,11 +4170,11 @@ impl SourceDist {
|
||||||
fn to_toml(&self) -> Result<InlineTable, toml_edit::ser::Error> {
|
fn to_toml(&self) -> Result<InlineTable, toml_edit::ser::Error> {
|
||||||
let mut table = InlineTable::new();
|
let mut table = InlineTable::new();
|
||||||
match &self {
|
match &self {
|
||||||
SourceDist::Metadata { .. } => {}
|
Self::Metadata { .. } => {}
|
||||||
SourceDist::Url { url, .. } => {
|
Self::Url { url, .. } => {
|
||||||
table.insert("url", Value::from(url.as_ref()));
|
table.insert("url", Value::from(url.as_ref()));
|
||||||
}
|
}
|
||||||
SourceDist::Path { path, .. } => {
|
Self::Path { path, .. } => {
|
||||||
table.insert("path", Value::from(PortablePath::from(path).to_string()));
|
table.insert("path", Value::from(PortablePath::from(path).to_string()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -4206,14 +4195,14 @@ impl SourceDist {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<SourceDistWire> for SourceDist {
|
impl From<SourceDistWire> for SourceDist {
|
||||||
fn from(wire: SourceDistWire) -> SourceDist {
|
fn from(wire: SourceDistWire) -> Self {
|
||||||
match wire {
|
match wire {
|
||||||
SourceDistWire::Url { url, metadata } => SourceDist::Url { url, metadata },
|
SourceDistWire::Url { url, metadata } => Self::Url { url, metadata },
|
||||||
SourceDistWire::Path { path, metadata } => SourceDist::Path {
|
SourceDistWire::Path { path, metadata } => Self::Path {
|
||||||
path: path.into(),
|
path: path.into(),
|
||||||
metadata,
|
metadata,
|
||||||
},
|
},
|
||||||
SourceDistWire::Metadata { metadata } => SourceDist::Metadata { metadata },
|
SourceDistWire::Metadata { metadata } => Self::Metadata { metadata },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -4221,12 +4210,12 @@ impl From<SourceDistWire> for SourceDist {
|
||||||
impl From<GitReference> for GitSourceKind {
|
impl From<GitReference> for GitSourceKind {
|
||||||
fn from(value: GitReference) -> Self {
|
fn from(value: GitReference) -> Self {
|
||||||
match value {
|
match value {
|
||||||
GitReference::Branch(branch) => GitSourceKind::Branch(branch.to_string()),
|
GitReference::Branch(branch) => Self::Branch(branch.to_string()),
|
||||||
GitReference::Tag(tag) => GitSourceKind::Tag(tag.to_string()),
|
GitReference::Tag(tag) => Self::Tag(tag.to_string()),
|
||||||
GitReference::BranchOrTag(rev) => GitSourceKind::Rev(rev.to_string()),
|
GitReference::BranchOrTag(rev) => Self::Rev(rev.to_string()),
|
||||||
GitReference::BranchOrTagOrCommit(rev) => GitSourceKind::Rev(rev.to_string()),
|
GitReference::BranchOrTagOrCommit(rev) => Self::Rev(rev.to_string()),
|
||||||
GitReference::NamedRef(rev) => GitSourceKind::Rev(rev.to_string()),
|
GitReference::NamedRef(rev) => Self::Rev(rev.to_string()),
|
||||||
GitReference::DefaultBranch => GitSourceKind::DefaultBranch,
|
GitReference::DefaultBranch => Self::DefaultBranch,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -4234,10 +4223,10 @@ impl From<GitReference> for GitSourceKind {
|
||||||
impl From<GitSourceKind> for GitReference {
|
impl From<GitSourceKind> for GitReference {
|
||||||
fn from(value: GitSourceKind) -> Self {
|
fn from(value: GitSourceKind) -> Self {
|
||||||
match value {
|
match value {
|
||||||
GitSourceKind::Branch(branch) => GitReference::Branch(branch),
|
GitSourceKind::Branch(branch) => Self::Branch(branch),
|
||||||
GitSourceKind::Tag(tag) => GitReference::Tag(tag),
|
GitSourceKind::Tag(tag) => Self::Tag(tag),
|
||||||
GitSourceKind::Rev(rev) => GitReference::from_rev(rev),
|
GitSourceKind::Rev(rev) => Self::from_rev(rev),
|
||||||
GitSourceKind::DefaultBranch => GitReference::DefaultBranch,
|
GitSourceKind::DefaultBranch => Self::DefaultBranch,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -4327,11 +4316,11 @@ struct Wheel {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Wheel {
|
impl Wheel {
|
||||||
fn from_annotated_dist(annotated_dist: &AnnotatedDist) -> Result<Vec<Wheel>, LockError> {
|
fn from_annotated_dist(annotated_dist: &AnnotatedDist) -> Result<Vec<Self>, LockError> {
|
||||||
match annotated_dist.dist {
|
match annotated_dist.dist {
|
||||||
// We pass empty installed packages for locking.
|
// We pass empty installed packages for locking.
|
||||||
ResolvedDist::Installed { .. } => unreachable!(),
|
ResolvedDist::Installed { .. } => unreachable!(),
|
||||||
ResolvedDist::Installable { ref dist, .. } => Wheel::from_dist(
|
ResolvedDist::Installable { ref dist, .. } => Self::from_dist(
|
||||||
dist,
|
dist,
|
||||||
annotated_dist.hashes.as_slice(),
|
annotated_dist.hashes.as_slice(),
|
||||||
annotated_dist.index(),
|
annotated_dist.index(),
|
||||||
|
|
@ -4343,9 +4332,9 @@ impl Wheel {
|
||||||
dist: &Dist,
|
dist: &Dist,
|
||||||
hashes: &[HashDigest],
|
hashes: &[HashDigest],
|
||||||
index: Option<&IndexUrl>,
|
index: Option<&IndexUrl>,
|
||||||
) -> Result<Vec<Wheel>, LockError> {
|
) -> Result<Vec<Self>, LockError> {
|
||||||
match *dist {
|
match *dist {
|
||||||
Dist::Built(ref built_dist) => Wheel::from_built_dist(built_dist, hashes, index),
|
Dist::Built(ref built_dist) => Self::from_built_dist(built_dist, hashes, index),
|
||||||
Dist::Source(uv_distribution_types::SourceDist::Registry(ref source_dist)) => {
|
Dist::Source(uv_distribution_types::SourceDist::Registry(ref source_dist)) => {
|
||||||
source_dist
|
source_dist
|
||||||
.wheels
|
.wheels
|
||||||
|
|
@ -4355,7 +4344,7 @@ impl Wheel {
|
||||||
// `--find-links`.
|
// `--find-links`.
|
||||||
index.is_some_and(|index| *index == wheel.index)
|
index.is_some_and(|index| *index == wheel.index)
|
||||||
})
|
})
|
||||||
.map(Wheel::from_registry_wheel)
|
.map(Self::from_registry_wheel)
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
Dist::Source(_) => Ok(vec![]),
|
Dist::Source(_) => Ok(vec![]),
|
||||||
|
|
@ -4366,20 +4355,20 @@ impl Wheel {
|
||||||
built_dist: &BuiltDist,
|
built_dist: &BuiltDist,
|
||||||
hashes: &[HashDigest],
|
hashes: &[HashDigest],
|
||||||
index: Option<&IndexUrl>,
|
index: Option<&IndexUrl>,
|
||||||
) -> Result<Vec<Wheel>, LockError> {
|
) -> Result<Vec<Self>, LockError> {
|
||||||
match *built_dist {
|
match *built_dist {
|
||||||
BuiltDist::Registry(ref reg_dist) => Wheel::from_registry_dist(reg_dist, index),
|
BuiltDist::Registry(ref reg_dist) => Self::from_registry_dist(reg_dist, index),
|
||||||
BuiltDist::DirectUrl(ref direct_dist) => {
|
BuiltDist::DirectUrl(ref direct_dist) => {
|
||||||
Ok(vec![Wheel::from_direct_dist(direct_dist, hashes)])
|
Ok(vec![Self::from_direct_dist(direct_dist, hashes)])
|
||||||
}
|
}
|
||||||
BuiltDist::Path(ref path_dist) => Ok(vec![Wheel::from_path_dist(path_dist, hashes)]),
|
BuiltDist::Path(ref path_dist) => Ok(vec![Self::from_path_dist(path_dist, hashes)]),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_registry_dist(
|
fn from_registry_dist(
|
||||||
reg_dist: &RegistryBuiltDist,
|
reg_dist: &RegistryBuiltDist,
|
||||||
index: Option<&IndexUrl>,
|
index: Option<&IndexUrl>,
|
||||||
) -> Result<Vec<Wheel>, LockError> {
|
) -> Result<Vec<Self>, LockError> {
|
||||||
reg_dist
|
reg_dist
|
||||||
.wheels
|
.wheels
|
||||||
.iter()
|
.iter()
|
||||||
|
|
@ -4388,11 +4377,11 @@ impl Wheel {
|
||||||
// `--find-links`.
|
// `--find-links`.
|
||||||
index.is_some_and(|index| *index == wheel.index)
|
index.is_some_and(|index| *index == wheel.index)
|
||||||
})
|
})
|
||||||
.map(Wheel::from_registry_wheel)
|
.map(Self::from_registry_wheel)
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_registry_wheel(wheel: &RegistryBuiltWheel) -> Result<Wheel, LockError> {
|
fn from_registry_wheel(wheel: &RegistryBuiltWheel) -> Result<Self, LockError> {
|
||||||
let url = match &wheel.index {
|
let url = match &wheel.index {
|
||||||
IndexUrl::Pypi(_) | IndexUrl::Url(_) => {
|
IndexUrl::Pypi(_) | IndexUrl::Url(_) => {
|
||||||
let url = normalize_file_location(&wheel.file.url)
|
let url = normalize_file_location(&wheel.file.url)
|
||||||
|
|
@ -4432,7 +4421,7 @@ impl Wheel {
|
||||||
.map(Timestamp::from_millisecond)
|
.map(Timestamp::from_millisecond)
|
||||||
.transpose()
|
.transpose()
|
||||||
.map_err(LockErrorKind::InvalidTimestamp)?;
|
.map_err(LockErrorKind::InvalidTimestamp)?;
|
||||||
Ok(Wheel {
|
Ok(Self {
|
||||||
url,
|
url,
|
||||||
hash,
|
hash,
|
||||||
size,
|
size,
|
||||||
|
|
@ -4441,8 +4430,8 @@ impl Wheel {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_direct_dist(direct_dist: &DirectUrlBuiltDist, hashes: &[HashDigest]) -> Wheel {
|
fn from_direct_dist(direct_dist: &DirectUrlBuiltDist, hashes: &[HashDigest]) -> Self {
|
||||||
Wheel {
|
Self {
|
||||||
url: WheelWireSource::Url {
|
url: WheelWireSource::Url {
|
||||||
url: normalize_url(direct_dist.url.to_url()),
|
url: normalize_url(direct_dist.url.to_url()),
|
||||||
},
|
},
|
||||||
|
|
@ -4453,8 +4442,8 @@ impl Wheel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_path_dist(path_dist: &PathBuiltDist, hashes: &[HashDigest]) -> Wheel {
|
fn from_path_dist(path_dist: &PathBuiltDist, hashes: &[HashDigest]) -> Self {
|
||||||
Wheel {
|
Self {
|
||||||
url: WheelWireSource::Filename {
|
url: WheelWireSource::Filename {
|
||||||
filename: path_dist.filename.clone(),
|
filename: path_dist.filename.clone(),
|
||||||
},
|
},
|
||||||
|
|
@ -4634,7 +4623,7 @@ impl Wheel {
|
||||||
impl TryFrom<WheelWire> for Wheel {
|
impl TryFrom<WheelWire> for Wheel {
|
||||||
type Error = String;
|
type Error = String;
|
||||||
|
|
||||||
fn try_from(wire: WheelWire) -> Result<Wheel, String> {
|
fn try_from(wire: WheelWire) -> Result<Self, String> {
|
||||||
let filename = match &wire.url {
|
let filename = match &wire.url {
|
||||||
WheelWireSource::Url { url } => {
|
WheelWireSource::Url { url } => {
|
||||||
let filename = url.filename().map_err(|err| err.to_string())?;
|
let filename = url.filename().map_err(|err| err.to_string())?;
|
||||||
|
|
@ -4656,7 +4645,7 @@ impl TryFrom<WheelWire> for Wheel {
|
||||||
WheelWireSource::Filename { filename } => filename.clone(),
|
WheelWireSource::Filename { filename } => filename.clone(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(Wheel {
|
Ok(Self {
|
||||||
url: wire.url,
|
url: wire.url,
|
||||||
hash: wire.hash,
|
hash: wire.hash,
|
||||||
size: wire.size,
|
size: wire.size,
|
||||||
|
|
@ -4703,10 +4692,10 @@ impl Dependency {
|
||||||
package_id: PackageId,
|
package_id: PackageId,
|
||||||
extra: BTreeSet<ExtraName>,
|
extra: BTreeSet<ExtraName>,
|
||||||
complexified_marker: UniversalMarker,
|
complexified_marker: UniversalMarker,
|
||||||
) -> Dependency {
|
) -> Self {
|
||||||
let simplified_marker =
|
let simplified_marker =
|
||||||
SimplifiedMarkerTree::new(requires_python, complexified_marker.combined());
|
SimplifiedMarkerTree::new(requires_python, complexified_marker.combined());
|
||||||
Dependency {
|
Self {
|
||||||
package_id,
|
package_id,
|
||||||
extra,
|
extra,
|
||||||
simplified_marker,
|
simplified_marker,
|
||||||
|
|
@ -4719,10 +4708,10 @@ impl Dependency {
|
||||||
annotated_dist: &AnnotatedDist,
|
annotated_dist: &AnnotatedDist,
|
||||||
complexified_marker: UniversalMarker,
|
complexified_marker: UniversalMarker,
|
||||||
root: &Path,
|
root: &Path,
|
||||||
) -> Result<Dependency, LockError> {
|
) -> Result<Self, LockError> {
|
||||||
let package_id = PackageId::from_annotated_dist(annotated_dist, root)?;
|
let package_id = PackageId::from_annotated_dist(annotated_dist, root)?;
|
||||||
let extra = annotated_dist.extra.iter().cloned().collect();
|
let extra = annotated_dist.extra.iter().cloned().collect();
|
||||||
Ok(Dependency::new(
|
Ok(Self::new(
|
||||||
requires_python,
|
requires_python,
|
||||||
package_id,
|
package_id,
|
||||||
extra,
|
extra,
|
||||||
|
|
@ -4813,22 +4802,22 @@ impl DependencyWire {
|
||||||
struct Hash(HashDigest);
|
struct Hash(HashDigest);
|
||||||
|
|
||||||
impl From<HashDigest> for Hash {
|
impl From<HashDigest> for Hash {
|
||||||
fn from(hd: HashDigest) -> Hash {
|
fn from(hd: HashDigest) -> Self {
|
||||||
Hash(hd)
|
Self(hd)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FromStr for Hash {
|
impl FromStr for Hash {
|
||||||
type Err = HashParseError;
|
type Err = HashParseError;
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<Hash, HashParseError> {
|
fn from_str(s: &str) -> Result<Self, HashParseError> {
|
||||||
let (algorithm, digest) = s.split_once(':').ok_or(HashParseError(
|
let (algorithm, digest) = s.split_once(':').ok_or(HashParseError(
|
||||||
"expected '{algorithm}:{digest}', but found no ':' in hash digest",
|
"expected '{algorithm}:{digest}', but found no ':' in hash digest",
|
||||||
))?;
|
))?;
|
||||||
let algorithm = algorithm
|
let algorithm = algorithm
|
||||||
.parse()
|
.parse()
|
||||||
.map_err(|_| HashParseError("unrecognized hash algorithm"))?;
|
.map_err(|_| HashParseError("unrecognized hash algorithm"))?;
|
||||||
Ok(Hash(HashDigest {
|
Ok(Self(HashDigest {
|
||||||
algorithm,
|
algorithm,
|
||||||
digest: digest.into(),
|
digest: digest.into(),
|
||||||
}))
|
}))
|
||||||
|
|
@ -4842,7 +4831,7 @@ impl Display for Hash {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'de> serde::Deserialize<'de> for Hash {
|
impl<'de> serde::Deserialize<'de> for Hash {
|
||||||
fn deserialize<D>(deserializer: D) -> Result<Hash, D::Error>
|
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||||
where
|
where
|
||||||
D: serde::de::Deserializer<'de>,
|
D: serde::de::Deserializer<'de>,
|
||||||
{
|
{
|
||||||
|
|
@ -4867,35 +4856,35 @@ impl<'de> serde::Deserialize<'de> for Hash {
|
||||||
impl From<Hash> for Hashes {
|
impl From<Hash> for Hashes {
|
||||||
fn from(value: Hash) -> Self {
|
fn from(value: Hash) -> Self {
|
||||||
match value.0.algorithm {
|
match value.0.algorithm {
|
||||||
HashAlgorithm::Md5 => Hashes {
|
HashAlgorithm::Md5 => Self {
|
||||||
md5: Some(value.0.digest),
|
md5: Some(value.0.digest),
|
||||||
sha256: None,
|
sha256: None,
|
||||||
sha384: None,
|
sha384: None,
|
||||||
sha512: None,
|
sha512: None,
|
||||||
blake2b: None,
|
blake2b: None,
|
||||||
},
|
},
|
||||||
HashAlgorithm::Sha256 => Hashes {
|
HashAlgorithm::Sha256 => Self {
|
||||||
md5: None,
|
md5: None,
|
||||||
sha256: Some(value.0.digest),
|
sha256: Some(value.0.digest),
|
||||||
sha384: None,
|
sha384: None,
|
||||||
sha512: None,
|
sha512: None,
|
||||||
blake2b: None,
|
blake2b: None,
|
||||||
},
|
},
|
||||||
HashAlgorithm::Sha384 => Hashes {
|
HashAlgorithm::Sha384 => Self {
|
||||||
md5: None,
|
md5: None,
|
||||||
sha256: None,
|
sha256: None,
|
||||||
sha384: Some(value.0.digest),
|
sha384: Some(value.0.digest),
|
||||||
sha512: None,
|
sha512: None,
|
||||||
blake2b: None,
|
blake2b: None,
|
||||||
},
|
},
|
||||||
HashAlgorithm::Sha512 => Hashes {
|
HashAlgorithm::Sha512 => Self {
|
||||||
md5: None,
|
md5: None,
|
||||||
sha256: None,
|
sha256: None,
|
||||||
sha384: None,
|
sha384: None,
|
||||||
sha512: Some(value.0.digest),
|
sha512: Some(value.0.digest),
|
||||||
blake2b: None,
|
blake2b: None,
|
||||||
},
|
},
|
||||||
HashAlgorithm::Blake2b => Hashes {
|
HashAlgorithm::Blake2b => Self {
|
||||||
md5: None,
|
md5: None,
|
||||||
sha256: None,
|
sha256: None,
|
||||||
sha384: None,
|
sha384: None,
|
||||||
|
|
@ -5122,7 +5111,7 @@ where
|
||||||
LockErrorKind: From<E>,
|
LockErrorKind: From<E>,
|
||||||
{
|
{
|
||||||
fn from(err: E) -> Self {
|
fn from(err: E) -> Self {
|
||||||
LockError {
|
Self {
|
||||||
kind: Box::new(LockErrorKind::from(err)),
|
kind: Box::new(LockErrorKind::from(err)),
|
||||||
hint: None,
|
hint: None,
|
||||||
}
|
}
|
||||||
|
|
@ -5165,7 +5154,7 @@ impl WheelTagHint {
|
||||||
version: Option<&Version>,
|
version: Option<&Version>,
|
||||||
filenames: &[&WheelFilename],
|
filenames: &[&WheelFilename],
|
||||||
tags: &Tags,
|
tags: &Tags,
|
||||||
) -> Option<WheelTagHint> {
|
) -> Option<Self> {
|
||||||
let incompatibility = filenames
|
let incompatibility = filenames
|
||||||
.iter()
|
.iter()
|
||||||
.map(|filename| {
|
.map(|filename| {
|
||||||
|
|
@ -5183,7 +5172,7 @@ impl WheelTagHint {
|
||||||
if tags.is_empty() {
|
if tags.is_empty() {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
Some(WheelTagHint::LanguageTags {
|
Some(Self::LanguageTags {
|
||||||
package: name.clone(),
|
package: name.clone(),
|
||||||
version: version.cloned(),
|
version: version.cloned(),
|
||||||
tags,
|
tags,
|
||||||
|
|
@ -5207,7 +5196,7 @@ impl WheelTagHint {
|
||||||
if tags.is_empty() {
|
if tags.is_empty() {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
Some(WheelTagHint::AbiTags {
|
Some(Self::AbiTags {
|
||||||
package: name.clone(),
|
package: name.clone(),
|
||||||
version: version.cloned(),
|
version: version.cloned(),
|
||||||
tags,
|
tags,
|
||||||
|
|
@ -5223,7 +5212,7 @@ impl WheelTagHint {
|
||||||
if tags.is_empty() {
|
if tags.is_empty() {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
Some(WheelTagHint::PlatformTags {
|
Some(Self::PlatformTags {
|
||||||
package: name.clone(),
|
package: name.clone(),
|
||||||
version: version.cloned(),
|
version: version.cloned(),
|
||||||
tags,
|
tags,
|
||||||
|
|
|
||||||
|
|
@ -109,17 +109,17 @@ impl PrereleaseStrategy {
|
||||||
env: &ResolverEnvironment,
|
env: &ResolverEnvironment,
|
||||||
) -> AllowPrerelease {
|
) -> AllowPrerelease {
|
||||||
match self {
|
match self {
|
||||||
PrereleaseStrategy::Disallow => AllowPrerelease::No,
|
Self::Disallow => AllowPrerelease::No,
|
||||||
PrereleaseStrategy::Allow => AllowPrerelease::Yes,
|
Self::Allow => AllowPrerelease::Yes,
|
||||||
PrereleaseStrategy::IfNecessary => AllowPrerelease::IfNecessary,
|
Self::IfNecessary => AllowPrerelease::IfNecessary,
|
||||||
PrereleaseStrategy::Explicit(packages) => {
|
Self::Explicit(packages) => {
|
||||||
if packages.contains(package_name, env) {
|
if packages.contains(package_name, env) {
|
||||||
AllowPrerelease::Yes
|
AllowPrerelease::Yes
|
||||||
} else {
|
} else {
|
||||||
AllowPrerelease::No
|
AllowPrerelease::No
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PrereleaseStrategy::IfNecessaryOrExplicit(packages) => {
|
Self::IfNecessaryOrExplicit(packages) => {
|
||||||
if packages.contains(package_name, env) {
|
if packages.contains(package_name, env) {
|
||||||
AllowPrerelease::Yes
|
AllowPrerelease::Yes
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -89,12 +89,12 @@ impl PubGrubDependency {
|
||||||
url,
|
url,
|
||||||
} = requirement;
|
} = requirement;
|
||||||
match &*package {
|
match &*package {
|
||||||
PubGrubPackageInner::Package { .. } => PubGrubDependency {
|
PubGrubPackageInner::Package { .. } => Self {
|
||||||
package,
|
package,
|
||||||
version,
|
version,
|
||||||
url,
|
url,
|
||||||
},
|
},
|
||||||
PubGrubPackageInner::Marker { .. } => PubGrubDependency {
|
PubGrubPackageInner::Marker { .. } => Self {
|
||||||
package,
|
package,
|
||||||
version,
|
version,
|
||||||
url,
|
url,
|
||||||
|
|
@ -107,7 +107,7 @@ impl PubGrubDependency {
|
||||||
"extras not flattened for {name}"
|
"extras not flattened for {name}"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
PubGrubDependency {
|
Self {
|
||||||
package,
|
package,
|
||||||
version,
|
version,
|
||||||
url,
|
url,
|
||||||
|
|
@ -121,7 +121,7 @@ impl PubGrubDependency {
|
||||||
"group not flattened for {name}"
|
"group not flattened for {name}"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
PubGrubDependency {
|
Self {
|
||||||
package,
|
package,
|
||||||
version,
|
version,
|
||||||
url,
|
url,
|
||||||
|
|
@ -227,7 +227,7 @@ impl PubGrubRequirement {
|
||||||
extra: Option<ExtraName>,
|
extra: Option<ExtraName>,
|
||||||
group: Option<GroupName>,
|
group: Option<GroupName>,
|
||||||
requirement: &Requirement,
|
requirement: &Requirement,
|
||||||
) -> PubGrubRequirement {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
package: PubGrubPackage::from_package(
|
package: PubGrubPackage::from_package(
|
||||||
requirement.name.clone(),
|
requirement.name.clone(),
|
||||||
|
|
|
||||||
|
|
@ -370,8 +370,8 @@ impl std::fmt::Display for PubGrubPackageInner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<&PubGrubPackage> for PubGrubPackage {
|
impl From<&Self> for PubGrubPackage {
|
||||||
fn from(package: &PubGrubPackage) -> Self {
|
fn from(package: &Self) -> Self {
|
||||||
package.clone()
|
package.clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2011,7 +2011,7 @@ impl<'a> DependsOn<'a> {
|
||||||
/// Adds an additional dependency.
|
/// Adds an additional dependency.
|
||||||
///
|
///
|
||||||
/// Note this overwrites previous calls to `DependsOn::and`.
|
/// Note this overwrites previous calls to `DependsOn::and`.
|
||||||
fn and(mut self, package: &'a PubGrubPackage, range: &'a Range<Version>) -> DependsOn<'a> {
|
fn and(mut self, package: &'a PubGrubPackage, range: &'a Range<Version>) -> Self {
|
||||||
self.dependency2 = Some(PackageRange {
|
self.dependency2 = Some(PackageRange {
|
||||||
package,
|
package,
|
||||||
range,
|
range,
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ impl<'a> DisplayResolutionGraph<'a> {
|
||||||
include_annotations: bool,
|
include_annotations: bool,
|
||||||
include_index_annotation: bool,
|
include_index_annotation: bool,
|
||||||
annotation_style: AnnotationStyle,
|
annotation_style: AnnotationStyle,
|
||||||
) -> DisplayResolutionGraph<'a> {
|
) -> Self {
|
||||||
for fork_marker in &underlying.fork_markers {
|
for fork_marker in &underlying.fork_markers {
|
||||||
assert!(
|
assert!(
|
||||||
fork_marker.conflict().is_true(),
|
fork_marker.conflict().is_true(),
|
||||||
|
|
|
||||||
|
|
@ -68,15 +68,15 @@ pub(crate) enum ResolutionGraphNode {
|
||||||
impl ResolutionGraphNode {
|
impl ResolutionGraphNode {
|
||||||
pub(crate) fn marker(&self) -> &UniversalMarker {
|
pub(crate) fn marker(&self) -> &UniversalMarker {
|
||||||
match self {
|
match self {
|
||||||
ResolutionGraphNode::Root => &UniversalMarker::TRUE,
|
Self::Root => &UniversalMarker::TRUE,
|
||||||
ResolutionGraphNode::Dist(dist) => &dist.marker,
|
Self::Dist(dist) => &dist.marker,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn package_extra_names(&self) -> Option<(&PackageName, &ExtraName)> {
|
pub(crate) fn package_extra_names(&self) -> Option<(&PackageName, &ExtraName)> {
|
||||||
match *self {
|
match *self {
|
||||||
ResolutionGraphNode::Root => None,
|
Self::Root => None,
|
||||||
ResolutionGraphNode::Dist(ref dist) => {
|
Self::Dist(ref dist) => {
|
||||||
let extra = dist.extra.as_ref()?;
|
let extra = dist.extra.as_ref()?;
|
||||||
Some((&dist.name, extra))
|
Some((&dist.name, extra))
|
||||||
}
|
}
|
||||||
|
|
@ -85,8 +85,8 @@ impl ResolutionGraphNode {
|
||||||
|
|
||||||
pub(crate) fn package_group_names(&self) -> Option<(&PackageName, &GroupName)> {
|
pub(crate) fn package_group_names(&self) -> Option<(&PackageName, &GroupName)> {
|
||||||
match *self {
|
match *self {
|
||||||
ResolutionGraphNode::Root => None,
|
Self::Root => None,
|
||||||
ResolutionGraphNode::Dist(ref dist) => {
|
Self::Dist(ref dist) => {
|
||||||
let group = dist.dev.as_ref()?;
|
let group = dist.dev.as_ref()?;
|
||||||
Some((&dist.name, group))
|
Some((&dist.name, group))
|
||||||
}
|
}
|
||||||
|
|
@ -95,8 +95,8 @@ impl ResolutionGraphNode {
|
||||||
|
|
||||||
pub(crate) fn package_name(&self) -> Option<&PackageName> {
|
pub(crate) fn package_name(&self) -> Option<&PackageName> {
|
||||||
match *self {
|
match *self {
|
||||||
ResolutionGraphNode::Root => None,
|
Self::Root => None,
|
||||||
ResolutionGraphNode::Dist(ref dist) => Some(&dist.name),
|
Self::Dist(ref dist) => Some(&dist.name),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -104,8 +104,8 @@ impl ResolutionGraphNode {
|
||||||
impl Display for ResolutionGraphNode {
|
impl Display for ResolutionGraphNode {
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
ResolutionGraphNode::Root => f.write_str("root"),
|
Self::Root => f.write_str("root"),
|
||||||
ResolutionGraphNode::Dist(dist) => Display::fmt(dist, f),
|
Self::Dist(dist) => Display::fmt(dist, f),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -832,7 +832,7 @@ impl std::error::Error for ConflictingDistributionError {}
|
||||||
|
|
||||||
impl Display for ConflictingDistributionError {
|
impl Display for ConflictingDistributionError {
|
||||||
fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
|
fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
|
||||||
let ConflictingDistributionError {
|
let Self {
|
||||||
ref name,
|
ref name,
|
||||||
ref version1,
|
ref version1,
|
||||||
ref version2,
|
ref version2,
|
||||||
|
|
@ -928,7 +928,7 @@ impl From<ResolverOutput> for uv_distribution_types::Resolution {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uv_distribution_types::Resolution::new(transformed).with_diagnostics(diagnostics)
|
Self::new(transformed).with_diagnostics(diagnostics)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,12 +48,12 @@ pub enum UnavailableVersion {
|
||||||
impl UnavailableVersion {
|
impl UnavailableVersion {
|
||||||
pub(crate) fn message(&self) -> String {
|
pub(crate) fn message(&self) -> String {
|
||||||
match self {
|
match self {
|
||||||
UnavailableVersion::IncompatibleDist(invalid_dist) => format!("{invalid_dist}"),
|
Self::IncompatibleDist(invalid_dist) => format!("{invalid_dist}"),
|
||||||
UnavailableVersion::InvalidMetadata => "invalid metadata".into(),
|
Self::InvalidMetadata => "invalid metadata".into(),
|
||||||
UnavailableVersion::InconsistentMetadata => "inconsistent metadata".into(),
|
Self::InconsistentMetadata => "inconsistent metadata".into(),
|
||||||
UnavailableVersion::InvalidStructure => "an invalid package format".into(),
|
Self::InvalidStructure => "an invalid package format".into(),
|
||||||
UnavailableVersion::Offline => "to be downloaded from a registry".into(),
|
Self::Offline => "to be downloaded from a registry".into(),
|
||||||
UnavailableVersion::RequiresPython(requires_python) => {
|
Self::RequiresPython(requires_python) => {
|
||||||
format!("Python {requires_python}")
|
format!("Python {requires_python}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -61,23 +61,23 @@ impl UnavailableVersion {
|
||||||
|
|
||||||
pub(crate) fn singular_message(&self) -> String {
|
pub(crate) fn singular_message(&self) -> String {
|
||||||
match self {
|
match self {
|
||||||
UnavailableVersion::IncompatibleDist(invalid_dist) => invalid_dist.singular_message(),
|
Self::IncompatibleDist(invalid_dist) => invalid_dist.singular_message(),
|
||||||
UnavailableVersion::InvalidMetadata => format!("has {self}"),
|
Self::InvalidMetadata => format!("has {self}"),
|
||||||
UnavailableVersion::InconsistentMetadata => format!("has {self}"),
|
Self::InconsistentMetadata => format!("has {self}"),
|
||||||
UnavailableVersion::InvalidStructure => format!("has {self}"),
|
Self::InvalidStructure => format!("has {self}"),
|
||||||
UnavailableVersion::Offline => format!("needs {self}"),
|
Self::Offline => format!("needs {self}"),
|
||||||
UnavailableVersion::RequiresPython(..) => format!("requires {self}"),
|
Self::RequiresPython(..) => format!("requires {self}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn plural_message(&self) -> String {
|
pub(crate) fn plural_message(&self) -> String {
|
||||||
match self {
|
match self {
|
||||||
UnavailableVersion::IncompatibleDist(invalid_dist) => invalid_dist.plural_message(),
|
Self::IncompatibleDist(invalid_dist) => invalid_dist.plural_message(),
|
||||||
UnavailableVersion::InvalidMetadata => format!("have {self}"),
|
Self::InvalidMetadata => format!("have {self}"),
|
||||||
UnavailableVersion::InconsistentMetadata => format!("have {self}"),
|
Self::InconsistentMetadata => format!("have {self}"),
|
||||||
UnavailableVersion::InvalidStructure => format!("have {self}"),
|
Self::InvalidStructure => format!("have {self}"),
|
||||||
UnavailableVersion::Offline => format!("need {self}"),
|
Self::Offline => format!("need {self}"),
|
||||||
UnavailableVersion::RequiresPython(..) => format!("require {self}"),
|
Self::RequiresPython(..) => format!("require {self}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -87,14 +87,14 @@ impl UnavailableVersion {
|
||||||
requires_python: Option<AbiTag>,
|
requires_python: Option<AbiTag>,
|
||||||
) -> Option<String> {
|
) -> Option<String> {
|
||||||
match self {
|
match self {
|
||||||
UnavailableVersion::IncompatibleDist(invalid_dist) => {
|
Self::IncompatibleDist(invalid_dist) => {
|
||||||
invalid_dist.context_message(tags, requires_python)
|
invalid_dist.context_message(tags, requires_python)
|
||||||
}
|
}
|
||||||
UnavailableVersion::InvalidMetadata => None,
|
Self::InvalidMetadata => None,
|
||||||
UnavailableVersion::InconsistentMetadata => None,
|
Self::InconsistentMetadata => None,
|
||||||
UnavailableVersion::InvalidStructure => None,
|
Self::InvalidStructure => None,
|
||||||
UnavailableVersion::Offline => None,
|
Self::Offline => None,
|
||||||
UnavailableVersion::RequiresPython(..) => None,
|
Self::RequiresPython(..) => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -108,14 +108,12 @@ impl Display for UnavailableVersion {
|
||||||
impl From<&MetadataUnavailable> for UnavailableVersion {
|
impl From<&MetadataUnavailable> for UnavailableVersion {
|
||||||
fn from(reason: &MetadataUnavailable) -> Self {
|
fn from(reason: &MetadataUnavailable) -> Self {
|
||||||
match reason {
|
match reason {
|
||||||
MetadataUnavailable::Offline => UnavailableVersion::Offline,
|
MetadataUnavailable::Offline => Self::Offline,
|
||||||
MetadataUnavailable::InvalidMetadata(_) => UnavailableVersion::InvalidMetadata,
|
MetadataUnavailable::InvalidMetadata(_) => Self::InvalidMetadata,
|
||||||
MetadataUnavailable::InconsistentMetadata(_) => {
|
MetadataUnavailable::InconsistentMetadata(_) => Self::InconsistentMetadata,
|
||||||
UnavailableVersion::InconsistentMetadata
|
MetadataUnavailable::InvalidStructure(_) => Self::InvalidStructure,
|
||||||
}
|
|
||||||
MetadataUnavailable::InvalidStructure(_) => UnavailableVersion::InvalidStructure,
|
|
||||||
MetadataUnavailable::RequiresPython(requires_python, _python_version) => {
|
MetadataUnavailable::RequiresPython(requires_python, _python_version) => {
|
||||||
UnavailableVersion::RequiresPython(requires_python.clone())
|
Self::RequiresPython(requires_python.clone())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -139,21 +137,21 @@ pub enum UnavailablePackage {
|
||||||
impl UnavailablePackage {
|
impl UnavailablePackage {
|
||||||
pub(crate) fn message(&self) -> &'static str {
|
pub(crate) fn message(&self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
UnavailablePackage::NoIndex => "not found in the provided package locations",
|
Self::NoIndex => "not found in the provided package locations",
|
||||||
UnavailablePackage::Offline => "not found in the cache",
|
Self::Offline => "not found in the cache",
|
||||||
UnavailablePackage::NotFound => "not found in the package registry",
|
Self::NotFound => "not found in the package registry",
|
||||||
UnavailablePackage::InvalidMetadata(_) => "invalid metadata",
|
Self::InvalidMetadata(_) => "invalid metadata",
|
||||||
UnavailablePackage::InvalidStructure(_) => "an invalid package format",
|
Self::InvalidStructure(_) => "an invalid package format",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn singular_message(&self) -> String {
|
pub(crate) fn singular_message(&self) -> String {
|
||||||
match self {
|
match self {
|
||||||
UnavailablePackage::NoIndex => format!("was {self}"),
|
Self::NoIndex => format!("was {self}"),
|
||||||
UnavailablePackage::Offline => format!("was {self}"),
|
Self::Offline => format!("was {self}"),
|
||||||
UnavailablePackage::NotFound => format!("was {self}"),
|
Self::NotFound => format!("was {self}"),
|
||||||
UnavailablePackage::InvalidMetadata(_) => format!("has {self}"),
|
Self::InvalidMetadata(_) => format!("has {self}"),
|
||||||
UnavailablePackage::InvalidStructure(_) => format!("has {self}"),
|
Self::InvalidStructure(_) => format!("has {self}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -122,9 +122,9 @@ impl ResolverEnvironment {
|
||||||
/// This enables `uv pip`-style resolutions. That is, the resolution
|
/// This enables `uv pip`-style resolutions. That is, the resolution
|
||||||
/// returned is only guaranteed to be installable for this specific marker
|
/// returned is only guaranteed to be installable for this specific marker
|
||||||
/// environment.
|
/// environment.
|
||||||
pub fn specific(marker_env: ResolverMarkerEnvironment) -> ResolverEnvironment {
|
pub fn specific(marker_env: ResolverMarkerEnvironment) -> Self {
|
||||||
let kind = Kind::Specific { marker_env };
|
let kind = Kind::Specific { marker_env };
|
||||||
ResolverEnvironment { kind }
|
Self { kind }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a resolver environment for producing a multi-platform
|
/// Create a resolver environment for producing a multi-platform
|
||||||
|
|
@ -145,14 +145,14 @@ impl ResolverEnvironment {
|
||||||
/// the order of dependencies specified is also significant but has no
|
/// the order of dependencies specified is also significant but has no
|
||||||
/// specific guarantees around it). Changing the ordering can help when our
|
/// specific guarantees around it). Changing the ordering can help when our
|
||||||
/// custom fork prioritization fails.
|
/// custom fork prioritization fails.
|
||||||
pub fn universal(initial_forks: Vec<MarkerTree>) -> ResolverEnvironment {
|
pub fn universal(initial_forks: Vec<MarkerTree>) -> Self {
|
||||||
let kind = Kind::Universal {
|
let kind = Kind::Universal {
|
||||||
initial_forks: initial_forks.into(),
|
initial_forks: initial_forks.into(),
|
||||||
markers: MarkerTree::TRUE,
|
markers: MarkerTree::TRUE,
|
||||||
include: Arc::new(crate::FxHashbrownSet::default()),
|
include: Arc::new(crate::FxHashbrownSet::default()),
|
||||||
exclude: Arc::new(crate::FxHashbrownSet::default()),
|
exclude: Arc::new(crate::FxHashbrownSet::default()),
|
||||||
};
|
};
|
||||||
ResolverEnvironment { kind }
|
Self { kind }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the marker environment corresponding to this resolver
|
/// Returns the marker environment corresponding to this resolver
|
||||||
|
|
@ -217,7 +217,7 @@ impl ResolverEnvironment {
|
||||||
///
|
///
|
||||||
/// This panics if the resolver environment corresponds to one and only one
|
/// This panics if the resolver environment corresponds to one and only one
|
||||||
/// specific marker environment. i.e., "pip"-style resolution.
|
/// specific marker environment. i.e., "pip"-style resolution.
|
||||||
fn narrow_environment(&self, rhs: MarkerTree) -> ResolverEnvironment {
|
fn narrow_environment(&self, rhs: MarkerTree) -> Self {
|
||||||
match self.kind {
|
match self.kind {
|
||||||
Kind::Specific { .. } => {
|
Kind::Specific { .. } => {
|
||||||
unreachable!("environment narrowing only happens in universal resolution")
|
unreachable!("environment narrowing only happens in universal resolution")
|
||||||
|
|
@ -236,7 +236,7 @@ impl ResolverEnvironment {
|
||||||
include: Arc::clone(include),
|
include: Arc::clone(include),
|
||||||
exclude: Arc::clone(exclude),
|
exclude: Arc::clone(exclude),
|
||||||
};
|
};
|
||||||
ResolverEnvironment { kind }
|
Self { kind }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -263,7 +263,7 @@ impl ResolverEnvironment {
|
||||||
pub(crate) fn filter_by_group(
|
pub(crate) fn filter_by_group(
|
||||||
&self,
|
&self,
|
||||||
rules: impl IntoIterator<Item = Result<ConflictItem, ConflictItem>>,
|
rules: impl IntoIterator<Item = Result<ConflictItem, ConflictItem>>,
|
||||||
) -> Option<ResolverEnvironment> {
|
) -> Option<Self> {
|
||||||
match self.kind {
|
match self.kind {
|
||||||
Kind::Specific { .. } => {
|
Kind::Specific { .. } => {
|
||||||
unreachable!("environment narrowing only happens in universal resolution")
|
unreachable!("environment narrowing only happens in universal resolution")
|
||||||
|
|
@ -298,7 +298,7 @@ impl ResolverEnvironment {
|
||||||
include: Arc::new(include),
|
include: Arc::new(include),
|
||||||
exclude: Arc::new(exclude),
|
exclude: Arc::new(exclude),
|
||||||
};
|
};
|
||||||
Some(ResolverEnvironment { kind })
|
Some(Self { kind })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -453,10 +453,7 @@ pub(crate) enum ForkingPossibility<'d> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d> ForkingPossibility<'d> {
|
impl<'d> ForkingPossibility<'d> {
|
||||||
pub(crate) fn new(
|
pub(crate) fn new(env: &ResolverEnvironment, dep: &'d PubGrubDependency) -> Self {
|
||||||
env: &ResolverEnvironment,
|
|
||||||
dep: &'d PubGrubDependency,
|
|
||||||
) -> ForkingPossibility<'d> {
|
|
||||||
let marker = dep.package.marker();
|
let marker = dep.package.marker();
|
||||||
if !env.included_by_marker(marker) {
|
if !env.included_by_marker(marker) {
|
||||||
ForkingPossibility::DependencyAlwaysExcluded
|
ForkingPossibility::DependencyAlwaysExcluded
|
||||||
|
|
@ -479,7 +476,7 @@ pub(crate) struct Forker<'d> {
|
||||||
marker: MarkerTree,
|
marker: MarkerTree,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d> Forker<'d> {
|
impl Forker<'_> {
|
||||||
/// Attempt a fork based on the given resolver environment.
|
/// Attempt a fork based on the given resolver environment.
|
||||||
///
|
///
|
||||||
/// If a fork is possible, then a new forker and at least one new
|
/// If a fork is possible, then a new forker and at least one new
|
||||||
|
|
@ -490,7 +487,7 @@ impl<'d> Forker<'d> {
|
||||||
pub(crate) fn fork(
|
pub(crate) fn fork(
|
||||||
&self,
|
&self,
|
||||||
env: &ResolverEnvironment,
|
env: &ResolverEnvironment,
|
||||||
) -> Option<(Forker<'d>, Vec<ResolverEnvironment>)> {
|
) -> Option<(Self, Vec<ResolverEnvironment>)> {
|
||||||
if !env.included_by_marker(self.marker) {
|
if !env.included_by_marker(self.marker) {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3327,7 +3327,7 @@ pub(crate) enum Request {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> From<ResolvedDistRef<'a>> for Request {
|
impl<'a> From<ResolvedDistRef<'a>> for Request {
|
||||||
fn from(dist: ResolvedDistRef<'a>) -> Request {
|
fn from(dist: ResolvedDistRef<'a>) -> Self {
|
||||||
// N.B. This is almost identical to `ResolvedDistRef::to_owned`, but
|
// N.B. This is almost identical to `ResolvedDistRef::to_owned`, but
|
||||||
// creates a `Request` instead of a `ResolvedDist`. There's probably
|
// creates a `Request` instead of a `ResolvedDist`. There's probably
|
||||||
// some room for DRYing this up a bit. The obvious way would be to
|
// some room for DRYing this up a bit. The obvious way would be to
|
||||||
|
|
@ -3343,7 +3343,7 @@ impl<'a> From<ResolvedDistRef<'a>> for Request {
|
||||||
(&source.name, &source.version),
|
(&source.name, &source.version),
|
||||||
"expected chosen sdist to match prioritized sdist"
|
"expected chosen sdist to match prioritized sdist"
|
||||||
);
|
);
|
||||||
Request::Dist(Dist::Source(SourceDist::Registry(source)))
|
Self::Dist(Dist::Source(SourceDist::Registry(source)))
|
||||||
}
|
}
|
||||||
ResolvedDistRef::InstallableRegistryBuiltDist {
|
ResolvedDistRef::InstallableRegistryBuiltDist {
|
||||||
wheel, prioritized, ..
|
wheel, prioritized, ..
|
||||||
|
|
@ -3356,9 +3356,9 @@ impl<'a> From<ResolvedDistRef<'a>> for Request {
|
||||||
// This is okay because we're only here if the prioritized dist
|
// This is okay because we're only here if the prioritized dist
|
||||||
// has at least one wheel, so this always succeeds.
|
// has at least one wheel, so this always succeeds.
|
||||||
let built = prioritized.built_dist().expect("at least one wheel");
|
let built = prioritized.built_dist().expect("at least one wheel");
|
||||||
Request::Dist(Dist::Built(BuiltDist::Registry(built)))
|
Self::Dist(Dist::Built(BuiltDist::Registry(built)))
|
||||||
}
|
}
|
||||||
ResolvedDistRef::Installed { dist } => Request::Installed(dist.clone()),
|
ResolvedDistRef::Installed { dist } => Self::Installed(dist.clone()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -3435,9 +3435,9 @@ impl Dependencies {
|
||||||
conflicts: &Conflicts,
|
conflicts: &Conflicts,
|
||||||
) -> ForkedDependencies {
|
) -> ForkedDependencies {
|
||||||
let deps = match self {
|
let deps = match self {
|
||||||
Dependencies::Available(deps) => deps,
|
Self::Available(deps) => deps,
|
||||||
Dependencies::Unforkable(deps) => return ForkedDependencies::Unforked(deps),
|
Self::Unforkable(deps) => return ForkedDependencies::Unforked(deps),
|
||||||
Dependencies::Unavailable(err) => return ForkedDependencies::Unavailable(err),
|
Self::Unavailable(err) => return ForkedDependencies::Unavailable(err),
|
||||||
};
|
};
|
||||||
let mut name_to_deps: BTreeMap<PackageName, Vec<PubGrubDependency>> = BTreeMap::new();
|
let mut name_to_deps: BTreeMap<PackageName, Vec<PubGrubDependency>> = BTreeMap::new();
|
||||||
for dep in deps {
|
for dep in deps {
|
||||||
|
|
@ -3509,7 +3509,7 @@ impl Forks {
|
||||||
env: &ResolverEnvironment,
|
env: &ResolverEnvironment,
|
||||||
python_requirement: &PythonRequirement,
|
python_requirement: &PythonRequirement,
|
||||||
conflicts: &Conflicts,
|
conflicts: &Conflicts,
|
||||||
) -> Forks {
|
) -> Self {
|
||||||
let python_marker = python_requirement.to_marker_tree();
|
let python_marker = python_requirement.to_marker_tree();
|
||||||
|
|
||||||
let mut forks = vec![Fork::new(env.clone())];
|
let mut forks = vec![Fork::new(env.clone())];
|
||||||
|
|
@ -3673,7 +3673,7 @@ impl Forks {
|
||||||
}
|
}
|
||||||
forks = new;
|
forks = new;
|
||||||
}
|
}
|
||||||
Forks {
|
Self {
|
||||||
forks,
|
forks,
|
||||||
diverging_packages,
|
diverging_packages,
|
||||||
}
|
}
|
||||||
|
|
@ -3723,8 +3723,8 @@ struct Fork {
|
||||||
impl Fork {
|
impl Fork {
|
||||||
/// Create a new fork with no dependencies with the given resolver
|
/// Create a new fork with no dependencies with the given resolver
|
||||||
/// environment.
|
/// environment.
|
||||||
fn new(env: ResolverEnvironment) -> Fork {
|
fn new(env: ResolverEnvironment) -> Self {
|
||||||
Fork {
|
Self {
|
||||||
dependencies: vec![],
|
dependencies: vec![],
|
||||||
conflicts: crate::FxHashbrownSet::default(),
|
conflicts: crate::FxHashbrownSet::default(),
|
||||||
env,
|
env,
|
||||||
|
|
@ -3772,7 +3772,7 @@ impl Fork {
|
||||||
fn filter(
|
fn filter(
|
||||||
mut self,
|
mut self,
|
||||||
rules: impl IntoIterator<Item = Result<ConflictItem, ConflictItem>>,
|
rules: impl IntoIterator<Item = Result<ConflictItem, ConflictItem>>,
|
||||||
) -> Option<Fork> {
|
) -> Option<Self> {
|
||||||
self.env = self.env.filter_by_group(rules)?;
|
self.env = self.env.filter_by_group(rules)?;
|
||||||
self.dependencies.retain(|dep| {
|
self.dependencies.retain(|dep| {
|
||||||
let Some(conflicting_item) = dep.package.conflicting_item() else {
|
let Some(conflicting_item) = dep.package.conflicting_item() else {
|
||||||
|
|
@ -3835,7 +3835,7 @@ impl Fork {
|
||||||
impl Eq for Fork {}
|
impl Eq for Fork {}
|
||||||
|
|
||||||
impl PartialEq for Fork {
|
impl PartialEq for Fork {
|
||||||
fn eq(&self, other: &Fork) -> bool {
|
fn eq(&self, other: &Self) -> bool {
|
||||||
self.dependencies == other.dependencies && self.env == other.env
|
self.dependencies == other.dependencies && self.env == other.env
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -67,11 +67,11 @@ impl MetadataUnavailable {
|
||||||
/// formatting system is more custom.
|
/// formatting system is more custom.
|
||||||
pub(crate) fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
|
pub(crate) fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
|
||||||
match self {
|
match self {
|
||||||
MetadataUnavailable::Offline => None,
|
Self::Offline => None,
|
||||||
MetadataUnavailable::InvalidMetadata(err) => Some(err),
|
Self::InvalidMetadata(err) => Some(err),
|
||||||
MetadataUnavailable::InconsistentMetadata(err) => Some(err),
|
Self::InconsistentMetadata(err) => Some(err),
|
||||||
MetadataUnavailable::InvalidStructure(err) => Some(err),
|
Self::InvalidStructure(err) => Some(err),
|
||||||
MetadataUnavailable::RequiresPython(_, _) => None,
|
Self::RequiresPython(_, _) => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ impl std::fmt::Display for SystemDependency {
|
||||||
|
|
||||||
impl From<SystemDependency> for PubGrubDependency {
|
impl From<SystemDependency> for PubGrubDependency {
|
||||||
fn from(value: SystemDependency) -> Self {
|
fn from(value: SystemDependency) -> Self {
|
||||||
PubGrubDependency {
|
Self {
|
||||||
package: PubGrubPackage::from(PubGrubPackageInner::System(value.name)),
|
package: PubGrubPackage::from(PubGrubPackageInner::System(value.name)),
|
||||||
version: Ranges::singleton(value.version),
|
version: Ranges::singleton(value.version),
|
||||||
url: None,
|
url: None,
|
||||||
|
|
|
||||||
|
|
@ -85,30 +85,27 @@ pub struct UniversalMarker {
|
||||||
|
|
||||||
impl UniversalMarker {
|
impl UniversalMarker {
|
||||||
/// A constant universal marker that always evaluates to `true`.
|
/// A constant universal marker that always evaluates to `true`.
|
||||||
pub(crate) const TRUE: UniversalMarker = UniversalMarker {
|
pub(crate) const TRUE: Self = Self {
|
||||||
marker: MarkerTree::TRUE,
|
marker: MarkerTree::TRUE,
|
||||||
pep508: MarkerTree::TRUE,
|
pep508: MarkerTree::TRUE,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A constant universal marker that always evaluates to `false`.
|
/// A constant universal marker that always evaluates to `false`.
|
||||||
pub(crate) const FALSE: UniversalMarker = UniversalMarker {
|
pub(crate) const FALSE: Self = Self {
|
||||||
marker: MarkerTree::FALSE,
|
marker: MarkerTree::FALSE,
|
||||||
pep508: MarkerTree::FALSE,
|
pep508: MarkerTree::FALSE,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Creates a new universal marker from its constituent pieces.
|
/// Creates a new universal marker from its constituent pieces.
|
||||||
pub(crate) fn new(
|
pub(crate) fn new(mut pep508_marker: MarkerTree, conflict_marker: ConflictMarker) -> Self {
|
||||||
mut pep508_marker: MarkerTree,
|
|
||||||
conflict_marker: ConflictMarker,
|
|
||||||
) -> UniversalMarker {
|
|
||||||
pep508_marker.and(conflict_marker.marker);
|
pep508_marker.and(conflict_marker.marker);
|
||||||
UniversalMarker::from_combined(pep508_marker)
|
Self::from_combined(pep508_marker)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new universal marker from a marker that has already been
|
/// Creates a new universal marker from a marker that has already been
|
||||||
/// combined from a PEP 508 and conflict marker.
|
/// combined from a PEP 508 and conflict marker.
|
||||||
pub(crate) fn from_combined(marker: MarkerTree) -> UniversalMarker {
|
pub(crate) fn from_combined(marker: MarkerTree) -> Self {
|
||||||
UniversalMarker {
|
Self {
|
||||||
marker,
|
marker,
|
||||||
pep508: marker.without_extras(),
|
pep508: marker.without_extras(),
|
||||||
}
|
}
|
||||||
|
|
@ -117,7 +114,7 @@ impl UniversalMarker {
|
||||||
/// Combine this universal marker with the one given in a way that unions
|
/// Combine this universal marker with the one given in a way that unions
|
||||||
/// them. That is, the updated marker will evaluate to `true` if `self` or
|
/// them. That is, the updated marker will evaluate to `true` if `self` or
|
||||||
/// `other` evaluate to `true`.
|
/// `other` evaluate to `true`.
|
||||||
pub(crate) fn or(&mut self, other: UniversalMarker) {
|
pub(crate) fn or(&mut self, other: Self) {
|
||||||
self.marker.or(other.marker);
|
self.marker.or(other.marker);
|
||||||
self.pep508.or(other.pep508);
|
self.pep508.or(other.pep508);
|
||||||
}
|
}
|
||||||
|
|
@ -125,7 +122,7 @@ impl UniversalMarker {
|
||||||
/// Combine this universal marker with the one given in a way that
|
/// Combine this universal marker with the one given in a way that
|
||||||
/// intersects them. That is, the updated marker will evaluate to `true` if
|
/// intersects them. That is, the updated marker will evaluate to `true` if
|
||||||
/// `self` and `other` evaluate to `true`.
|
/// `self` and `other` evaluate to `true`.
|
||||||
pub(crate) fn and(&mut self, other: UniversalMarker) {
|
pub(crate) fn and(&mut self, other: Self) {
|
||||||
self.marker.and(other.marker);
|
self.marker.and(other.marker);
|
||||||
self.pep508.and(other.pep508);
|
self.pep508.and(other.pep508);
|
||||||
}
|
}
|
||||||
|
|
@ -230,7 +227,7 @@ impl UniversalMarker {
|
||||||
///
|
///
|
||||||
/// Two universal markers are disjoint when it is impossible for them both
|
/// Two universal markers are disjoint when it is impossible for them both
|
||||||
/// to evaluate to `true` simultaneously.
|
/// to evaluate to `true` simultaneously.
|
||||||
pub(crate) fn is_disjoint(self, other: UniversalMarker) -> bool {
|
pub(crate) fn is_disjoint(self, other: Self) -> bool {
|
||||||
self.marker.is_disjoint(other.marker)
|
self.marker.is_disjoint(other.marker)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -321,26 +318,26 @@ pub struct ConflictMarker {
|
||||||
|
|
||||||
impl ConflictMarker {
|
impl ConflictMarker {
|
||||||
/// A constant conflict marker that always evaluates to `true`.
|
/// A constant conflict marker that always evaluates to `true`.
|
||||||
pub const TRUE: ConflictMarker = ConflictMarker {
|
pub const TRUE: Self = Self {
|
||||||
marker: MarkerTree::TRUE,
|
marker: MarkerTree::TRUE,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A constant conflict marker that always evaluates to `false`.
|
/// A constant conflict marker that always evaluates to `false`.
|
||||||
pub const FALSE: ConflictMarker = ConflictMarker {
|
pub const FALSE: Self = Self {
|
||||||
marker: MarkerTree::FALSE,
|
marker: MarkerTree::FALSE,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Creates a new conflict marker from the declared conflicts provided.
|
/// Creates a new conflict marker from the declared conflicts provided.
|
||||||
pub fn from_conflicts(conflicts: &Conflicts) -> ConflictMarker {
|
pub fn from_conflicts(conflicts: &Conflicts) -> Self {
|
||||||
if conflicts.is_empty() {
|
if conflicts.is_empty() {
|
||||||
return ConflictMarker::TRUE;
|
return Self::TRUE;
|
||||||
}
|
}
|
||||||
let mut marker = ConflictMarker::TRUE;
|
let mut marker = Self::TRUE;
|
||||||
for set in conflicts.iter() {
|
for set in conflicts.iter() {
|
||||||
for (item1, item2) in set.iter().tuple_combinations() {
|
for (item1, item2) in set.iter().tuple_combinations() {
|
||||||
let pair = ConflictMarker::from_conflict_item(item1)
|
let pair = Self::from_conflict_item(item1)
|
||||||
.negate()
|
.negate()
|
||||||
.or(ConflictMarker::from_conflict_item(item2).negate());
|
.or(Self::from_conflict_item(item2).negate());
|
||||||
marker = marker.and(pair);
|
marker = marker.and(pair);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -349,37 +346,37 @@ impl ConflictMarker {
|
||||||
|
|
||||||
/// Create a conflict marker that is true only when the given extra or
|
/// Create a conflict marker that is true only when the given extra or
|
||||||
/// group (for a specific package) is activated.
|
/// group (for a specific package) is activated.
|
||||||
pub fn from_conflict_item(item: &ConflictItem) -> ConflictMarker {
|
pub fn from_conflict_item(item: &ConflictItem) -> Self {
|
||||||
match *item.conflict() {
|
match *item.conflict() {
|
||||||
ConflictPackage::Extra(ref extra) => ConflictMarker::extra(item.package(), extra),
|
ConflictPackage::Extra(ref extra) => Self::extra(item.package(), extra),
|
||||||
ConflictPackage::Group(ref group) => ConflictMarker::group(item.package(), group),
|
ConflictPackage::Group(ref group) => Self::group(item.package(), group),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a conflict marker that is true only when the given extra for the
|
/// Create a conflict marker that is true only when the given extra for the
|
||||||
/// given package is activated.
|
/// given package is activated.
|
||||||
pub fn extra(package: &PackageName, extra: &ExtraName) -> ConflictMarker {
|
pub fn extra(package: &PackageName, extra: &ExtraName) -> Self {
|
||||||
let operator = uv_pep508::ExtraOperator::Equal;
|
let operator = uv_pep508::ExtraOperator::Equal;
|
||||||
let name = uv_pep508::MarkerValueExtra::Extra(encode_package_extra(package, extra));
|
let name = uv_pep508::MarkerValueExtra::Extra(encode_package_extra(package, extra));
|
||||||
let expr = uv_pep508::MarkerExpression::Extra { operator, name };
|
let expr = uv_pep508::MarkerExpression::Extra { operator, name };
|
||||||
let marker = MarkerTree::expression(expr);
|
let marker = MarkerTree::expression(expr);
|
||||||
ConflictMarker { marker }
|
Self { marker }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a conflict marker that is true only when the given group for the
|
/// Create a conflict marker that is true only when the given group for the
|
||||||
/// given package is activated.
|
/// given package is activated.
|
||||||
pub fn group(package: &PackageName, group: &GroupName) -> ConflictMarker {
|
pub fn group(package: &PackageName, group: &GroupName) -> Self {
|
||||||
let operator = uv_pep508::ExtraOperator::Equal;
|
let operator = uv_pep508::ExtraOperator::Equal;
|
||||||
let name = uv_pep508::MarkerValueExtra::Extra(encode_package_group(package, group));
|
let name = uv_pep508::MarkerValueExtra::Extra(encode_package_group(package, group));
|
||||||
let expr = uv_pep508::MarkerExpression::Extra { operator, name };
|
let expr = uv_pep508::MarkerExpression::Extra { operator, name };
|
||||||
let marker = MarkerTree::expression(expr);
|
let marker = MarkerTree::expression(expr);
|
||||||
ConflictMarker { marker }
|
Self { marker }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a new conflict marker that is the negation of this one.
|
/// Returns a new conflict marker that is the negation of this one.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn negate(self) -> ConflictMarker {
|
pub fn negate(self) -> Self {
|
||||||
ConflictMarker {
|
Self {
|
||||||
marker: self.marker.negate(),
|
marker: self.marker.negate(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -387,19 +384,19 @@ impl ConflictMarker {
|
||||||
/// Returns a new conflict marker corresponding to the union of `self` and
|
/// Returns a new conflict marker corresponding to the union of `self` and
|
||||||
/// `other`.
|
/// `other`.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn or(self, other: ConflictMarker) -> ConflictMarker {
|
pub fn or(self, other: Self) -> Self {
|
||||||
let mut marker = self.marker;
|
let mut marker = self.marker;
|
||||||
marker.or(other.marker);
|
marker.or(other.marker);
|
||||||
ConflictMarker { marker }
|
Self { marker }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a new conflict marker corresponding to the intersection of
|
/// Returns a new conflict marker corresponding to the intersection of
|
||||||
/// `self` and `other`.
|
/// `self` and `other`.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn and(self, other: ConflictMarker) -> ConflictMarker {
|
pub fn and(self, other: Self) -> Self {
|
||||||
let mut marker = self.marker;
|
let mut marker = self.marker;
|
||||||
marker.and(other.marker);
|
marker.and(other.marker);
|
||||||
ConflictMarker { marker }
|
Self { marker }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a new conflict marker corresponding to the logical implication
|
/// Returns a new conflict marker corresponding to the logical implication
|
||||||
|
|
@ -408,10 +405,10 @@ impl ConflictMarker {
|
||||||
/// If the conflict marker returned is always `true`, then it can be said
|
/// If the conflict marker returned is always `true`, then it can be said
|
||||||
/// that `self` implies `consequent`.
|
/// that `self` implies `consequent`.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn implies(self, other: ConflictMarker) -> ConflictMarker {
|
pub fn implies(self, other: Self) -> Self {
|
||||||
let mut marker = self.marker;
|
let mut marker = self.marker;
|
||||||
marker.implies(other.marker);
|
marker.implies(other.marker);
|
||||||
ConflictMarker { marker }
|
Self { marker }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns true if this conflict marker will always evaluate to `true`.
|
/// Returns true if this conflict marker will always evaluate to `true`.
|
||||||
|
|
@ -526,7 +523,7 @@ enum ParsedRawExtra<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ParsedRawExtra<'a> {
|
impl<'a> ParsedRawExtra<'a> {
|
||||||
fn parse(raw_extra: &'a ExtraName) -> Result<ParsedRawExtra<'a>, ResolveError> {
|
fn parse(raw_extra: &'a ExtraName) -> Result<Self, ResolveError> {
|
||||||
fn mkerr(raw_extra: &ExtraName, reason: impl Into<String>) -> ResolveError {
|
fn mkerr(raw_extra: &ExtraName, reason: impl Into<String>) -> ResolveError {
|
||||||
let raw_extra = raw_extra.to_owned();
|
let raw_extra = raw_extra.to_owned();
|
||||||
let reason = reason.into();
|
let reason = reason.into();
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue