Skip to content

Commit

Permalink
Merge pull request #79 from davidhewitt/namespace-packages
Browse files Browse the repository at this point in the history
Fix support for namespace packages
  • Loading branch information
davidhewitt authored Aug 9, 2020
2 parents 2704a9a + fbf8aa5 commit de4489d
Show file tree
Hide file tree
Showing 9 changed files with 341 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Unreleased

- Fix support for namespace packages. [#79](https://github.com/PyO3/setuptools-rust/pull/79)

## 0.11.1 (2020-08-07)

- Fix building for 32-bit Python on 64-bit Windows. [#77](https://github.com/PyO3/setuptools-rust/pull/77)
Expand Down
286 changes: 286 additions & 0 deletions examples/namespace_package/Cargo.lock

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

11 changes: 11 additions & 0 deletions examples/namespace_package/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "namespace_package_bar"
version = "0.1.0"
edition = "2018"

[lib]
crate-type = ["cdylib"]

[dependencies.pyo3]
version = "0.11.1"
features = ["extension-module"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def python_func():
return 15
2 changes: 2 additions & 0 deletions examples/namespace_package/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[build-system]
requires = ["setuptools", "wheel", "setuptools-rust", "cffi"]
11 changes: 11 additions & 0 deletions examples/namespace_package/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from setuptools import setup, find_namespace_packages
from setuptools_rust import Binding, RustExtension


setup(
name='namespace_package',
version="0.1.0",
packages=find_namespace_packages(include=['namespace_package.*']),
zip_safe=False,
rust_extensions=[RustExtension("namespace_package.bar", path="Cargo.toml", binding=Binding.PyO3, debug=False)],
)
15 changes: 15 additions & 0 deletions examples/namespace_package/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use pyo3::prelude::*;
use pyo3::wrap_pyfunction;

#[pyfunction]
fn rust_func() -> usize {
14
}

/// A Python module implemented in Rust.
#[pymodule]
fn rust(py: Python, m: &PyModule) -> PyResult<()> {
m.add_wrapped(wrap_pyfunction!(rust_func))?;

Ok(())
}
9 changes: 9 additions & 0 deletions examples/namespace_package/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from namespace_package import rust, python


def test_rust():
assert rust.rust_func() == 14


def test_cffi():
assert python.python_func() == 15
3 changes: 1 addition & 2 deletions setuptools_rust/setuptools_ext.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from distutils import log
from distutils.command.check import check
from distutils.command.clean import clean
from distutils.command.install import install

from setuptools.command.install import install
from setuptools.command.build_ext import build_ext

try:
Expand Down

0 comments on commit de4489d

Please sign in to comment.