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 python-source option in Cargo.toml #1291

Merged
merged 1 commit into from
Nov 23, 2022
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
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
7 changes: 5 additions & 2 deletions src/project_layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,12 @@ impl ProjectResolver {
manifest_dir
};
let py_root = match pyproject.and_then(|x| x.python_source()) {
Some(py_src) => py_src.to_path_buf(),
Some(py_src) => project_root.join(py_src),
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
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"