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

Remove workspace.members in Cargo.toml from sdist if there isn't any path dependency #1227

Merged
merged 2 commits into from
Oct 30, 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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ version = "0.14.0-beta.3"
description = "Build and publish crates with pyo3, rust-cpython and cffi bindings as well as rust binaries as python packages"
exclude = ["test-crates/**/*", "sysconfig/*", "test-data/*", "ci/*", "tests/*", "guide/*", ".github/*"]
homepage = "https://github.com/pyo3/maturin"
readme = "Readme.md"
readme = "README.md"
repository = "https://github.com/pyo3/maturin"
license = "MIT OR Apache-2.0"
keywords = ["python", "cffi", "packaging", "pypi", "pyo3"]
Expand Down
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Add `--src` option to generate src layout for mixed Python/Rust projects in [#1189](https://github.com/PyO3/maturin/pull/1189)
* Add Python metadata support for `license-file` field of `Cargo.toml` in [#1195](https://github.com/PyO3/maturin/pull/1195)
* Upgrade to clap 4.0 in [#1197](https://github.com/PyO3/maturin/pull/1197). This bumps MSRV to 1.61.0.
* Remove `workspace.members` in `Cargo.toml` from sdist if there isn't any path dependency in #[1227](https://github.com/PyO3/maturin/pull/1227)

## [0.13.7] - 2022-10-29

Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include Cargo.toml Cargo.lock
include Readme.md
include README.md
include license-apache license-mit
recursive-include src *.rs *.py
recursive-include src/auditwheel *.json
Expand Down
6 changes: 3 additions & 3 deletions Readme.md → README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ my-project
│   ├── __init__.py
│   └── bar.py
├── pyproject.toml
├── Readme.md
├── README.md
└── src
   └── lib.rs
```
Expand Down Expand Up @@ -135,7 +135,7 @@ my-project
│ ├── __init__.py
│ └── bar.py
├── pyproject.toml
├── Readme.md
├── README.md
└── src
   └── lib.rs
```
Expand All @@ -156,7 +156,7 @@ my-project
│   ├── __init__.py
│   ├── bar.py
│   └── my_project.cpython-36m-x86_64-linux-gnu.so
├── Readme.md
├── README.md
└── src
   └── lib.rs
```
Expand Down
2 changes: 1 addition & 1 deletion ci/build_deb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ install -Dm755 "target/$TARGET/release/$BINARY_NAME" "$tempdir/usr/bin/$BINARY_N
strip "$tempdir/usr/bin/$BINARY_NAME"

# readme and license
install -Dm644 Readme.md "$tempdir/usr/share/doc/$BINARY_NAME/Readme.md"
install -Dm644 README.md "$tempdir/usr/share/doc/$BINARY_NAME/README.md"
install -Dm644 license-mit "$tempdir/usr/share/doc/$BINARY_NAME/license-mit"
install -Dm644 license-apache "$tempdir/usr/share/doc/$BINARY_NAME/license-apache"

Expand Down
2 changes: 1 addition & 1 deletion guide/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ Welcome to the maturin user guide! It contains examples and documentation to exp

Please choose from the chapters on the left to jump to individual topics, or continue below to start with maturin's README.

{{#include ../../Readme.md}}
{{#include ../../README.md}}
2 changes: 1 addition & 1 deletion guide/src/project_layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ my-rust-and-python-project
│ ├── __init__.py
│ └── bar.py
├── pyproject.toml
├── Readme.md
├── README.md
└── src
└── lib.rs
```
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def finalize_options(self):
except ImportError:
bdist_wheel = None

with open("Readme.md", encoding="utf-8", errors="ignore") as fp:
with open("README.md", encoding="utf-8", errors="ignore") as fp:
long_description = fp.read()

with open("Cargo.toml", "rb") as fp:
Expand Down
2 changes: 1 addition & 1 deletion src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ mod test {
);
assert_eq!(
metadata.description,
Some(fs_err::read_to_string("test-crates/pyo3-pure/Readme.md").unwrap())
Some(fs_err::read_to_string("test-crates/pyo3-pure/README.md").unwrap())
);
assert_eq!(metadata.classifiers, &["Programming Language :: Rust"]);
assert_eq!(
Expand Down
2 changes: 1 addition & 1 deletion src/project_layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ impl ProjectResolver {
// Detect src layout:
//
// my-project
// ├── Readme.md
// ├── README.md
// ├── pyproject.toml
// ├── src
// │ └── my_project
Expand Down
33 changes: 22 additions & 11 deletions src/source_distribution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,20 +187,31 @@ fn rewrite_cargo_toml(
// Update workspace members
if let Some(workspace) = data.get_mut("workspace").and_then(|x| x.as_table_mut()) {
if let Some(members) = workspace.get_mut("members").and_then(|x| x.as_array_mut()) {
let mut new_members = toml_edit::Array::new();
for member in members.iter() {
if let toml_edit::Value::String(ref s) = member {
let path = Path::new(s.value());
if let Some(name) = path.file_name().and_then(|x| x.to_str()) {
if known_path_deps.contains_key(name) {
new_members.push(format!("{}/{}", LOCAL_DEPENDENCIES_FOLDER, name));
if known_path_deps.is_empty() {
// Remove workspace members when there isn't any path dep
workspace.remove("members");
if workspace.is_empty() {
// Remove workspace all together if it's empty
data.remove("workspace");
}
rewritten = true;
} else {
let mut new_members = toml_edit::Array::new();
for member in members.iter() {
if let toml_edit::Value::String(ref s) = member {
let path = Path::new(s.value());
if let Some(name) = path.file_name().and_then(|x| x.to_str()) {
if known_path_deps.contains_key(name) {
new_members
.push(format!("{}/{}", LOCAL_DEPENDENCIES_FOLDER, name));
}
}
}
}
}
if !new_members.is_empty() {
workspace["members"] = toml_edit::value(new_members);
rewritten = true;
if !new_members.is_empty() {
workspace["members"] = toml_edit::value(new_members);
rewritten = true;
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion test-crates/hello-world/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
authors = ["konstin <[email protected]>"]
edition = "2018"
# Test references to out-of-project files
readme = "../../Readme.md"
readme = "../../README.md"
default-run = "hello-world"

[dependencies]
2 changes: 1 addition & 1 deletion test-crates/pyo3-ffi-pure/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ classifiers = [
"Programming Language :: Rust"
]
description = "Tests compilation of packages using pyo3-ffi bindings"
readme = "Readme.md"
readme = "README.md"
maintainers = [
{name = "messense", email = "[email protected]"}
]
Expand Down
2 changes: 1 addition & 1 deletion test-crates/pyo3-mixed-py-subdir/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ authors = ["konstin <[email protected]>"]
name = "pyo3-mixed-py-subdir"
version = "2.1.3"
description = "Implements a dummy function combining rust and python"
readme = "Readme.md"
readme = "README.md"
edition = "2018"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion test-crates/pyo3-mixed-submodule/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ authors = ["konstin <[email protected]>"]
name = "pyo3-mixed-submodule"
version = "2.1.3"
description = "Implements a dummy function combining rust and python"
readme = "Readme.md"
readme = "README.md"
edition = "2018"

[package.metadata.maturin]
Expand Down
12 changes: 8 additions & 4 deletions test-crates/pyo3-pure/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions test-crates/pyo3-pure/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ pyo3 = { version = "0.17.2", features = ["abi3-py37", "extension-module", "gener
[lib]
name = "pyo3_pure"
crate-type = ["cdylib"]

[workspace]
members = [".", "local-test"]
File renamed without changes.
8 changes: 8 additions & 0 deletions test-crates/pyo3-pure/local-test/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "local-test"
version = "0.1.0"
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
14 changes: 14 additions & 0 deletions test-crates/pyo3-pure/local-test/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
pub fn add(left: usize, right: usize) -> usize {
left + right
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
}
2 changes: 1 addition & 1 deletion test-crates/pyo3-pure/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ classifiers = [
"Programming Language :: Rust"
]
description = "Implements a dummy function in Rust"
readme = "Readme.md"
readme = "README.md"
maintainers = [
{name = "messense", email = "[email protected]"}
]
Expand Down
2 changes: 1 addition & 1 deletion test-crates/update_readme.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


FILES = [
"Readme.md",
"README.md",
"guide/src/develop.md",
"guide/src/tutorial.md",
"guide/src/distribution.md",
Expand Down
19 changes: 17 additions & 2 deletions tests/common/other.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use flate2::read::GzDecoder;
use maturin::{BuildOptions, CargoOptions};
use pretty_assertions::assert_eq;
use std::collections::BTreeSet;
use std::io::Read;
use std::iter::FromIterator;
use std::path::{Path, PathBuf};
use tar::Archive;
Expand All @@ -19,7 +20,6 @@ pub fn test_musl() -> Result<bool> {
use fs_err::File;
use goblin::elf::Elf;
use std::io::ErrorKind;
use std::io::Read;
use std::process::Command;

let get_target_list = Command::new("rustup")
Expand Down Expand Up @@ -114,6 +114,7 @@ pub fn test_workspace_cargo_lock() -> Result<()> {
pub fn test_source_distribution(
package: impl AsRef<Path>,
expected_files: Vec<&str>,
expected_cargo_toml: Option<(&Path, &str)>,
unique_name: &str,
) -> Result<()> {
let manifest_path = package.as_ref().join("Cargo.toml");
Expand Down Expand Up @@ -142,16 +143,30 @@ pub fn test_source_distribution(
let mut archive = Archive::new(tar);
let mut files = BTreeSet::new();
let mut file_count = 0;
let mut cargo_toml = None;
for entry in archive.entries()? {
let entry = entry?;
let mut entry = entry?;
files.insert(format!("{}", entry.path()?.display()));
file_count += 1;
if let Some(cargo_toml_path) = expected_cargo_toml.as_ref().map(|(p, _)| *p) {
if entry.path()? == cargo_toml_path {
let mut contents = String::new();
entry.read_to_string(&mut contents)?;
cargo_toml = Some(contents);
}
}
}
assert_eq!(
files,
BTreeSet::from_iter(expected_files.into_iter().map(ToString::to_string))
);
assert_eq!(file_count, files.len(), "duplicated files found in sdist");

if let Some((cargo_toml_path, expected)) = expected_cargo_toml {
let cargo_toml = cargo_toml
.with_context(|| format!("{} not found in sdist", cargo_toml_path.display()))?;
assert_eq!(cargo_toml, expected);
}
Ok(())
}

Expand Down
Loading