Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix importing submodules in pythonizations #667

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions python/podio/pythonizations/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
"""cppyy pythonizations for podio"""

from importlib import import_module
from pkgutil import walk_packages
from pkgutil import iter_modules
from os import path
from .utils.pythonizer import Pythonizer


def load_pythonizations(namespace):
"""Register all available pythonizations for a given namespace"""
module_names = [name for _, name, _ in walk_packages(__path__) if not name.startswith("test_")]
pythonizations_dir = path.dirname(__file__)
# find only direct submodules of the current module
module_names = [name for _, name, _ in iter_modules([pythonizations_dir])]
for module_name in module_names:
import_module(__name__ + "." + module_name)
pythonizers = sorted(Pythonizer.__subclasses__(), key=lambda x: x.priority())
Expand Down