Skip to content

Commit

Permalink
Feat/split crates (#16)
Browse files Browse the repository at this point in the history
Split binary crates up as described in: #8
  • Loading branch information
tdejager authored Sep 26, 2023
1 parent c19fabd commit 83f4751
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 62 deletions.
8 changes: 3 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions crates/index/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand All @@ -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]
Expand Down
14 changes: 4 additions & 10 deletions crates/index/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -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"))?
Expand Down
4 changes: 3 additions & 1 deletion crates/rattler_installs_packages/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "rattler_installs_packages"
version.workspace = true
edition.workspace = true
authors = ["Bas Zalmstra <[email protected]>"]
authors = ["Bas Zalmstra <[email protected]>", "Tim de Jager <[email protected]>"]
description = "Datastructures and algorithms to interact with Python packaging ecosystem"
categories.workspace = true
homepage.workspace = true
Expand All @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
5 changes: 5 additions & 0 deletions crates/rattler_installs_packages/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
2 changes: 1 addition & 1 deletion crates/rattler_installs_packages/src/package_database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ mod test {
.unwrap();

let (_artifact, _metadata) = package_db
.get_pep658_metadata::<Wheel>(&artifact_info)
.get_pep658_metadata::<Wheel>(artifact_info)
.await
.unwrap();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use rattler_installs_packages::{
use crate::{
CompareOp, Extra, NormalizedPackageName, PackageDb, Requirement, Specifier, Specifiers,
Version, Wheel,
};
Expand Down
10 changes: 10 additions & 0 deletions crates/rattler_installs_packages/src/utils.rs
Original file line number Diff line number Diff line change
@@ -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`].
Expand Down Expand Up @@ -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
}
2 changes: 0 additions & 2 deletions crates/rip/src/lib.rs

This file was deleted.

33 changes: 16 additions & 17 deletions crates/rip/Cargo.toml → crates/rip_bin/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,42 +1,41 @@
[package]
name = "rip"
name = "rip_bin"
version.workspace = true
edition.workspace = true
authors = ["Bas Zalmstra <[email protected]>"]
authors = ["Bas Zalmstra <[email protected]>", "Tim de Jager <[email protected]>"]
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
Expand Down
File renamed without changes.
27 changes: 5 additions & 22 deletions crates/rip/src/main.rs → crates/rip_bin/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use rip_bin::{global_multi_progress, IndicatifWriter};
use std::io::Write;

use clap::Parser;
Expand All @@ -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)]
Expand Down Expand Up @@ -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());
}
}

0 comments on commit 83f4751

Please sign in to comment.