Skip to content

Commit

Permalink
Fix resolving crate name bug
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Sep 27, 2022
1 parent 887fbf3 commit 722f5f2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
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

0 comments on commit 722f5f2

Please sign in to comment.