diff --git a/Cargo.lock b/Cargo.lock index 676b797f..f2f2eaab 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -117,6 +117,28 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "async-stream" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51" +dependencies = [ + "async-stream-impl", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "async-trait" version = "0.1.73" @@ -1785,6 +1807,7 @@ dependencies = [ "ciborium", "criterion", "data-encoding", + "dirs", "elsa", "fs4", "futures", @@ -1811,6 +1834,7 @@ dependencies = [ "thiserror", "tl", "tokio", + "tokio-test", "tokio-util", "tracing", "url", @@ -2560,6 +2584,30 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-stream" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-test" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e89b3cbabd3ae862100094ae433e1def582cf86451b4e9bf83aa7ac1d8a7d719" +dependencies = [ + "async-stream", + "bytes", + "futures-core", + "tokio", + "tokio-stream", +] + [[package]] name = "tokio-util" version = "0.7.9" diff --git a/crates/rattler_installs_packages/Cargo.toml b/crates/rattler_installs_packages/Cargo.toml index aac6ea24..435f34a0 100644 --- a/crates/rattler_installs_packages/Cargo.toml +++ b/crates/rattler_installs_packages/Cargo.toml @@ -50,13 +50,15 @@ tracing = { version = "0.1.37", default-features = false, features = ["attribute url = { version = "2.4.1", features = ["serde"] } zip = "0.6.6" resolvo = { version = "0.1.0", optional = true } +dirs = "5.0.1" [dev-dependencies] criterion = "0.3" insta = { version = "1.32.0", features = ["ron"] } miette = { version = "5.10.0", features = ["fancy"] } once_cell = "1.18.0" -tokio = { version = "1.32.0", features = ["rt", "macros"] } +tokio = { version = "1.32.0", features = ["rt", "macros", "rt-multi-thread"] } +tokio-test = "0.4.3" [[bench]] name = "html" diff --git a/crates/rattler_installs_packages/src/requirement.rs b/crates/rattler_installs_packages/src/requirement.rs index cf5447d8..d391b6a2 100644 --- a/crates/rattler_installs_packages/src/requirement.rs +++ b/crates/rattler_installs_packages/src/requirement.rs @@ -325,6 +325,16 @@ impl Deref for PackageRequirement { #[derive(Debug, Clone, PartialEq, Eq, DeserializeFromStr, SerializeDisplay)] pub struct UserRequirement(Requirement); +impl UserRequirement { + pub fn into_inner(self) -> Requirement { + self.0 + } + + pub fn as_inner(&self) -> &Requirement { + &self.0 + } +} + impl Display for UserRequirement { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { self.0.fmt(f) diff --git a/crates/rattler_installs_packages/src/resolve.rs b/crates/rattler_installs_packages/src/resolve.rs index 85a1fca0..6d7a17c9 100644 --- a/crates/rattler_installs_packages/src/resolve.rs +++ b/crates/rattler_installs_packages/src/resolve.rs @@ -1,6 +1,6 @@ use crate::{ - CompareOp, Extra, NormalizedPackageName, PackageDb, PackageName, PackageRequirement, - Requirement, Specifier, Specifiers, Version, Wheel, + CompareOp, Extra, NormalizedPackageName, PackageDb, PackageName, Requirement, Specifier, + Specifiers, UserRequirement, Version, Wheel, }; use resolvo::{ Candidates, DefaultSolvableDisplay, Dependencies, DependencyProvider, NameId, Pool, SolvableId, @@ -302,7 +302,7 @@ impl<'db> DependencyProvider for PypiDependency /// requirements. pub async fn resolve( package_db: &PackageDb, - requirements: impl IntoIterator, + requirements: impl IntoIterator, ) -> Result)>, String> { // Construct a provider let provider = PypiDependencyProvider::new(package_db); @@ -319,7 +319,7 @@ pub async fn resolve( specifiers, extras, .. - } in requirements.map(PackageRequirement::as_inner) + } in requirements.map(UserRequirement::as_inner) { let dependency_package_name = pool.intern_package_name(PypiPackageName::Base(name.clone().into())); diff --git a/crates/rip_bin/src/main.rs b/crates/rip_bin/src/main.rs index 8b886b57..62c8f053 100644 --- a/crates/rip_bin/src/main.rs +++ b/crates/rip_bin/src/main.rs @@ -7,13 +7,13 @@ use miette::IntoDiagnostic; use tracing_subscriber::{fmt, layer::SubscriberExt, util::SubscriberInitExt, EnvFilter}; use url::Url; -use rattler_installs_packages::{normalize_index_url, resolve, PackageRequirement}; +use rattler_installs_packages::{normalize_index_url, resolve, UserRequirement}; #[derive(Parser)] #[command(author, version, about, long_about = None)] struct Args { #[clap(num_args=1.., required=true)] - specs: Vec, + specs: Vec, /// Base URL of the Python Package Index (default https://pypi.org/simple). This should point /// to a repository compliant with PEP 503 (the simple repository API).