Loosely-coupled Python namespace package

55 Views Asked by At

Given the namespace package structure as indicated below (example from Install namespace packages using pyproject.toml).

bundle_root/
├── calculator-divide/
│   ├── ...
│   └── src/
│   │   └── calculator/
│   │       └── divider/
│   │           └── ...
|   ├── pyproject.toml
└── calculator-add/
|   ├── ...
|   └── src/
|   │  └── calculator/
|   │       └── adder/
|   │           └── ...
│   ├── pyproject.toml

The namespace package is called calculator and contains two subpackages (calculator-divide and calculator-add). The pyproject.toml of each file contains the following block:

[tool.setuptools.packages.find]
where = ["src"]
include = ["calculator.*"]

In this way, it is possible to create several packages (calculator-add and calculator-divide) and publish them separately.

Now suppose that calculator-add REQUIRES calculator-divide. How do you (properly) adjust the pyproject.toml of calculator-add? I imagine the [project] [dependencies] could be used, but I feel like it is better to include it in the [tool.setuptools.packages.find] somehow. My question is: how to do this?

My goal is to publish each subpackage individually, so that the subpackages can be installed individually by the user. Yet, I want to ensure that if calculator-add is installed, that its dependency calculator-divide is also immediately installed.

0

There are 0 best solutions below