-
-
Notifications
You must be signed in to change notification settings - Fork 275
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove __init__.py requirement (#1696)
* remove __init__.py requirement * formatting fix * remove init so test will confirm implicit namespaces * putting this back * new test for implicit namespaces * black * ruff fixes using __all__ * black my ruff * making sure new package is run in testing * black fixes * check installed script update, changelog.md
- Loading branch information
1 parent
0b22535
commit 4f173f1
Showing
13 changed files
with
133 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[package] | ||
authors = ["Kevin Patterson <kevin.r.patterson@intel.com>"] | ||
name = "pyo3-mixed-implicit" | ||
version = "2.1.3" | ||
description = "Implements a dummy function combining rust and python" | ||
readme = "README.md" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
pyo3 = { version = "0.19.0", features = ["extension-module"] } | ||
|
||
[lib] | ||
name = "pyo3_mixed_implicit" | ||
crate-type = ["cdylib"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# pyo3-mixed-implicit | ||
|
||
A package for testing maturin with a mixed pyo3/python project with an implicit namespace package and Rust submodule. | ||
|
||
## Usage | ||
|
||
```bash | ||
pip install . | ||
``` | ||
|
||
```python | ||
import pyo3_mixed_implicit | ||
assert pyo3_mixed_implicit.some_rust.get_22() == 22 | ||
``` | ||
|
||
## Testing | ||
|
||
Install tox: | ||
|
||
```bash | ||
pip install tox | ||
``` | ||
|
||
Run it: | ||
|
||
```bash | ||
tox | ||
``` | ||
|
||
The tests are in `tests/test_pyo3_mixed_implicit.py`, while the configuration is in tox.ini |
8 changes: 8 additions & 0 deletions
8
test-crates/pyo3-mixed-implicit/check_installed/check_installed.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import pyo3_mixed_implicit.some_rust as some_rust | ||
|
||
assert some_rust.get_22() == 22 | ||
assert some_rust.double(lambda: 4) == 8 | ||
|
||
print("SUCCESS") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[build-system] | ||
requires = ["maturin>=0.15,<0.16"] | ||
build-backend = "maturin" | ||
|
||
[project] | ||
name = "pyo3_mixed_implicit.some_rust" | ||
classifiers = [ | ||
"Programming Language :: Python", | ||
"Programming Language :: Rust" | ||
] | ||
|
||
[tool.maturin] | ||
features = ["pyo3/extension-module"] | ||
module-name = "pyo3_mixed_implicit.some_rust.rust" | ||
python-source = "pysrc" | ||
|
4 changes: 4 additions & 0 deletions
4
test-crates/pyo3-mixed-implicit/pysrc/pyo3_mixed_implicit/some_rust/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from .rust import get_22 | ||
from .double import double | ||
|
||
__all__ = ["get_22", "double"] |
5 changes: 5 additions & 0 deletions
5
test-crates/pyo3-mixed-implicit/pysrc/pyo3_mixed_implicit/some_rust/double.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from typing import Callable | ||
|
||
|
||
def double(fn: Callable[[], int]) -> int: | ||
return 2 * fn() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
use pyo3::prelude::*; | ||
|
||
#[pyfunction] | ||
fn get_22() -> usize { | ||
22 | ||
} | ||
|
||
#[pymodule] | ||
fn rust(_py: Python, m: &PyModule) -> PyResult<()> { | ||
m.add_wrapped(wrap_pyfunction!(get_22))?; | ||
|
||
Ok(()) | ||
} |
11 changes: 11 additions & 0 deletions
11
test-crates/pyo3-mixed-implicit/tests/test_pyo3_mixed_implicit.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import pyo3_mixed_implicit.some_rust as some_rust | ||
|
||
|
||
def test_get_rust_and_python(): | ||
assert some_rust.get_22() == 22 | ||
assert some_rust.double(lambda: 4) == 8 | ||
|
||
|
||
print("SUCCESS") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[tox] | ||
envlist = py36,py37,py38 | ||
isolated_build = True | ||
|
||
[testenv] | ||
deps = pytest | ||
commands = pytest tests/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters