-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Imports made through sys.meta_path do not work #2246
Description
I would like to reopen Issue #758. I am using Python 2.7.12, PyInstaller 3.3dev0+b78bfe5, Kivy 1.9.1, and Kivy-Garden 0.1.4. I would like to use kivy.garden.graph (a module for Kivy-Garden) in my application. I get an ImportError at run-time, because even though Analysis knows to look for kivy.garden.graph when analyzing my main script, it cannot find it.
The reason is as follows: kivy.garden modifies sys.meta_path when it is loaded in order to be able to find its submodules. However, if you want to modify the module search path for Analysis, say for example using pre_find_module_path, you can only change the actual path and not the meta_path.
I already tried modifying the meta_path by importing kivy.garden at the beginning of my spec file, but this modification causes other aspects of the build process to fail. Also, I tried adding the module directly to the TOC, for example:
a.pure = a.pure + TOC([('kivy.garden.graph','T:\\appdir\\libs\\garden\\garden.graph\\__init__.py','PYMODULE')])
but this also does not cause PyInstaller to properly find kivy.garden.graph for inclusion into the app bundle.
A link to how kivy.garden modifies sys.meta_path in a way that seems incompatible with the way PyInstaller finds modules is below:
https://github.com/kivy/kivy/blob/master/kivy/garden/__init__.py