How to organize the file structure of my existing plugin system?

I am working on a project whose main principle is extensibility.

I implemented a plug-in system by defining a metaclass that registers - using the class method - the class name of any plug-in that is loaded (each type of plug-in inherits from a particular class defined in the core of the code, since there are different types of plug-ins in the application). This basically means that the developer will have to define his class as

class PieChart(ChartPluginAncestor):
    # Duck typing:
    # Implement compulsory methods for Plugins 
    # extending Chart functionality

and the main program will know about its presence, because it PieChartwill be included in the list of registered plugins available in ChartPluginAncestor.plugins.

Being a mount method of a class method, all plugins are registered when their class code is loaded into memory (so even before an object of this class is created) .

The system works well enough ™ for me (although I am always open to suggestions on how to improve the architecture!), But now I wonder what would be the best way to manage plug-in files (i.e. where and how files containing plugins should be saved ).

So far, I use - for development purposes - a package that I called "plugins." I put all my * .py files containing the plugin classes in the package directory, and I simply output import pluginsin the main.py file so that all the plugins are installed correctly.

EDIT: , import plugins , , ( , - - from plugins.myAI import AI).

, , :

  • unittests, .
  • , , , , , config.
  • - : (, - /usr/local/bin/) (, - /home/<user>/.myprogram/).

, - - :

  • :, ? ? ? .py ?)
  • , () :, Python ?
  • : / ( , gnu/linux)?
+5
2

, . .

: / ( gnu/linux, at ) ?

- . Virtualenv - python "" python. . -, .

: http://pypi.python.org/pypi/virtualenv

: ? ? ? .py ?)

python, " " : init.py

http://www.qgis.org/wiki/Writing_Python_Plugins API http://twistedmatrix.com/documents/current/core/howto/plugin.html

. http://pypi.python.org/pypi/giblets/0.2.1

Giblets - Trac. , , .

Giblets .

+3

, , . .

(, MethodPlugins), (, MethodPlugins.IRV). :

  • (import MethodPlugins)

  • pkgutil.iter_modules (, MethodPlugins.IRV)

  • , __subclassess__, .

, , , , .

, , os.listdir . , .

, .:)

+1

All Articles