For the program I'm writing, I set up a package which defines an interface
for algorithms to convert CSV files from one format to another, scans the
package directory for modules which implement the interface, then gives
them to the importing program as a list[ModuleType], so that the importing
program can list them in a dropdown and present them to the user. Here's
the code I used to make the list of modules:
./conversionAlgos/__init__.py:
>>> algos: list[ModuleType] = sorted(
... [
... importlib.import_module("." + name, __name__)
... for _, name, _ in pkgutil.iter_modules(__path__)
... ],
... key=lambda item: item.PRIORITY,
... )
In my main.py that I package with pyinstaller I access the modules like
this:
./main.py
>>> from conversionAlgos import algos
...
... for algo in algos:
... print(algo.Converter().friendly_name)
algorithm 1
algorithm 2
etc.
This works fine when I run the program a script, but because the package
isn't laid out in the filesystem after I build it with pyinstaller, it
can't find the modules. Is there a better way to make the list of modules
that will be compatible with pyinstaller?
--
You received this message because you are subscribed to the Google Groups
"PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/pyinstaller/87f4fce7-ae4c-431a-8eff-750ededdfaf1n%40googlegroups.com.