Skip to content

Commit

Permalink
Deprecate support for specifying python metadata in Cargo.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Aug 8, 2022
1 parent d68b55d commit 5b154ce
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
It's technically a **breaking change**, but previously it doesn't work properly
if the directory containing `pyproject.toml` isn't recognized as project root.
* Add `python-source` option to `[tool.maturin]` section of pyproject.toml in [#1046](https://github.com/PyO3/maturin/pull/1046)
* Deprecate support for specifying python metadata in `Cargo.toml` in [#1048](https://github.com/PyO3/maturin/pull/1048).
Please migrate to [PEP 621](https://peps.python.org/pep-0621/) instead.

## [0.13.1] - 2022-07-26

Expand Down
52 changes: 52 additions & 0 deletions src/cargo_toml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,57 @@ impl CargoToml {
_ => Default::default(),
}
}

/// Warn about deprecated python metadata support
pub fn warn_deprecated_python_metadata(&self) -> bool {
let mut deprecated = Vec::new();
if let Some(CargoTomlMetadata {
maturin: Some(extra_metadata),
}) = &self.package.metadata
{
if extra_metadata.scripts.is_some() {
deprecated.push("scripts");
}
if extra_metadata.classifiers.is_some() {
deprecated.push("classifiers");
}
if extra_metadata.maintainer.is_some() {
deprecated.push("maintainer");
}
if extra_metadata.maintainer_email.is_some() {
deprecated.push("maintainer-email");
}
if extra_metadata.requires_dist.is_some() {
deprecated.push("requires-dist");
}
if extra_metadata.requires_python.is_some() {
deprecated.push("requires-python");
}
if extra_metadata.requires_external.is_some() {
deprecated.push("requires-external");
}
if extra_metadata.project_url.is_some() {
deprecated.push("project-url");
}
if extra_metadata.provides_extra.is_some() {
deprecated.push("provides-extra");
}
if extra_metadata.description_content_type.is_some() {
deprecated.push("description-content-type");
}
}
if !deprecated.is_empty() {
println!(
"⚠️ Warning: the following metadata fields in `package.metadata.maturin` section \
of Cargo.toml are deprecated and will be removed in future versions: {}, \
please set them in pyproject.toml as PEP 621 specifies.",
deprecated.join(", ")
);
true
} else {
false
}
}
}

#[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq)]
Expand Down Expand Up @@ -203,6 +254,7 @@ mod test {
let classifiers = vec!["Programming Language :: Python".to_string()];

assert_eq!(cargo_toml.classifiers(), classifiers);
assert!(cargo_toml.warn_deprecated_python_metadata());
}

#[test]
Expand Down
2 changes: 2 additions & 0 deletions src/project_layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ impl ProjectResolver {
);
}
let cargo_toml = CargoToml::from_path(&manifest_file)?;
cargo_toml.warn_deprecated_python_metadata();

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

0 comments on commit 5b154ce

Please sign in to comment.