-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Support pkgutil.iter_modules #1905
Copy link
Copy link
Closed
Labels
featureFeature requestFeature requestpull-request wantedPlease submit a pull-request for this, maintainers will not actively work on this.Please submit a pull-request for this, maintainers will not actively work on this.
Metadata
Metadata
Assignees
Labels
featureFeature requestFeature requestpull-request wantedPlease submit a pull-request for this, maintainers will not actively work on this.Please submit a pull-request for this, maintainers will not actively work on this.
I have a plugin system in Dosage which uses pkgutil.iter_modules (https://github.com/webcomics/dosage/blob/master/dosagelib/loader.py) to find all modules with plugins. It seems iter_modules is only supported for Python's built in loaders at the moment (see https://hg.python.org/cpython/file/tip/Lib/pkgutil.py#l128, https://hg.python.org/cpython/file/tip/Lib/pkgutil.py#l176 and https://hg.python.org/cpython/file/tip/Lib/pkgutil.py#l391). It would be nice if PyInstaller's FrozenImporter had a iter_modules implementing the pkgutil protocol¹, so one could discover modules in PyInstaller-packaged libraries.
(As you can see, I'm currently special-casing PyInstaller by accessing the "toc" set of FrozenImporter directly. This works, but feels a bit hacky to me...)
¹ This "contract" seems to be rather under-documented. It's implemented in pkgutil, which references PEP-302 a lot, but that does not mention iter_modules anywhere - I can only find a reference to this method in some bug report, commit message and withdrawn PEP-402.