Skip to content

Commit

Permalink
Deprecate python-source option in Cargo.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Nov 23, 2022
1 parent 41edf7b commit 9f02a30
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 24 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

* Tighten src-layout detection logic in [#1281](https://github.com/PyO3/maturin/pull/1282)
* Fix generating pep517 sdist for src-layout in [#1288](https://github.com/PyO3/maturin/pull/1288)
* Deprecate `python-source` option in Cargo.toml in [#1291](https://github.com/PyO3/maturin/pull/1291)

## [0.14.1] - 2022-11-20

Expand Down
10 changes: 1 addition & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ my-project
   └── lib.rs
```

You can specify a different python source directory in `pyproject.toml` by setting `tool.maturin.python-source`
or in `Cargo.toml` by setting `package.metadata.maturin.python-source`, for example
You can specify a different python source directory in `pyproject.toml` by setting `tool.maturin.python-source`, for example

**pyproject.toml**

Expand All @@ -124,13 +123,6 @@ or in `Cargo.toml` by setting `package.metadata.maturin.python-source`, for exam
python-source = "python"
```

**Cargo.toml**

```toml
[package.metadata.maturin]
python-source = "python"
```

then the project structure would look like this:

```
Expand Down
11 changes: 1 addition & 10 deletions guide/src/project_layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ modules. A popular way to avoid this is with the `src`-layout, where the Python
package is nested within a `src` directory. Unfortunately this interferes with
the structure of a typical Rust project. Fortunately, Python is nor particular
about the name of the parent source directory. You tell maturin to use a
different Python source directory in `pyproject.toml` by setting `tool.maturin.python-source`
or in `Cargo.toml` by setting `package.metadata.maturin.python-source`, for example
different Python source directory in `pyproject.toml` by setting `tool.maturin.python-source`, for example

**pyproject.toml**

Expand All @@ -90,13 +89,6 @@ or in `Cargo.toml` by setting `package.metadata.maturin.python-source`, for exam
python-source = "python"
```

**Cargo.toml**

```toml
[package.metadata.maturin]
python-source = "python"
```

then the project structure would look like this:

```
Expand All @@ -117,7 +109,6 @@ If the Python module created by Rust has the same name as the Python package in

```toml
[package.metadata.maturin]
python-source = "python"
name = "my_project._my_project"
```

Expand Down
4 changes: 2 additions & 2 deletions src/develop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,13 @@ pub fn develop(
}
if !output.stderr.is_empty() {
eprintln!(
"⚠️ Warning: pip raised a warning running {:?}:\n{}",
"⚠️ Warning: pip raised a warning running {:?}:\n{}",
&command,
String::from_utf8_lossy(&output.stderr).trim(),
);
}
println!(
"🛠 Installed {}-{}",
"🛠 Installed {}-{}",
build_context.metadata21.name, build_context.metadata21.version
);
}
Expand Down
5 changes: 4 additions & 1 deletion src/project_layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,10 @@ impl ProjectResolver {
let py_root = match pyproject.and_then(|x| x.python_source()) {
Some(py_src) => py_src.to_path_buf(),
None => match extra_metadata.python_source.as_ref() {
Some(py_src) => manifest_dir.join(py_src),
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
Expand Down
2 changes: 1 addition & 1 deletion src/source_distribution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ pub fn source_distribution(
let pyproject_dir = pyproject_toml_path.parent().unwrap();
// Add python source files
if let Some(python_source) = build_context.project_layout.python_module.as_ref() {
for entry in ignore::Walk::new(python_source) {
for entry in ignore::Walk::new(pyproject_dir.join(python_source)) {
let source = entry?.into_path();
// Technically, `ignore` crate should handle this,
// but somehow it doesn't on Alpine Linux running in GitHub Actions,
Expand Down
1 change: 0 additions & 1 deletion test-crates/pyo3-mixed-py-subdir/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@ name = "pyo3_mixed_py_subdir"
crate-type = ["cdylib"]

[package.metadata.maturin]
python-source = "python"
name = "pyo3_mixed_py_subdir._pyo3_mixed"
3 changes: 3 additions & 0 deletions test-crates/pyo3-mixed-py-subdir/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ requires-python = ">=3.6"

[project.scripts]
get_42 = "pyo3_mixed_py_subdir:get_42"

[tool.maturin]
python-source = "python"

0 comments on commit 9f02a30

Please sign in to comment.