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

Fix support for namespace packages #79

Merged
merged 1 commit into from
Aug 9, 2020
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
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