Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix resolving crate name bug #1142

Merged
merged 2 commits into from
Sep 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 7 additions & 64 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion src/build_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ impl BuildOptions {
let ProjectResolver {
project_layout,
cargo_toml_path,
cargo_toml,
pyproject_toml_path,
pyproject_toml,
module_name,
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/cargo_toml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<CargoTomlMetadata>,
}

Expand Down
5 changes: 4 additions & 1 deletion src/project_layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down