I have projects using namespace packages that need to be distributed as separate packages but live in the same source tree. I currently use setup.py
files to do this and put each in their own directory, e.g.
src/
acme/
core/
...
client/
...
server/
...
acme-core/
setup.py
acme-client/
setup.py
acme-server/
setup.py
Each setup.py
simply cds to its parent directory and uses requirements
and package selectors specific to that package. This is a little kludgey but
allows me to work with just one source tree in my IDE while still being able
to generate separate installable packages.
The question is, how do I accomplish the same thing using pyproject.toml
files?
As far as I can tell, there is no way for pyproject.toml
to specify the root directory.
It is simply assumed to be the same directory as the file or perhaps in a src/
subdir.
Obviously, I could split up my project into multiple source trees, but I would rather not do that if I can avoid it. I would like to maintain the original project structure but just change the project build configuration.
I could resort to a hack where a package specific pyproject.toml
file gets moved into place temporarily during builds, but that seems pretty horrible. A better option would probably be to customize a build tool like hatchling to provide a way to alter the root.
Really I wish I could just write something like this in a pyproject.toml
file:
[project]
name = acme.core
root = ..
...
and someday have tools recognize that.
Any other ideas?
Please just assume that I have a good reason to want to keep my packages in one source tree.