Skip to content

Commit

Permalink
Remove deprecated python-source option in Cargo.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Dec 5, 2022
1 parent 3bc309d commit d279f32
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 25 deletions.
2 changes: 0 additions & 2 deletions src/cargo_toml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,6 @@ struct CargoTomlMetadata {
#[serde(rename_all = "kebab-case")]
pub struct RemainingCoreMetadata {
pub name: Option<String>,
/// The directory with python module, contains `<module_name>/__init__.py`
pub python_source: Option<String>,
/// The directory containing the wheel data
pub data: Option<String>,
#[serde(flatten)]
Expand Down
40 changes: 17 additions & 23 deletions src/project_layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,30 +137,24 @@ impl ProjectResolver {
};
let py_root = match pyproject.and_then(|x| x.python_source()) {
Some(py_src) => project_root.join(py_src),
None => match extra_metadata.python_source.as_ref() {
Some(py_src) => {
println!("⚠️ Warning: specify python-source in Cargo.toml is deprecated, use python-source in [tool.maturin] section in pyproject.toml instead");
manifest_dir.join(py_src)
}
None => match pyproject.and_then(|x| x.project_name()) {
Some(project_name) => {
// Detect src layout
let import_name = project_name.replace('-', "_");
let rust_cargo_toml_found =
project_root.join("rust").join("Cargo.toml").is_file();
let python_src_found = project_root
.join("src")
.join(import_name)
.join("__init__.py")
.is_file();
if rust_cargo_toml_found && python_src_found {
project_root.join("src")
} else {
project_root.to_path_buf()
}
None => match pyproject.and_then(|x| x.project_name()) {
Some(project_name) => {
// Detect src layout
let import_name = project_name.replace('-', "_");
let rust_cargo_toml_found =
project_root.join("rust").join("Cargo.toml").is_file();
let python_src_found = project_root
.join("src")
.join(import_name)
.join("__init__.py")
.is_file();
if rust_cargo_toml_found && python_src_found {
project_root.join("src")
} else {
project_root.to_path_buf()
}
None => project_root.to_path_buf(),
},
}
None => project_root.to_path_buf(),
},
};
let data = match pyproject.and_then(|x| x.data()) {
Expand Down

0 comments on commit d279f32

Please sign in to comment.