From a5bd8e594df3f099e63feafdaa674023b841acc1 Mon Sep 17 00:00:00 2001 From: messense Date: Tue, 27 Sep 2022 14:52:43 +0800 Subject: [PATCH 1/2] Fix resolving crate name bug --- Changelog.md | 2 ++ src/build_options.rs | 3 ++- src/cargo_toml.rs | 1 + src/project_layout.rs | 5 ++++- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Changelog.md b/Changelog.md index e46c9419c..83073485e 100644 --- a/Changelog.md +++ b/Changelog.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +* Fix resolving crate name bug in [#1142](https://github.com/PyO3/maturin/pull/1142) + ## [0.13.4] - 2022-09-27 * Fix `Cargo.toml` in new project template in [#1109](https://github.com/PyO3/maturin/pull/1109) diff --git a/src/build_options.rs b/src/build_options.rs index c63effba3..7fd5f620d 100644 --- a/src/build_options.rs +++ b/src/build_options.rs @@ -488,6 +488,7 @@ impl BuildOptions { let ProjectResolver { project_layout, cargo_toml_path, + cargo_toml, pyproject_toml_path, pyproject_toml, module_name, @@ -684,7 +685,7 @@ impl BuildOptions { .target_dir .clone() .unwrap_or_else(|| cargo_metadata.target_directory.clone().into_std_path_buf()); - let crate_name = metadata21.name.clone(); + let crate_name = cargo_toml.package.name; Ok(BuildContext { target, diff --git a/src/cargo_toml.rs b/src/cargo_toml.rs index 4bfff0f7c..6f3dd0d27 100644 --- a/src/cargo_toml.rs +++ b/src/cargo_toml.rs @@ -16,6 +16,7 @@ pub(crate) struct CargoTomlLib { #[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq)] #[serde(rename_all = "kebab-case")] pub(crate) struct CargoTomlPackage { + pub(crate) name: String, metadata: Option, } diff --git a/src/project_layout.rs b/src/project_layout.rs index 98b882ce3..9c87f380f 100644 --- a/src/project_layout.rs +++ b/src/project_layout.rs @@ -31,6 +31,8 @@ pub struct ProjectResolver { pub project_layout: ProjectLayout, /// Cargo.toml path pub cargo_toml_path: PathBuf, + /// Parsed Cargo.toml + pub cargo_toml: CargoToml, /// pyproject.toml path pub pyproject_toml_path: PathBuf, /// Parsed pyproject.toml @@ -94,7 +96,7 @@ impl ProjectResolver { } let extra_metadata = cargo_toml.remaining_core_metadata(); - let crate_name = &metadata21.name; + let crate_name = &cargo_toml.package.name; // If the package name contains minuses, you must declare a module with // underscores as lib name @@ -145,6 +147,7 @@ impl ProjectResolver { Ok(Self { project_layout, cargo_toml_path: manifest_file, + cargo_toml, pyproject_toml_path: pyproject_file, pyproject_toml, module_name, From 3258ab770be438c1a067b78cf859641c3247a484 Mon Sep 17 00:00:00 2001 From: messense Date: Tue, 27 Sep 2022 14:59:18 +0800 Subject: [PATCH 2/2] Downgrade clap & textwrap to avoid rustix depdendency https://github.com/bytecodealliance/rustix/issues/415 --- Cargo.lock | 71 ++++++------------------------------------------------ 1 file changed, 7 insertions(+), 64 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 80c79207e..e59b34b82 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -371,9 +371,9 @@ dependencies = [ [[package]] name = "clap" -version = "3.2.22" +version = "3.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86447ad904c7fb335a790c9d7fe3d0d971dc523b8ccd1561a520de9a85302750" +checksum = "1ed5341b2301a26ab80be5cbdced622e80ed808483c52e45e3310a877d3b37d7" dependencies = [ "atty", "bitflags", @@ -383,7 +383,7 @@ dependencies = [ "once_cell", "strsim", "termcolor", - "terminal_size 0.2.1", + "terminal_size", "textwrap", ] @@ -472,7 +472,7 @@ dependencies = [ "encode_unicode", "libc", "once_cell", - "terminal_size 0.1.17", + "terminal_size", "unicode-width", "winapi", ] @@ -782,27 +782,6 @@ dependencies = [ "termcolor", ] -[[package]] -name = "errno" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" -dependencies = [ - "errno-dragonfly", - "libc", - "winapi", -] - -[[package]] -name = "errno-dragonfly" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" -dependencies = [ - "cc", - "libc", -] - [[package]] name = "fastrand" version = "1.8.0" @@ -1172,12 +1151,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "io-lifetimes" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ea37f355c05dde75b84bba2d767906ad522e97cd9e2eef2be7a4ab7fb442c06" - [[package]] name = "itertools" version = "0.10.5" @@ -1237,12 +1210,6 @@ version = "0.2.133" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0f80d65747a3e43d1596c7c5492d95d5edddaabd45a7fcdb02b95f644164966" -[[package]] -name = "linux-raw-sys" -version = "0.0.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4d2456c373231a208ad294c33dc5bff30051eafd954cd4caae83a712b12854d" - [[package]] name = "lock_api" version = "0.4.9" @@ -2052,20 +2019,6 @@ dependencies = [ "semver", ] -[[package]] -name = "rustix" -version = "0.35.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af895b90e5c071badc3136fc10ff0bcfc98747eadbaf43ed8f214e07ba8f8477" -dependencies = [ - "bitflags", - "errno", - "io-lifetimes", - "libc", - "linux-raw-sys", - "windows-sys", -] - [[package]] name = "rustls" version = "0.20.6" @@ -2405,24 +2358,14 @@ dependencies = [ "winapi", ] -[[package]] -name = "terminal_size" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8440c860cf79def6164e4a0a983bcc2305d82419177a0e0c71930d049e3ac5a1" -dependencies = [ - "rustix", - "windows-sys", -] - [[package]] name = "textwrap" -version = "0.15.1" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "949517c0cf1bf4ee812e2e07e08ab448e3ae0d23472aee8a06c985f0c8815b16" +checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb" dependencies = [ "smawk", - "terminal_size 0.2.1", + "terminal_size", "unicode-linebreak", "unicode-width", ]