I'm trying use "plugins" subdirectory inside my app's directory but without complete success. I'm creating a signed SIS-package with ensymble's py2sis-command.
Originally Posted by y.a.k
If I put my 2 test-plugins (test1_plugin.py and test2_plugin.py) to e.g. "E:\Python\plugins" and then sys.path.append("E:\\Python\\plugins")
those plugins can be __import__:ed successfully.
If I put them to the apps main directory those plugins are __import__:ed successfully without need to append anything to the sys.path (because "C:\Private\0xUID\" is already in the sys.path).
But if I create plugins-subdirectory and then try __import__ plugins from there, python claims: ImportError: No module named test1_plugin. (I use "exception harness" to catch traceback in SIS-packaged app.)
What I'm doing wrong?
Here is how I add plugins-dir to the sys.path in the last case:
And here is the function to get a list of available plugins, works as expected:
self.plugin_dir = os.path.join(os.getcwd(), u"plugins")
appuifw.note(u"%s" % self.plugin_dir, "info")
# sys.path contains now C:\Private\0xUID\ AND C:\Private\0xUID\plugins
And here is the snippet which hopefully shows how I try to import plugins:
Get a list of available plugins.
All files starting with a letter and ending with .py
are considered as a plugin.
r = re.compile(r'^([a-zA-Z]+[\w]*)\.py$')
pluginlist = 
for file in os.listdir(self.plugin_dir):
matches = r.match(file)
if matches is not None and matches.groups() != 'BasePlugin':
#print "Not included: " + file
# "plugin" contains plugin's name e.g. test1_plugin
for plugin in self.get_plugins():
appuifw.note(u"%s" % plugin, "info")
# THIS RAISES ImportError:
self.mods[plugin] = __import__(plugin)
plugin_instance = self.mods[plugin].Plugin(self)