Skip to content

Fix sdist missing tests/__init__.py causing ImportError#356

Closed
nuglifeleoji wants to merge 1 commit intojmespath:developfrom
nuglifeleoji:fix/sdist-missing-tests-init
Closed

Fix sdist missing tests/__init__.py causing ImportError#356
nuglifeleoji wants to merge 1 commit intojmespath:developfrom
nuglifeleoji:fix/sdist-missing-tests-init

Conversation

@nuglifeleoji
Copy link
Copy Markdown

Problem (fixes #341)

The sdist published on PyPI omits tests/__init__.py because MANIFEST.in only includes top-level files. Without this file, running the test suite from an unpacked sdist fails with:

ImportError: cannot import name 'OrderedDict' from 'tests' (unknown location)

This happens because test_compliance.py does from tests import OrderedDict, which requires tests to be a proper package (i.e., have an __init__.py).

Fix

Add recursive-include tests * to MANIFEST.in so that all files under the tests/ directory are included in source distributions.

Verification

$ python -c "from tests import OrderedDict; print('OK', OrderedDict)"
OK <class 'collections.OrderedDict'>
$ python -m pytest tests/   # 991 passed

Made with Cursor

The sdist tarball on PyPI omitted the tests/__init__.py file because
MANIFEST.in only listed top-level files (README.rst and LICENSE).
Without tests/__init__.py, importing `from tests import OrderedDict`
in test_compliance.py fails with:

    ImportError: cannot import name 'OrderedDict' from 'tests' (unknown location)

Add `recursive-include tests *` to MANIFEST.in so that all files under
the tests/ directory are included in the source distribution.

Fixes #341

Made-with: Cursor
@nuglifeleoji nuglifeleoji closed this by deleting the head repository Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sdist is missing tests/__init__.py

1 participant