Hello there! Thanks for maintaining draccus :)
I wanted to raise an important issue that causes downstream projects relying on draccus to have issues with their tests:
draccus 0.10.0 installs 28 files under a top-level tests/ package into site-packages, including tests/__init__.py and tests/conftest.py.
$ grep "^tests/" .venv/lib/python3.12/site-packages/draccus-0.10.0.dist-info/RECORD | wc -l
28
This causes a namespace collision for any project whose own tests/ directory uses PEP 420 namespace packages (i.e. no __init__.py). Because draccus's tests/__init__.py makes it a regular package, Python's import machinery always resolves import tests to the draccus copy — regardless of sys.path ordering — since regular packages take precedence over namespace packages.
In practice this means downstream projects cannot remove their tests/__init__.py files without their from tests.xxx.conftest import … cross-imports breaking at runtime (they resolve to draccus's tests/conftest.py instead).
Suggested fix
Exclude tests from the wheel by adding an explicit exclude in pyproject.toml:
[tool.setuptools.packages.find]
exclude = ["tests", "tests.*"]
This is a well-documented anti-pattern — see [pypa/setuptools#3340](pypa/setuptools#3340) and the [Python Packaging User Guide](https://packaging.python.org/en/latest/guides/using-testpypi/).
Environment
- draccus 0.10.0
- Python 3.12
- pip / setuptools
Hello there! Thanks for maintaining
draccus:)I wanted to raise an important issue that causes downstream projects relying on
draccusto have issues with their tests:draccus 0.10.0installs 28 files under a top-leveltests/package intosite-packages, includingtests/__init__.pyandtests/conftest.py.This causes a namespace collision for any project whose own
tests/directory uses PEP 420 namespace packages (i.e. no__init__.py). Because draccus'stests/__init__.pymakes it a regular package, Python's import machinery always resolvesimport teststo the draccus copy — regardless ofsys.pathordering — since regular packages take precedence over namespace packages.In practice this means downstream projects cannot remove their
tests/__init__.pyfiles without theirfrom tests.xxx.conftest import …cross-imports breaking at runtime (they resolve to draccus'stests/conftest.pyinstead).Suggested fix
Exclude
testsfrom the wheel by adding an explicit exclude inpyproject.toml:This is a well-documented anti-pattern — see [pypa/setuptools#3340](pypa/setuptools#3340) and the [Python Packaging User Guide](https://packaging.python.org/en/latest/guides/using-testpypi/).
Environment