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

Deprecate support for specifying python metadata in Cargo.toml #1048

Merged
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
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