Add support for pkgutil.iter_modules#5959
Conversation
d87b987 to
6f8cc30
Compare
|
The initial plan for this was to implement support for While it is possible to create a factory/finder for All in all, it seems easier and cleaner to monkey-patch |
Test that pkgutil.iter_modules() lists same contents of a package in unfrozen and frozen version. For tests, we use altgraph (pure python) and psutil (contains binary extensions), as well as psutil.tests (as an example of a sub-package). We also test both archive and noarchive mode, because in the latter, .pyc modules end up directly on filesystem, and are subject of python's built-in FileFinder. There, noarchive variants of tests pass without additional changes, while archive variants fail as frozen versions do not list PYZ-embedded modules.
Provide custom implementation of iter_modules() that works with our FrozenImporter and allows listing of sub-modules that are embedded in the PYZ archive.
This is not needed with pyinstaller 4.4 and in fact causes every module to be listed twice. See also: pyinstaller/pyinstaller#5959 Change-Id: Ic188da1bea27ed8fbb2526d7171df8ece75b88ed GitOrigin-RevId: 77601a8
Implement support for
pkgutil.iter_modules.This is done by an rthook that monkey-patches the function with our implementation, which extends the contents listed by original implementation (on-filesystem resources) with PYZ-embedded resources.
Closes #1905.
Fixes #5167 (the
iter_modulesnot returning anything unlessnoarchiveis used; however, the modules still need to be collected bycollect_submodulesin the first place).Fixes #5799.