Skip to content

🗑️ Remove __init__.py to comply with PEP 420#500

Open
munechika-koyo wants to merge 5 commits into
cherab:developmentfrom
munechika-koyo:fix/pep420
Open

🗑️ Remove __init__.py to comply with PEP 420#500
munechika-koyo wants to merge 5 commits into
cherab:developmentfrom
munechika-koyo:fix/pep420

Conversation

@munechika-koyo
Copy link
Copy Markdown
Member

@munechika-koyo munechika-koyo commented May 18, 2026

Summary

Eliminate the init.py file to adhere to PEP 420, allowing for namespace packages without requiring an init.py file.

Why do we need this PR?

In CI with Python 3.12 and later, the deprecated namespace configuration produces the following errors:

======================================================================
ERROR: cherab (unittest.loader._FailedTest.cherab)
----------------------------------------------------------------------
ImportError: Failed to import test module: cherab
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/unittest/loader.py", line 429, in _find_test_path
    package = self._get_module_from_name(name)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/unittest/loader.py", line 339, in _get_module_from_name
    __import__(name)
  File "/home/runner/work/core/core/cherab/__init__.py", line 19, in <module>
    __import__('pkg_resources').declare_namespace(__name__)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'pkg_resources'

Note

I also fixed the test script because only python -m unittest couldn't discover the cherab directory.
(Reference: https://docs.python.org/3/library/unittest.html#test-discovery)

@jacklovell
Copy link
Copy Markdown
Member

Looks good. I see in CI there is a warning from setuptools about namespace_packages being deprecated. Can you update setup.py to remove this too and check that it still works OK?

@munechika-koyo
Copy link
Copy Markdown
Member Author

@jacklovell Thank you for your review!
I updated setup.py as well.

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.

2 participants