-
Notifications
You must be signed in to change notification settings - Fork 17
Description
Packages constructed using this recipe would be installed like:
pip install ppt-foo ppt-bar ppt-blat
And code would import like:
from ppt import foo, bar, blat
We could document this as a recipe for the user. We could also incorporate it into the answers if that seems useful.
PEP 420 introduced namespaces so that organizations with related packages could present them under a common prefix while separately maintaining the contained packages. This is similar in concept to C++ namespaces and share some features. They are open and so the namespace package can be built by composition.
The modifications from a python-project-template created repository are shown below. I did verify that it builds and installs locally. I have yet to run the full suite of tests so there may be other changes involved as well. Nor have I tried to create it on pypi-test.
This assumes that the namespace is "ppt" (python-project-template?).
The first variation exactly maintains the file structure but renames src to the namespace package name, reflects that change pyproject.toml and then add a clause at the end of pyproject.toml to identify this as a subpackage of a namespace package.
mv src ppt
sed <pyproject.toml '/^write_to = /s%src/%ppt/%' > .tmp
cat >>.tmp <<!
[tool.setuptools.packages.find]
where = ["."]
include = ["ppt"]
namespaces = true
!
cat .tmp >pyproject.toml
rm .tmp
The second variation I have similarly verified creates a layer underneath src for the namespace package but otherwise keeps the file structure.
mv src ppt; mkdir src; mv ppt src
sed <pyproject.toml '/^write_to = /s%src/%src/ppt/%' > .tmp
cat >>.tmp <<!
[tool.setuptools.packages.find]
where = ["src"]
include = ["ppt"]
namespaces = true
!
cat .tmp >pyproject.toml
rm .tmp