Improvement: Adding component modules to environment

20 views
Skip to first unread message

Louis Amon

unread,
Jul 9, 2014, 11:13:25 AM7/9/14
to web...@googlegroups.com
Say you want to develop and distribute a plugin, and that this plugin relies on a third-party module or package.
For the example, we'll say the third-party is matplotlib.

In order to distribute your plugin, you'd need give instructions so that your plugin's users install matplotlib either in their environment or in the site-package folder of their web2py installation.

One way to avoid the hassle is to install matplotlib in the modules folder of your application. The custom_import function of gluon should do the rest of the work. Great.

Now what if you develop a big application that relies on 4 plugins that each rely on 6 third-parties ?
Should you install all 24 third-parties in your module folder ?
Wouldn't it become quite a mess ?

Here are suggestions to handling this issue :
  • Option 1:

    Modify the custom_import function so that it could add subdirectories of the modules folder that are plugin components (for instance all file paths that start with 'APP_NAME/modules/PLUGIN_NAME')

    Adding a plugin's module folder to the environment could be optional, just like running a plugin's models is optional and possible via the 'models_to_run' variable.

  • Option 2:

    Implementing pip inside web2py to manage plugin requirements upon install.
    This way, a plugin's installation would automatically trigger the installation of required third-parties into the site-package folder.
In my opinion both solutions could be interesting and complementary.

Feel free to contribute with your own opinion !
Reply all
Reply to author
Forward
0 new messages