diff --git a/Makefile b/Makefile index 75fbb43..6cf070a 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ endef export PRINT_HELP_PYSCRIPT BROWSER := python -c "$$BROWSER_PYSCRIPT" -PY_PATHS = ncollpyde tests +PY_PATHS = python/ncollpyde tests help: @python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST) @@ -87,7 +87,7 @@ install-opt: maturin develop --release coverage: install-dev - coverage run --source ncollpyde -m pytest && \ + coverage run --source python/ncollpyde -m pytest && \ coverage report -m && \ coverage html && \ $(BROWSER) htmlcov/index.html diff --git a/pyproject.toml b/pyproject.toml index 07a6d81..7798565 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,6 +37,10 @@ repository = "https://github.com/clbarnes/ncollpyde/" requires = ["maturin==0.14", "numpy>=1.21"] build-backend = "maturin" +[tool.maturin] +python-source = "python" +module-name = "ncollpyde._ncollpyde" + [tool.mypy] ignore_missing_imports = true plugins = ["numpy.typing.mypy_plugin"] diff --git a/ncollpyde/__init__.py b/python/ncollpyde/__init__.py similarity index 88% rename from ncollpyde/__init__.py rename to python/ncollpyde/__init__.py index 16d9c0b..96614cc 100644 --- a/ncollpyde/__init__.py +++ b/python/ncollpyde/__init__.py @@ -13,8 +13,8 @@ from .main import PRECISION # noqa: F401 from .main import Volume # noqa: F401 from .main import configure_threadpool # noqa: F401 -from .ncollpyde import n_threads # noqa: F401 -from .ncollpyde import _version +from ._ncollpyde import n_threads # noqa: F401 +from ._ncollpyde import _version __version__ = _version() __version_info__ = tuple(int(n) for n in __version__.split("-")[0].split(".")) diff --git a/ncollpyde/ncollpyde.pyi b/python/ncollpyde/_ncollpyde.pyi similarity index 92% rename from ncollpyde/ncollpyde.pyi rename to python/ncollpyde/_ncollpyde.pyi index d7fbb01..f94a936 100644 --- a/ncollpyde/ncollpyde.pyi +++ b/python/ncollpyde/_ncollpyde.pyi @@ -7,7 +7,7 @@ def _precision() -> str: ... def _index() -> str: ... def _version() -> str: ... def n_threads() -> int: ... -def configure_threadpool(n_threads: Optional[int], name_prefix: Optional[str]): ... +def _configure_threadpool(n_threads: Optional[int], name_prefix: Optional[str]): ... Points = npt.NDArray[np.float64] Indices = npt.NDArray[np.uint32] diff --git a/ncollpyde/main.py b/python/ncollpyde/main.py similarity index 99% rename from ncollpyde/main.py rename to python/ncollpyde/main.py index f201927..0e651ba 100644 --- a/ncollpyde/main.py +++ b/python/ncollpyde/main.py @@ -12,11 +12,11 @@ except ImportError: trimesh = None -from .ncollpyde import ( +from ._ncollpyde import ( TriMeshWrapper, _index, _precision, - configure_threadpool as _configure_threadpool, + _configure_threadpool, ) if TYPE_CHECKING: diff --git a/src/interface.rs b/src/interface.rs index d8c8e1e..f3a5319 100644 --- a/src/interface.rs +++ b/src/interface.rs @@ -221,6 +221,7 @@ impl TriMeshWrapper { } #[pymodule] +#[pyo3(name = "_ncollpyde")] pub fn ncollpyde(_py: Python, m: &PyModule) -> PyResult<()> { m.add_class::()?; @@ -249,7 +250,7 @@ pub fn ncollpyde(_py: Python, m: &PyModule) -> PyResult<()> { } #[pyfn(m)] - #[pyo3(name = "configure_threadpool")] + #[pyo3(name = "_configure_threadpool")] pub fn configure_threadpool( _py: Python, n_threads: Option, diff --git a/tests/test_ncollpyde.py b/tests/test_ncollpyde.py index c288641..743d143 100644 --- a/tests/test_ncollpyde.py +++ b/tests/test_ncollpyde.py @@ -5,6 +5,7 @@ from itertools import product import sys import subprocess as sp +import logging import numpy as np import pytest @@ -16,6 +17,8 @@ from ncollpyde import PRECISION, Volume, configure_threadpool +logger = logging.getLogger(__name__) + points_expected = [ ([-2.3051376, -4.1556454, 1.9047838], True), # internal ([-0.35222054, -0.513299, 7.6191354], False), # external but in AABB @@ -300,7 +303,10 @@ def test_configure_threadpool_subprocess(): ) args = [sys.executable, "-c", cmd] - sp.run(args, check=True, text=True, capture_output=True) + result = sp.run(args, text=True, capture_output=True) + logger.info(result.stdout) + logger.warning(result.stderr) + result.check_returncode() def test_configure_threadpool_twice():