diff --git a/Cargo.lock b/Cargo.lock index 7a8847ff..413dd567 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1129,7 +1129,7 @@ dependencies = [ "miette", "rand", "rattler_installs_packages", - "rip", + "rip_bin", "rusqlite", "serde_json", "tokio", @@ -1802,6 +1802,7 @@ dependencies = [ "rattler_digest", "regex", "reqwest", + "resolvo", "serde", "serde_json", "serde_with", @@ -1982,7 +1983,7 @@ dependencies = [ ] [[package]] -name = "rip" +name = "rip_bin" version = "0.1.0" dependencies = [ "clap 4.4.5", @@ -1994,12 +1995,9 @@ dependencies = [ "miette", "rand", "rattler_installs_packages", - "reqwest", "resolvo", - "rusqlite", "serde", "serde_json", - "serde_with", "tabwriter", "tokio", "tracing", diff --git a/crates/index/Cargo.toml b/crates/index/Cargo.toml index 3eab6855..95a6d2cd 100644 --- a/crates/index/Cargo.toml +++ b/crates/index/Cargo.toml @@ -12,8 +12,8 @@ rust-version.workspace = true [features] default = ["native-tls"] -native-tls = ['rattler_installs_packages/native-tls', 'rip/native-tls'] -rustls-tls = ['rattler_installs_packages/rustls-tls', 'rip/rustls-tls'] +native-tls = ['rattler_installs_packages/native-tls', 'rip_bin/native-tls'] +rustls-tls = ['rattler_installs_packages/rustls-tls', 'rip_bin/rustls-tls'] [dependencies] clap = { version = "4.4.5", features = ["derive"] } @@ -23,13 +23,13 @@ indicatif = "0.17.7" miette = { version = "5.10.0", features = ["fancy"] } rand = "0.8.5" rattler_installs_packages = { path = "../rattler_installs_packages", default-features = false } -rip = { path = "../rip", default-features = false } rusqlite = { version = "0.29.0", features = ["bundled"] } serde_json = "1.0.107" 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" +rip_bin = { path = "../rip_bin", default-features = false } [package.metadata.release] diff --git a/crates/index/src/main.rs b/crates/index/src/main.rs index 265c9774..d99aa5ef 100644 --- a/crates/index/src/main.rs +++ b/crates/index/src/main.rs @@ -14,8 +14,10 @@ use tracing_subscriber::fmt::format::FmtSpan; use tracing_subscriber::util::SubscriberInitExt; use url::Url; -use rattler_installs_packages::{Extra, PackageName, PackageRequirement, Wheel}; -use rip::writer::{global_multi_progress, IndicatifWriter}; +use rattler_installs_packages::{ + normalize_index_url, Extra, PackageName, PackageRequirement, Wheel, +}; +use rip_bin::{global_multi_progress, IndicatifWriter}; #[derive(Parser)] #[command(author, version, about, long_about = None)] @@ -33,14 +35,6 @@ enum Command { Index, ListExtras, } -fn normalize_index_url(mut url: Url) -> Url { - let path = url.path(); - if !path.ends_with('/') { - url.set_path(&format!("{path}/")); - } - url -} - pub async fn index(index_url: Url) -> Result<(), miette::Error> { let cache_dir = dirs::cache_dir() .ok_or_else(|| miette::miette!("failed to determine cache directory"))? diff --git a/crates/rattler_installs_packages/Cargo.toml b/crates/rattler_installs_packages/Cargo.toml index bb54abfe..e69cc431 100644 --- a/crates/rattler_installs_packages/Cargo.toml +++ b/crates/rattler_installs_packages/Cargo.toml @@ -2,7 +2,7 @@ name = "rattler_installs_packages" version.workspace = true edition.workspace = true -authors = ["Bas Zalmstra "] +authors = ["Bas Zalmstra ", "Tim de Jager "] description = "Datastructures and algorithms to interact with Python packaging ecosystem" categories.workspace = true homepage.workspace = true @@ -15,6 +15,7 @@ rust-version.workspace = true default = ["native-tls"] native-tls = ['reqwest/native-tls'] rustls-tls = ['reqwest/rustls-tls'] +resolvo-pypi = [] [dependencies] async-trait = "0.1.73" @@ -49,6 +50,7 @@ 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"] } zip = "0.6.6" +resolvo = "0.1.0" [dev-dependencies] criterion = "0.3" diff --git a/crates/rattler_installs_packages/src/lib.rs b/crates/rattler_installs_packages/src/lib.rs index dcbaa8e1..8c225d7a 100644 --- a/crates/rattler_installs_packages/src/lib.rs +++ b/crates/rattler_installs_packages/src/lib.rs @@ -15,6 +15,9 @@ mod seek_slice; mod specifier; mod utils; +#[cfg(feature = "resolvo-pypi")] +pub mod resolvo_pypi; + pub use file_store::{CacheKey, FileStore}; pub use package_database::PackageDb; @@ -31,3 +34,5 @@ pub use requirement::{ marker, PackageRequirement, ParseExtra, PythonRequirement, Requirement, UserRequirement, }; pub use specifier::{CompareOp, Specifier, Specifiers}; + +pub use utils::normalize_index_url; diff --git a/crates/rattler_installs_packages/src/package_database.rs b/crates/rattler_installs_packages/src/package_database.rs index c923fee8..ba1fe4de 100644 --- a/crates/rattler_installs_packages/src/package_database.rs +++ b/crates/rattler_installs_packages/src/package_database.rs @@ -396,7 +396,7 @@ mod test { .unwrap(); let (_artifact, _metadata) = package_db - .get_pep658_metadata::(&artifact_info) + .get_pep658_metadata::(artifact_info) .await .unwrap(); } diff --git a/crates/rip/src/pypi_provider.rs b/crates/rattler_installs_packages/src/resolvo_pypi.rs similarity index 99% rename from crates/rip/src/pypi_provider.rs rename to crates/rattler_installs_packages/src/resolvo_pypi.rs index 0d9b71a1..cf579c38 100644 --- a/crates/rip/src/pypi_provider.rs +++ b/crates/rattler_installs_packages/src/resolvo_pypi.rs @@ -1,4 +1,4 @@ -use rattler_installs_packages::{ +use crate::{ CompareOp, Extra, NormalizedPackageName, PackageDb, Requirement, Specifier, Specifiers, Version, Wheel, }; diff --git a/crates/rattler_installs_packages/src/utils.rs b/crates/rattler_installs_packages/src/utils.rs index 3933a04f..a9486abc 100644 --- a/crates/rattler_installs_packages/src/utils.rs +++ b/crates/rattler_installs_packages/src/utils.rs @@ -1,6 +1,7 @@ use futures::{AsyncRead, AsyncReadExt, AsyncSeekExt}; use std::io::{Read, Seek, SeekFrom}; use tokio_util::compat::TokioAsyncReadCompatExt; +use url::Url; /// Keep retrying a certain IO function until it either succeeds or until it doesnt return /// [`std::io::ErrorKind::Interrupted`]. @@ -72,3 +73,12 @@ impl StreamingOrLocal { } } } + +/// Normalize url according to pip standards +pub fn normalize_index_url(mut url: Url) -> Url { + let path = url.path(); + if !path.ends_with('/') { + url.set_path(&format!("{path}/")); + } + url +} diff --git a/crates/rip/src/lib.rs b/crates/rip/src/lib.rs deleted file mode 100644 index c644d7af..00000000 --- a/crates/rip/src/lib.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod pypi_provider; -pub mod writer; diff --git a/crates/rip/Cargo.toml b/crates/rip_bin/Cargo.toml similarity index 55% rename from crates/rip/Cargo.toml rename to crates/rip_bin/Cargo.toml index f76e2614..9d516bcd 100644 --- a/crates/rip/Cargo.toml +++ b/crates/rip_bin/Cargo.toml @@ -1,42 +1,41 @@ [package] -name = "rip" +name = "rip_bin" version.workspace = true edition.workspace = true -authors = ["Bas Zalmstra "] +authors = ["Bas Zalmstra ", "Tim de Jager "] description = "Binary to verify and play around with rattler_installs_packages" categories.workspace = true homepage.workspace = true repository.workspace = true license.workspace = true readme.workspace = true -default-run = "rip" +default-run = "rip_bin" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [features] default = ["native-tls"] -native-tls = ['reqwest/native-tls', 'rattler_installs_packages/native-tls'] -rustls-tls = ['reqwest/rustls-tls', 'rattler_installs_packages/rustls-tls'] +native-tls = ['rattler_installs_packages/native-tls'] +rustls-tls = ['rattler_installs_packages/rustls-tls'] [dependencies] -clap = { version = "4.4.5", features = ["derive"] } +clap = { version = "4.3.23", features = ["derive"] } console = { version = "0.15.7", features = ["windows-console-colors"] } dirs = "5.0.1" indexmap = "2.0.0" -indicatif = "0.17.7" +indicatif = "0.17.6" itertools = "0.11.0" miette = { version = "5.10.0", features = ["fancy"] } -rand = "0.8.5" -rattler_installs_packages = { path = "../rattler_installs_packages", default-features = false } -reqwest = { version = "0.11.20", default-features = false } +rattler_installs_packages = { path = "../rattler_installs_packages", default-features = false, features = ["resolvo-pypi"] } resolvo = "0.1.0" -rusqlite = { version = "0.29.0", features = ["bundled"] } +tabwriter = { version = "1.2.1", features = ["ansi_formatting"] } +tokio = { version = "1.29.1", features = ["rt", "macros", "rt-multi-thread"] } +tracing = "0.1.37" +tracing-subscriber = { version = "0.3.17", features = ["env-filter"]} +url = "2.4.0" +rand = "0.8.4" serde = "1.0.188" serde_json = "1.0.107" -serde_with = "3.3.0" -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" [package.metadata.release] # Dont publish the binary diff --git a/crates/rip/src/writer.rs b/crates/rip_bin/src/lib.rs similarity index 100% rename from crates/rip/src/writer.rs rename to crates/rip_bin/src/lib.rs diff --git a/crates/rip/src/main.rs b/crates/rip_bin/src/main.rs similarity index 89% rename from crates/rip/src/main.rs rename to crates/rip_bin/src/main.rs index cd8351e7..bb3db76f 100644 --- a/crates/rip/src/main.rs +++ b/crates/rip_bin/src/main.rs @@ -1,3 +1,4 @@ +use rip_bin::{global_multi_progress, IndicatifWriter}; use std::io::Write; use clap::Parser; @@ -6,11 +7,11 @@ use resolvo::{DefaultSolvableDisplay, DependencyProvider, Solver}; use tracing_subscriber::{fmt, layer::SubscriberExt, util::SubscriberInitExt, EnvFilter}; use url::Url; -use rattler_installs_packages::{PackageRequirement, Requirement}; -use rip::{ - pypi_provider::{PypiDependencyProvider, PypiPackageName}, - writer::{global_multi_progress, IndicatifWriter}, +use rattler_installs_packages::{ + normalize_index_url, + resolvo_pypi::{PypiDependencyProvider, PypiPackageName}, }; +use rattler_installs_packages::{PackageRequirement, Requirement}; #[derive(Parser)] #[command(author, version, about, long_about = None)] @@ -128,21 +129,3 @@ async fn main() { eprintln!("{e:?}"); } } - -fn normalize_index_url(mut url: Url) -> Url { - let path = url.path(); - if !path.ends_with('/') { - url.set_path(&format!("{path}/")); - } - url -} - -#[cfg(test)] -mod test { - use rattler_installs_packages::Version; - - #[test] - fn valid_version() { - assert!(Version::parse("1.2.1").is_some()); - } -}