From ace6d2f592afd553f193ee2a8a617c0002a7f4bd Mon Sep 17 00:00:00 2001 From: Kelwing Date: Thu, 8 Feb 2024 03:23:26 -0500 Subject: [PATCH 1/8] fix: actually skip 404s (#204) The current method of skipping 404s when making calls to the simple API does not work, as the 404 is actually returned as a Result::Err, so the check is never reached. This PR corrects the logic so 404's are actually skipped. --------- Co-authored-by: jacob.wiltse --- .../src/index/package_database.rs | 33 +++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/crates/rattler_installs_packages/src/index/package_database.rs b/crates/rattler_installs_packages/src/index/package_database.rs index f0d062ea..36e00862 100644 --- a/crates/rattler_installs_packages/src/index/package_database.rs +++ b/crates/rattler_installs_packages/src/index/package_database.rs @@ -634,14 +634,20 @@ async fn fetch_simple_api(http: &Http, url: Url) -> miette::Result response, + Err(err) => { + if let HttpRequestError::HttpError(err) = &err { + if err.status() == Some(StatusCode::NOT_FOUND) { + return Ok(None); + } + } + return Err(err.into()); + } + }; let content_type = response .headers() @@ -820,15 +826,8 @@ mod test { .available_artifacts(ArtifactRequest::FromIndex(pytest_name.into())) .await; - // Should fail because pytest is associated with test index - assert!(pytest_result.is_err()); - match pytest_result - .unwrap_err() - .downcast_ref::() - { - Some(HttpRequestError::HttpError(e)) if e.status() == Some(StatusCode::NOT_FOUND) => (), - _ => panic!("unexpected error type"), - }; + // Should not fail because 404s are skipped + assert!(pytest_result.is_ok()); let test_package_result = package_db .available_artifacts(ArtifactRequest::FromIndex(normalized_name)) From 9f78ae00087b81b0dafb08f29f8a17b83d7db13c Mon Sep 17 00:00:00 2001 From: Kelwing Date: Thu, 8 Feb 2024 03:29:40 -0500 Subject: [PATCH 2/8] fix: only write out amount of bytes read for gzip (#203) Fixes a bug when pulling sdists where data from a previous chunk will be written to the end of the final chunk, causing gzip to throw errors. Co-authored-by: jacob.wiltse --- .../rattler_installs_packages/src/utils/streaming_or_local.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/rattler_installs_packages/src/utils/streaming_or_local.rs b/crates/rattler_installs_packages/src/utils/streaming_or_local.rs index 2802a3dd..e72d14ce 100644 --- a/crates/rattler_installs_packages/src/utils/streaming_or_local.rs +++ b/crates/rattler_installs_packages/src/utils/streaming_or_local.rs @@ -40,7 +40,7 @@ impl StreamingOrLocal { if bytes_read == 0 { break; } - local_file.write_all(&buf)?; + local_file.write_all(&buf[..bytes_read])?; } // Restart the file from the start so we can start reading from it. From 106da762c00e6b57e4fd7f3f87b31a4d7bd1deb3 Mon Sep 17 00:00:00 2001 From: Wolf Vollprecht Date: Thu, 8 Feb 2024 11:24:38 +0100 Subject: [PATCH 3/8] refactor: access PKG-INFO and pyproject.toml directly(#206) We were using a subset of these types before, now we are able to use them in completeness in the library. --- Cargo.toml | 2 -- .../src/artifacts/sdist.rs | 21 ++++++------ .../src/artifacts/stree.rs | 7 ++-- .../src/types/artifact.rs | 2 +- .../src/types/core_metadata.rs | 34 +++++++++++++++++-- .../src/types/mod.rs | 2 +- .../src/wheel_builder/build_environment.rs | 6 ++-- 7 files changed, 49 insertions(+), 25 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index aff56fc6..8a3041bc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,5 +19,3 @@ rust-version = "1.70" allow-branch = ["main"] consolidate-commits = true tag-prefix = "" - -[patch.crates-io] diff --git a/crates/rattler_installs_packages/src/artifacts/sdist.rs b/crates/rattler_installs_packages/src/artifacts/sdist.rs index 2d643397..472707cf 100644 --- a/crates/rattler_installs_packages/src/artifacts/sdist.rs +++ b/crates/rattler_installs_packages/src/artifacts/sdist.rs @@ -1,6 +1,6 @@ use crate::resolve::PypiVersion; use crate::types::{ - ArtifactFromBytes, ArtifactFromSource, HasArtifactName, NormalizedPackageName, + ArtifactFromBytes, ArtifactFromSource, HasArtifactName, NormalizedPackageName, PackageInfo, ReadPyProjectError, SDistFilename, SDistFormat, SourceArtifactName, }; use crate::types::{WheelCoreMetaDataError, WheelCoreMetadata}; @@ -105,12 +105,12 @@ impl SDist { } /// Read .PKG-INFO from the archive - pub fn read_package_info(&self) -> Result<(Vec, WheelCoreMetadata), SDistError> { + pub fn read_package_info(&self) -> Result<(Vec, PackageInfo), SDistError> { if let Some(bytes) = self .find_entry("PKG-INFO") .map_err(SDistError::PkgInfoIOError)? { - let metadata = WheelCoreMetadata::try_from(bytes.as_slice())?; + let metadata = PackageInfo::from_bytes(bytes.as_slice())?; Ok((bytes, metadata)) } else { @@ -123,6 +123,8 @@ impl SDist { pub fn pep643_metadata(&self) -> Result, WheelCoreMetadata)>, SDistError> { // Assume we have a PKG-INFO let (bytes, metadata) = self.read_package_info()?; + let metadata = + WheelCoreMetadata::try_from(metadata).map_err(SDistError::WheelCoreMetaDataError)?; if metadata.metadata_version.implements_pep643() { Ok(Some((bytes, metadata))) } else { @@ -177,7 +179,7 @@ impl ArtifactFromSource for SDist { SourceArtifactName::SDist(self.name().to_owned()) } - fn read_build_info(&self) -> Result { + fn read_pyproject_toml(&self) -> Result { if let Some(bytes) = self.find_entry("pyproject.toml")? { let source = String::from_utf8(bytes).map_err(|e| { ReadPyProjectError::PyProjectTomlParseError(format!( @@ -191,9 +193,7 @@ impl ArtifactFromSource for SDist { e )) })?; - Ok(project - .build_system - .ok_or_else(|| std::io::Error::new(ErrorKind::NotFound, "no build-system found"))?) + Ok(project) } else { Err(ReadPyProjectError::NoPyProjectTomlFound) } @@ -265,10 +265,9 @@ mod tests { use crate::python_env::Pep508EnvMakers; use crate::resolve::PypiVersion; use crate::resolve::SDistResolution; - use crate::types::PackageName; + use crate::types::{ArtifactFromSource, PackageName}; use crate::types::{ - ArtifactFromSource, ArtifactInfo, ArtifactName, DistInfoMetadata, Extra, STreeFilename, - Yanked, + ArtifactInfo, ArtifactName, DistInfoMetadata, Extra, STreeFilename, Yanked, }; use crate::wheel_builder::WheelBuilder; use crate::{index::PackageDb, resolve::ResolveOptions}; @@ -318,7 +317,7 @@ mod tests { // Load sdist let sdist = super::SDist::from_path(&path, &"rich".parse().unwrap()).unwrap(); - let build_system = sdist.read_build_info().unwrap(); + let build_system = sdist.read_pyproject_toml().unwrap().build_system.unwrap(); assert_ron_snapshot!(build_system, @r###" BuildSystem( diff --git a/crates/rattler_installs_packages/src/artifacts/stree.rs b/crates/rattler_installs_packages/src/artifacts/stree.rs index 3952ae67..3e54ba3c 100644 --- a/crates/rattler_installs_packages/src/artifacts/stree.rs +++ b/crates/rattler_installs_packages/src/artifacts/stree.rs @@ -5,7 +5,6 @@ use crate::types::{HasArtifactName, STreeFilename, SourceArtifactName}; use fs_err as fs; use std::collections::hash_map::DefaultHasher; use std::hash::{Hash, Hasher}; -use std::io::ErrorKind; use std::path::{Path, PathBuf}; /// Represents a source tree which can be a simple directory on filesystem @@ -78,7 +77,7 @@ impl ArtifactFromSource for STree { SourceArtifactName::STree(self.name.clone()) } - fn read_build_info(&self) -> Result { + fn read_pyproject_toml(&self) -> Result { let location = self.lock_data().join("pyproject.toml"); if let Ok(bytes) = fs::read(location) { @@ -94,9 +93,7 @@ impl ArtifactFromSource for STree { e )) })?; - Ok(project - .build_system - .ok_or_else(|| std::io::Error::new(ErrorKind::NotFound, "no build-system found"))?) + Ok(project) } else { Err(ReadPyProjectError::NoPyProjectTomlFound) } diff --git a/crates/rattler_installs_packages/src/types/artifact.rs b/crates/rattler_installs_packages/src/types/artifact.rs index 26e24d06..2aa0aea3 100644 --- a/crates/rattler_installs_packages/src/types/artifact.rs +++ b/crates/rattler_installs_packages/src/types/artifact.rs @@ -57,7 +57,7 @@ pub trait ArtifactFromSource: HasArtifactName + Sync { fn artifact_name(&self) -> SourceArtifactName; /// Read the build system info from the pyproject.toml - fn read_build_info(&self) -> Result; + fn read_pyproject_toml(&self) -> Result; /// extract to a specific location /// for sdist we unpack it diff --git a/crates/rattler_installs_packages/src/types/core_metadata.rs b/crates/rattler_installs_packages/src/types/core_metadata.rs index 6c3d93c0..e4f558fd 100644 --- a/crates/rattler_installs_packages/src/types/core_metadata.rs +++ b/crates/rattler_installs_packages/src/types/core_metadata.rs @@ -12,6 +12,27 @@ use pep508_rs::Requirement; use std::{collections::HashSet, str::FromStr}; use thiserror::Error; +/// Holds the parsed PKG-INFO file. +pub struct PackageInfo { + /// The parsed PKG-INFO file. + pub parsed: RFC822ish, +} + +impl PackageInfo { + /// Parse the PKG-INFO file from bytes. + pub fn from_bytes(bytes: &[u8]) -> Result { + let s = String::from_utf8_lossy(bytes); + Ok(Self { + parsed: RFC822ish::from_str(&s)?, + }) + } + + /// Create a new PackageInfo from a parsed RFC822ish. + pub fn new(parsed: RFC822ish) -> Self { + Self { parsed } + } +} + #[derive(Debug, Clone)] /// The core metadata of a wheel. @@ -89,6 +110,14 @@ impl TryFrom<&[u8]> for WheelCoreMetadata { type Error = WheelCoreMetaDataError; fn try_from(value: &[u8]) -> Result { + PackageInfo::from_bytes(value)?.try_into() + } +} + +impl TryFrom for WheelCoreMetadata { + type Error = WheelCoreMetaDataError; + + fn try_from(value: PackageInfo) -> Result { let (name, version, metadata_version, mut parsed) = parse_common(value)?; let mut requires_dist = Vec::new(); @@ -130,10 +159,9 @@ impl TryFrom<&[u8]> for WheelCoreMetadata { } fn parse_common( - input: &[u8], + input: PackageInfo, ) -> Result<(PackageName, Version, MetadataVersion, RFC822ish), WheelCoreMetaDataError> { - let input = String::from_utf8_lossy(input); - let mut parsed = RFC822ish::from_str(&input)?; + let mut parsed = input.parsed; static NEXT_MAJOR_METADATA_VERSION: Lazy = Lazy::new(|| Version::from_str("3").unwrap()); diff --git a/crates/rattler_installs_packages/src/types/mod.rs b/crates/rattler_installs_packages/src/types/mod.rs index 93ef4f6d..9ff7a785 100644 --- a/crates/rattler_installs_packages/src/types/mod.rs +++ b/crates/rattler_installs_packages/src/types/mod.rs @@ -28,7 +28,7 @@ pub use artifact_name::{ pub use direct_url_json::{DirectUrlHashes, DirectUrlJson, DirectUrlSource, DirectUrlVcs}; -pub use core_metadata::{MetadataVersion, WheelCoreMetaDataError, WheelCoreMetadata}; +pub use core_metadata::{MetadataVersion, PackageInfo, WheelCoreMetaDataError, WheelCoreMetadata}; pub use record::{Record, RecordEntry}; diff --git a/crates/rattler_installs_packages/src/wheel_builder/build_environment.rs b/crates/rattler_installs_packages/src/wheel_builder/build_environment.rs index 8b7154e3..95767570 100644 --- a/crates/rattler_installs_packages/src/wheel_builder/build_environment.rs +++ b/crates/rattler_installs_packages/src/wheel_builder/build_environment.rs @@ -361,8 +361,10 @@ impl BuildEnvironment { // Find the build system let build_system = sdist - .read_build_info() - .unwrap_or_else(|_| Self::default_build_system()); + .read_pyproject_toml() + .ok() + .and_then(|t| t.build_system) + .unwrap_or_else(Self::default_build_system); let build_system = if build_system.build_backend.is_none() { Self::default_build_system() From af4af2b033fca22f0167ed983974dd1013b20050 Mon Sep 17 00:00:00 2001 From: Wolf Vollprecht Date: Thu, 8 Feb 2024 11:25:05 +0100 Subject: [PATCH 4/8] re-export all types from pep440_rs and pep508_rs (#207) --- crates/rattler_installs_packages/src/types/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/rattler_installs_packages/src/types/mod.rs b/crates/rattler_installs_packages/src/types/mod.rs index 9ff7a785..29768d2e 100644 --- a/crates/rattler_installs_packages/src/types/mod.rs +++ b/crates/rattler_installs_packages/src/types/mod.rs @@ -42,5 +42,5 @@ pub use project_info::{ArtifactHashes, ArtifactInfo, DistInfoMetadata, Meta, Pro pub(crate) use rfc822ish::RFC822ish; -pub use pep440_rs::{Version, VersionSpecifier, VersionSpecifiers}; -pub use pep508_rs::{MarkerEnvironment, Requirement}; +pub use pep440_rs::*; +pub use pep508_rs::*; From 5d2422f38b4210429bbb2bfc0544665e2810bd05 Mon Sep 17 00:00:00 2001 From: Tim de Jager Date: Thu, 8 Feb 2024 12:05:45 +0100 Subject: [PATCH 5/8] refactor: move types in `resolve` module to seperate files for clarity (#208) It was getting hard to find the functions that you needed while browsing the module. So moved some types to their own files. No functionality has changed. --- .../src/artifacts/sdist.rs | 4 +- .../src/resolve/dependency_provider.rs | 181 +-------------- .../src/resolve/mod.rs | 11 +- .../src/resolve/pypi_version_types.rs | 178 +++++++++++++++ .../src/resolve/solve.rs | 211 +----------------- .../src/resolve/solve_options.rs | 211 ++++++++++++++++++ .../src/resolve/solve_types.rs | 1 + .../src/wheel_builder/mod.rs | 7 +- .../tests/resolver.rs | 3 +- crates/rip_bin/src/main.rs | 26 +-- 10 files changed, 427 insertions(+), 406 deletions(-) create mode 100644 crates/rattler_installs_packages/src/resolve/pypi_version_types.rs create mode 100644 crates/rattler_installs_packages/src/resolve/solve_options.rs create mode 100644 crates/rattler_installs_packages/src/resolve/solve_types.rs diff --git a/crates/rattler_installs_packages/src/artifacts/sdist.rs b/crates/rattler_installs_packages/src/artifacts/sdist.rs index 472707cf..429971e8 100644 --- a/crates/rattler_installs_packages/src/artifacts/sdist.rs +++ b/crates/rattler_installs_packages/src/artifacts/sdist.rs @@ -261,16 +261,16 @@ fn generic_archive_reader( #[cfg(test)] mod tests { use crate::artifacts::SDist; + use crate::index::PackageDb; use crate::index::{ArtifactRequest, PackageSourcesBuilder}; use crate::python_env::Pep508EnvMakers; + use crate::resolve::solve_options::{ResolveOptions, SDistResolution}; use crate::resolve::PypiVersion; - use crate::resolve::SDistResolution; use crate::types::{ArtifactFromSource, PackageName}; use crate::types::{ ArtifactInfo, ArtifactName, DistInfoMetadata, Extra, STreeFilename, Yanked, }; use crate::wheel_builder::WheelBuilder; - use crate::{index::PackageDb, resolve::ResolveOptions}; use insta::{assert_debug_snapshot, assert_ron_snapshot}; use pep440_rs::Version; use reqwest::Client; diff --git a/crates/rattler_installs_packages/src/resolve/dependency_provider.rs b/crates/rattler_installs_packages/src/resolve/dependency_provider.rs index a47aa6bb..5912764a 100644 --- a/crates/rattler_installs_packages/src/resolve/dependency_provider.rs +++ b/crates/rattler_installs_packages/src/resolve/dependency_provider.rs @@ -1,10 +1,10 @@ -use super::solve::PreReleaseResolution; -use super::SDistResolution; use crate::artifacts::SDist; use crate::artifacts::Wheel; use crate::index::{ArtifactRequest, PackageDb}; use crate::python_env::WheelTags; -use crate::resolve::{PinnedPackage, ResolveOptions}; +use crate::resolve::solve_options::SDistResolution; +use crate::resolve::solve_options::{PreReleaseResolution, ResolveOptions}; +use crate::resolve::PinnedPackage; use crate::types::{ ArtifactFromBytes, ArtifactInfo, ArtifactName, Extra, NormalizedPackageName, PackageName, }; @@ -13,19 +13,18 @@ use elsa::FrozenMap; use itertools::Itertools; use miette::{Diagnostic, IntoDiagnostic, MietteDiagnostic}; use parking_lot::Mutex; -use pep440_rs::{Operator, Version, VersionSpecifier, VersionSpecifiers}; +use pep440_rs::{Operator, VersionSpecifier, VersionSpecifiers}; use pep508_rs::{MarkerEnvironment, Requirement, VersionOrUrl}; use resolvo::{ Candidates, Dependencies, DependencyProvider, KnownDependencies, NameId, Pool, SolvableId, - SolverCache, VersionSet, + SolverCache, }; -use serde::Deserialize; -use serde::Serialize; use std::any::Any; use std::borrow::Borrow; use std::cmp::Ordering; use std::collections::HashMap; -use std::fmt::{Display, Formatter}; + +use crate::resolve::pypi_version_types::{PypiPackageName, PypiVersion, PypiVersionSet}; use std::str::FromStr; use std::sync::Arc; use thiserror::Error; @@ -33,172 +32,6 @@ use tokio::runtime::Handle; use tokio::task; use url::Url; -#[derive(Clone, Debug, Hash, Eq, PartialEq)] -/// This is a wrapper around Specifiers that implements [`VersionSet`] -pub struct PypiVersionSet { - /// The spec to match against - spec: Option, - /// If the VersionOrUrl is a Version specifier and any of the specifiers contains a - /// prerelease, then pre-releases are allowed. For example, - /// `jupyterlab==3.0.0a1` allows pre-releases, but `jupyterlab==3.0.0` does not. - /// - /// We pre-compute if any of the items in the specifiers contains a pre-release and store - /// this as a boolean which is later used during matching. - allows_prerelease: bool, -} - -impl PypiVersionSet { - /// Create a PyPiVersionSeet from VersionOrUrl specifier - pub fn from_spec(spec: Option, prerelease_option: &PreReleaseResolution) -> Self { - let allows_prerelease = match prerelease_option { - PreReleaseResolution::Disallow => false, - PreReleaseResolution::AllowIfNoOtherVersionsOrEnabled { .. } => match spec.as_ref() { - Some(VersionOrUrl::VersionSpecifier(v)) => { - v.iter().any(|s| s.version().any_prerelease()) - } - _ => false, - }, - PreReleaseResolution::Allow => true, - }; - - Self { - spec, - allows_prerelease, - } - } -} - -impl Display for PypiVersionSet { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - match &self.spec { - None => write!(f, "*"), - Some(VersionOrUrl::Url(url)) => write!(f, "{url}"), - Some(VersionOrUrl::VersionSpecifier(spec)) => write!(f, "{spec}"), - } - } -} - -/// This is a wrapper around [`Version`] that serves a version -/// within the [`PypiVersionSet`] version set. -#[derive(Clone, Debug, Ord, PartialOrd, Eq, PartialEq, Hash, Serialize, Deserialize)] -pub enum PypiVersion { - /// Version of artifact - Version { - /// Version of Artifact - version: Version, - - /// Given that the [`PreReleaseResolution`] is - /// AllowIfNoOtherVersionsOrEnabled, this field is true if there are - /// only pre-releases available for this package or if a spec explicitly - /// enabled pre-releases for this package. For example, if the package - /// `foo` has only versions `foo-1.0.0a1` and `foo-1.0.0a2` then this - /// will be true. This allows us later to match against this version and - /// allow the selection of pre-releases. Additionally, this is also true - /// if any of the explicitly mentioned specs (by the user) contains a - /// prerelease (for example c>0.0.0b0) contains the `b0` which signifies - /// a pre-release. - package_allows_prerelease: bool, - }, - /// Direct reference for artifact - Url(Url), -} - -impl PypiVersion { - /// Return if there are any prereleases for version - pub fn any_prerelease(&self) -> bool { - match self { - PypiVersion::Url(_) => false, - PypiVersion::Version { version, .. } => version.any_prerelease(), - } - } - - /// Return if pypi version is git url version - pub fn is_git(&self) -> bool { - match self { - PypiVersion::Version { .. } => false, - PypiVersion::Url(url) => url.scheme().contains("git"), - } - } -} - -impl VersionSet for PypiVersionSet { - type V = PypiVersion; - - fn contains(&self, v: &Self::V) -> bool { - match (self.spec.as_ref(), v) { - (Some(VersionOrUrl::Url(a)), PypiVersion::Url(b)) => a == b, - ( - Some(VersionOrUrl::VersionSpecifier(spec)), - PypiVersion::Version { - version, - package_allows_prerelease, - }, - ) => { - spec.contains(version) - // pre-releases are allowed only when the versionset allows them (jupyterlab==3.0.0a1) - // or there are no other versions available (foo-1.0.0a1, foo-1.0.0a2) - // or alternatively if the user has enabled all pre-releases or this specific (this is encoded in the allows_prerelease field) - && (self.allows_prerelease || *package_allows_prerelease || !version.any_prerelease()) - } - ( - None, - PypiVersion::Version { - version, - package_allows_prerelease, - }, - ) => self.allows_prerelease || *package_allows_prerelease || !version.any_prerelease(), - (None, PypiVersion::Url(_)) => true, - _ => false, - } - } -} - -impl Display for PypiVersion { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - match self { - PypiVersion::Version { version, .. } => write!(f, "{version}"), - PypiVersion::Url(u) => write!(f, "{u}"), - } - } -} - -#[derive(PartialEq, Eq, Hash, Clone, Debug)] -/// This can either be a base package name or with an extra -/// this is used to support optional dependencies -pub(crate) enum PypiPackageName { - /// Regular dependency - Base(NormalizedPackageName), - /// Optional dependency - Extra(NormalizedPackageName, Extra), -} - -impl PypiPackageName { - /// Returns the actual package (normalized) name without the extra - pub fn base(&self) -> &NormalizedPackageName { - match self { - PypiPackageName::Base(normalized) => normalized, - PypiPackageName::Extra(normalized, _) => normalized, - } - } - - /// Retrieves the extra if it is available - pub fn extra(&self) -> Option<&Extra> { - match self { - PypiPackageName::Base(_) => None, - PypiPackageName::Extra(_, e) => Some(e), - } - } -} - -impl Display for PypiPackageName { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - match self { - PypiPackageName::Base(name) => write!(f, "{}", name), - PypiPackageName::Extra(name, extra) => write!(f, "{}[{}]", name, extra.as_str()), - } - } -} - /// This is a [`DependencyProvider`] for PyPI packages pub(crate) struct PypiDependencyProvider { pub pool: Pool, diff --git a/crates/rattler_installs_packages/src/resolve/mod.rs b/crates/rattler_installs_packages/src/resolve/mod.rs index b5dde58b..8bd8a96c 100644 --- a/crates/rattler_installs_packages/src/resolve/mod.rs +++ b/crates/rattler_installs_packages/src/resolve/mod.rs @@ -9,10 +9,11 @@ //! mod dependency_provider; +mod pypi_version_types; mod solve; +pub mod solve_options; +mod solve_types; -pub use dependency_provider::{PypiVersion, PypiVersionSet}; -pub use solve::{ - resolve, OnWheelBuildFailure, PinnedPackage, PreReleaseResolution, ResolveOptions, - SDistResolution, -}; +pub use pypi_version_types::PypiVersion; +pub use pypi_version_types::PypiVersionSet; +pub use solve::{resolve, PinnedPackage}; diff --git a/crates/rattler_installs_packages/src/resolve/pypi_version_types.rs b/crates/rattler_installs_packages/src/resolve/pypi_version_types.rs new file mode 100644 index 00000000..238c6e04 --- /dev/null +++ b/crates/rattler_installs_packages/src/resolve/pypi_version_types.rs @@ -0,0 +1,178 @@ +//! This module contains types that are used to represent versions and version sets +//! these are used by the [`resolvo`] crate to resolve dependencies. +//! This module, in combination with the [`super::dependency_provider`] modules is used to make the PyPI ecosystem compatible with the [`resolvo`] crate. + +use crate::resolve::solve_options::PreReleaseResolution; +use crate::types::{Extra, NormalizedPackageName}; +use pep440_rs::Version; +use pep508_rs::VersionOrUrl; +use resolvo::VersionSet; +use serde::{Deserialize, Serialize}; +use std::fmt::{Display, Formatter}; +use url::Url; + +#[derive(Clone, Debug, Hash, Eq, PartialEq)] +/// This is a wrapper around Specifiers that implements [`VersionSet`] +pub struct PypiVersionSet { + /// The spec to match against + spec: Option, + /// If the VersionOrUrl is a Version specifier and any of the specifiers contains a + /// prerelease, then pre-releases are allowed. For example, + /// `jupyterlab==3.0.0a1` allows pre-releases, but `jupyterlab==3.0.0` does not. + /// + /// We pre-compute if any of the items in the specifiers contains a pre-release and store + /// this as a boolean which is later used during matching. + allows_prerelease: bool, +} + +impl PypiVersionSet { + /// Create a PyPiVersionSeet from VersionOrUrl specifier + pub fn from_spec(spec: Option, prerelease_option: &PreReleaseResolution) -> Self { + let allows_prerelease = match prerelease_option { + PreReleaseResolution::Disallow => false, + PreReleaseResolution::AllowIfNoOtherVersionsOrEnabled { .. } => match spec.as_ref() { + Some(VersionOrUrl::VersionSpecifier(v)) => { + v.iter().any(|s| s.version().any_prerelease()) + } + _ => false, + }, + PreReleaseResolution::Allow => true, + }; + + Self { + spec, + allows_prerelease, + } + } +} + +impl Display for PypiVersionSet { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + match &self.spec { + None => write!(f, "*"), + Some(VersionOrUrl::Url(url)) => write!(f, "{url}"), + Some(VersionOrUrl::VersionSpecifier(spec)) => write!(f, "{spec}"), + } + } +} + +/// This is a wrapper around [`Version`] that serves a version +/// within the [`PypiVersionSet`] version set. +#[derive(Clone, Debug, Ord, PartialOrd, Eq, PartialEq, Hash, Serialize, Deserialize)] +pub enum PypiVersion { + /// Version of artifact + Version { + /// Version of Artifact + version: Version, + + /// Given that the [`PreReleaseResolution`] is + /// AllowIfNoOtherVersionsOrEnabled, this field is true if there are + /// only pre-releases available for this package or if a spec explicitly + /// enabled pre-releases for this package. For example, if the package + /// `foo` has only versions `foo-1.0.0a1` and `foo-1.0.0a2` then this + /// will be true. This allows us later to match against this version and + /// allow the selection of pre-releases. Additionally, this is also true + /// if any of the explicitly mentioned specs (by the user) contains a + /// prerelease (for example c>0.0.0b0) contains the `b0` which signifies + /// a pre-release. + package_allows_prerelease: bool, + }, + /// Direct reference for artifact + Url(Url), +} + +impl PypiVersion { + /// Return if there are any prereleases for version + pub fn any_prerelease(&self) -> bool { + match self { + PypiVersion::Url(_) => false, + PypiVersion::Version { version, .. } => version.any_prerelease(), + } + } + + /// Return if pypi version is git url version + pub fn is_git(&self) -> bool { + match self { + PypiVersion::Version { .. } => false, + PypiVersion::Url(url) => url.scheme().contains("git"), + } + } +} + +impl VersionSet for PypiVersionSet { + type V = PypiVersion; + + fn contains(&self, v: &Self::V) -> bool { + match (self.spec.as_ref(), v) { + (Some(VersionOrUrl::Url(a)), PypiVersion::Url(b)) => a == b, + ( + Some(VersionOrUrl::VersionSpecifier(spec)), + PypiVersion::Version { + version, + package_allows_prerelease, + }, + ) => { + spec.contains(version) + // pre-releases are allowed only when the versionset allows them (jupyterlab==3.0.0a1) + // or there are no other versions available (foo-1.0.0a1, foo-1.0.0a2) + // or alternatively if the user has enabled all pre-releases or this specific (this is encoded in the allows_prerelease field) + && (self.allows_prerelease || *package_allows_prerelease || !version.any_prerelease()) + } + ( + None, + PypiVersion::Version { + version, + package_allows_prerelease, + }, + ) => self.allows_prerelease || *package_allows_prerelease || !version.any_prerelease(), + (None, PypiVersion::Url(_)) => true, + _ => false, + } + } +} + +impl Display for PypiVersion { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + match self { + PypiVersion::Version { version, .. } => write!(f, "{version}"), + PypiVersion::Url(u) => write!(f, "{u}"), + } + } +} + +#[derive(PartialEq, Eq, Hash, Clone, Debug)] +/// This can either be a base package name or with an extra +/// this is used to support optional dependencies +pub(crate) enum PypiPackageName { + /// Regular dependency + Base(NormalizedPackageName), + /// Optional dependency + Extra(NormalizedPackageName, Extra), +} + +impl PypiPackageName { + /// Returns the actual package (normalized) name without the extra + pub fn base(&self) -> &NormalizedPackageName { + match self { + PypiPackageName::Base(normalized) => normalized, + PypiPackageName::Extra(normalized, _) => normalized, + } + } + + /// Retrieves the extra if it is available + pub fn extra(&self) -> Option<&Extra> { + match self { + PypiPackageName::Base(_) => None, + PypiPackageName::Extra(_, e) => Some(e), + } + } +} + +impl Display for PypiPackageName { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + match self { + PypiPackageName::Base(name) => write!(f, "{}", name), + PypiPackageName::Extra(name, extra) => write!(f, "{}[{}]", name, extra.as_str()), + } + } +} diff --git a/crates/rattler_installs_packages/src/resolve/solve.rs b/crates/rattler_installs_packages/src/resolve/solve.rs index ec925858..d8b75b87 100644 --- a/crates/rattler_installs_packages/src/resolve/solve.rs +++ b/crates/rattler_installs_packages/src/resolve/solve.rs @@ -1,8 +1,7 @@ -use super::dependency_provider::{PypiPackageName, PypiVersionSet}; use crate::index::PackageDb; -use crate::python_env::{PythonLocation, WheelTags}; +use crate::python_env::WheelTags; use crate::resolve::dependency_provider::PypiDependencyProvider; -use crate::resolve::PypiVersion; +use crate::resolve::pypi_version_types::PypiVersion; use crate::types::PackageName; use crate::{types::ArtifactInfo, types::Extra, types::NormalizedPackageName}; use elsa::FrozenMap; @@ -13,6 +12,8 @@ use std::collections::HashMap; use std::str::FromStr; use url::Url; +use crate::resolve::pypi_version_types::{PypiPackageName, PypiVersionSet}; +use crate::resolve::solve_options::ResolveOptions; use std::collections::HashSet; use std::ops::Deref; use std::sync::Arc; @@ -39,210 +40,6 @@ pub struct PinnedPackage { pub artifacts: Vec>, } -/// Defines how to handle sdists during resolution. -#[derive(Default, Debug, Clone, Copy, Eq, PartialOrd, PartialEq)] -pub enum SDistResolution { - /// Both versions with wheels and/or sdists are allowed to be selected during resolution. But - /// during resolution the metadata from wheels is preferred over sdists. - /// - /// If we have the following scenario: - /// - /// ```txt - /// Version@1 - /// - WheelA - /// - WheelB - /// Version@2 - /// - SDist - /// - WheelA - /// - WheelB - /// Version@3 - /// - SDist - /// ``` - /// - /// Then the Version@3 will be selected because it has the highest version. This option makes no - /// distinction between whether the version has wheels or sdist. - #[default] - Normal, - - /// Allow sdists to be selected during resolution but only if all versions with wheels cannot - /// be selected. This means that even if a higher version is technically available it might not - /// be selected if it only has an available sdist. - /// - /// If we have the following scenario: - /// - /// ```txt - /// Version@1 - /// - SDist - /// - WheelA - /// - WheelB - /// Version@2 - /// - SDist - /// ``` - /// - /// Then the Version@1 will be selected even though the highest version is 2. This is because - /// version 2 has no available wheels. If version 1 would not exist though then version 2 is - /// selected because there are no other versions with a wheel. - PreferWheels, - - /// Allow sdists to be selected during resolution and prefer them over wheels. This means that - /// even if a higher version is available but it only includes wheels it might not be selected. - /// - /// If we have the following scenario: - /// - /// ```txt - /// Version@1 - /// - SDist - /// - WheelA - /// Version@2 - /// - WheelA - /// ``` - /// - /// Then the version@1 will be selected even though the highest version is 2. This is because - /// version 2 has no sdists available. If version 1 would not exist though then version 2 is - /// selected because there are no other versions with an sdist. - PreferSDists, - - /// Don't select sdists during resolution - /// - /// If we have the following scenario: - /// - /// ```txt - /// Version@1 - /// - SDist - /// - WheelA - /// - WheelB - /// Version@2 - /// - SDist - /// ``` - /// - /// Then version 1 will be selected because it has wheels and version 2 does not. If version 1 - /// would not exist there would be no solution because none of the versions have wheels. - OnlyWheels, - - /// Only select sdists during resolution - /// - /// If we have the following scenario: - /// - /// ```txt - /// Version@1 - /// - SDist - /// Version@2 - /// - WheelA - /// ``` - /// - /// Then version 1 will be selected because it has an sdist and version 2 does not. If version 1 - /// would not exist there would be no solution because none of the versions have sdists. - OnlySDists, -} - -/// Defines how to pre-releases are handled during package resolution. -#[derive(Debug, Clone, Eq, PartialOrd, PartialEq)] -pub enum PreReleaseResolution { - /// Don't allow pre-releases to be selected during resolution - Disallow, - - /// Conditionally allow pre-releases to be selected during resolution. This - /// behavior emulates `pip`'s pre-release resolution, which is not according - /// to "spec" but the most widely used logic. - /// - /// It works as follows: - /// - /// - if a version specifier mentions a pre-release, then we allow - /// pre-releases to be selected, for example `jupyterlab==4.1.0b0` will - /// allow the selection of the `jupyterlab-4.1.0b0` beta release during - /// resolution. - /// - if a package _only_ contains pre-release versions then we allow - /// pre-releases to be selected for any version specifier. For example, if - /// the package `supernew` only contains `supernew-1.0.0b0` and - /// `supernew-1.0.0b1` then we allow `supernew==1.0.0` to select - /// `supernew-1.0.0b1` during resolution. - /// - Any name that is mentioned in the `allow` list will allow pre-releases (this - /// is usually derived from the specs given by the user). For example, if the user - /// asks for `foo>0.0.0b0`, pre-releases are globally enabled for package foo (also as - /// transitive dependency). - AllowIfNoOtherVersionsOrEnabled { - /// A list of package names that will allow pre-releases to be selected - allow_names: Vec, - }, - - /// Allow any pre-releases to be selected during resolution - Allow, -} - -impl Default for PreReleaseResolution { - fn default() -> Self { - PreReleaseResolution::AllowIfNoOtherVersionsOrEnabled { - allow_names: Vec::new(), - } - } -} - -impl PreReleaseResolution { - /// Return a AllowIfNoOtherVersionsOrEnabled variant from a list of requirements - pub fn from_specs(specs: &[Requirement]) -> Self { - let mut allow_names = Vec::new(); - for spec in specs { - match &spec.version_or_url { - Some(VersionOrUrl::VersionSpecifier(v)) => { - if v.iter().any(|s| s.version().any_prerelease()) { - let name = PackageName::from_str(&spec.name).expect("invalid package name"); - allow_names.push(name.as_str().to_string()); - } - } - _ => continue, - }; - } - PreReleaseResolution::AllowIfNoOtherVersionsOrEnabled { allow_names } - } -} - -impl SDistResolution { - /// Returns true if sdists are allowed to be selected during resolution - pub fn allow_sdists(&self) -> bool { - !matches!(self, SDistResolution::OnlyWheels) - } - - /// Returns true if sdists are allowed to be selected during resolution - pub fn allow_wheels(&self) -> bool { - !matches!(self, SDistResolution::OnlySDists) - } -} - -/// Specifies what to do with failed build environments -#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)] -pub enum OnWheelBuildFailure { - /// Save failed build environments to temporary directory - SaveBuildEnv, - /// Delete failed build environments - #[default] - DeleteBuildEnv, -} - -/// Additional options that may influence the solver. In general passing [`Default::default`] to -/// the [`resolve`] function should provide sane defaults, however if you want to fine tune the -/// resolver you can do so via this struct. -#[derive(Default, Clone)] -pub struct ResolveOptions { - /// Defines how to handle sdists during resolution. By default sdists will be treated the same - /// as wheels. - pub sdist_resolution: SDistResolution, - - /// Defines what python interpreter to use for resolution. By default the python interpreter - /// from the system is used. This is only used during resolution and building of wheel files - pub python_location: PythonLocation, - - /// Defines if we should inherit env variables during build process of wheel files - pub clean_env: bool, - - /// Defines what to do with failed build environments - /// by default these are deleted but can also be saved for debugging purposes - pub on_wheel_build_failure: OnWheelBuildFailure, - - /// Defines whether pre-releases are allowed to be selected during resolution. By default - /// pre-releases are not allowed (only if there are no other versions available for a given dependency). - pub pre_release_resolution: PreReleaseResolution, -} - /// Resolves an environment that contains the given requirements and all dependencies of those /// requirements. /// diff --git a/crates/rattler_installs_packages/src/resolve/solve_options.rs b/crates/rattler_installs_packages/src/resolve/solve_options.rs new file mode 100644 index 00000000..69549712 --- /dev/null +++ b/crates/rattler_installs_packages/src/resolve/solve_options.rs @@ -0,0 +1,211 @@ +//! Contains the options that can be passed to the [`super::solve::resolve`] function. + +use crate::python_env::PythonLocation; +use pep508_rs::{Requirement, VersionOrUrl}; +use std::str::FromStr; + +use crate::types::PackageName; + +/// Defines how to handle sdists during resolution. +#[derive(Default, Debug, Clone, Copy, Eq, PartialOrd, PartialEq)] +pub enum SDistResolution { + /// Both versions with wheels and/or sdists are allowed to be selected during resolution. But + /// during resolution the metadata from wheels is preferred over sdists. + /// + /// If we have the following scenario: + /// + /// ```txt + /// Version@1 + /// - WheelA + /// - WheelB + /// Version@2 + /// - SDist + /// - WheelA + /// - WheelB + /// Version@3 + /// - SDist + /// ``` + /// + /// Then the Version@3 will be selected because it has the highest version. This option makes no + /// distinction between whether the version has wheels or sdist. + #[default] + Normal, + + /// Allow sdists to be selected during resolution but only if all versions with wheels cannot + /// be selected. This means that even if a higher version is technically available it might not + /// be selected if it only has an available sdist. + /// + /// If we have the following scenario: + /// + /// ```txt + /// Version@1 + /// - SDist + /// - WheelA + /// - WheelB + /// Version@2 + /// - SDist + /// ``` + /// + /// Then the Version@1 will be selected even though the highest version is 2. This is because + /// version 2 has no available wheels. If version 1 would not exist though then version 2 is + /// selected because there are no other versions with a wheel. + PreferWheels, + + /// Allow sdists to be selected during resolution and prefer them over wheels. This means that + /// even if a higher version is available but it only includes wheels it might not be selected. + /// + /// If we have the following scenario: + /// + /// ```txt + /// Version@1 + /// - SDist + /// - WheelA + /// Version@2 + /// - WheelA + /// ``` + /// + /// Then the version@1 will be selected even though the highest version is 2. This is because + /// version 2 has no sdists available. If version 1 would not exist though then version 2 is + /// selected because there are no other versions with an sdist. + PreferSDists, + + /// Don't select sdists during resolution + /// + /// If we have the following scenario: + /// + /// ```txt + /// Version@1 + /// - SDist + /// - WheelA + /// - WheelB + /// Version@2 + /// - SDist + /// ``` + /// + /// Then version 1 will be selected because it has wheels and version 2 does not. If version 1 + /// would not exist there would be no solution because none of the versions have wheels. + OnlyWheels, + + /// Only select sdists during resolution + /// + /// If we have the following scenario: + /// + /// ```txt + /// Version@1 + /// - SDist + /// Version@2 + /// - WheelA + /// ``` + /// + /// Then version 1 will be selected because it has an sdist and version 2 does not. If version 1 + /// would not exist there would be no solution because none of the versions have sdists. + OnlySDists, +} + +/// Defines how to pre-releases are handled during package resolution. +#[derive(Debug, Clone, Eq, PartialOrd, PartialEq)] +pub enum PreReleaseResolution { + /// Don't allow pre-releases to be selected during resolution + Disallow, + + /// Conditionally allow pre-releases to be selected during resolution. This + /// behavior emulates `pip`'s pre-release resolution, which is not according + /// to "spec" but the most widely used logic. + /// + /// It works as follows: + /// + /// - if a version specifier mentions a pre-release, then we allow + /// pre-releases to be selected, for example `jupyterlab==4.1.0b0` will + /// allow the selection of the `jupyterlab-4.1.0b0` beta release during + /// resolution. + /// - if a package _only_ contains pre-release versions then we allow + /// pre-releases to be selected for any version specifier. For example, if + /// the package `supernew` only contains `supernew-1.0.0b0` and + /// `supernew-1.0.0b1` then we allow `supernew==1.0.0` to select + /// `supernew-1.0.0b1` during resolution. + /// - Any name that is mentioned in the `allow` list will allow pre-releases (this + /// is usually derived from the specs given by the user). For example, if the user + /// asks for `foo>0.0.0b0`, pre-releases are globally enabled for package foo (also as + /// transitive dependency). + AllowIfNoOtherVersionsOrEnabled { + /// A list of package names that will allow pre-releases to be selected + allow_names: Vec, + }, + + /// Allow any pre-releases to be selected during resolution + Allow, +} + +impl Default for PreReleaseResolution { + fn default() -> Self { + PreReleaseResolution::AllowIfNoOtherVersionsOrEnabled { + allow_names: Vec::new(), + } + } +} + +impl PreReleaseResolution { + /// Return a AllowIfNoOtherVersionsOrEnabled variant from a list of requirements + pub fn from_specs(specs: &[Requirement]) -> Self { + let mut allow_names = Vec::new(); + for spec in specs { + match &spec.version_or_url { + Some(VersionOrUrl::VersionSpecifier(v)) => { + if v.iter().any(|s| s.version().any_prerelease()) { + let name = PackageName::from_str(&spec.name).expect("invalid package name"); + allow_names.push(name.as_str().to_string()); + } + } + _ => continue, + }; + } + PreReleaseResolution::AllowIfNoOtherVersionsOrEnabled { allow_names } + } +} + +impl SDistResolution { + /// Returns true if sdists are allowed to be selected during resolution + pub fn allow_sdists(&self) -> bool { + !matches!(self, SDistResolution::OnlyWheels) + } + + /// Returns true if sdists are allowed to be selected during resolution + pub fn allow_wheels(&self) -> bool { + !matches!(self, SDistResolution::OnlySDists) + } +} + +/// Specifies what to do with failed build environments +#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)] +pub enum OnWheelBuildFailure { + /// Save failed build environments to temporary directory + SaveBuildEnv, + /// Delete failed build environments + #[default] + DeleteBuildEnv, +} + +/// Additional options that may influence the solver. In general passing [`Default::default`] to +/// the [`resolve::resolve`] function should provide sane defaults, however if you want to fine tune the +/// resolver you can do so via this struct. +#[derive(Default, Clone)] +pub struct ResolveOptions { + /// Defines how to handle sdists during resolution. By default sdists will be treated the same + /// as wheels. + pub sdist_resolution: SDistResolution, + + /// Defines what python interpreter to use for resolution. By default the python interpreter + /// from the system is used. This is only used during resolution and building of wheel files + pub python_location: PythonLocation, + + /// Defines if we should inherit env variables during build process of wheel files + pub clean_env: bool, + + /// Defines what to do with failed build environments + /// by default these are deleted but can also be saved for debugging purposes + pub on_wheel_build_failure: OnWheelBuildFailure, + + /// Defines whether pre-releases are allowed to be selected during resolution. By default + /// pre-releases are not allowed (only if there are no other versions available for a given dependency). + pub pre_release_resolution: PreReleaseResolution, +} diff --git a/crates/rattler_installs_packages/src/resolve/solve_types.rs b/crates/rattler_installs_packages/src/resolve/solve_types.rs new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/crates/rattler_installs_packages/src/resolve/solve_types.rs @@ -0,0 +1 @@ + diff --git a/crates/rattler_installs_packages/src/wheel_builder/mod.rs b/crates/rattler_installs_packages/src/wheel_builder/mod.rs index 299db35c..22f68b9f 100644 --- a/crates/rattler_installs_packages/src/wheel_builder/mod.rs +++ b/crates/rattler_installs_packages/src/wheel_builder/mod.rs @@ -16,7 +16,7 @@ use parking_lot::Mutex; use pep508_rs::MarkerEnvironment; use crate::python_env::{ParsePythonInterpreterVersionError, PythonInterpreterVersion}; -use crate::resolve::{OnWheelBuildFailure, ResolveOptions}; +use crate::resolve::solve_options::{OnWheelBuildFailure, ResolveOptions}; use crate::types::ArtifactFromSource; use crate::types::{NormalizedPackageName, PackageName, SourceArtifactName, WheelFilename}; use crate::wheel_builder::build_environment::BuildEnvironment; @@ -291,7 +291,7 @@ mod tests { use crate::artifacts::SDist; use crate::index::{PackageDb, PackageSourcesBuilder}; use crate::python_env::{Pep508EnvMakers, PythonInterpreterVersion}; - use crate::resolve::ResolveOptions; + use crate::resolve::solve_options::ResolveOptions; use crate::wheel_builder::wheel_cache::WheelCacheKey; use crate::wheel_builder::WheelBuilder; use reqwest::Client; @@ -365,7 +365,8 @@ mod tests { let package_db = get_package_db(); let env_markers = Arc::new(Pep508EnvMakers::from_env().await.unwrap().0); let resolve_options = ResolveOptions { - on_wheel_build_failure: crate::resolve::OnWheelBuildFailure::SaveBuildEnv, + on_wheel_build_failure: + crate::resolve::solve_options::OnWheelBuildFailure::SaveBuildEnv, ..Default::default() }; diff --git a/crates/rattler_installs_packages/tests/resolver.rs b/crates/rattler_installs_packages/tests/resolver.rs index 1a179848..f8883624 100644 --- a/crates/rattler_installs_packages/tests/resolver.rs +++ b/crates/rattler_installs_packages/tests/resolver.rs @@ -1,13 +1,12 @@ #![cfg(feature = "resolvo")] use pep508_rs::{MarkerEnvironment, Requirement}; +use rattler_installs_packages::resolve::solve_options::{ResolveOptions, SDistResolution}; use rattler_installs_packages::{ index::PackageDb, python_env::{WheelTag, WheelTags}, resolve::resolve, resolve::PinnedPackage, - resolve::ResolveOptions, - resolve::SDistResolution, types::NormalizedPackageName, }; use std::{collections::HashMap, path::Path, str::FromStr, sync::OnceLock}; diff --git a/crates/rip_bin/src/main.rs b/crates/rip_bin/src/main.rs index c8e30f5b..fed018a9 100644 --- a/crates/rip_bin/src/main.rs +++ b/crates/rip_bin/src/main.rs @@ -1,5 +1,5 @@ use fs_err as fs; -use rattler_installs_packages::resolve::PreReleaseResolution; +use rattler_installs_packages::resolve::solve_options::{PreReleaseResolution, ResolveOptions}; use rip_bin::{global_multi_progress, IndicatifWriter}; use serde::Serialize; use std::collections::HashMap; @@ -19,11 +19,10 @@ use url::Url; use rattler_installs_packages::artifacts::wheel::UnpackWheelOptions; use rattler_installs_packages::index::PackageSourcesBuilder; use rattler_installs_packages::python_env::{PythonLocation, WheelTags}; -use rattler_installs_packages::resolve::OnWheelBuildFailure; +use rattler_installs_packages::resolve::solve_options::OnWheelBuildFailure; use rattler_installs_packages::wheel_builder::WheelBuilder; use rattler_installs_packages::{ - normalize_index_url, python_env::Pep508EnvMakers, resolve, resolve::resolve, - resolve::ResolveOptions, types::Requirement, + normalize_index_url, python_env::Pep508EnvMakers, resolve, resolve::resolve, types::Requirement, }; #[derive(Serialize, Debug)] @@ -55,7 +54,7 @@ struct Args { /// How to handle sidsts #[clap(flatten)] - sdist_resolution: SDistResolution, + sdist_resolution: SDistResolutionArgs, /// Path to the python interpreter to use for resolving environment markers and creating venvs #[clap(long, short)] @@ -79,7 +78,7 @@ struct Args { #[derive(Parser)] #[group(multiple = false)] -struct SDistResolution { +struct SDistResolutionArgs { /// Prefer any version with wheels over any version with sdists #[clap(long)] prefer_wheels: bool, @@ -97,18 +96,19 @@ struct SDistResolution { only_sdists: bool, } -impl From for resolve::SDistResolution { - fn from(value: SDistResolution) -> Self { +use resolve::solve_options::SDistResolution; +impl From for SDistResolution { + fn from(value: SDistResolutionArgs) -> Self { if value.only_sdists { - resolve::SDistResolution::OnlySDists + SDistResolution::OnlySDists } else if value.only_wheels { - resolve::SDistResolution::OnlyWheels + SDistResolution::OnlyWheels } else if value.prefer_sdists { - resolve::SDistResolution::PreferSDists + SDistResolution::PreferSDists } else if value.prefer_wheels { - resolve::SDistResolution::PreferWheels + SDistResolution::PreferWheels } else { - resolve::SDistResolution::Normal + SDistResolution::Normal } } } From 7f3e8bcde6f2c77cac5de7e7a905d70e86371a76 Mon Sep 17 00:00:00 2001 From: Tim de Jager Date: Thu, 8 Feb 2024 13:46:45 +0100 Subject: [PATCH 6/8] fix: fix an intra-doc link failure that passed through (#210) --- crates/rattler_installs_packages/src/resolve/solve_options.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/rattler_installs_packages/src/resolve/solve_options.rs b/crates/rattler_installs_packages/src/resolve/solve_options.rs index 69549712..2ee88a75 100644 --- a/crates/rattler_installs_packages/src/resolve/solve_options.rs +++ b/crates/rattler_installs_packages/src/resolve/solve_options.rs @@ -186,7 +186,7 @@ pub enum OnWheelBuildFailure { } /// Additional options that may influence the solver. In general passing [`Default::default`] to -/// the [`resolve::resolve`] function should provide sane defaults, however if you want to fine tune the +/// the [`super::resolve`] function should provide sane defaults, however if you want to fine tune the /// resolver you can do so via this struct. #[derive(Default, Clone)] pub struct ResolveOptions { From 01883bbc676f2da0331a312c73bf604086806410 Mon Sep 17 00:00:00 2001 From: nichmor Date: Thu, 8 Feb 2024 15:28:16 +0200 Subject: [PATCH 7/8] feat: add support for stree installing (#202) closes: #201 --- .../src/artifacts/sdist.rs | 252 +++++++++- ...__tests__get_metadata_for_local_sdist.snap | 240 +++++++++ ...h_without_calling_available_artifacts.snap | 240 +++++++++ ...h_without_calling_available_artifacts.snap | 469 ++++++++++++++++++ ...__tests__get_whl_for_local_sdist_rich.snap | 240 +++++++++ ...__tests__get_whl_for_local_stree_rich.snap | 236 +++++++++ ...__sdist__tests__get_whl_for_local_whl.snap | 469 ++++++++++++++++++ .../src/artifacts/wheel.rs | 4 +- .../src/index/direct_url/file.rs | 51 +- .../src/index/direct_url/git.rs | 16 +- .../src/index/direct_url/http.rs | 32 +- .../src/index/git_interop.rs | 9 +- .../src/index/html.rs | 1 + .../src/index/package_database.rs | 92 +++- .../src/types/artifact_name.rs | 59 +++ .../src/types/mod.rs | 4 +- .../src/types/project_info.rs | 3 + crates/rip_bin/src/main.rs | 3 +- .../dev_folder_with_rich/rich/__init__.py | 173 +------ 19 files changed, 2346 insertions(+), 247 deletions(-) create mode 100644 crates/rattler_installs_packages/src/artifacts/snapshots/rattler_installs_packages__artifacts__sdist__tests__get_metadata_for_local_sdist.snap create mode 100644 crates/rattler_installs_packages/src/artifacts/snapshots/rattler_installs_packages__artifacts__sdist__tests__get_only_metadata_for_local_sdist_rich_without_calling_available_artifacts.snap create mode 100644 crates/rattler_installs_packages/src/artifacts/snapshots/rattler_installs_packages__artifacts__sdist__tests__get_only_metadata_for_local_whl_rich_without_calling_available_artifacts.snap create mode 100644 crates/rattler_installs_packages/src/artifacts/snapshots/rattler_installs_packages__artifacts__sdist__tests__get_whl_for_local_sdist_rich.snap create mode 100644 crates/rattler_installs_packages/src/artifacts/snapshots/rattler_installs_packages__artifacts__sdist__tests__get_whl_for_local_stree_rich.snap create mode 100644 crates/rattler_installs_packages/src/artifacts/snapshots/rattler_installs_packages__artifacts__sdist__tests__get_whl_for_local_whl.snap diff --git a/crates/rattler_installs_packages/src/artifacts/sdist.rs b/crates/rattler_installs_packages/src/artifacts/sdist.rs index 429971e8..08643ace 100644 --- a/crates/rattler_installs_packages/src/artifacts/sdist.rs +++ b/crates/rattler_installs_packages/src/artifacts/sdist.rs @@ -19,7 +19,7 @@ use zip::ZipArchive; /// Represents a source distribution artifact. pub struct SDist { /// Name of the source distribution - name: SDistFilename, + pub name: SDistFilename, /// Source dist archive file: parking_lot::Mutex>, @@ -263,24 +263,25 @@ mod tests { use crate::artifacts::SDist; use crate::index::PackageDb; use crate::index::{ArtifactRequest, PackageSourcesBuilder}; - use crate::python_env::Pep508EnvMakers; + use crate::python_env::{Pep508EnvMakers, PythonLocation, VEnv}; use crate::resolve::solve_options::{ResolveOptions, SDistResolution}; use crate::resolve::PypiVersion; use crate::types::{ArtifactFromSource, PackageName}; use crate::types::{ - ArtifactInfo, ArtifactName, DistInfoMetadata, Extra, STreeFilename, Yanked, + ArtifactInfo, ArtifactName, DistInfoMetadata, Extra, NormalizedPackageName, STreeFilename, + WheelFilename, Yanked, }; + use crate::types::{SDistFilename, SDistFormat}; use crate::wheel_builder::WheelBuilder; use insta::{assert_debug_snapshot, assert_ron_snapshot}; use pep440_rs::Version; use reqwest::Client; use reqwest_middleware::ClientWithMiddleware; use std::collections::{HashMap, HashSet}; - use std::env; use std::path::Path; use std::str::FromStr; use std::sync::Arc; - use tempfile::TempDir; + use tempfile::{tempdir, TempDir}; use url::Url; fn get_package_db() -> (Arc, TempDir) { @@ -867,6 +868,7 @@ mod tests { let artifact_info = vec![ArtifactInfo { filename: ArtifactName::STree(stree_file_name), url: url, + is_direct_url: true, hashes: None, requires_python: None, dist_info_metadata: DistInfoMetadata::default(), @@ -882,4 +884,244 @@ mod tests { assert_debug_snapshot!(wheel_metadata.1); } + + #[tokio::test(flavor = "multi_thread")] + pub async fn get_whl_for_local_stree_rich() { + let path = Path::new(env!("CARGO_MANIFEST_DIR")) + .join("../../test-data/stree/dev_folder_with_rich"); + + let url = Url::from_file_path(path.canonicalize().unwrap()).unwrap(); + + let package_db = get_package_db(); + let env_markers = Arc::new(Pep508EnvMakers::from_env().await.unwrap().0); + let wheel_builder = WheelBuilder::new( + package_db.0.clone(), + env_markers, + None, + ResolveOptions::default(), + HashMap::default(), + ) + .unwrap(); + + let norm_name = PackageName::from_str("rich").unwrap(); + let stree_file_name = STreeFilename { + distribution: norm_name, + version: Version::from_str("0.0.0").unwrap(), + url: url.clone(), + }; + + let artifact_info = ArtifactInfo { + filename: ArtifactName::STree(stree_file_name), + url: url.clone(), + is_direct_url: true, + hashes: None, + requires_python: None, + dist_info_metadata: DistInfoMetadata::default(), + yanked: Yanked::default(), + }; + + let whl = package_db + .0 + .get_wheel(&artifact_info, Some(&wheel_builder)) + .await + .unwrap(); + + // Install wheel to test if all vitals are correctly built + let tmpdir = tempdir().unwrap(); + + let venv = VEnv::create(tmpdir.path(), PythonLocation::System).unwrap(); + + venv.install_wheel(&whl, &Default::default()).unwrap(); + + // Check to make sure that the headers directory was created + assert!(venv + .root() + .join( + venv.install_paths() + .site_packages() + .join("rich/__init__.py") + ) + .exists()); + + let whl_metadata = whl.metadata().unwrap(); + + assert_debug_snapshot!(whl_metadata.1); + } + + #[tokio::test(flavor = "multi_thread")] + pub async fn get_whl_for_local_sdist_rich() { + let path = + Path::new(env!("CARGO_MANIFEST_DIR")).join("../../test-data/sdists/rich-13.6.0.tar.gz"); + + let url = Url::from_file_path(path.canonicalize().unwrap()).unwrap(); + + let package_db = get_package_db(); + let env_markers = Arc::new(Pep508EnvMakers::from_env().await.unwrap().0); + let wheel_builder = WheelBuilder::new( + package_db.0.clone(), + env_markers, + None, + ResolveOptions::default(), + HashMap::default(), + ) + .unwrap(); + + let norm_name = PackageName::from_str("rich").unwrap(); + let sdist_file_name = SDistFilename { + distribution: norm_name, + version: Version::from_str("0.0.0").unwrap(), + format: SDistFormat::TarGz, + }; + + let artifact_info = ArtifactInfo { + filename: ArtifactName::SDist(sdist_file_name), + url: url.clone(), + is_direct_url: true, + hashes: None, + requires_python: None, + dist_info_metadata: DistInfoMetadata::default(), + yanked: Yanked::default(), + }; + + let whl = package_db + .0 + .get_wheel(&artifact_info, Some(&wheel_builder)) + .await + .unwrap(); + + let whl_metadata = whl.metadata().unwrap(); + + assert_debug_snapshot!(whl_metadata.1); + } + + #[tokio::test(flavor = "multi_thread")] + pub async fn get_whl_for_local_whl() { + let path = Path::new(env!("CARGO_MANIFEST_DIR")) + .join("../../test-data/wheels/miniblack-23.1.0-py3-none-any.whl"); + + let url = Url::from_file_path(path.canonicalize().unwrap()).unwrap(); + + let package_db = get_package_db(); + let env_markers = Arc::new(Pep508EnvMakers::from_env().await.unwrap().0); + let wheel_builder = WheelBuilder::new( + package_db.0.clone(), + env_markers, + None, + ResolveOptions::default(), + HashMap::default(), + ) + .unwrap(); + + let norm_name = NormalizedPackageName::from(PackageName::from_str("miniblack").unwrap()); + let whl_file_name = + WheelFilename::from_filename("miniblack-23.1.0-py3-none-any.whl", &norm_name).unwrap(); + + let artifact_info = ArtifactInfo { + filename: ArtifactName::Wheel(whl_file_name), + url: url.clone(), + is_direct_url: true, + hashes: None, + requires_python: None, + dist_info_metadata: DistInfoMetadata::default(), + yanked: Yanked::default(), + }; + + let whl = package_db + .0 + .get_wheel(&artifact_info, Some(&wheel_builder)) + .await + .unwrap(); + + let whl_metadata = whl.metadata().unwrap(); + + assert_debug_snapshot!(whl_metadata.1.requires_dist); + } + + #[tokio::test(flavor = "multi_thread")] + pub async fn get_only_metadata_for_local_sdist_rich_without_calling_available_artifacts() { + let path = + Path::new(env!("CARGO_MANIFEST_DIR")).join("../../test-data/sdists/rich-13.6.0.tar.gz"); + + let url = Url::from_file_path(path.canonicalize().unwrap()).unwrap(); + + let package_db = get_package_db(); + let env_markers = Arc::new(Pep508EnvMakers::from_env().await.unwrap().0); + let wheel_builder = WheelBuilder::new( + package_db.0.clone(), + env_markers, + None, + ResolveOptions::default(), + HashMap::default(), + ) + .unwrap(); + + let norm_name = PackageName::from_str("rich").unwrap(); + let sdist_file_name = SDistFilename { + distribution: norm_name, + version: Version::from_str("0.0.0").unwrap(), + format: SDistFormat::TarGz, + }; + + let artifact_info = vec![ArtifactInfo { + filename: ArtifactName::SDist(sdist_file_name), + url: url.clone(), + is_direct_url: true, + hashes: None, + requires_python: None, + dist_info_metadata: DistInfoMetadata::default(), + yanked: Yanked::default(), + }]; + + let wheel_metadata = package_db + .0 + .get_metadata(artifact_info.as_slice(), Some(&wheel_builder)) + .await + .unwrap() + .unwrap(); + + assert_debug_snapshot!(wheel_metadata.1); + } + + #[tokio::test(flavor = "multi_thread")] + pub async fn get_only_metadata_for_local_whl_rich_without_calling_available_artifacts() { + let path = Path::new(env!("CARGO_MANIFEST_DIR")) + .join("../../test-data/wheels/miniblack-23.1.0-py3-none-any.whl"); + + let url = Url::from_file_path(path.canonicalize().unwrap()).unwrap(); + + let package_db = get_package_db(); + let env_markers = Arc::new(Pep508EnvMakers::from_env().await.unwrap().0); + let wheel_builder = WheelBuilder::new( + package_db.0.clone(), + env_markers, + None, + ResolveOptions::default(), + HashMap::default(), + ) + .unwrap(); + + let package_name = PackageName::from_str("miniblack").unwrap(); + let norm_name = NormalizedPackageName::from(package_name); + let whl_file_name = + WheelFilename::from_filename("miniblack-23.1.0-py3-none-any.whl", &norm_name).unwrap(); + + let artifact_info = vec![ArtifactInfo { + filename: ArtifactName::Wheel(whl_file_name), + url: url.clone(), + is_direct_url: true, + hashes: None, + requires_python: None, + dist_info_metadata: DistInfoMetadata::default(), + yanked: Yanked::default(), + }]; + + let wheel_metadata = package_db + .0 + .get_metadata(artifact_info.as_slice(), Some(&wheel_builder)) + .await + .unwrap() + .unwrap(); + + assert_debug_snapshot!(wheel_metadata.1.requires_dist); + } } diff --git a/crates/rattler_installs_packages/src/artifacts/snapshots/rattler_installs_packages__artifacts__sdist__tests__get_metadata_for_local_sdist.snap b/crates/rattler_installs_packages/src/artifacts/snapshots/rattler_installs_packages__artifacts__sdist__tests__get_metadata_for_local_sdist.snap new file mode 100644 index 00000000..61c65b4a --- /dev/null +++ b/crates/rattler_installs_packages/src/artifacts/snapshots/rattler_installs_packages__artifacts__sdist__tests__get_metadata_for_local_sdist.snap @@ -0,0 +1,240 @@ +--- +source: crates/rattler_installs_packages/src/artifacts/sdist.rs +expression: wheel_metadata.1 +--- +WheelCoreMetadata { + name: PackageName { + source: "rich", + normalized: "rich", + }, + version: Version { + epoch: 0, + release: [ + 13, + 6, + 0, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + metadata_version: MetadataVersion( + Version { + epoch: 0, + release: [ + 2, + 1, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + ), + requires_dist: [ + Requirement { + name: "ipywidgets", + extras: None, + version_or_url: Some( + VersionSpecifier( + VersionSpecifiers( + [ + VersionSpecifier { + operator: GreaterThanEqual, + version: Version { + epoch: 0, + release: [ + 7, + 5, + 1, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + VersionSpecifier { + operator: LessThan, + version: Version { + epoch: 0, + release: [ + 9, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + ], + ), + ), + ), + marker: Some( + Expression( + MarkerExpression { + l_value: Extra, + operator: Equal, + r_value: QuotedString( + "jupyter", + ), + }, + ), + ), + }, + Requirement { + name: "markdown-it-py", + extras: None, + version_or_url: Some( + VersionSpecifier( + VersionSpecifiers( + [ + VersionSpecifier { + operator: GreaterThanEqual, + version: Version { + epoch: 0, + release: [ + 2, + 2, + 0, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + ], + ), + ), + ), + marker: None, + }, + Requirement { + name: "pygments", + extras: None, + version_or_url: Some( + VersionSpecifier( + VersionSpecifiers( + [ + VersionSpecifier { + operator: GreaterThanEqual, + version: Version { + epoch: 0, + release: [ + 2, + 13, + 0, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + VersionSpecifier { + operator: LessThan, + version: Version { + epoch: 0, + release: [ + 3, + 0, + 0, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + ], + ), + ), + ), + marker: None, + }, + Requirement { + name: "typing-extensions", + extras: None, + version_or_url: Some( + VersionSpecifier( + VersionSpecifiers( + [ + VersionSpecifier { + operator: GreaterThanEqual, + version: Version { + epoch: 0, + release: [ + 4, + 0, + 0, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + VersionSpecifier { + operator: LessThan, + version: Version { + epoch: 0, + release: [ + 5, + 0, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + ], + ), + ), + ), + marker: Some( + Expression( + MarkerExpression { + l_value: MarkerEnvVersion( + PythonVersion, + ), + operator: LessThan, + r_value: QuotedString( + "3.9", + ), + }, + ), + ), + }, + ], + requires_python: Some( + VersionSpecifiers( + [ + VersionSpecifier { + operator: GreaterThanEqual, + version: Version { + epoch: 0, + release: [ + 3, + 7, + 0, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + ], + ), + ), + extras: { + Extra { + source: "jupyter", + normalized: "jupyter", + }, + }, +} diff --git a/crates/rattler_installs_packages/src/artifacts/snapshots/rattler_installs_packages__artifacts__sdist__tests__get_only_metadata_for_local_sdist_rich_without_calling_available_artifacts.snap b/crates/rattler_installs_packages/src/artifacts/snapshots/rattler_installs_packages__artifacts__sdist__tests__get_only_metadata_for_local_sdist_rich_without_calling_available_artifacts.snap new file mode 100644 index 00000000..61c65b4a --- /dev/null +++ b/crates/rattler_installs_packages/src/artifacts/snapshots/rattler_installs_packages__artifacts__sdist__tests__get_only_metadata_for_local_sdist_rich_without_calling_available_artifacts.snap @@ -0,0 +1,240 @@ +--- +source: crates/rattler_installs_packages/src/artifacts/sdist.rs +expression: wheel_metadata.1 +--- +WheelCoreMetadata { + name: PackageName { + source: "rich", + normalized: "rich", + }, + version: Version { + epoch: 0, + release: [ + 13, + 6, + 0, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + metadata_version: MetadataVersion( + Version { + epoch: 0, + release: [ + 2, + 1, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + ), + requires_dist: [ + Requirement { + name: "ipywidgets", + extras: None, + version_or_url: Some( + VersionSpecifier( + VersionSpecifiers( + [ + VersionSpecifier { + operator: GreaterThanEqual, + version: Version { + epoch: 0, + release: [ + 7, + 5, + 1, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + VersionSpecifier { + operator: LessThan, + version: Version { + epoch: 0, + release: [ + 9, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + ], + ), + ), + ), + marker: Some( + Expression( + MarkerExpression { + l_value: Extra, + operator: Equal, + r_value: QuotedString( + "jupyter", + ), + }, + ), + ), + }, + Requirement { + name: "markdown-it-py", + extras: None, + version_or_url: Some( + VersionSpecifier( + VersionSpecifiers( + [ + VersionSpecifier { + operator: GreaterThanEqual, + version: Version { + epoch: 0, + release: [ + 2, + 2, + 0, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + ], + ), + ), + ), + marker: None, + }, + Requirement { + name: "pygments", + extras: None, + version_or_url: Some( + VersionSpecifier( + VersionSpecifiers( + [ + VersionSpecifier { + operator: GreaterThanEqual, + version: Version { + epoch: 0, + release: [ + 2, + 13, + 0, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + VersionSpecifier { + operator: LessThan, + version: Version { + epoch: 0, + release: [ + 3, + 0, + 0, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + ], + ), + ), + ), + marker: None, + }, + Requirement { + name: "typing-extensions", + extras: None, + version_or_url: Some( + VersionSpecifier( + VersionSpecifiers( + [ + VersionSpecifier { + operator: GreaterThanEqual, + version: Version { + epoch: 0, + release: [ + 4, + 0, + 0, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + VersionSpecifier { + operator: LessThan, + version: Version { + epoch: 0, + release: [ + 5, + 0, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + ], + ), + ), + ), + marker: Some( + Expression( + MarkerExpression { + l_value: MarkerEnvVersion( + PythonVersion, + ), + operator: LessThan, + r_value: QuotedString( + "3.9", + ), + }, + ), + ), + }, + ], + requires_python: Some( + VersionSpecifiers( + [ + VersionSpecifier { + operator: GreaterThanEqual, + version: Version { + epoch: 0, + release: [ + 3, + 7, + 0, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + ], + ), + ), + extras: { + Extra { + source: "jupyter", + normalized: "jupyter", + }, + }, +} diff --git a/crates/rattler_installs_packages/src/artifacts/snapshots/rattler_installs_packages__artifacts__sdist__tests__get_only_metadata_for_local_whl_rich_without_calling_available_artifacts.snap b/crates/rattler_installs_packages/src/artifacts/snapshots/rattler_installs_packages__artifacts__sdist__tests__get_only_metadata_for_local_whl_rich_without_calling_available_artifacts.snap new file mode 100644 index 00000000..af22f094 --- /dev/null +++ b/crates/rattler_installs_packages/src/artifacts/snapshots/rattler_installs_packages__artifacts__sdist__tests__get_only_metadata_for_local_whl_rich_without_calling_available_artifacts.snap @@ -0,0 +1,469 @@ +--- +source: crates/rattler_installs_packages/src/artifacts/sdist.rs +expression: wheel_metadata.1.requires_dist +--- +[ + Requirement { + name: "click", + extras: None, + version_or_url: Some( + VersionSpecifier( + VersionSpecifiers( + [ + VersionSpecifier { + operator: GreaterThanEqual, + version: Version { + epoch: 0, + release: [ + 8, + 0, + 0, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + ], + ), + ), + ), + marker: None, + }, + Requirement { + name: "mypy-extensions", + extras: None, + version_or_url: Some( + VersionSpecifier( + VersionSpecifiers( + [ + VersionSpecifier { + operator: GreaterThanEqual, + version: Version { + epoch: 0, + release: [ + 0, + 4, + 3, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + ], + ), + ), + ), + marker: None, + }, + Requirement { + name: "packaging", + extras: None, + version_or_url: Some( + VersionSpecifier( + VersionSpecifiers( + [ + VersionSpecifier { + operator: GreaterThanEqual, + version: Version { + epoch: 0, + release: [ + 22, + 0, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + ], + ), + ), + ), + marker: None, + }, + Requirement { + name: "pathspec", + extras: None, + version_or_url: Some( + VersionSpecifier( + VersionSpecifiers( + [ + VersionSpecifier { + operator: GreaterThanEqual, + version: Version { + epoch: 0, + release: [ + 0, + 9, + 0, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + ], + ), + ), + ), + marker: None, + }, + Requirement { + name: "platformdirs", + extras: None, + version_or_url: Some( + VersionSpecifier( + VersionSpecifiers( + [ + VersionSpecifier { + operator: GreaterThanEqual, + version: Version { + epoch: 0, + release: [ + 2, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + ], + ), + ), + ), + marker: None, + }, + Requirement { + name: "tomli", + extras: None, + version_or_url: Some( + VersionSpecifier( + VersionSpecifiers( + [ + VersionSpecifier { + operator: GreaterThanEqual, + version: Version { + epoch: 0, + release: [ + 1, + 1, + 0, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + ], + ), + ), + ), + marker: Some( + Expression( + MarkerExpression { + l_value: MarkerEnvVersion( + PythonVersion, + ), + operator: LessThan, + r_value: QuotedString( + "3.11", + ), + }, + ), + ), + }, + Requirement { + name: "typed-ast", + extras: None, + version_or_url: Some( + VersionSpecifier( + VersionSpecifiers( + [ + VersionSpecifier { + operator: GreaterThanEqual, + version: Version { + epoch: 0, + release: [ + 1, + 4, + 2, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + ], + ), + ), + ), + marker: Some( + And( + [ + Expression( + MarkerExpression { + l_value: MarkerEnvVersion( + PythonVersion, + ), + operator: LessThan, + r_value: QuotedString( + "3.8", + ), + }, + ), + Expression( + MarkerExpression { + l_value: MarkerEnvString( + ImplementationName, + ), + operator: Equal, + r_value: QuotedString( + "cpython", + ), + }, + ), + ], + ), + ), + }, + Requirement { + name: "typing-extensions", + extras: None, + version_or_url: Some( + VersionSpecifier( + VersionSpecifiers( + [ + VersionSpecifier { + operator: GreaterThanEqual, + version: Version { + epoch: 0, + release: [ + 3, + 10, + 0, + 0, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + ], + ), + ), + ), + marker: Some( + Expression( + MarkerExpression { + l_value: MarkerEnvVersion( + PythonVersion, + ), + operator: LessThan, + r_value: QuotedString( + "3.10", + ), + }, + ), + ), + }, + Requirement { + name: "colorama", + extras: None, + version_or_url: Some( + VersionSpecifier( + VersionSpecifiers( + [ + VersionSpecifier { + operator: GreaterThanEqual, + version: Version { + epoch: 0, + release: [ + 0, + 4, + 3, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + ], + ), + ), + ), + marker: Some( + Expression( + MarkerExpression { + l_value: Extra, + operator: Equal, + r_value: QuotedString( + "colorama", + ), + }, + ), + ), + }, + Requirement { + name: "aiohttp", + extras: None, + version_or_url: Some( + VersionSpecifier( + VersionSpecifiers( + [ + VersionSpecifier { + operator: GreaterThanEqual, + version: Version { + epoch: 0, + release: [ + 3, + 7, + 4, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + ], + ), + ), + ), + marker: Some( + Expression( + MarkerExpression { + l_value: Extra, + operator: Equal, + r_value: QuotedString( + "d", + ), + }, + ), + ), + }, + Requirement { + name: "ipython", + extras: None, + version_or_url: Some( + VersionSpecifier( + VersionSpecifiers( + [ + VersionSpecifier { + operator: GreaterThanEqual, + version: Version { + epoch: 0, + release: [ + 7, + 8, + 0, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + ], + ), + ), + ), + marker: Some( + Expression( + MarkerExpression { + l_value: Extra, + operator: Equal, + r_value: QuotedString( + "jupyter", + ), + }, + ), + ), + }, + Requirement { + name: "tokenize-rt", + extras: None, + version_or_url: Some( + VersionSpecifier( + VersionSpecifiers( + [ + VersionSpecifier { + operator: GreaterThanEqual, + version: Version { + epoch: 0, + release: [ + 3, + 2, + 0, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + ], + ), + ), + ), + marker: Some( + Expression( + MarkerExpression { + l_value: Extra, + operator: Equal, + r_value: QuotedString( + "jupyter", + ), + }, + ), + ), + }, + Requirement { + name: "uvloop", + extras: None, + version_or_url: Some( + VersionSpecifier( + VersionSpecifiers( + [ + VersionSpecifier { + operator: GreaterThanEqual, + version: Version { + epoch: 0, + release: [ + 0, + 15, + 2, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + ], + ), + ), + ), + marker: Some( + Expression( + MarkerExpression { + l_value: Extra, + operator: Equal, + r_value: QuotedString( + "uvloop", + ), + }, + ), + ), + }, +] diff --git a/crates/rattler_installs_packages/src/artifacts/snapshots/rattler_installs_packages__artifacts__sdist__tests__get_whl_for_local_sdist_rich.snap b/crates/rattler_installs_packages/src/artifacts/snapshots/rattler_installs_packages__artifacts__sdist__tests__get_whl_for_local_sdist_rich.snap new file mode 100644 index 00000000..fd3b9512 --- /dev/null +++ b/crates/rattler_installs_packages/src/artifacts/snapshots/rattler_installs_packages__artifacts__sdist__tests__get_whl_for_local_sdist_rich.snap @@ -0,0 +1,240 @@ +--- +source: crates/rattler_installs_packages/src/artifacts/sdist.rs +expression: whl_metadata.1 +--- +WheelCoreMetadata { + name: PackageName { + source: "rich", + normalized: "rich", + }, + version: Version { + epoch: 0, + release: [ + 13, + 6, + 0, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + metadata_version: MetadataVersion( + Version { + epoch: 0, + release: [ + 2, + 1, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + ), + requires_dist: [ + Requirement { + name: "ipywidgets", + extras: None, + version_or_url: Some( + VersionSpecifier( + VersionSpecifiers( + [ + VersionSpecifier { + operator: GreaterThanEqual, + version: Version { + epoch: 0, + release: [ + 7, + 5, + 1, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + VersionSpecifier { + operator: LessThan, + version: Version { + epoch: 0, + release: [ + 9, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + ], + ), + ), + ), + marker: Some( + Expression( + MarkerExpression { + l_value: Extra, + operator: Equal, + r_value: QuotedString( + "jupyter", + ), + }, + ), + ), + }, + Requirement { + name: "markdown-it-py", + extras: None, + version_or_url: Some( + VersionSpecifier( + VersionSpecifiers( + [ + VersionSpecifier { + operator: GreaterThanEqual, + version: Version { + epoch: 0, + release: [ + 2, + 2, + 0, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + ], + ), + ), + ), + marker: None, + }, + Requirement { + name: "pygments", + extras: None, + version_or_url: Some( + VersionSpecifier( + VersionSpecifiers( + [ + VersionSpecifier { + operator: GreaterThanEqual, + version: Version { + epoch: 0, + release: [ + 2, + 13, + 0, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + VersionSpecifier { + operator: LessThan, + version: Version { + epoch: 0, + release: [ + 3, + 0, + 0, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + ], + ), + ), + ), + marker: None, + }, + Requirement { + name: "typing-extensions", + extras: None, + version_or_url: Some( + VersionSpecifier( + VersionSpecifiers( + [ + VersionSpecifier { + operator: GreaterThanEqual, + version: Version { + epoch: 0, + release: [ + 4, + 0, + 0, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + VersionSpecifier { + operator: LessThan, + version: Version { + epoch: 0, + release: [ + 5, + 0, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + ], + ), + ), + ), + marker: Some( + Expression( + MarkerExpression { + l_value: MarkerEnvVersion( + PythonVersion, + ), + operator: LessThan, + r_value: QuotedString( + "3.9", + ), + }, + ), + ), + }, + ], + requires_python: Some( + VersionSpecifiers( + [ + VersionSpecifier { + operator: GreaterThanEqual, + version: Version { + epoch: 0, + release: [ + 3, + 7, + 0, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + ], + ), + ), + extras: { + Extra { + source: "jupyter", + normalized: "jupyter", + }, + }, +} diff --git a/crates/rattler_installs_packages/src/artifacts/snapshots/rattler_installs_packages__artifacts__sdist__tests__get_whl_for_local_stree_rich.snap b/crates/rattler_installs_packages/src/artifacts/snapshots/rattler_installs_packages__artifacts__sdist__tests__get_whl_for_local_stree_rich.snap new file mode 100644 index 00000000..4e6fdbce --- /dev/null +++ b/crates/rattler_installs_packages/src/artifacts/snapshots/rattler_installs_packages__artifacts__sdist__tests__get_whl_for_local_stree_rich.snap @@ -0,0 +1,236 @@ +--- +source: crates/rattler_installs_packages/src/artifacts/sdist.rs +expression: whl_metadata.1 +--- +WheelCoreMetadata { + name: PackageName { + source: "rich", + normalized: "rich", + }, + version: Version { + epoch: 0, + release: [ + 13, + 6, + 0, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + metadata_version: MetadataVersion( + Version { + epoch: 0, + release: [ + 2, + 1, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + ), + requires_dist: [ + Requirement { + name: "ipywidgets", + extras: None, + version_or_url: Some( + VersionSpecifier( + VersionSpecifiers( + [ + VersionSpecifier { + operator: GreaterThanEqual, + version: Version { + epoch: 0, + release: [ + 7, + 5, + 1, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + VersionSpecifier { + operator: LessThan, + version: Version { + epoch: 0, + release: [ + 9, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + ], + ), + ), + ), + marker: Some( + Expression( + MarkerExpression { + l_value: Extra, + operator: Equal, + r_value: QuotedString( + "jupyter", + ), + }, + ), + ), + }, + Requirement { + name: "markdown-it-py", + extras: None, + version_or_url: Some( + Url( + Url { + scheme: "git+https", + cannot_be_a_base: false, + username: "", + password: None, + host: Some( + Domain( + "github.com", + ), + ), + port: None, + path: "/executablebooks/markdown-it-py.git", + query: None, + fragment: None, + }, + ), + ), + marker: None, + }, + Requirement { + name: "pygments", + extras: None, + version_or_url: Some( + VersionSpecifier( + VersionSpecifiers( + [ + VersionSpecifier { + operator: GreaterThanEqual, + version: Version { + epoch: 0, + release: [ + 2, + 13, + 0, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + VersionSpecifier { + operator: LessThan, + version: Version { + epoch: 0, + release: [ + 3, + 0, + 0, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + ], + ), + ), + ), + marker: None, + }, + Requirement { + name: "typing-extensions", + extras: None, + version_or_url: Some( + VersionSpecifier( + VersionSpecifiers( + [ + VersionSpecifier { + operator: GreaterThanEqual, + version: Version { + epoch: 0, + release: [ + 4, + 0, + 0, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + VersionSpecifier { + operator: LessThan, + version: Version { + epoch: 0, + release: [ + 5, + 0, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + ], + ), + ), + ), + marker: Some( + Expression( + MarkerExpression { + l_value: MarkerEnvVersion( + PythonVersion, + ), + operator: LessThan, + r_value: QuotedString( + "3.9", + ), + }, + ), + ), + }, + ], + requires_python: Some( + VersionSpecifiers( + [ + VersionSpecifier { + operator: GreaterThanEqual, + version: Version { + epoch: 0, + release: [ + 3, + 7, + 0, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + ], + ), + ), + extras: { + Extra { + source: "jupyter", + normalized: "jupyter", + }, + }, +} diff --git a/crates/rattler_installs_packages/src/artifacts/snapshots/rattler_installs_packages__artifacts__sdist__tests__get_whl_for_local_whl.snap b/crates/rattler_installs_packages/src/artifacts/snapshots/rattler_installs_packages__artifacts__sdist__tests__get_whl_for_local_whl.snap new file mode 100644 index 00000000..c6499a2f --- /dev/null +++ b/crates/rattler_installs_packages/src/artifacts/snapshots/rattler_installs_packages__artifacts__sdist__tests__get_whl_for_local_whl.snap @@ -0,0 +1,469 @@ +--- +source: crates/rattler_installs_packages/src/artifacts/sdist.rs +expression: whl_metadata.1.requires_dist +--- +[ + Requirement { + name: "click", + extras: None, + version_or_url: Some( + VersionSpecifier( + VersionSpecifiers( + [ + VersionSpecifier { + operator: GreaterThanEqual, + version: Version { + epoch: 0, + release: [ + 8, + 0, + 0, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + ], + ), + ), + ), + marker: None, + }, + Requirement { + name: "mypy-extensions", + extras: None, + version_or_url: Some( + VersionSpecifier( + VersionSpecifiers( + [ + VersionSpecifier { + operator: GreaterThanEqual, + version: Version { + epoch: 0, + release: [ + 0, + 4, + 3, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + ], + ), + ), + ), + marker: None, + }, + Requirement { + name: "packaging", + extras: None, + version_or_url: Some( + VersionSpecifier( + VersionSpecifiers( + [ + VersionSpecifier { + operator: GreaterThanEqual, + version: Version { + epoch: 0, + release: [ + 22, + 0, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + ], + ), + ), + ), + marker: None, + }, + Requirement { + name: "pathspec", + extras: None, + version_or_url: Some( + VersionSpecifier( + VersionSpecifiers( + [ + VersionSpecifier { + operator: GreaterThanEqual, + version: Version { + epoch: 0, + release: [ + 0, + 9, + 0, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + ], + ), + ), + ), + marker: None, + }, + Requirement { + name: "platformdirs", + extras: None, + version_or_url: Some( + VersionSpecifier( + VersionSpecifiers( + [ + VersionSpecifier { + operator: GreaterThanEqual, + version: Version { + epoch: 0, + release: [ + 2, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + ], + ), + ), + ), + marker: None, + }, + Requirement { + name: "tomli", + extras: None, + version_or_url: Some( + VersionSpecifier( + VersionSpecifiers( + [ + VersionSpecifier { + operator: GreaterThanEqual, + version: Version { + epoch: 0, + release: [ + 1, + 1, + 0, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + ], + ), + ), + ), + marker: Some( + Expression( + MarkerExpression { + l_value: MarkerEnvVersion( + PythonVersion, + ), + operator: LessThan, + r_value: QuotedString( + "3.11", + ), + }, + ), + ), + }, + Requirement { + name: "typed-ast", + extras: None, + version_or_url: Some( + VersionSpecifier( + VersionSpecifiers( + [ + VersionSpecifier { + operator: GreaterThanEqual, + version: Version { + epoch: 0, + release: [ + 1, + 4, + 2, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + ], + ), + ), + ), + marker: Some( + And( + [ + Expression( + MarkerExpression { + l_value: MarkerEnvVersion( + PythonVersion, + ), + operator: LessThan, + r_value: QuotedString( + "3.8", + ), + }, + ), + Expression( + MarkerExpression { + l_value: MarkerEnvString( + ImplementationName, + ), + operator: Equal, + r_value: QuotedString( + "cpython", + ), + }, + ), + ], + ), + ), + }, + Requirement { + name: "typing-extensions", + extras: None, + version_or_url: Some( + VersionSpecifier( + VersionSpecifiers( + [ + VersionSpecifier { + operator: GreaterThanEqual, + version: Version { + epoch: 0, + release: [ + 3, + 10, + 0, + 0, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + ], + ), + ), + ), + marker: Some( + Expression( + MarkerExpression { + l_value: MarkerEnvVersion( + PythonVersion, + ), + operator: LessThan, + r_value: QuotedString( + "3.10", + ), + }, + ), + ), + }, + Requirement { + name: "colorama", + extras: None, + version_or_url: Some( + VersionSpecifier( + VersionSpecifiers( + [ + VersionSpecifier { + operator: GreaterThanEqual, + version: Version { + epoch: 0, + release: [ + 0, + 4, + 3, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + ], + ), + ), + ), + marker: Some( + Expression( + MarkerExpression { + l_value: Extra, + operator: Equal, + r_value: QuotedString( + "colorama", + ), + }, + ), + ), + }, + Requirement { + name: "aiohttp", + extras: None, + version_or_url: Some( + VersionSpecifier( + VersionSpecifiers( + [ + VersionSpecifier { + operator: GreaterThanEqual, + version: Version { + epoch: 0, + release: [ + 3, + 7, + 4, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + ], + ), + ), + ), + marker: Some( + Expression( + MarkerExpression { + l_value: Extra, + operator: Equal, + r_value: QuotedString( + "d", + ), + }, + ), + ), + }, + Requirement { + name: "ipython", + extras: None, + version_or_url: Some( + VersionSpecifier( + VersionSpecifiers( + [ + VersionSpecifier { + operator: GreaterThanEqual, + version: Version { + epoch: 0, + release: [ + 7, + 8, + 0, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + ], + ), + ), + ), + marker: Some( + Expression( + MarkerExpression { + l_value: Extra, + operator: Equal, + r_value: QuotedString( + "jupyter", + ), + }, + ), + ), + }, + Requirement { + name: "tokenize-rt", + extras: None, + version_or_url: Some( + VersionSpecifier( + VersionSpecifiers( + [ + VersionSpecifier { + operator: GreaterThanEqual, + version: Version { + epoch: 0, + release: [ + 3, + 2, + 0, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + ], + ), + ), + ), + marker: Some( + Expression( + MarkerExpression { + l_value: Extra, + operator: Equal, + r_value: QuotedString( + "jupyter", + ), + }, + ), + ), + }, + Requirement { + name: "uvloop", + extras: None, + version_or_url: Some( + VersionSpecifier( + VersionSpecifiers( + [ + VersionSpecifier { + operator: GreaterThanEqual, + version: Version { + epoch: 0, + release: [ + 0, + 15, + 2, + ], + pre: None, + post: None, + dev: None, + local: None, + }, + }, + ], + ), + ), + ), + marker: Some( + Expression( + MarkerExpression { + l_value: Extra, + operator: Equal, + r_value: QuotedString( + "uvloop", + ), + }, + ), + ), + }, +] diff --git a/crates/rattler_installs_packages/src/artifacts/wheel.rs b/crates/rattler_installs_packages/src/artifacts/wheel.rs index 254c3f01..f106d9f6 100644 --- a/crates/rattler_installs_packages/src/artifacts/wheel.rs +++ b/crates/rattler_installs_packages/src/artifacts/wheel.rs @@ -44,7 +44,9 @@ use crate::win::launcher::{build_windows_launcher, LauncherType, WindowsLauncher /// See the [Reference Page](https://packaging.python.org/en/latest/specifications/binary-distribution-format/#binary-distribution-format) /// for more information. pub struct Wheel { - name: WheelFilename, + /// Name of wheel + pub name: WheelFilename, + archive: Mutex>>, } diff --git a/crates/rattler_installs_packages/src/index/direct_url/file.rs b/crates/rattler_installs_packages/src/index/direct_url/file.rs index fad828a0..e15717ad 100644 --- a/crates/rattler_installs_packages/src/index/direct_url/file.rs +++ b/crates/rattler_installs_packages/src/index/direct_url/file.rs @@ -2,8 +2,8 @@ use crate::artifacts::{SDist, STree, Wheel}; use crate::index::package_database::DirectUrlArtifactResponse; use crate::resolve::PypiVersion; use crate::types::{ - ArtifactFromBytes, ArtifactHashes, ArtifactInfo, ArtifactName, DistInfoMetadata, - HasArtifactName, NormalizedPackageName, PackageName, SDistFilename, SDistFormat, STreeFilename, + ArtifactFromBytes, ArtifactHashes, ArtifactInfo, ArtifactType, DistInfoMetadata, + NormalizedPackageName, PackageName, SDistFilename, SDistFormat, STreeFilename, WheelCoreMetadata, Yanked, }; use crate::wheel_builder::{WheelBuildError, WheelBuilder}; @@ -23,7 +23,7 @@ pub(crate) async fn get_sdist_from_file_path( normalized_package_name: &NormalizedPackageName, path: &PathBuf, wheel_builder: &WheelBuilder, -) -> miette::Result<((Vec, WheelCoreMetadata), ArtifactName)> { +) -> miette::Result<((Vec, WheelCoreMetadata), SDist)> { let distribution = PackageName::from(normalized_package_name.clone()); let path_str = if let Some(path_str) = path.as_os_str().to_str() { @@ -47,10 +47,10 @@ pub(crate) async fn get_sdist_from_file_path( let file = File::open(path).into_diagnostic()?; - let dummy_sdist = SDist::from_bytes(dummy_sdist_file_name, Box::new(file))?; + let mut sdist = SDist::from_bytes(dummy_sdist_file_name, Box::new(file))?; let wheel_metadata = wheel_builder - .get_sdist_metadata(&dummy_sdist) + .get_sdist_metadata(&sdist) .await .into_diagnostic()?; @@ -61,9 +61,9 @@ pub(crate) async fn get_sdist_from_file_path( format, }; - let filename = ArtifactName::SDist(sdist_filename.clone()); + sdist.name = sdist_filename; - Ok((wheel_metadata, filename)) + Ok((wheel_metadata, sdist)) } /// Return an stree from file path @@ -72,7 +72,7 @@ pub(crate) async fn get_stree_from_file_path( url: Url, path: Option, wheel_builder: &WheelBuilder, -) -> miette::Result<((Vec, WheelCoreMetadata), ArtifactName)> { +) -> miette::Result<((Vec, WheelCoreMetadata), STree)> { let distribution = PackageName::from(normalized_package_name.clone()); let path = match path { None => PathBuf::from_str(url.path()).into_diagnostic()?, @@ -88,7 +88,7 @@ pub(crate) async fn get_stree_from_file_path( url: url.clone(), }; - let stree = STree { + let mut stree = STree { name: stree_file_name, location: Mutex::new(path), }; @@ -104,7 +104,9 @@ pub(crate) async fn get_stree_from_file_path( url: url.clone(), }; - Ok((wheel_metadata, ArtifactName::STree(stree_file_name))) + stree.name = stree_file_name; + + Ok((wheel_metadata, stree)) } /// Get artifact by file URL @@ -126,31 +128,34 @@ pub(crate) async fn get_artifacts_and_metadata>( let normalized_package_name = p.into(); - let (metadata_bytes, metadata, artifact_name) = if path.is_file() && str_name.ends_with(".whl") - { + let (metadata_bytes, metadata, artifact) = if path.is_file() && str_name.ends_with(".whl") { let wheel = Wheel::from_path(&path, &normalized_package_name) .map_err(|e| WheelBuildError::Error(format!("Could not build wheel: {}", e))) .into_diagnostic()?; let (data_bytes, metadata) = wheel.metadata()?; - ( - data_bytes, - metadata, - ArtifactName::Wheel(wheel.name().clone()), - ) + (data_bytes, metadata, ArtifactType::Wheel(wheel)) } else if path.is_file() { - let (wheel_metadata, name) = + let (wheel_metadata, sdist) = get_sdist_from_file_path(&normalized_package_name, &path, wheel_builder).await?; - (wheel_metadata.0, wheel_metadata.1, name) + ( + wheel_metadata.0, + wheel_metadata.1, + ArtifactType::SDist(sdist), + ) } else { - let (wheel_metadata, name) = get_stree_from_file_path( + let (wheel_metadata, stree) = get_stree_from_file_path( &normalized_package_name, url.clone(), Some(path), wheel_builder, ) .await?; - (wheel_metadata.0, wheel_metadata.1, name) + ( + wheel_metadata.0, + wheel_metadata.1, + ArtifactType::STree(stree), + ) }; let artifact_hash = { @@ -162,8 +167,9 @@ pub(crate) async fn get_artifacts_and_metadata>( }; let artifact_info = Arc::new(ArtifactInfo { - filename: artifact_name, + filename: artifact.name(), url: url.clone(), + is_direct_url: true, hashes: Some(artifact_hash), requires_python: metadata.requires_python.clone(), dist_info_metadata: DistInfoMetadata::default(), @@ -177,5 +183,6 @@ pub(crate) async fn get_artifacts_and_metadata>( artifact_info, metadata: (metadata_bytes, metadata), artifact_versions: result, + artifact, }) } diff --git a/crates/rattler_installs_packages/src/index/direct_url/git.rs b/crates/rattler_installs_packages/src/index/direct_url/git.rs index a72cf479..625da61c 100644 --- a/crates/rattler_installs_packages/src/index/direct_url/git.rs +++ b/crates/rattler_installs_packages/src/index/direct_url/git.rs @@ -1,13 +1,15 @@ use crate::index::git_interop::{git_clone, GitSource, ParsedUrl}; use crate::index::package_database::DirectUrlArtifactResponse; use crate::resolve::PypiVersion; -use crate::types::{ArtifactHashes, ArtifactInfo, DistInfoMetadata, NormalizedPackageName, Yanked}; +use crate::types::{ + ArtifactHashes, ArtifactInfo, ArtifactName, ArtifactType, DistInfoMetadata, HasArtifactName, + NormalizedPackageName, Yanked, +}; use crate::wheel_builder::WheelBuilder; use indexmap::IndexMap; use miette::IntoDiagnostic; use rattler_digest::{compute_bytes_digest, Sha256}; use std::sync::Arc; -use tempfile::tempdir; use url::Url; /// Get artifact by git reference @@ -25,9 +27,7 @@ pub(crate) async fn get_artifacts_and_metadata>( rev: parsed_url.revision, }; - let temp_dir = tempdir().unwrap(); - - let mut location = git_clone(&git_source, &temp_dir).into_diagnostic()?; + let mut location = git_clone(&git_source).into_diagnostic()?; if let Some(subdirectory) = parsed_url.subdirectory { location.push(&subdirectory); @@ -40,7 +40,7 @@ pub(crate) async fn get_artifacts_and_metadata>( } }; - let (wheel_metadata, filename) = super::file::get_stree_from_file_path( + let (wheel_metadata, artifact) = super::file::get_stree_from_file_path( &normalized_package_name, url.clone(), Some(location), @@ -65,8 +65,9 @@ pub(crate) async fn get_artifacts_and_metadata>( }; let artifact_info = Arc::new(ArtifactInfo { - filename, + filename: ArtifactName::STree(artifact.name().clone()), url: url.clone(), + is_direct_url: true, hashes: Some(project_hash), requires_python, dist_info_metadata, @@ -80,5 +81,6 @@ pub(crate) async fn get_artifacts_and_metadata>( artifact_info, metadata: (wheel_metadata.0, wheel_metadata.1), artifact_versions: result, + artifact: ArtifactType::STree(artifact), }) } diff --git a/crates/rattler_installs_packages/src/index/direct_url/http.rs b/crates/rattler_installs_packages/src/index/direct_url/http.rs index 34f1a0e8..7a74c076 100644 --- a/crates/rattler_installs_packages/src/index/direct_url/http.rs +++ b/crates/rattler_installs_packages/src/index/direct_url/http.rs @@ -3,9 +3,8 @@ use crate::index::http::Http; use crate::index::{parse_hash, CacheMode}; use crate::resolve::PypiVersion; use crate::types::{ - ArtifactFromBytes, ArtifactHashes, ArtifactInfo, ArtifactName, DistInfoMetadata, - HasArtifactName, NormalizedPackageName, PackageName, SDistFilename, SDistFormat, - WheelCoreMetadata, Yanked, + ArtifactFromBytes, ArtifactHashes, ArtifactInfo, ArtifactType, DistInfoMetadata, + NormalizedPackageName, PackageName, SDistFilename, SDistFormat, WheelCoreMetadata, Yanked, }; use crate::utils::ReadAndSeek; use crate::wheel_builder::WheelBuilder; @@ -62,24 +61,28 @@ pub(crate) async fn get_artifacts_and_metadata>( assert_eq!(hash, artifact_hash); }; - let (filename, metadata_bytes, metadata) = if str_name.ends_with(".whl") { + let (metadata_bytes, metadata, artifact) = if str_name.ends_with(".whl") { let wheel = Wheel::from_url_and_bytes(url.path(), &normalized_package_name, bytes)?; - let filename = ArtifactName::Wheel(wheel.name().clone()); let (data_bytes, metadata) = wheel.metadata()?; - (filename, data_bytes, metadata) + (data_bytes, metadata, ArtifactType::Wheel(wheel)) } else { - let (wheel_metadata, filename) = + let (wheel_metadata, sdist) = get_sdist_from_bytes(&normalized_package_name, url.clone(), bytes, wheel_builder) .await?; - (filename, wheel_metadata.0, wheel_metadata.1) + ( + wheel_metadata.0, + wheel_metadata.1, + ArtifactType::SDist(sdist), + ) }; let artifact_info = Arc::new(ArtifactInfo { - filename, + filename: artifact.name(), url: url.clone(), + is_direct_url: true, hashes: Some(artifact_hash), requires_python: metadata.requires_python.clone(), dist_info_metadata: DistInfoMetadata::default(), @@ -93,6 +96,7 @@ pub(crate) async fn get_artifacts_and_metadata>( artifact_info, metadata: (metadata_bytes, metadata), artifact_versions: result, + artifact, }) } @@ -102,7 +106,7 @@ async fn get_sdist_from_bytes( url: Url, bytes: Box, wheel_builder: &WheelBuilder, -) -> miette::Result<((Vec, WheelCoreMetadata), ArtifactName)> { +) -> miette::Result<((Vec, WheelCoreMetadata), SDist)> { // it's probably an sdist let distribution = PackageName::from(normalized_package_name.clone()); let version = Version::from_str("0.0.0").expect("0.0.0 version should always be parseable"); @@ -118,10 +122,10 @@ async fn get_sdist_from_bytes( // we don't know the version for artifact until we extract the actual metadata // so we create a plain sdist object aka dummy // and populate it with correct metadata after calling `get_sdist_metadata` - let dummy_sdist = SDist::from_bytes(dummy_sdist_file_name, Box::new(bytes))?; + let mut sdist = SDist::from_bytes(dummy_sdist_file_name, Box::new(bytes))?; let wheel_metadata = wheel_builder - .get_sdist_metadata(&dummy_sdist) + .get_sdist_metadata(&sdist) .await .into_diagnostic()?; @@ -131,7 +135,7 @@ async fn get_sdist_from_bytes( version: wheel_metadata.1.version.clone(), format, }; - let filename = ArtifactName::SDist(sdist_filename.clone()); + sdist.name = sdist_filename; - Ok((wheel_metadata, filename)) + Ok((wheel_metadata, sdist)) } diff --git a/crates/rattler_installs_packages/src/index/git_interop.rs b/crates/rattler_installs_packages/src/index/git_interop.rs index 1184d9aa..72fcec8b 100644 --- a/crates/rattler_installs_packages/src/index/git_interop.rs +++ b/crates/rattler_installs_packages/src/index/git_interop.rs @@ -12,7 +12,6 @@ use fs_extra::dir::remove; use miette::IntoDiagnostic; use regex::Regex; use serde::{Deserialize, Serialize}; -use tempfile::TempDir; use url::Url; /// A Git repository URL or a local path to a Git repository @@ -301,7 +300,7 @@ fn get_revision_sha(dest: &PathBuf, rev: Option) -> Result Result { +pub fn git_clone(source: &GitSource) -> Result { // test if git is available locally as we fetch the git from PATH, if !Command::new("git") .arg("--version") @@ -314,8 +313,10 @@ pub fn git_clone(source: &GitSource, tmp_dir: &TempDir) -> Result (|| Some(url.path_segments()?.last()?.to_string()))() diff --git a/crates/rattler_installs_packages/src/index/html.rs b/crates/rattler_installs_packages/src/index/html.rs index 7525bd28..72c46ec4 100644 --- a/crates/rattler_installs_packages/src/index/html.rs +++ b/crates/rattler_installs_packages/src/index/html.rs @@ -93,6 +93,7 @@ fn into_artifact_info( Some(ArtifactInfo { filename, url, + is_direct_url: false, hashes: hash, requires_python, dist_info_metadata, diff --git a/crates/rattler_installs_packages/src/index/package_database.rs b/crates/rattler_installs_packages/src/index/package_database.rs index 36e00862..8f1b8226 100644 --- a/crates/rattler_installs_packages/src/index/package_database.rs +++ b/crates/rattler_installs_packages/src/index/package_database.rs @@ -5,9 +5,9 @@ use crate::index::html::{parse_package_names_html, parse_project_info_html}; use crate::index::http::{CacheMode, Http, HttpRequestError}; use crate::index::package_sources::PackageSources; use crate::resolve::PypiVersion; -use crate::types::{ArtifactInfo, ProjectInfo, STreeFilename, WheelCoreMetadata}; +use crate::types::{ArtifactInfo, ArtifactType, ProjectInfo, STreeFilename, WheelCoreMetadata}; -use crate::wheel_builder::{WheelBuilder, WheelCache}; +use crate::wheel_builder::{WheelBuildError, WheelBuilder, WheelCache}; use crate::{ types::ArtifactFromBytes, types::InnerAsArtifactName, types::NormalizedPackageName, types::WheelFilename, @@ -71,6 +71,7 @@ pub(crate) struct DirectUrlArtifactResponse { pub(crate) artifact_info: Arc, pub(crate) artifact_versions: VersionArtifacts, pub(crate) metadata: (Vec, WheelCoreMetadata), + pub(crate) artifact: ArtifactType, } impl PackageDb { @@ -199,7 +200,7 @@ impl PackageDb { // network to get to the information. // Let's try to get information for any wheels that we have // first - let result = self.get_metadata_wheels(artifacts).await?; + let result = self.get_metadata_wheels(artifacts, wheel_builder).await?; if result.is_some() { return Ok(result); } @@ -230,9 +231,29 @@ impl PackageDb { artifact_info: &ArtifactInfo, builder: Option<&'async_recursion WheelBuilder>, ) -> miette::Result { - // TODO: add support for this currently there are not saved - if artifact_info.is::() { - miette::bail!("STree artifacts are not supported"); + // TODO: add support for this currently there are not cached, they will be repeatedly downloaded between runs + if artifact_info.is_direct_url { + if let Some(builder) = builder { + let response = super::direct_url::fetch_artifact_and_metadata_by_direct_url( + &self.http, + artifact_info.filename.distribution_name(), + artifact_info.url.clone(), + builder, + ) + .await?; + + match response.artifact { + ArtifactType::Wheel(wheel) => return Ok(wheel), + ArtifactType::SDist(sdist) => { + return builder.build_wheel(&sdist).await.into_diagnostic() + } + ArtifactType::STree(stree) => { + return builder.build_wheel(&stree).await.into_diagnostic() + } + } + } else { + miette::bail!("cannot build wheel without a wheel builder"); + } } // Try to build the wheel for this SDist if possible @@ -312,7 +333,7 @@ impl PackageDb { ) -> miette::Result> { for artifact_info in artifacts.iter() { let artifact_info_ref = artifact_info.borrow(); - if artifact_info_ref.is::() { + if artifact_info_ref.is::() && !artifact_info_ref.is_direct_url { let result = self .get_cached_artifact::(artifact_info_ref, CacheMode::OnlyIfCached) .await; @@ -343,7 +364,7 @@ impl PackageDb { } } // We know that it is an sdist - else if artifact_info_ref.is::() { + else if artifact_info_ref.is::() && !artifact_info_ref.is_direct_url { let result = self .get_cached_artifact::(artifact_info_ref, CacheMode::OnlyIfCached) .await; @@ -370,6 +391,7 @@ impl PackageDb { async fn get_metadata_wheels<'a, A: Borrow>( &self, artifacts: &'a [A], + wheel_builder: Option<&WheelBuilder>, ) -> miette::Result> { let wheels = artifacts .iter() @@ -391,11 +413,30 @@ impl PackageDb { return Ok(Some((artifact_info, metadata))); } - // Otherwise download the entire artifact - let artifact = self - .get_cached_artifact::(ai, CacheMode::Default) - .await?; - let metadata = artifact.metadata(); + let metadata = if ai.is_direct_url { + if let Some(wheel_builder) = wheel_builder { + let response = super::direct_url::fetch_artifact_and_metadata_by_direct_url( + &self.http, + ai.filename.distribution_name(), + ai.url.clone(), + wheel_builder, + ) + .await; + match response { + Err(err) => Err(miette::miette!(err.to_string())), + Ok(response) => Ok(response.metadata), + } + } else { + miette::bail!("cannot build wheel without a wheel builder"); + } + } else { + // Otherwise download the entire artifact + let artifact = self + .get_cached_artifact::(ai, CacheMode::Default) + .await?; + artifact.metadata() + }; + match metadata { Ok((blob, metadata)) => { self.put_metadata_in_cache(ai, &blob).await?; @@ -427,11 +468,26 @@ impl PackageDb { // only print these if we have not been able to find any metadata let mut errors = Vec::new(); for ai in sdists { - let artifact_info = ai.borrow(); - let artifact = self - .get_cached_artifact::(artifact_info, CacheMode::Default) - .await?; - let metadata = wheel_builder.get_sdist_metadata(&artifact).await; + let artifact_info: &ArtifactInfo = ai.borrow(); + let metadata = if artifact_info.is_direct_url { + let response = super::direct_url::fetch_artifact_and_metadata_by_direct_url( + &self.http, + artifact_info.filename.distribution_name(), + artifact_info.url.clone(), + wheel_builder, + ) + .await; + match response { + Err(err) => Err(WheelBuildError::Error(err.to_string())), + Ok(response) => Ok(response.metadata), + } + } else { + let artifact = self + .get_cached_artifact::(artifact_info, CacheMode::Default) + .await?; + wheel_builder.get_sdist_metadata(&artifact).await + }; + match metadata { Ok((blob, metadata)) => { self.put_metadata_in_cache(artifact_info, &blob).await?; diff --git a/crates/rattler_installs_packages/src/types/artifact_name.rs b/crates/rattler_installs_packages/src/types/artifact_name.rs index 9c679f18..39e02396 100644 --- a/crates/rattler_installs_packages/src/types/artifact_name.rs +++ b/crates/rattler_installs_packages/src/types/artifact_name.rs @@ -1,4 +1,5 @@ use super::{NormalizedPackageName, PackageName, ParsePackageNameError}; +use crate::artifacts::{SDist, STree, Wheel}; use crate::python_env::WheelTag; use crate::types::Version; use itertools::Itertools; @@ -79,6 +80,15 @@ impl ArtifactName { pub fn as_inner(&self) -> Option<&T> { T::try_as(self) } + + /// Tries to convert the specialized instance + pub fn distribution_name(&self) -> PackageName { + match self { + ArtifactName::Wheel(name) => name.distribution.clone(), + ArtifactName::STree(name) => name.distribution.clone(), + ArtifactName::SDist(name) => name.distribution.clone(), + } + } } impl Display for ArtifactName { @@ -530,6 +540,55 @@ impl InnerAsArtifactName for STreeFilename { } } +/// Enum that contains the different artifacts types: +/// * SDist is a python source distribution +/// * Wheel is a python binary distribution +/// * STree (is not an official PyPa name) but represents a source code tree +#[allow(missing_docs)] +pub enum ArtifactType { + Wheel(Wheel), + SDist(SDist), + STree(STree), +} + +impl ArtifactType { + /// Return the name of artifact + pub fn name(&self) -> ArtifactName { + match self { + ArtifactType::Wheel(artifact) => ArtifactName::Wheel(artifact.name.clone()), + ArtifactType::SDist(artifact) => ArtifactName::SDist(artifact.name.clone()), + ArtifactType::STree(artifact) => ArtifactName::STree(artifact.name.clone()), + } + } + + /// Returns this artifact as wheel + pub fn as_wheel(self) -> Option { + match self { + ArtifactType::Wheel(wheel) => Some(wheel), + ArtifactType::SDist(_) => None, + ArtifactType::STree(_) => None, + } + } + + /// Returns this name as a wheel name + pub fn as_sdist(self) -> Option { + match self { + ArtifactType::Wheel(_) => None, + ArtifactType::STree(_) => None, + ArtifactType::SDist(sdist) => Some(sdist), + } + } + + /// Returns this name as a source tree name + pub fn as_stree(self) -> Option { + match self { + ArtifactType::Wheel(_) => None, + ArtifactType::STree(stree) => Some(stree), + ArtifactType::SDist(_) => None, + } + } +} + #[cfg(test)] mod test { use super::*; diff --git a/crates/rattler_installs_packages/src/types/mod.rs b/crates/rattler_installs_packages/src/types/mod.rs index 29768d2e..1e175e2f 100644 --- a/crates/rattler_installs_packages/src/types/mod.rs +++ b/crates/rattler_installs_packages/src/types/mod.rs @@ -22,8 +22,8 @@ mod rfc822ish; pub use artifact::{ArtifactFromBytes, ArtifactFromSource, HasArtifactName, ReadPyProjectError}; pub use artifact_name::{ - ArtifactName, BuildTag, InnerAsArtifactName, ParseArtifactNameError, SDistFilename, - SDistFormat, STreeFilename, SourceArtifactName, WheelFilename, + ArtifactName, ArtifactType, BuildTag, InnerAsArtifactName, ParseArtifactNameError, + SDistFilename, SDistFormat, STreeFilename, SourceArtifactName, WheelFilename, }; pub use direct_url_json::{DirectUrlHashes, DirectUrlJson, DirectUrlSource, DirectUrlVcs}; diff --git a/crates/rattler_installs_packages/src/types/project_info.rs b/crates/rattler_installs_packages/src/types/project_info.rs index eecfec4c..504671c8 100644 --- a/crates/rattler_installs_packages/src/types/project_info.rs +++ b/crates/rattler_installs_packages/src/types/project_info.rs @@ -28,6 +28,9 @@ pub struct ArtifactInfo { pub filename: ArtifactName, /// Url to download the artifact pub url: url::Url, + /// Is url a direct reference + #[serde(skip_serializing)] + pub is_direct_url: bool, /// Hashes of the artifact pub hashes: Option, /// Python requirement diff --git a/crates/rip_bin/src/main.rs b/crates/rip_bin/src/main.rs index fed018a9..b629d741 100644 --- a/crates/rip_bin/src/main.rs +++ b/crates/rip_bin/src/main.rs @@ -303,8 +303,7 @@ async fn actual_main() -> miette::Result<()> { let artifact_info = pinned_package.artifacts.first().unwrap(); let artifact = package_db .get_wheel(artifact_info, Some(&wheel_builder)) - .await - .expect("could not get artifact"); + .await?; venv.install_wheel(&artifact, &UnpackWheelOptions::default()) .into_diagnostic()?; } diff --git a/test-data/stree/dev_folder_with_rich/rich/__init__.py b/test-data/stree/dev_folder_with_rich/rich/__init__.py index b631d544..fd64f6dd 100644 --- a/test-data/stree/dev_folder_with_rich/rich/__init__.py +++ b/test-data/stree/dev_folder_with_rich/rich/__init__.py @@ -1,177 +1,6 @@ """Rich text and beautiful formatting in the terminal.""" -import os -from typing import IO, TYPE_CHECKING, Any, Callable, Optional, Union - -from ._extension import load_ipython_extension # noqa: F401 - -__all__ = ["get_console", "reconfigure", "print", "inspect", "print_json"] - -if TYPE_CHECKING: - from .console import Console - -# Global console used by alternative print -_console: Optional["Console"] = None - -try: - _IMPORT_CWD = os.path.abspath(os.getcwd()) -except FileNotFoundError: - # Can happen if the cwd has been deleted - _IMPORT_CWD = "" - - -def get_console() -> "Console": - """Get a global :class:`~rich.console.Console` instance. This function is used when Rich requires a Console, - and hasn't been explicitly given one. - - Returns: - Console: A console instance. - """ - global _console - if _console is None: - from .console import Console - - _console = Console() - - return _console - - -def reconfigure(*args: Any, **kwargs: Any) -> None: - """Reconfigures the global console by replacing it with another. - - Args: - *args (Any): Positional arguments for the replacement :class:`~rich.console.Console`. - **kwargs (Any): Keyword arguments for the replacement :class:`~rich.console.Console`. - """ - from rich.console import Console - - new_console = Console(*args, **kwargs) - _console = get_console() - _console.__dict__ = new_console.__dict__ - - -def print( - *objects: Any, - sep: str = " ", - end: str = "\n", - file: Optional[IO[str]] = None, - flush: bool = False, -) -> None: - r"""Print object(s) supplied via positional arguments. - This function has an identical signature to the built-in print. - For more advanced features, see the :class:`~rich.console.Console` class. - - Args: - sep (str, optional): Separator between printed objects. Defaults to " ". - end (str, optional): Character to write at end of output. Defaults to "\\n". - file (IO[str], optional): File to write to, or None for stdout. Defaults to None. - flush (bool, optional): Has no effect as Rich always flushes output. Defaults to False. - - """ - from .console import Console - - write_console = get_console() if file is None else Console(file=file) - return write_console.print(*objects, sep=sep, end=end) - - -def print_json( - json: Optional[str] = None, - *, - data: Any = None, - indent: Union[None, int, str] = 2, - highlight: bool = True, - skip_keys: bool = False, - ensure_ascii: bool = False, - check_circular: bool = True, - allow_nan: bool = True, - default: Optional[Callable[[Any], Any]] = None, - sort_keys: bool = False, -) -> None: - """Pretty prints JSON. Output will be valid JSON. - - Args: - json (str): A string containing JSON. - data (Any): If json is not supplied, then encode this data. - indent (int, optional): Number of spaces to indent. Defaults to 2. - highlight (bool, optional): Enable highlighting of output: Defaults to True. - skip_keys (bool, optional): Skip keys not of a basic type. Defaults to False. - ensure_ascii (bool, optional): Escape all non-ascii characters. Defaults to False. - check_circular (bool, optional): Check for circular references. Defaults to True. - allow_nan (bool, optional): Allow NaN and Infinity values. Defaults to True. - default (Callable, optional): A callable that converts values that can not be encoded - in to something that can be JSON encoded. Defaults to None. - sort_keys (bool, optional): Sort dictionary keys. Defaults to False. - """ - - get_console().print_json( - json, - data=data, - indent=indent, - highlight=highlight, - skip_keys=skip_keys, - ensure_ascii=ensure_ascii, - check_circular=check_circular, - allow_nan=allow_nan, - default=default, - sort_keys=sort_keys, - ) - - -def inspect( - obj: Any, - *, - console: Optional["Console"] = None, - title: Optional[str] = None, - help: bool = False, - methods: bool = False, - docs: bool = True, - private: bool = False, - dunder: bool = False, - sort: bool = True, - all: bool = False, - value: bool = True, -) -> None: - """Inspect any Python object. - - * inspect() to see summarized info. - * inspect(, methods=True) to see methods. - * inspect(, help=True) to see full (non-abbreviated) help. - * inspect(, private=True) to see private attributes (single underscore). - * inspect(, dunder=True) to see attributes beginning with double underscore. - * inspect(, all=True) to see all attributes. - - Args: - obj (Any): An object to inspect. - title (str, optional): Title to display over inspect result, or None use type. Defaults to None. - help (bool, optional): Show full help text rather than just first paragraph. Defaults to False. - methods (bool, optional): Enable inspection of callables. Defaults to False. - docs (bool, optional): Also render doc strings. Defaults to True. - private (bool, optional): Show private attributes (beginning with underscore). Defaults to False. - dunder (bool, optional): Show attributes starting with double underscore. Defaults to False. - sort (bool, optional): Sort attributes alphabetically. Defaults to True. - all (bool, optional): Show all attributes. Defaults to False. - value (bool, optional): Pretty print value. Defaults to True. - """ - _console = console or get_console() - from rich._inspect import Inspect - - # Special case for inspect(inspect) - is_inspect = obj is inspect - - _inspect = Inspect( - obj, - title=title, - help=is_inspect or help, - methods=is_inspect or methods, - docs=is_inspect or docs, - private=private, - dunder=dunder, - sort=sort, - all=all, - value=value, - ) - _console.print(_inspect) - +print("HEY IMPORTING IT IT's working") if __name__ == "__main__": # pragma: no cover print("Hello, **World**") From ecaaf7c57d7e2e2ed6f9b157a1b4efee34c4a3cb Mon Sep 17 00:00:00 2001 From: Wolf Vollprecht Date: Thu, 8 Feb 2024 15:23:02 +0100 Subject: [PATCH 8/8] chore: update dependencies and use fork of pyproject-toml-rs (#209) I had to make a PR to pyproject-toml-rs to support the latest versions of the pep* crates. Otherwise we're in dependency hell unfortunately (because rattler has already updated, these are incompatible). https://github.com/PyO3/pyproject-toml-rs/pull/18 --------- Co-authored-by: Tim de Jager --- Cargo.lock | 509 +++++++++++------- Cargo.toml | 3 + crates/rattler_installs_packages/Cargo.toml | 71 +-- .../src/artifacts/wheel.rs | 8 +- .../src/index/direct_url/http.rs | 3 +- .../src/index/http.rs | 2 +- .../src/index/package_database.rs | 35 +- crates/rip_bin/Cargo.toml | 24 +- crates/test-utils/Cargo.toml | 14 +- 9 files changed, 389 insertions(+), 280 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4652e9af..6042830b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -74,9 +74,9 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.4" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" +checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" [[package]] name = "anstyle-parse" @@ -114,9 +114,9 @@ checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca" [[package]] name = "async-compression" -version = "0.3.15" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "942c7cd7ae39e91bde4820d74132e9862e62c2f386c3aa90ccf55949f5bad63a" +checksum = "a116f46a969224200a0a97f29cfd4c50e7534e4b4826bd23ea2c3c533039c82c" dependencies = [ "flate2", "futures-core", @@ -197,14 +197,13 @@ dependencies = [ [[package]] name = "async_zip" -version = "0.0.15" +version = "0.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "795310de3218cde15219fc98c1cf7d8fe9db4865aab27fcf1d535d6cb61c6b54" +checksum = "527207465fb6dcafbf661b0d4a51d0d2306c9d0c2975423079a6caa807930daf" dependencies = [ "async-compression", "crc32fast", - "futures-util", - "log", + "futures-lite", "pin-project", "thiserror", "tokio", @@ -219,18 +218,19 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "axum" -version = "0.6.20" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" +checksum = "1236b4b292f6c4d6dc34604bb5120d85c3fe1d1aa596bd5cc52ca054d13e7b9e" dependencies = [ "async-trait", "axum-core", - "bitflags 1.3.2", "bytes", "futures-util", - "http", - "http-body", - "hyper", + "http 1.0.0", + "http-body 1.0.0", + "http-body-util", + "hyper 1.1.0", + "hyper-util", "itoa", "matchit", "memchr", @@ -247,23 +247,28 @@ dependencies = [ "tower", "tower-layer", "tower-service", + "tracing", ] [[package]] name = "axum-core" -version = "0.3.4" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c" +checksum = "a15c63fd72d41492dc4f497196f5da1fb04fb7529e631d73630d1b491e47a2e3" dependencies = [ "async-trait", "bytes", "futures-util", - "http", - "http-body", + "http 1.0.0", + "http-body 1.0.0", + "http-body-util", "mime", + "pin-project-lite", "rustversion", + "sync_wrapper", "tower-layer", "tower-service", + "tracing", ] [[package]] @@ -407,7 +412,7 @@ dependencies = [ "hex", "libc", "memmap2 0.5.10", - "miette", + "miette 5.10.0", "reflink-copy", "serde", "serde_derive", @@ -699,9 +704,9 @@ dependencies = [ [[package]] name = "darling" -version = "0.20.3" +version = "0.20.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0209d94da627ab5605dcccf08bb18afa5009cfbef48d8a8b7d7bdbc79be25c5e" +checksum = "fc5d6b04b3fd0ba9926f945895de7d806260a2d7431ba82e7edaecb043c4c6b8" dependencies = [ "darling_core", "darling_macro", @@ -709,9 +714,9 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.20.3" +version = "0.20.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "177e3443818124b357d8e76f53be906d60937f0d3a90773a664fa63fa253e621" +checksum = "04e48a959bcd5c761246f5d090ebc2fbf7b9cd527a492b07a67510c108f1e7e3" dependencies = [ "fnv", "ident_case", @@ -723,9 +728,9 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.20.3" +version = "0.20.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" +checksum = "1d1545d67a2149e1d93b7e5c7752dce5a7426eb5d1357ddcfd89336b94444f77" dependencies = [ "darling_core", "quote", @@ -907,9 +912,9 @@ dependencies = [ [[package]] name = "fs4" -version = "0.6.6" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2eeb4ed9e12f43b7fa0baae3f9cdda28352770132ef2e09a23760c29cae8bd47" +checksum = "29f9df8a11882c4e3335eb2d18a0137c505d9ca927470b0cac9c6f0ae07d28f7" dependencies = [ "rustix", "windows-sys 0.48.0", @@ -985,6 +990,19 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" +[[package]] +name = "futures-lite" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "445ba825b27408685aaecefd65178908c36c6e96aaf6d8599419d46e624192ba" +dependencies = [ + "fastrand", + "futures-core", + "futures-io", + "parking", + "pin-project-lite", +] + [[package]] name = "futures-macro" version = "0.3.30" @@ -1076,8 +1094,27 @@ dependencies = [ "futures-core", "futures-sink", "futures-util", - "http", - "indexmap 2.1.0", + "http 0.2.11", + "indexmap 2.2.2", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "h2" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31d030e59af851932b72ceebadf4a2b5986dba4c3b99dd2493f8273a0f151943" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http 1.0.0", + "indexmap 2.2.2", "slab", "tokio", "tokio-util", @@ -1114,9 +1151,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d3d0e0f38255e7fa3cf31335b3a56f05febd18025f4db5ef7a0cfb4f8da651f" +checksum = "d0c62115964e08cb8039170eb33c1d0e2388a256930279edca206fff675f82c3" [[package]] name = "hex" @@ -1153,6 +1190,17 @@ dependencies = [ "itoa", ] +[[package]] +name = "http" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b32afd38673a8016f7c9ae69e5af41a58f81b1d31689040f2f1959594ce194ea" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + [[package]] name = "http-body" version = "0.4.6" @@ -1160,7 +1208,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ "bytes", - "http", + "http 0.2.11", + "pin-project-lite", +] + +[[package]] +name = "http-body" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" +dependencies = [ + "bytes", + "http 1.0.0", +] + +[[package]] +name = "http-body-util" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41cb79eb393015dadd30fc252023adb0b2400a0caee0fa2a077e6e21a551e840" +dependencies = [ + "bytes", + "futures-util", + "http 1.0.0", + "http-body 1.0.0", "pin-project-lite", ] @@ -1170,7 +1241,7 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7aec9f678bca3f4a15194b980f20ed9bfe0dd38e8d298c65c559a93dfbd6380a" dependencies = [ - "http", + "http 0.2.11", "http-serde", "reqwest", "serde", @@ -1183,19 +1254,13 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f0d1a8ef218a86416107794b34cc446958d9203556c312bb41eab4c924c1d2e" -[[package]] -name = "http-range-header" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "add0ab9360ddbd88cfeb3bd9574a1d85cfdfa14db10b3e21d3700dbc4328758f" - [[package]] name = "http-serde" version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f560b665ad9f1572cfcaf034f7fb84338a7ce945216d64a90fd81f046a3caee" dependencies = [ - "http", + "http 0.2.11", "serde", ] @@ -1221,9 +1286,9 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", - "h2", - "http", - "http-body", + "h2 0.3.24", + "http 0.2.11", + "http-body 0.4.6", "httparse", "httpdate", "itoa", @@ -1235,6 +1300,25 @@ dependencies = [ "want", ] +[[package]] +name = "hyper" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5aa53871fc917b1a9ed87b683a5d86db645e23acb32c2e0785a353e522fb75" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "h2 0.4.2", + "http 1.0.0", + "http-body 1.0.0", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "tokio", +] + [[package]] name = "hyper-rustls" version = "0.24.2" @@ -1242,8 +1326,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", - "http", - "hyper", + "http 0.2.11", + "hyper 0.14.28", "rustls", "tokio", "tokio-rustls", @@ -1256,17 +1340,33 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" dependencies = [ "bytes", - "hyper", + "hyper 0.14.28", "native-tls", "tokio", "tokio-native-tls", ] +[[package]] +name = "hyper-util" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca38ef113da30126bbff9cd1705f9273e15d45498615d138b0c20279ac7a76aa" +dependencies = [ + "bytes", + "futures-util", + "http 1.0.0", + "http-body 1.0.0", + "hyper 1.1.0", + "pin-project-lite", + "socket2", + "tokio", +] + [[package]] name = "iana-time-zone" -version = "0.1.59" +version = "0.1.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6a67363e2aa4443928ce15e57ebae94fd8949958fd1223c4cfc0cd473ad7539" +checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -1333,9 +1433,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.1.0" +version = "2.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" +checksum = "824b2ae422412366ba479e8111fd301f7b5faece8149317bb81925979a53f520" dependencies = [ "equivalent", "hashbrown 0.14.3", @@ -1409,9 +1509,9 @@ dependencies = [ [[package]] name = "is_ci" -version = "1.1.1" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "616cde7c720bb2bb5824a224687d8f77bfd38922027f01d825cd7453be5099fb" +checksum = "7655c9839580ee829dfacba1d1278c2b7883e50a277ff7541299489d6bdfdc45" [[package]] name = "itertools" @@ -1448,18 +1548,18 @@ checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] name = "jobserver" -version = "0.1.27" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c37f63953c4c63420ed5fd3d6d398c719489b9f872b9fa683262f8edd363c7d" +checksum = "ab46a6e9526ddef3ae7f787c06f0f2600639ba80ea3eade3d8e670a2230f51d6" dependencies = [ "libc", ] [[package]] name = "js-sys" -version = "0.3.67" +version = "0.3.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a1d36f1235bc969acba30b7f5990b864423a6068a10f7c90ae8f0112e3a59d1" +checksum = "406cda4b368d531c842222cf9d2600a9a4acce8d29423695379c6868a143a9ee" dependencies = [ "wasm-bindgen", ] @@ -1472,9 +1572,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.152" +version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "libredox" @@ -1569,12 +1669,22 @@ name = "miette" version = "5.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "59bb584eaeeab6bd0226ccf3509a69d7936d148cf3d036ad350abe35e8c6856e" +dependencies = [ + "miette-derive 5.10.0", + "once_cell", + "thiserror", + "unicode-width", +] + +[[package]] +name = "miette" +version = "7.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98a72adfa0c7ae88ba0abcbd00047a476616c66b831d628b8ac7f1e9de0cfd67" dependencies = [ "backtrace", "backtrace-ext", - "is-terminal", - "miette-derive", - "once_cell", + "miette-derive 7.0.0", "owo-colors", "supports-color", "supports-hyperlinks", @@ -1596,6 +1706,17 @@ dependencies = [ "syn 2.0.48", ] +[[package]] +name = "miette-derive" +version = "7.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "279def6bf114a34b3cf887489eb440d4dfcf709ab3ce9955e4a6f957ce5cce77" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + [[package]] name = "mime" version = "0.3.17" @@ -1614,9 +1735,9 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" dependencies = [ "adler", ] @@ -1660,11 +1781,17 @@ dependencies = [ "winapi", ] +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + [[package]] name = "num-traits" -version = "0.2.17" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" dependencies = [ "autocfg", ] @@ -1764,9 +1891,15 @@ checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" [[package]] name = "owo-colors" -version = "3.5.0" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" +checksum = "caff54706df99d2a78a5a4e3455ff45448d81ef1bb63c22cd14052ca0e993a3f" + +[[package]] +name = "parking" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae" [[package]] name = "parking_lot" @@ -1847,18 +1980,6 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "36bae92c60fa2398ce4678b98b2c4b5a7c61099961ca1fa305aec04a9ad28922" -[[package]] -name = "pep440_rs" -version = "0.3.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "887f66cc62717ea72caac4f1eb4e6f392224da3ffff3f40ec13ab427802746d6" -dependencies = [ - "lazy_static", - "regex", - "serde", - "unicode-width", -] - [[package]] name = "pep440_rs" version = "0.4.0" @@ -1873,12 +1994,12 @@ dependencies = [ [[package]] name = "pep508_rs" -version = "0.2.4" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa9d1320b78f4a5715b3ec914f32b5e85a50287ad923730e3cbf0255259432eb" +checksum = "910c513bea0f4f833122321c0f20e8c704e01de98692f6989c2ec21f43d88b1e" dependencies = [ "once_cell", - "pep440_rs 0.4.0", + "pep440_rs", "regex", "serde", "thiserror", @@ -1895,9 +2016,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.7.6" +version = "2.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f200d8d83c44a45b21764d1916299752ca035d15ecd46faca3e9a2a2bf6ad06" +checksum = "219c0dcc30b6a27553f9cc242972b67f75b60eb0db71f0b5462f38b058c41546" dependencies = [ "memchr", "thiserror", @@ -1906,9 +2027,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.6" +version = "2.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcd6ab1236bbdb3a49027e920e693192ebfe8913f6d60e294de57463a493cfde" +checksum = "22e1288dbd7786462961e69bfd4df7848c1e37e8b74303dbdab82c3a9cdd2809" dependencies = [ "pest", "pest_generator", @@ -1916,9 +2037,9 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.6" +version = "2.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a31940305ffc96863a735bef7c7994a00b325a7138fdbc5bda0f1a0476d3275" +checksum = "1381c29a877c6d34b8c176e734f35d7f7f5b3adaefe940cb4d1bb7af94678e2e" dependencies = [ "pest", "pest_meta", @@ -1929,9 +2050,9 @@ dependencies = [ [[package]] name = "pest_meta" -version = "2.7.6" +version = "2.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7ff62f5259e53b78d1af898941cdcdccfae7385cf7d793a6e55de5d05bb4b7d" +checksum = "d0934d6907f148c22a3acbda520c7eed243ad7487a30f51f6ce52b58b7077a8a" dependencies = [ "once_cell", "pest", @@ -1945,7 +2066,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" dependencies = [ "fixedbitset", - "indexmap 2.1.0", + "indexmap 2.2.2", ] [[package]] @@ -2043,12 +2164,11 @@ dependencies = [ [[package]] name = "pyproject-toml" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46d4a5e69187f23a29f8aa0ea57491d104ba541bc55f76552c2a74962aa20e04" +version = "0.8.2" +source = "git+https://github.com/wolfv/pyproject-toml-rs?branch=update-deps#98dfe9f560bca6b838080ab06db1a161dd085f1b" dependencies = [ - "indexmap 2.1.0", - "pep440_rs 0.3.12", + "indexmap 2.2.2", + "pep440_rs", "pep508_rs", "serde", "toml", @@ -2101,9 +2221,9 @@ dependencies = [ [[package]] name = "rattler_digest" -version = "0.9.0" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881d6040b07c00070386bc7d98f21b71474a0b7847fa5b32a7c5a0a01d028f8f" +checksum = "26606e577c9c5b214023c8a31a12753cffd2b09a6768d1d556b99ae9d730bc23" dependencies = [ "blake2", "digest", @@ -2114,20 +2234,6 @@ dependencies = [ "sha2", ] -[[package]] -name = "rattler_digest" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ba0c817d1dc9a34eb2a8c558756f6a3debb0751607af5c932405c6030f3a2e2" -dependencies = [ - "blake2", - "digest", - "hex", - "md-5", - "serde_with", - "sha2", -] - [[package]] name = "rattler_installs_packages" version = "0.6.0" @@ -2154,23 +2260,23 @@ dependencies = [ "fs_extra", "futures", "html-escape", - "http", + "http 0.2.11", "http-cache-semantics", "include_dir", - "indexmap 2.1.0", + "indexmap 2.2.2", "insta", "itertools 0.12.1", - "miette", + "miette 7.0.0", "mime", "once_cell", "parking_lot", "pathdiff", "peg", - "pep440_rs 0.4.0", + "pep440_rs", "pep508_rs", "pin-project-lite", "pyproject-toml", - "rattler_digest 0.9.0", + "rattler_digest", "regex", "reqwest", "reqwest-middleware", @@ -2298,19 +2404,19 @@ checksum = "e898588f33fdd5b9420719948f9f2a32c922a246964576f71ba7f24f80610fbc" [[package]] name = "reqwest" -version = "0.11.23" +version = "0.11.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37b1ae8d9ac08420c66222fb9096fc5de435c3c48542bc5336c51892cffafb41" +checksum = "c6920094eb85afde5e4a138be3f2de8bbdf28000f0029e72c45025a56b042251" dependencies = [ "base64 0.21.7", "bytes", "encoding_rs", "futures-core", "futures-util", - "h2", - "http", - "http-body", - "hyper", + "h2 0.3.24", + "http 0.2.11", + "http-body 0.4.6", + "hyper 0.14.28", "hyper-rustls", "hyper-tls", "ipnet", @@ -2327,6 +2433,7 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", + "sync_wrapper", "system-configuration", "tokio", "tokio-native-tls", @@ -2350,7 +2457,7 @@ checksum = "88a3e86aa6053e59030e7ce2d2a3b258dd08fc2d337d52f73f6cb480f5858690" dependencies = [ "anyhow", "async-trait", - "http", + "http 0.2.11", "reqwest", "serde", "task-local-extensions", @@ -2392,10 +2499,10 @@ dependencies = [ "console", "dirs", "fs-err", - "indexmap 2.1.0", + "indexmap 2.2.2", "indicatif", "itertools 0.12.1", - "miette", + "miette 7.0.0", "rand", "rattler_installs_packages", "reqwest", @@ -2466,9 +2573,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.30" +version = "0.38.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "322394588aaf33c24007e8bb3238ee3e4c5c09c084ab32bc73890b99ff326bca" +checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" dependencies = [ "bitflags 2.4.2", "errno", @@ -2585,18 +2692,18 @@ checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0" [[package]] name = "serde" -version = "1.0.195" +version = "1.0.196" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02" +checksum = "870026e60fa08c69f064aa766c10f10b1d62db9ccd4d0abb206472bee0ce3b32" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.195" +version = "1.0.196" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c" +checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67" dependencies = [ "proc-macro2", "quote", @@ -2605,9 +2712,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.111" +version = "1.0.113" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4" +checksum = "69801b70b1c3dac963ecb03a364ba0ceda9cf60c71cfe475e99864759c8b8a79" dependencies = [ "itoa", "ryu", @@ -2616,9 +2723,9 @@ dependencies = [ [[package]] name = "serde_path_to_error" -version = "0.1.14" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4beec8bce849d58d06238cb50db2e1c417cfeafa4c63f692b15c82b7c80f8335" +checksum = "ebd154a240de39fdebcf5775d2675c204d7c13cf39a4c697be6493c8e734337c" dependencies = [ "itoa", "serde", @@ -2647,15 +2754,15 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.5.1" +version = "3.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5c9fdb6b00a489875b22efd4b78fe2b363b72265cc5f6eb2e2b9ee270e6140c" +checksum = "1b0ed1662c5a68664f45b76d18deb0e234aff37207086803165c961eb695e981" dependencies = [ "base64 0.21.7", "chrono", "hex", "indexmap 1.9.3", - "indexmap 2.1.0", + "indexmap 2.2.2", "serde", "serde_json", "serde_with_macros", @@ -2664,9 +2771,9 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.5.1" +version = "3.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbff351eb4b33600a2e138dfa0b10b65a238ea8ff8fb2387c422c5022a3e8298" +checksum = "568577ff0ef47b879f736cd66740e022f3672788cdf002a05a4e609ea5a6fb15" dependencies = [ "darling", "proc-macro2", @@ -2777,7 +2884,7 @@ dependencies = [ "base64 0.21.7", "digest", "hex", - "miette", + "miette 5.10.0", "serde", "sha-1", "sha2", @@ -2805,31 +2912,24 @@ checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" [[package]] name = "supports-color" -version = "2.1.0" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6398cde53adc3c4557306a96ce67b302968513830a77a95b2b17305d9719a89" +checksum = "9829b314621dfc575df4e409e79f9d6a66a3bd707ab73f23cb4aa3a854ac854f" dependencies = [ - "is-terminal", "is_ci", ] [[package]] name = "supports-hyperlinks" -version = "2.1.0" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f84231692eb0d4d41e4cdd0cabfdd2e6cd9e255e65f80c9aa7c98dd502b4233d" -dependencies = [ - "is-terminal", -] +checksum = "2c0a1e5168041f5f3ff68ff7d95dcb9c8749df29f6e7e89ada40dd4c9de404ee" [[package]] name = "supports-unicode" -version = "2.1.0" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f850c19edd184a205e883199a261ed44471c81e39bd95b1357f5febbef00e77a" -dependencies = [ - "is-terminal", -] +checksum = "b7401a30af6cb5818bb64852270bb722533397edcfc7344954a38f420819ece2" [[package]] name = "syn" @@ -2917,25 +3017,24 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.9.0" +version = "3.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01ce4141aa927a6d1bd34a041795abd0db1cccba5d5f24b009f694bdf3a1f3fa" +checksum = "a365e8cd18e44762ef95d87f284f4b5cd04107fec2ff3052bd6a3e6069669e67" dependencies = [ "cfg-if", "fastrand", - "redox_syscall", "rustix", "windows-sys 0.52.0", ] [[package]] name = "terminal_size" -version = "0.1.17" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "633c1a546cee861a1a6d0dc69ebeca693bf4296661ba7852b9d21d159e0506df" +checksum = "21bebf2b7c9e0a515f6e0f8c51dc0f8e4696391e6f1ff30379559f8365fb0df7" dependencies = [ - "libc", - "winapi", + "rustix", + "windows-sys 0.48.0", ] [[package]] @@ -2945,7 +3044,7 @@ dependencies = [ "data-encoding", "dirs", "fslock", - "rattler_digest 0.11.0", + "rattler_digest", "reqwest", "tempfile", "thiserror", @@ -2955,9 +3054,9 @@ dependencies = [ [[package]] name = "textwrap" -version = "0.15.2" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7b3e525a49ec206798b40326a44121291b530c963cfb01018f63e135bac543d" +checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" dependencies = [ "smawk", "unicode-linebreak", @@ -2996,12 +3095,13 @@ dependencies = [ [[package]] name = "time" -version = "0.3.31" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f657ba42c3f86e7680e53c8cd3af8abbe56b5491790b46e22e19c0d57463583e" +checksum = "c8248b6521bb14bc45b4067159b9b6ad792e2d6d754d6c41fb50e29fefe38749" dependencies = [ "deranged", "itoa", + "num-conv", "powerfmt", "serde", "time-core", @@ -3016,10 +3116,11 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26197e33420244aeb70c3e8c78376ca46571bc4e701e4791c2cd9f57dcb3a43f" +checksum = "7ba3a3ef41e6672a2f0f001392bb5dcd3ff0a9992d618ca761a11c3121547774" dependencies = [ + "num-conv", "time-core", ] @@ -3050,15 +3151,15 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tl" -version = "0.7.7" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5e993a1c7c32fdf90a308cec4d457f507b2573acc909bd6e7a092321664fdb3" +checksum = "b130bd8a58c163224b44e217b4239ca7b927d82bf6cc2fea1fc561d15056e3f7" [[package]] name = "tokio" -version = "1.35.1" +version = "1.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c89b4efa943be685f629b149f53829423f8f5531ea21249408e8e2f8671ec104" +checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931" dependencies = [ "backtrace", "bytes", @@ -3145,9 +3246,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.8" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1a195ec8c9da26928f773888e0742ca3ca1040c6cd859c919c9f59c1954ab35" +checksum = "9a9aad4a3066010876e8dcf5a8a06e70a558751117a145c6ce2b82c2e2054290" dependencies = [ "serde", "serde_spanned", @@ -3166,11 +3267,11 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.21.0" +version = "0.22.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03" +checksum = "0c9ffdf896f8daaabf9b66ba8e77ea1ed5ed0f72821b398aba62352e95062951" dependencies = [ - "indexmap 2.1.0", + "indexmap 2.2.2", "serde", "serde_spanned", "toml_datetime", @@ -3195,17 +3296,15 @@ dependencies = [ [[package]] name = "tower-http" -version = "0.4.4" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61c5bb1d698276a2443e5ecfabc1008bf15a36c12e6a7176e7bf089ea9131140" +checksum = "0da193277a4e2c33e59e09b5861580c33dd0a637c3883d0fa74ba40c0374af2e" dependencies = [ "bitflags 2.4.2", "bytes", - "futures-core", - "futures-util", - "http", - "http-body", - "http-range-header", + "http 1.0.0", + "http-body 1.0.0", + "http-body-util", "pin-project-lite", "tower-layer", "tower-service", @@ -3443,9 +3542,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1223296a201415c7fad14792dbefaace9bd52b62d33453ade1c5b5f07555406" +checksum = "c1e124130aee3fb58c5bdd6b639a0509486b0338acaaae0c84a5124b0f588b7f" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -3453,9 +3552,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcdc935b63408d58a32f8cc9738a0bffd8f05cc7c002086c6ef20b7312ad9dcd" +checksum = "c9e7e1900c352b609c8488ad12639a311045f40a35491fb69ba8c12f758af70b" dependencies = [ "bumpalo", "log", @@ -3468,9 +3567,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.40" +version = "0.4.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bde2032aeb86bdfaecc8b261eef3cba735cc426c1f3a3416d1e0791be95fc461" +checksum = "877b9c3f61ceea0e56331985743b13f3d25c406a7098d45180fb5f09bc19ed97" dependencies = [ "cfg-if", "js-sys", @@ -3480,9 +3579,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e4c238561b2d428924c49815533a8b9121c664599558a5d9ec51f8a1740a999" +checksum = "b30af9e2d358182b5c7449424f017eba305ed32a7010509ede96cdc4696c46ed" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3490,9 +3589,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bae1abb6806dc1ad9e560ed242107c0f6c84335f1749dd4e8ddb012ebd5e25a7" +checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66" dependencies = [ "proc-macro2", "quote", @@ -3503,15 +3602,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d91413b1c31d7539ba5ef2451af3f0b833a005eb27a631cec32bc0635a8602b" +checksum = "4f186bd2dcf04330886ce82d6f33dd75a7bfcf69ecf5763b89fcde53b6ac9838" [[package]] name = "wasm-streams" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4609d447824375f43e1ffbc051b50ad8f4b3ae8219680c94452ea05eb240ac7" +checksum = "b65dc4c90b63b118468cf747d8bf3566c1913ef60be765b5730ead9e0a3ba129" dependencies = [ "futures-util", "js-sys", @@ -3522,9 +3621,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.67" +version = "0.3.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58cd2333b6e0be7a39605f0e255892fd7418a682d8da8fe042fe25128794d2ed" +checksum = "96565907687f7aceb35bc5fc03770a8a0471d82e479f25832f54a0e3f4b28446" dependencies = [ "js-sys", "wasm-bindgen", @@ -3532,9 +3631,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.25.3" +version = "0.25.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1778a42e8b3b90bff8d0f5032bf22250792889a5cdc752aa0020c84abe3aaf10" +checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" [[package]] name = "winapi" @@ -3720,9 +3819,9 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] name = "winnow" -version = "0.5.34" +version = "0.5.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7cf47b659b318dccbd69cc4797a39ae128f533dce7902a1096044d1967b9c16" +checksum = "5389a154b01683d28c77f8f68f49dea75f0a4da32557a58f68ee51ebba472d29" dependencies = [ "memchr", ] diff --git a/Cargo.toml b/Cargo.toml index 8a3041bc..53486992 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,3 +19,6 @@ rust-version = "1.70" allow-branch = ["main"] consolidate-commits = true tag-prefix = "" + +[patch.crates-io] +pyproject-toml = { git = "https://github.com/wolfv/pyproject-toml-rs", branch = "update-deps" } diff --git a/crates/rattler_installs_packages/Cargo.toml b/crates/rattler_installs_packages/Cargo.toml index d2ccc925..177121e2 100644 --- a/crates/rattler_installs_packages/Cargo.toml +++ b/crates/rattler_installs_packages/Cargo.toml @@ -18,53 +18,54 @@ native-tls = ['reqwest/native-tls'] rustls-tls = ['reqwest/rustls-tls'] [dependencies] -async-trait = "0.1.73" +async-trait = "0.1.77" bytes = "1.5.0" -ciborium = "0.2.1" +ciborium = "0.2.2" csv = "1.3.0" -data-encoding = "2.4.0" +data-encoding = "2.5.0" dunce = "1.0.4" -elsa = "1.9.0" -fs4 = "0.6.6" -futures = "0.3.28" +elsa = "1.10.0" +fs4 = "0.7.0" +futures = "0.3.30" html-escape = "0.2.13" -http = "0.2.9" +# reqwest needs an update to 1.0.0 +http = "0.2.1" http-cache-semantics = { version = "1.0.1", default-features = false, features = ["with_serde", "reqwest"] } include_dir = "0.7.3" -indexmap = { version = "2.0.1", features = ["serde"] } +indexmap = { version = "2.2.2", features = ["serde"] } itertools = "0.12.1" -miette = "5.10.0" +miette = "7.0.0" mime = "0.3.17" -once_cell = "1.18.0" +once_cell = "1.19.0" parking_lot = "0.12.1" -peg = "0.8.1" +peg = "0.8.2" pep440_rs = { version = "0.4.0", features = ["serde"] } -pep508_rs = { version = "0.2.4", features = ["serde"] } +pep508_rs = { version = "0.3.0", features = ["serde"] } pin-project-lite = "0.2.13" -rattler_digest = { version = "0.9.0", features = ["serde"] } -regex = "1.9.5" -reqwest = { version = "0.11.20", default-features = false, features = ["json", "stream"] } +rattler_digest = { version = "0.17.0", features = ["serde"] } +regex = "1.10.3" +reqwest = { version = "0.11.24", default-features = false, features = ["json", "stream"] } reqwest-middleware = "0.2.4" -serde = "1.0.188" -serde_json = "1.0.107" -serde_with = "3.3.0" -smallvec = { version = "1.11.1", features = ["const_generics", "const_new"] } -tempfile = "3.8.0" -thiserror = "1.0.49" -tl = "0.7.7" -tokio = { version = "1.32.0", features = ["process", "rt-multi-thread"] } -tokio-util = { version = "0.7.9", features = ["compat"] } -tracing = { version = "0.1.37", default-features = false, features = ["attributes"] } -url = { version = "2.4.1", features = ["serde"] } +serde = "1.0.196" +serde_json = "1.0.113" +serde_with = "3.6.0" +smallvec = { version = "1.13.1", features = ["const_generics", "const_new"] } +tempfile = "3.10.0" +thiserror = "1.0.56" +tl = "0.7.8" +tokio = { version = "1.36.0", features = ["process", "rt-multi-thread"] } +tokio-util = { version = "0.7.10", features = ["compat"] } +tracing = { version = "0.1.40", default-features = false, features = ["attributes"] } +url = { version = "2.5.0", features = ["serde"] } zip = "0.6.6" resolvo = { version = "0.3.0", default-features = false } pathdiff = "0.2.1" -async_zip = { version = "0.0.15", features = ["tokio", "deflate"] } +async_zip = { version = "0.0.16", features = ["tokio", "deflate"] } tar = "0.4.40" flate2 = "1.0.28" -pyproject-toml = "0.8.0" +pyproject-toml = "0.8.2" async-once-cell = "0.5.3" -configparser = "3.0.3" +configparser = "3.0.4" cacache = { version = "12.0.0", default-features = false, features = ["tokio-runtime", "mmap"] } async-recursion = "1.0.5" fs-err = "2.11.0" @@ -73,16 +74,16 @@ async_http_range_reader = "0.6.0" [dev-dependencies] anyhow = "1.0.79" -axum = "0.6.20" +axum = "0.7.4" criterion = "0.5" -insta = { version = "1.33.0", features = ["ron", "redactions"] } -miette = { version = "5.10.0", features = ["fancy"] } -once_cell = "1.18.0" +insta = { version = "1.34.0", features = ["ron", "redactions"] } +miette = { version = "7.0.0", features = ["fancy"] } +once_cell = "1.19.0" rstest = "0.18.2" test-utils = { path = "../test-utils" } -tokio = { version = "1.32.0", features = ["rt", "macros", "rt-multi-thread"] } +tokio = { version = "1.36.0", features = ["rt", "macros", "rt-multi-thread"] } tokio-test = "0.4.3" -tower-http = { version = "0.4.4", features = ["add-extension"] } +tower-http = { version = "0.5.1", features = ["add-extension"] } tracing-test = "0.2.4" [[bench]] diff --git a/crates/rattler_installs_packages/src/artifacts/wheel.rs b/crates/rattler_installs_packages/src/artifacts/wheel.rs index f106d9f6..7ae89590 100644 --- a/crates/rattler_installs_packages/src/artifacts/wheel.rs +++ b/crates/rattler_installs_packages/src/artifacts/wheel.rs @@ -165,7 +165,7 @@ impl Wheel { .file() .entries() .iter() - .filter_map(|e| e.entry().filename().as_str().ok()) + .filter_map(|e| e.filename().as_str().ok()) .map(|filename| { filename .split_once(['/', '\\']) @@ -189,15 +189,15 @@ impl Wheel { .entries() .iter() .enumerate() - .find(|(_, p)| p.entry().filename().as_str().ok() == Some(metadata_path.as_str())) + .find(|(_, p)| p.filename().as_str().ok() == Some(metadata_path.as_str())) .ok_or(WheelVitalsError::MetadataMissing)?; // Get the size of the entry plus the header + size of the filename. We should also actually // include bytes for the extra fields but we don't have that information. let offset = metadata_entry.header_offset(); - let size = metadata_entry.entry().compressed_size() + let size = metadata_entry.compressed_size() + 30 // Header size in bytes - + metadata_entry.entry().filename().as_bytes().len() as u64; + + metadata_entry.filename().as_bytes().len() as u64; // The zip archive uses as BufReader which reads in chunks of 8192. To ensure we prefetch // enough data we round the size up to the nearest multiple of the buffer size. diff --git a/crates/rattler_installs_packages/src/index/direct_url/http.rs b/crates/rattler_installs_packages/src/index/direct_url/http.rs index 7a74c076..cf582f89 100644 --- a/crates/rattler_installs_packages/src/index/direct_url/http.rs +++ b/crates/rattler_installs_packages/src/index/direct_url/http.rs @@ -8,11 +8,12 @@ use crate::types::{ }; use crate::utils::ReadAndSeek; use crate::wheel_builder::WheelBuilder; -use http::{HeaderMap, Method}; use indexmap::IndexMap; use miette::IntoDiagnostic; use pep440_rs::Version; use rattler_digest::Sha256; +use reqwest::header::HeaderMap; +use reqwest::Method; use std::str::FromStr; use std::sync::Arc; use url::Url; diff --git a/crates/rattler_installs_packages/src/index/http.rs b/crates/rattler_installs_packages/src/index/http.rs index 2e9dae1f..232c9b5b 100644 --- a/crates/rattler_installs_packages/src/index/http.rs +++ b/crates/rattler_installs_packages/src/index/http.rs @@ -4,9 +4,9 @@ use super::package_database::NotCached; use crate::utils::{ReadAndSeek, SeekSlice, StreamingOrLocal}; use bytes::Bytes; use futures::{Stream, StreamExt, TryStreamExt}; -use http::header::{ACCEPT, CACHE_CONTROL}; use http_cache_semantics::{AfterResponse, BeforeRequest, CachePolicy}; use miette::Diagnostic; +use reqwest::header::{ACCEPT, CACHE_CONTROL}; use reqwest::{header::HeaderMap, Method}; use reqwest_middleware::ClientWithMiddleware; use serde::{Deserialize, Serialize}; diff --git a/crates/rattler_installs_packages/src/index/package_database.rs b/crates/rattler_installs_packages/src/index/package_database.rs index 8f1b8226..4aa381ce 100644 --- a/crates/rattler_installs_packages/src/index/package_database.rs +++ b/crates/rattler_installs_packages/src/index/package_database.rs @@ -16,9 +16,10 @@ use async_http_range_reader::{AsyncHttpRangeReader, CheckSupportMethod}; use async_recursion::async_recursion; use elsa::sync::FrozenMap; use futures::{pin_mut, stream, StreamExt}; -use http::{header::CONTENT_TYPE, HeaderMap, HeaderValue, Method}; use indexmap::IndexMap; use miette::{self, Diagnostic, IntoDiagnostic}; +use reqwest::header::{HeaderMap, HeaderValue, CONTENT_TYPE}; +use reqwest::Method; use reqwest::{header::CACHE_CONTROL, StatusCode}; use reqwest_middleware::ClientWithMiddleware; @@ -743,13 +744,15 @@ mod test { use crate::types::PackageName; use reqwest::Client; use tempfile::TempDir; + use tokio::task::JoinHandle; use crate::index::package_sources::PackageSourcesBuilder; use axum::response::{Html, IntoResponse}; use axum::routing::get; use axum::Router; use insta::assert_debug_snapshot; - use std::net::{SocketAddr, TcpListener}; + use std::future::IntoFuture; + use std::net::SocketAddr; use tower_http::add_extension::AddExtensionLayer; async fn get_index( @@ -781,14 +784,15 @@ mod test { let html = format!("{}", link_list); Html(html).into_response() } else { - StatusCode::NOT_FOUND.into_response() + axum::http::StatusCode::NOT_FOUND.into_response() } } async fn make_simple_server( package_name: &str, - ) -> anyhow::Result<(Url, tokio::task::JoinHandle<()>)> { - let listener = TcpListener::bind(SocketAddr::from(([127, 0, 0, 1], 0)))?; + ) -> anyhow::Result<(Url, JoinHandle>)> { + let addr = SocketAddr::new([127, 0, 0, 1].into(), 0); + let listener = tokio::net::TcpListener::bind(&addr).await.unwrap(); let address = listener.local_addr()?; let router = Router::new() @@ -796,17 +800,14 @@ mod test { .route("/simple/:package/", get(get_package)) .layer(AddExtensionLayer::new(package_name.to_string())); - let listener = listener.try_into()?; - let server = tokio::spawn(async move { - axum::Server::from_tcp(listener) - .unwrap() - .serve(router.into_make_service()) - .await - .unwrap() - }); + let server = axum::serve(listener, router).into_future(); + + // Spawn the server. + let join_handle = tokio::spawn(server); + println!("Server started"); let url = format!("http://{}/simple/", address).parse()?; - Ok((url, server)) + Ok((url, join_handle)) } fn make_package_db() -> (TempDir, PackageDb) { @@ -883,7 +884,11 @@ mod test { .await; // Should not fail because 404s are skipped - assert!(pytest_result.is_ok()); + assert!( + pytest_result.is_ok(), + "`pytest_result` not ok: {:?}", + pytest_result + ); let test_package_result = package_db .available_artifacts(ArtifactRequest::FromIndex(normalized_name)) diff --git a/crates/rip_bin/Cargo.toml b/crates/rip_bin/Cargo.toml index 05e7709f..fe2c02b7 100644 --- a/crates/rip_bin/Cargo.toml +++ b/crates/rip_bin/Cargo.toml @@ -21,24 +21,24 @@ native-tls = ['rattler_installs_packages/native-tls'] rustls-tls = ['rattler_installs_packages/rustls-tls'] [dependencies] -clap = { version = "4.4.5", features = ["derive"] } -console = { version = "0.15.7", features = ["windows-console-colors"] } +clap = { version = "4.4.18", features = ["derive"] } +console = { version = "0.15.8", features = ["windows-console-colors"] } dirs = "5.0.1" -indexmap = "2.0.1" +indexmap = "2.2.2" indicatif = "0.17.7" itertools = "0.12.1" -miette = { version = "5.10.0", features = ["fancy"] } +miette = { version = "7.0.0", features = ["fancy"] } rattler_installs_packages = { path = "../rattler_installs_packages", default-features = false } -reqwest = { version = "0.11.20", default-features = false } +reqwest = { version = "0.11.24", default-features = false } reqwest-middleware = "0.2.4" -tabwriter = { version = "1.3.0", features = ["ansi_formatting"] } -tokio = { version = "1.32.0", features = ["rt", "macros", "rt-multi-thread"] } -tracing = "0.1.37" -tracing-subscriber = { version = "0.3.17", features = ["env-filter"] } -url = "2.4.1" +tabwriter = { version = "1.4.0", features = ["ansi_formatting"] } +tokio = { version = "1.36.0", features = ["rt", "macros", "rt-multi-thread"] } +tracing = "0.1.40" +tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } +url = "2.5.0" rand = "0.8.5" -serde = "1.0.188" -serde_json = "1.0.107" +serde = "1.0.196" +serde_json = "1.0.113" fs-err = "2.11.0" [package.metadata.release] diff --git a/crates/test-utils/Cargo.toml b/crates/test-utils/Cargo.toml index 3d486cc8..5098c535 100644 --- a/crates/test-utils/Cargo.toml +++ b/crates/test-utils/Cargo.toml @@ -10,15 +10,15 @@ readme.workspace = true rust-version.workspace = true [dependencies] -url = "2.4.1" -thiserror = "1.0.49" -rattler_digest = "0.11.0" -reqwest = { version = "0.11.22", default-features = false, features = ["blocking", "rustls"] } -tempfile = "3.8.0" +url = "2.5.0" +thiserror = "1.0.56" +rattler_digest = "0.17.0" +reqwest = { version = "0.11.24", default-features = false, features = ["blocking", "rustls"] } +tempfile = "3.10.0" dirs = "5.0.1" fslock = "0.2.1" -data-encoding = "2.4.0" -tokio = "1.34.0" +data-encoding = "2.5.0" +tokio = "1.36.0" [package.metadata.release] release = false