Search code examples
pythonpluginspy2exe

How to include Yapsy with py2exe?


I'm working with Python. My file GUI.py uses Yapsy for including new plugins into my software. I have finished all my work and now I want to use py2exe to generate a executable. I don't know how can I order py2exe to include Yapsy and all their modules. I have tried that and it doesn't work:

opts = {
    'py2exe': { "includes" : ["yapsy.PluginManager","sip", "matplotlib.backends",  "matplotlib.backends.backend_qt4agg",
                               "matplotlib.figure","pylab", "numpy","matplotlib.backends.backend_tkagg"]}

...

setup(
      name='PImageQT',
      version='1.0',
      author='Jaime',
      package={'images/*', 'Windows6S/*', 'modulos6S/*', 'OperacionesPlugins/*'},
      scripts=['GUI.py'],
      console=["GUI.py"],
      options=opts,
      data_files=data_files,
      zipfile=None
      )

I have found something in this link http://notinthestars.blogspot.com.es/2011/04/using-python-plugin-scripts-with-py2exe.html but it doesn't solve my problem.

In my Gui.py file for each plugin I add an action into a menu. This menu in the executable doesn't appear.

Does anyone know how I must do it?

Thank you very much.

Edit:

I have used breakpoints and yapsy works fine, but it doesn't found my plugins directory. The directory's name is the same.

Edit 2:

The path is ok and the directory is into the path. I don't know why it doesn't find the plugins directory after packing with py2exe. My code line for set the directory is the same like other web pages: self.manager.setPluginPlaces(["plugins"])

Edit 3:

I tried use a relative path to search the plugins and, it doesn't work.

self.manager.setPluginPlaces([os.getcwd() + os.sep + "plugins"])

Edit 4:

Today, I tried to list the directory were am I and my directory "plugins" is in. I don't understand nothing but the problem continue.

print(os.listdir('.'))

Edit 5:

This is the neverending story. I have used PYInstaller to make an executable file to check if the problem is py2exe. And it doesn't work. Now I think that the problem is Yapsy. Any ideas?


Solution

  • From your EDITS it seems that the problem is related to accessing some packaged plugin (and not the yapsy module per se).

    For that you might want to check the following two points:

    • when you call self.manager.setPluginPlaces(["plugins"]) be aware that the path "plugin" may not be related to the directory you think. You should use a more specific path, using tips from the "where Am I" faq of py2exe: http://www.py2exe.org/index.cgi/WhereAmI

    • you might also try to package the plugins as data_files (like in the web page you've linked to), I'm not sure anymore how exactly the "package" argument (in your code sample) is handled by py2exe.

    EDIT: for people that may come by later, the answer is in the comments below and basically what happened is that one of the plugin had an import error (a dependency not packaged by py2exe) and this import error could only be seen if python's standard logging is properly configured/activated with:

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