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):
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)?