Skip to content

Commit

Permalink
Add support for Cargo workspace inheritance
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Sep 23, 2022
1 parent 71ccc6b commit 84e52cd
Show file tree
Hide file tree
Showing 8 changed files with 318 additions and 0 deletions.
254 changes: 254 additions & 0 deletions test-crates/workspace-inheritance/Cargo.lock

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

8 changes: 8 additions & 0 deletions test-crates/workspace-inheritance/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[workspace]
members = [
"generic_lib",
"python"
]

[workspace.dependencies]
generic_lib = { path = "generic_lib" }
8 changes: 8 additions & 0 deletions test-crates/workspace-inheritance/generic_lib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "generic_lib"
version = "0.1.0"
edition = "2018"

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

[dependencies]
3 changes: 3 additions & 0 deletions test-crates/workspace-inheritance/generic_lib/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub fn foo() -> &'static str {
"foo"
}
12 changes: 12 additions & 0 deletions test-crates/workspace-inheritance/python/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "workspace_with_path_dep"
version = "0.1.0"
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
crate-type = ["cdylib"]

[dependencies]
pyo3 = { version = "0.16.5", features = ["extension-module"] }
generic_lib.workspace = true
3 changes: 3 additions & 0 deletions test-crates/workspace-inheritance/python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["maturin>=0.13,<0.14"]
build-backend = "maturin"
14 changes: 14 additions & 0 deletions test-crates/workspace-inheritance/python/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use pyo3::prelude::*;

/// Formats the sum of two numbers as string.
#[pyfunction]
fn sum_as_string(a: usize, b: usize) -> PyResult<String> {
Ok((a + b).to_string())
}

/// A Python module implemented in Rust.
#[pymodule]
fn workspace_with_path_dep(_py: Python, m: &PyModule) -> PyResult<()> {
m.add_function(wrap_pyfunction!(sum_as_string, m)?)?;
Ok(())
}
16 changes: 16 additions & 0 deletions tests/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,22 @@ fn workspace_with_path_dep_sdist() {
))
}

#[test]
fn workspace_inheritance_sdist() {
handle_result(other::test_source_distribution(
"test-crates/workspace-inheritance/python",
vec![
"workspace-inheritance-0.1.0/local_dependencies/generic_lib/Cargo.toml",
"workspace-inheritance-0.1.0/local_dependencies/generic_lib/src/lib.rs",
"workspace-inheritance-0.1.0/Cargo.toml",
"workspace-inheritance-0.1.0/pyproject.toml",
"workspace-inheritance-0.1.0/src/lib.rs",
"workspace-inheritance-0.1.0/PKG-INFO",
],
"workspace_inheritance_sdist",
))
}

#[test]
fn abi3_python_interpreter_args() {
handle_result(other::abi3_python_interpreter_args());
Expand Down

0 comments on commit 84e52cd

Please sign in to comment.