From b013ea9c93863d674bd35a5267e7cdb974e6aeb1 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Mon, 6 Nov 2023 10:26:33 -0800 Subject: [PATCH] Move `DirectUrl` into `pypi-types` (#343) This needs to be reused elsewhere, and there's nothing specific to wheel installation about it. --- Cargo.lock | 1 + crates/install-wheel-rs/Cargo.toml | 3 ++- crates/install-wheel-rs/src/lib.rs | 2 -- crates/install-wheel-rs/src/linker.rs | 4 +++- crates/install-wheel-rs/src/wheel.rs | 4 ++-- crates/{install-wheel-rs => pypi-types}/src/direct_url.rs | 0 crates/pypi-types/src/lib.rs | 2 ++ 7 files changed, 10 insertions(+), 6 deletions(-) rename crates/{install-wheel-rs => pypi-types}/src/direct_url.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index 0fd03a70d..738c54ea1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1445,6 +1445,7 @@ dependencies = [ "platform-info", "plist", "pyo3", + "pypi-types", "rayon", "reflink-copy", "regex", diff --git a/crates/install-wheel-rs/Cargo.toml b/crates/install-wheel-rs/Cargo.toml index d7f206fdf..e935fe7d5 100644 --- a/crates/install-wheel-rs/Cargo.toml +++ b/crates/install-wheel-rs/Cargo.toml @@ -17,8 +17,9 @@ license = { workspace = true } name = "install_wheel_rs" [dependencies] -platform-host = { path = "../platform-host" } distribution-filename = { path = "../distribution-filename" } +platform-host = { path = "../platform-host" } +pypi-types = { path = "../pypi-types" } clap = { workspace = true, optional = true, features = ["derive", "env"] } configparser = { workspace = true } diff --git a/crates/install-wheel-rs/src/lib.rs b/crates/install-wheel-rs/src/lib.rs index c49f4b774..d2839ee9a 100644 --- a/crates/install-wheel-rs/src/lib.rs +++ b/crates/install-wheel-rs/src/lib.rs @@ -7,7 +7,6 @@ use platform_info::PlatformInfoError; use thiserror::Error; use zip::result::ZipError; -pub use direct_url::DirectUrl; pub use install_location::{normalize_name, InstallLocation, LockedDir}; use platform_host::{Arch, Os}; pub use record::RecordEntry; @@ -18,7 +17,6 @@ pub use wheel::{ relative_to, SHEBANG_PYTHON, }; -mod direct_url; mod install_location; pub mod linker; #[cfg(feature = "python_bindings")] diff --git a/crates/install-wheel-rs/src/linker.rs b/crates/install-wheel-rs/src/linker.rs index ad487c265..cc2a0875a 100644 --- a/crates/install-wheel-rs/src/linker.rs +++ b/crates/install-wheel-rs/src/linker.rs @@ -10,12 +10,14 @@ use fs_err::File; use mailparse::MailHeaderMap; use tracing::{debug, span, Level}; +use pypi_types::DirectUrl; + use crate::install_location::InstallLocation; use crate::wheel::{ extra_dist_info, install_data, parse_wheel_version, read_scripts_from_section, write_script_entrypoints, }; -use crate::{read_record_file, DirectUrl, Error, Script}; +use crate::{read_record_file, Error, Script}; /// Install the given wheel to the given venv /// diff --git a/crates/install-wheel-rs/src/wheel.rs b/crates/install-wheel-rs/src/wheel.rs index 8c81e3b25..ef9904930 100644 --- a/crates/install-wheel-rs/src/wheel.rs +++ b/crates/install-wheel-rs/src/wheel.rs @@ -14,18 +14,18 @@ use mailparse::MailHeaderMap; use sha2::{Digest, Sha256}; use tempfile::tempdir; use tracing::{debug, error, span, warn, Level}; - use walkdir::WalkDir; use zip::result::ZipError; use zip::write::FileOptions; use zip::{ZipArchive, ZipWriter}; use distribution_filename::WheelFilename; +use pypi_types::DirectUrl; use crate::install_location::{InstallLocation, LockedDir}; use crate::record::RecordEntry; use crate::script::Script; -use crate::{DirectUrl, Error}; +use crate::Error; /// `#!/usr/bin/env python` pub const SHEBANG_PYTHON: &str = "#!/usr/bin/env python"; diff --git a/crates/install-wheel-rs/src/direct_url.rs b/crates/pypi-types/src/direct_url.rs similarity index 100% rename from crates/install-wheel-rs/src/direct_url.rs rename to crates/pypi-types/src/direct_url.rs diff --git a/crates/pypi-types/src/lib.rs b/crates/pypi-types/src/lib.rs index 7eebebae1..21fdc091e 100644 --- a/crates/pypi-types/src/lib.rs +++ b/crates/pypi-types/src/lib.rs @@ -1,5 +1,7 @@ +pub use direct_url::DirectUrl; pub use metadata::{Error, Metadata21}; pub use simple_json::{File, SimpleJson}; +mod direct_url; mod metadata; mod simple_json;