diff --git a/Changelog.md b/Changelog.md index cec2ca48c..7b9eabea0 100644 --- a/Changelog.md +++ b/Changelog.md @@ -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 diff --git a/src/cargo_toml.rs b/src/cargo_toml.rs index 646b576ae..59a1de34c 100644 --- a/src/cargo_toml.rs +++ b/src/cargo_toml.rs @@ -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; @@ -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), @@ -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(()) } } diff --git a/src/project_layout.rs b/src/project_layout.rs index 7b4a0d5e1..61956eec2 100644 --- a/src/project_layout.rs +++ b/src/project_layout.rs @@ -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 = if pyproject_file.is_file() {