Skip to content

Commit de4489d

Browse files
authored
Merge pull request #79 from davidhewitt/namespace-packages
Fix support for namespace packages
2 parents 2704a9a + fbf8aa5 commit de4489d

File tree

9 files changed

+341
-2
lines changed

9 files changed

+341
-2
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
- Fix support for namespace packages. [#79](https://github.com/PyO3/setuptools-rust/pull/79)
6+
37
## 0.11.1 (2020-08-07)
48

59
- Fix building for 32-bit Python on 64-bit Windows. [#77](https://github.com/PyO3/setuptools-rust/pull/77)

examples/namespace_package/Cargo.lock

+286
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/namespace_package/Cargo.toml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[package]
2+
name = "namespace_package_bar"
3+
version = "0.1.0"
4+
edition = "2018"
5+
6+
[lib]
7+
crate-type = ["cdylib"]
8+
9+
[dependencies.pyo3]
10+
version = "0.11.1"
11+
features = ["extension-module"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def python_func():
2+
return 15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[build-system]
2+
requires = ["setuptools", "wheel", "setuptools-rust", "cffi"]

examples/namespace_package/setup.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from setuptools import setup, find_namespace_packages
2+
from setuptools_rust import Binding, RustExtension
3+
4+
5+
setup(
6+
name='namespace_package',
7+
version="0.1.0",
8+
packages=find_namespace_packages(include=['namespace_package.*']),
9+
zip_safe=False,
10+
rust_extensions=[RustExtension("namespace_package.bar", path="Cargo.toml", binding=Binding.PyO3, debug=False)],
11+
)

examples/namespace_package/src/lib.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
use pyo3::prelude::*;
2+
use pyo3::wrap_pyfunction;
3+
4+
#[pyfunction]
5+
fn rust_func() -> usize {
6+
14
7+
}
8+
9+
/// A Python module implemented in Rust.
10+
#[pymodule]
11+
fn rust(py: Python, m: &PyModule) -> PyResult<()> {
12+
m.add_wrapped(wrap_pyfunction!(rust_func))?;
13+
14+
Ok(())
15+
}

examples/namespace_package/tests.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from namespace_package import rust, python
2+
3+
4+
def test_rust():
5+
assert rust.rust_func() == 14
6+
7+
8+
def test_cffi():
9+
assert python.python_func() == 15

setuptools_rust/setuptools_ext.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
from distutils import log
22
from distutils.command.check import check
33
from distutils.command.clean import clean
4-
from distutils.command.install import install
5-
4+
from setuptools.command.install import install
65
from setuptools.command.build_ext import build_ext
76

87
try:

0 commit comments

Comments
 (0)