From b5e4eb7fd91c434faa422d12cde2a5c7868556dc Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Tue, 16 Jan 2024 23:05:44 -0500 Subject: [PATCH] Move OnceMap into its own crate --- Cargo.lock | 12 ++++++++++-- crates/once-map/Cargo.toml | 17 +++++++++++++++++ .../src/once_map.rs => once-map/src/lib.rs} | 0 crates/puffin-resolver/Cargo.toml | 3 ++- crates/puffin-resolver/src/error.rs | 2 +- crates/puffin-resolver/src/resolution.rs | 2 +- crates/puffin-resolver/src/resolver/index.rs | 2 +- crates/puffin-traits/Cargo.toml | 3 +-- crates/puffin-traits/src/lib.rs | 4 +--- 9 files changed, 34 insertions(+), 11 deletions(-) create mode 100644 crates/once-map/Cargo.toml rename crates/{puffin-traits/src/once_map.rs => once-map/src/lib.rs} (100%) diff --git a/Cargo.lock b/Cargo.lock index 7304c4508a486..c9f42ce25292e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1922,6 +1922,14 @@ dependencies = [ "memchr", ] +[[package]] +name = "once-map" +version = "0.0.1" +dependencies = [ + "rustc-hash", + "waitmap", +] + [[package]] name = "once_cell" version = "1.19.0" @@ -2680,6 +2688,7 @@ dependencies = [ "insta", "install-wheel-rs", "itertools 0.12.0", + "once-map", "once_cell", "owo-colors", "pep440_rs 0.3.12", @@ -2718,12 +2727,11 @@ version = "0.0.1" dependencies = [ "anyhow", "distribution-types", + "once-map", "pep508_rs", "puffin-cache", "puffin-interpreter", - "rustc-hash", "tokio", - "waitmap", ] [[package]] diff --git a/crates/once-map/Cargo.toml b/crates/once-map/Cargo.toml new file mode 100644 index 0000000000000..c0332d4a50346 --- /dev/null +++ b/crates/once-map/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "once-map" +version = "0.0.1" +edition = { workspace = true } +rust-version = { workspace = true } +homepage = { workspace = true } +documentation = { workspace = true } +repository = { workspace = true } +authors = { workspace = true } +license = { workspace = true } + +[lints] +workspace = true + +[dependencies] +rustc-hash = { workspace = true } +waitmap = { workspace = true } diff --git a/crates/puffin-traits/src/once_map.rs b/crates/once-map/src/lib.rs similarity index 100% rename from crates/puffin-traits/src/once_map.rs rename to crates/once-map/src/lib.rs diff --git a/crates/puffin-resolver/Cargo.toml b/crates/puffin-resolver/Cargo.toml index dff6a2607d071..3690498c92e39 100644 --- a/crates/puffin-resolver/Cargo.toml +++ b/crates/puffin-resolver/Cargo.toml @@ -17,6 +17,7 @@ cache-key = { path = "../cache-key" } distribution-filename = { path = "../distribution-filename", features = ["serde"] } distribution-types = { path = "../distribution-types" } install-wheel-rs = { path = "../install-wheel-rs" } +once-map = { path = "../once-map" } pep440_rs = { path = "../pep440-rs", features = ["pubgrub"] } pep508_rs = { path = "../pep508-rs" } platform-host = { path = "../platform-host" } @@ -26,9 +27,9 @@ puffin-client = { path = "../puffin-client" } puffin-distribution = { path = "../puffin-distribution" } puffin-git = { path = "../puffin-git" } puffin-interpreter = { path = "../puffin-interpreter" } -puffin-warnings = { path = "../puffin-warnings" } puffin-normalize = { path = "../puffin-normalize" } puffin-traits = { path = "../puffin-traits" } +puffin-warnings = { path = "../puffin-warnings" } pypi-types = { path = "../pypi-types" } requirements-txt = { path = "../requirements-txt" } diff --git a/crates/puffin-resolver/src/error.rs b/crates/puffin-resolver/src/error.rs index 1d29e5afa97dd..71fdac5547c48 100644 --- a/crates/puffin-resolver/src/error.rs +++ b/crates/puffin-resolver/src/error.rs @@ -8,11 +8,11 @@ use thiserror::Error; use url::Url; use distribution_types::{BuiltDist, PathBuiltDist, PathSourceDist, SourceDist}; +use once_map::OnceMap; use pep440_rs::Version; use pep508_rs::Requirement; use puffin_distribution::DistributionDatabaseError; use puffin_normalize::PackageName; -use puffin_traits::OnceMap; use crate::candidate_selector::CandidateSelector; use crate::pubgrub::{PubGrubPackage, PubGrubPython, PubGrubReportFormatter}; diff --git a/crates/puffin-resolver/src/resolution.rs b/crates/puffin-resolver/src/resolution.rs index 41f201eafdeef..20a8795548a43 100644 --- a/crates/puffin-resolver/src/resolution.rs +++ b/crates/puffin-resolver/src/resolution.rs @@ -12,10 +12,10 @@ use rustc_hash::FxHashMap; use url::Url; use distribution_types::{Dist, DistributionMetadata, LocalEditable, Name, PackageId, Verbatim}; +use once_map::OnceMap; use pep440_rs::Version; use pep508_rs::VerbatimUrl; use puffin_normalize::{ExtraName, PackageName}; -use puffin_traits::OnceMap; use pypi_types::{Hashes, Metadata21}; use crate::pins::FilePins; diff --git a/crates/puffin-resolver/src/resolver/index.rs b/crates/puffin-resolver/src/resolver/index.rs index a5e9b51859a31..c8e58fbfd2f11 100644 --- a/crates/puffin-resolver/src/resolver/index.rs +++ b/crates/puffin-resolver/src/resolver/index.rs @@ -2,8 +2,8 @@ use dashmap::DashMap; use url::Url; use distribution_types::PackageId; +use once_map::OnceMap; use puffin_normalize::PackageName; -use puffin_traits::OnceMap; use pypi_types::Metadata21; use crate::version_map::VersionMap; diff --git a/crates/puffin-traits/Cargo.toml b/crates/puffin-traits/Cargo.toml index 08ddf697af6a0..ed80f348d8682 100644 --- a/crates/puffin-traits/Cargo.toml +++ b/crates/puffin-traits/Cargo.toml @@ -14,11 +14,10 @@ workspace = true [dependencies] distribution-types = { path = "../distribution-types" } +once-map = { path = "../once-map" } pep508_rs = { path = "../pep508-rs" } puffin-cache = { path = "../puffin-cache" } puffin-interpreter = { path = "../puffin-interpreter" } anyhow = { workspace = true } -rustc-hash = { workspace = true } tokio = { workspace = true, features = ["sync"] } -waitmap = { workspace = true } diff --git a/crates/puffin-traits/src/lib.rs b/crates/puffin-traits/src/lib.rs index 20637697c094a..0641e33b1871a 100644 --- a/crates/puffin-traits/src/lib.rs +++ b/crates/puffin-traits/src/lib.rs @@ -7,13 +7,11 @@ use std::path::{Path, PathBuf}; use anyhow::Result; use distribution_types::{CachedDist, DistributionId, Resolution}; -pub use once_map::OnceMap; +use once_map::OnceMap; use pep508_rs::Requirement; use puffin_cache::Cache; use puffin_interpreter::{Interpreter, Virtualenv}; -mod once_map; - /// Avoid cyclic crate dependencies between resolver, installer and builder. /// /// To resolve the dependencies of a packages, we may need to build one or more source