Skip to content

Commit

Permalink
Fix missing member in Cargo.toml for sdist of nested workspace layo…
Browse files Browse the repository at this point in the history
…ut (#1828)

* use file_name to get bindings manifest name

* update test readme

* strip workspace root instead of using filename

* fix test and apply clippy suggestion

* Try to fix windows test failure

---------

Co-authored-by: messense <messense@icloud.com>
  • Loading branch information
nreinicke and messense authored Nov 2, 2023
1 parent 3cf1815 commit 84b3dba
Show file tree
Hide file tree
Showing 18 changed files with 446 additions and 2 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ lddtree = "0.3.3"
cc = "1.0.72"
dunce = "1.0.2"
normpath = "1.0.0"
path-slash = "0.2.1"
pep440_rs = { version = "0.3.6", features = ["serde"] }
pep508_rs = { version = "0.2.1", features = ["serde"] }
time = "0.3.17"
Expand Down
5 changes: 3 additions & 2 deletions src/source_distribution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use cargo_metadata::{Metadata, MetadataCommand};
use fs_err as fs;
use ignore::overrides::Override;
use normpath::PathExt as _;
use path_slash::PathExt as _;
use std::collections::HashMap;
use std::path::{Path, PathBuf};
use std::process::Command;
Expand Down Expand Up @@ -456,9 +457,9 @@ fn add_cargo_package_files_to_sdist(
let mut deps_to_keep = known_path_deps.clone();
// Also need to the main Python binding crate
let main_member_name = abs_manifest_dir
.strip_prefix(&sdist_root)
.strip_prefix(workspace_root)
.unwrap()
.to_str()
.to_slash()
.unwrap()
.to_string();
deps_to_keep.insert(
Expand Down
14 changes: 14 additions & 0 deletions test-crates/pyo3-mixed-workspace/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# pyo3-mixed src layout

A package for testing maturin with a nested workspace.

## Usage

```bash
pip install .
```

```python
import pyo3_mixed_workspace
assert pyo3_mixed_workspace.get_42() == 42
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env python3

import pyo3_mixed_workspace as pyo3_mixed

assert pyo3_mixed.get_42() == 42

print("SUCCESS")
19 changes: 19 additions & 0 deletions test-crates/pyo3-mixed-workspace/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[build-system]
requires = ["maturin>=1.0,<2.0"]
build-backend = "maturin"

[project]
name = "pyo3-mixed-workspace"
classifiers = [
"Programming Language :: Python",
"Programming Language :: Rust"
]
requires-python = ">=3.7"

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

[tool.maturin]
python-packages = ["pyo3_mixed_workspace", "tests"]
module-name = "pyo3_mixed_workspace.pyo3_mixed_workspace_py"
manifest-path = "rust/python/pyo3-mixed-workspace-py/Cargo.toml"
297 changes: 297 additions & 0 deletions test-crates/pyo3-mixed-workspace/rust/Cargo.lock

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

6 changes: 6 additions & 0 deletions test-crates/pyo3-mixed-workspace/rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[workspace]
resolver = "2"
members = [
"pyo3-mixed-workspace",
"python/pyo3-mixed-workspace-py",
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "pyo3-mixed-workspace"
version = "2.1.3"
description = "Implements a dummy function combining rust and python"
edition = "2021"

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub fn get_21_lib() -> usize {
21
}
Loading

0 comments on commit 84b3dba

Please sign in to comment.