`pkgutil.walk_packages` not working when loading libmat2 from `PYTHONPATH`
Hello,
now that setup.py
supports installing mat2 into the operating system, the way libmat2 parser modules are included needs to be changed. The relevant part of libmat2/parser_factory.py
:
# This loads every parser in a dynamic way
for module_loader, name, ispkg in pkgutil.walk_packages('.libmat2'):
if not name.startswith('libmat2.'):
continue
elif name == 'libmat2.abstract':
continue
importlib.import_module(name)
This doesn't work with libmat2 being in PYTHONPATH
as pkgutil.walk_packages
doesn't search in PYTHONPATH
if you give it a path (.libmat2
).
The best solution I could find is documented here: https://stackoverflow.com/questions/1707709/list-all-the-modules-that-are-part-of-a-python-package/1707786#1707786