MCPcopy Create free account
hub / github.com/pyfa-org/Pyfa / iterNamespace

Function iterNamespace

eos/utils/pyinst_support.py:10–39  ·  view source on GitHub ↗

Pyinstaller-compatible namespace iteration. Yields the name of all modules found at a given Fully-qualified path. To have it running with pyinstaller, it requires to ensure a hook inject the "hidden" modules from your plugins folder inside the executable: - if your plugins

(name, path)

Source from the content-addressed store, hash-verified

8
9
10def iterNamespace(name, path):
11 """Pyinstaller-compatible namespace iteration.
12
13 Yields the name of all modules found at a given Fully-qualified path.
14
15 To have it running with pyinstaller, it requires to ensure a hook inject the
16 "hidden" modules from your plugins folder inside the executable:
17
18 - if your plugins are under the ``myappname/pluginfolder`` module
19 - create a file ``specs/hook-<myappname.pluginfolder>.py``
20 - content of this file should be:
21
22 .. code-block:: python
23
24 from PyInstaller.utils.hooks import collect_submodules
25 hiddenimports = collect_submodules('<myappname.pluginfolder>')
26 """
27 prefix = name + "."
28 for p in pkgutil.iter_modules(path, prefix):
29 yield p[1]
30
31 # special handling when the package is bundled with PyInstaller 3.5
32 # See https://github.com/pyinstaller/pyinstaller/issues/1905#issuecomment-445787510
33 toc = set()
34 for importer in pkgutil.iter_importers(name.partition(".")[0]):
35 if hasattr(importer, 'toc'):
36 toc |= importer.toc
37 for name in toc:
38 if name.startswith(prefix):
39 yield name

Callers 2

__init__.pyFile · 0.90
__init__.pyFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected