From 069a4f354596c6de9086b0834601c54db730ce96 Mon Sep 17 00:00:00 2001 From: "Murilo M. Marinho" Date: Thu, 1 Oct 2026 13:55:19 +0100 Subject: [PATCH] Make marinholab and marinholab.sas namespace packages marinholab/__init__.py and marinholab/sas/__init__.py made both regular packages. Installed next to another distribution with a marinholab.* package, the regular package wins and hides the other: with marinholab-sas-core installed, `import marinholab.ur3e_r820` fails (MarinhoLab/ur3e_r820), and so would marinholab.solvers if marinholab-solvers-qpoases were installed in a directory searched later. marinholab-solvers-qpoases already leaves its marinholab/ without an __init__.py. - Delete both __init__.py; they held only a docstring. - pyproject: packages.find with namespaces = true (the default, now explicit and explained) is the one package list; setup.py's explicit `packages=` list, which also missed marinholab.sas.core.modeling, goes. - CI smoke test: import marinholab.sas.core next to a marinholab.other_package on PYTHONPATH and assert that neither marinholab nor marinholab.sas has a __file__. It fails on the published 26.9.13 and passes here. The wheel holds the same files as before minus the two __init__.py. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/publish.yml | 11 +++++++++++ marinholab/__init__.py | 1 - marinholab/sas/__init__.py | 1 - pyproject.toml | 7 +++++++ setup.py | 7 ------- 5 files changed, 18 insertions(+), 9 deletions(-) delete mode 100644 marinholab/__init__.py delete mode 100644 marinholab/sas/__init__.py diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index f2e4b52..1f83db9 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -122,6 +122,17 @@ jobs: assert np.allclose(arm.pose_jacobian(q), arm.raw_pose_jacobian(q, 2)) print(arm.fkm(q)) " + # marinholab and marinholab.sas must stay namespace packages (no + # __init__.py), or they hide the marinholab.* packages of other + # distributions (marinholab-solvers-qpoases, marinholab-ur3e-r820). + mkdir -p other/marinholab/other_package + echo "VALUE = 1" > other/marinholab/other_package/__init__.py + PYTHONPATH=other $GITHUB_WORKSPACE/$PY -c " + import marinholab, marinholab.sas, marinholab.sas.core, marinholab.other_package + assert getattr(marinholab, '__file__', None) is None, marinholab.__file__ + assert getattr(marinholab.sas, '__file__', None) is None, marinholab.sas.__file__ + print('namespace packages OK') + " - name: Upload wheel artifact uses: actions/upload-artifact@v6 diff --git a/marinholab/__init__.py b/marinholab/__init__.py deleted file mode 100644 index d0aeda8..0000000 --- a/marinholab/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""marinholab package.""" diff --git a/marinholab/sas/__init__.py b/marinholab/sas/__init__.py deleted file mode 100644 index a79a748..0000000 --- a/marinholab/sas/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""marinholab.sas package.""" diff --git a/pyproject.toml b/pyproject.toml index fd52f4b..4484d55 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,8 +46,15 @@ sas_core_clock_example = "marinholab.sas.core.example_clock:main" sas_core_clock_sched_fifo_example = "marinholab.sas.core.example_clock_sched_fifo:main" sas_core_robot_driver_subclass_example = "marinholab.sas.core.example_robot_driver_subclass:main" +# `marinholab` and `marinholab.sas` are PEP 420 namespace packages (no +# __init__.py), shared with other distributions such as +# marinholab-solvers-qpoases (marinholab.solvers) and marinholab-ur3e-r820 +# (marinholab.ur3e_r820). An __init__.py in either would make it a regular +# package and hide the others' subpackages. `namespaces` (true by default) +# makes find include them. [tool.setuptools.packages.find] include = ["marinholab*"] +namespaces = true [tool.setuptools.package-data] "marinholab.sas.core" = ["py.typed", "*.pyi"] diff --git a/setup.py b/setup.py index 252d7fd..1466109 100644 --- a/setup.py +++ b/setup.py @@ -120,13 +120,6 @@ def build_extension(self, ext: CMakeExtension) -> None: setup( license="LGPL-3.0-or-later", - packages=[ - "marinholab", - "marinholab.sas", - "marinholab.sas.core", - "marinholab.sas.core.papers", - "marinholab.sas.core.papers.icra2019", - ], ext_modules=[CMakeExtension("marinholab.sas.core._core")], cmdclass={"build_ext": CMakeBuild}, zip_safe=False,