[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Doubt about developing plugins for python applications



Dear Gurus,

I have a question about plugins structure, and I would like to get some advise from you. It is basically related to how I can reach a private module (for python applications) while compiling a plugin that uses that module.

I have an application to which I would like to add some external plugins, that will be essentially part of the application, thus using its existing modules, but adding functionality to the main application. For that, I designed the following structure:

program/
    |
    |---- program.py
    |
    |---- programlib/
    |
    |---- setup.py
    |
    |---- plugins/
    |         |
   
where program.py is the application entry point, which uses the programlib package, and so the plugins. The plugins have access to all packages/modules within programlib and to their own directory tree.

In this sense, the programlib is shared by the main program and its plugins, but it is still private to the rest of python.

When compiling/building the source with setup.py, I encountered the problem that separating the plugin as an independent solution: 

program/
    |
    |---- setup.py
    |
    |---- plugins/
    |         |
    |         |--pluginA/
    |         |

the setup.py fails (obviously) because it does not find the packages/modules from programlib, which are only available to the main application source.

Installing program from source, the setup.py places the files under dist-packages, making programlib accessible to the program-pluginA setup.py. But as being an application, the debian packaging will install it into /usr/share/program, so the compilation of the plugin will fail.

Long story short, I guess my question is: what would be the best way to overcome this problem? I can see a couple of workarounds, but I do not know the best approach, or if there are alternatives to what I have in mind. I could think of:

a) make the package programlib public (meaning storing the files in pymodules/dist-packages) - but this does not seem good solution, because it does not have any need for programlib to be accessible by all python code

or 

b) add current installation to python path (eg. /usr/share/program) so the plugin can import the programlib packages/modules.


What would you suggest me to do?

Thank you for your help.

--
Braga, Bruno
www.brunobraga.net
bruno.braga@gmail.com


Reply to: