Skip to content

Commit

Permalink
Merge pull request #1471 from messense/hard-error-on-removed-metadata
Browse files Browse the repository at this point in the history
Raise an error when `Cargo.toml` contains removed python package metadata
  • Loading branch information
messense authored Feb 9, 2023
2 parents 2eac680 + 2ff6d78 commit 5028681
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Respect `rustflags` settings in cargo configuration file in [#1405](https://github.com/PyO3/maturin/pull/1405)
* Bump MSRV to 1.63.0 in [#1407](https://github.com/PyO3/maturin/pull/1407)
* Deprecate `--univeral2` in favor of `universal2-apple-darwin` target in [#1457](https://github.com/PyO3/maturin/pull/1457)
* Raise an error when `Cargo.toml` contains removed python package metadata in [#1471](https://github.com/PyO3/maturin/pull/1471)

## [0.14.12] - 2023-01-31

Expand Down
14 changes: 6 additions & 8 deletions src/cargo_toml.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use anyhow::{Context, Result};
use anyhow::{bail, Context, Result};
use fs_err as fs;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
Expand Down Expand Up @@ -53,8 +53,8 @@ impl CargoToml {
}
}

/// Warn about removed python metadata support in `Cargo.toml`
pub fn warn_removed_python_metadata(&self) -> bool {
/// Check removed python metadata support in `Cargo.toml`
pub fn check_removed_python_metadata(&self) -> Result<()> {
let mut removed = Vec::new();
if let Some(CargoTomlMetadata {
maturin: Some(extra_metadata),
Expand All @@ -80,16 +80,14 @@ impl CargoToml {
}
}
if !removed.is_empty() {
eprintln!(
"⚠️ Warning: the following metadata fields in `package.metadata.maturin` section \
bail!(
"The following metadata fields in `package.metadata.maturin` section \
of Cargo.toml are removed since maturin 0.14.0: {}, \
please set them in pyproject.toml as PEP 621 specifies.",
removed.join(", ")
);
true
} else {
false
}
Ok(())
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/project_layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl ProjectResolver {
cargo_options.manifest_path = Some(manifest_file.clone());

let cargo_toml = CargoToml::from_path(&manifest_file)?;
cargo_toml.warn_removed_python_metadata();
cargo_toml.check_removed_python_metadata()?;

let manifest_dir = manifest_file.parent().unwrap();
let pyproject_toml: Option<PyProjectToml> = if pyproject_file.is_file() {
Expand Down

0 comments on commit 5028681

Please sign in to comment.