My setuptools config left the subpackages out of the wheel
v1.0.0 of my GA decision-tree library installed fine from the wheel, and then:
ModuleNotFoundError: No module named 'ga_trees.data'
the wheel was 9 KB.
why: packages lists packages, not trees
pyproject.toml had:
[tool.setuptools]
packages = ["ga_trees"]
that’s exactly one package. ga_trees.data, ga_trees.ga and the other subpackages aren’t included just because they live under it. so pip install git+..., the built wheel and the release all shipped the top-level package and none of its subpackages.
fix: let setuptools find them
[tool.setuptools.packages.find]
where = ["src"]
91 KB after, all 30 modules.
why CI didn’t catch it
every test job ran on pip install -e .. an editable install points at the source tree, so every module is importable whether or not it’d be in the wheel. the packaging job only ran twine check, which checks metadata, not contents.
so now the packaging job installs the built wheel into a clean venv and imports everything from outside the repo:
python -m venv /tmp/wheel-venv
/tmp/wheel-venv/bin/pip install dist/*.whl
cd /tmp
/tmp/wheel-venv/bin/python -c "import ga_trees, ga_trees.ga, ga_trees.genotype, ga_trees.fitness, ga_trees.evaluation, ga_trees.benchmark, ga_trees.data, ga_trees.baselines; from ga_trees import GAEngine, GAConfig; print(ga_trees.__file__)"
1.0.1 went out the same day.