Search code examples
pythoncx-freeze

Yapsy finding plugins through eclipse versus cx_Freeze executable


I'm working on a program that uses Yapsy as a backend for a plugin system. User's can write their own plugins and load them at runtime. I've got a menu that displays all the loaded plugins, each as it's own menuitem. I also supply two pre-made plugins with the program. These pre-made plugins load fine when running the program through eclipse (i.e. the menu displays both plugins); however, after I've create an executable, using cx_Freeze, the plugins are not loading correctly for some reason. Only the first plugin is found, which is odd since both plugins reside in the same directory, and the code has not been changed on my end. I'm wondering if there's something wrong with Yapsy? Why would it only be finding one plugin, when both are in the same directory (only after creating an executable with cx_Freeze)?

Here's an example of the way I'm getting the pre-made plugins:

default_dir = os.path.expanduser('~') + os.sep + "plugins"

if xml.get_plugin_directory() == "":
    directory = [default_dir] # no user specified directory
else:
    directory = [default_dir, xml.get_plugin_directory()] # user specified dir too

# Load the plugins from the specified plugin directory/s.
manager = PluginManager()
manager.setPluginPlaces(directory)
manager.setPluginInfoExtension('plugin')
manager.collectPlugins()

for plugin in manager.getAllPlugins():
    ...

As you can see, I set the default directory (it always should have been created and I've tested this to make sure), and then set the plugin places to that directory or that directory and a user specified directory via yapsy.PluginManager().setPluginPlaces(directory). The default plugin location isn't in my eclipse workspace; it resides somewhere else. As I said before, this works fine when running the program through Eclipse, but once I create an executable, only one of the plugins is being found. I'd expect an error where no plugins were being found, but this is strange that one is indeed being found and not the other. Also, if I add more test plugin files to the default directory, these are found. It's almost as if Yapsy skips over the second plugin completely (only when running the executable).

Any ideas why I may be getting this behavior?

Thanks, Adam


Solution

  • The way you describe your problem, it seems that yapsy is unable to load only one of all the plugins you've tested.

    If I had to guess I would say that the plugin that doesn't load outside Eclipse has an import error (it's possible that the import path in Eclipse is different, and that this import error doesn't happen when tried inside Eclipse).

    Of course, that's just a wild guess and to investigate a little deeper you can display more debug info via the Python logging module that Yapsy uses in a rather standard way.

    To activate debug-level info you can use the following code:

    import logging
    logging.basicConfig(level=logging.DEBUG)
    

    If the problem remains unsolved you can still submit a bug to Yapsy's tracker with strimmed down version of your plugins and plugin manager code. The tracker is at: http://sourceforge.net/tracker/?group_id=208383