Skip to content

Support pkgutil.iter_modules #1905

@TobiX

Description

@TobiX

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureFeature requestpull-request wantedPlease submit a pull-request for this, maintainers will not actively work on this.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions