User installed PLUGINs

Asked by Zachary Marshall on 2019-07-11

Hi,

We'd like to be able to operate with a central installation of MG5_aMC, and still allow users to install their own plugins when they wish. It seems as though the current mechanism is to look for the PLUGIN module in MG5. One of our users pointed out that if you add to the __init__.py in the central PLUGIN directory:

import pkgutil
__path__ = pkgutil.extend_path(__path__, __name__)

Then a local user can have a PLUGIN directory in their PYTHONPATH that will be searched in addition to the MG5_aMC PLUGIN directory (currently this doesn't work because it always searches the MG5_aMC path first, and looks for PLUGIN.X, where X is the user plugin; if it added the PLUGIN directory to the PYTHONPATH and tried to import X, then that would be extensible).

Is that possible? Is there some other mechanism that you have in mind for users to be able to extend the set of PLUGINs that are installed centrally?

Thanks,
Zach

Question information

Language:
English Edit question
Status:
Solved
For:
MadGraph5_aMC@NLO Edit question
Assignee:
No assignee Edit question
Solved by:
Zachary Marshall
Solved:
2019-07-11
Last query:
2019-07-11
Last reply:
2019-07-11

Sorry, I should add: hat tip to Philipp Windischhofer for the suggestion!

Hi,

This is already extensible since the code is the following:
So you can set a directory named MG5aMC_PLUGIN within your pythonpath
and put all your plugin inside.

Cheers,

Olivier

    try:
        _temp = __import__('PLUGIN.%s' % module, globals(), locals(), fcts, -1)
    except ImportError:
        try:
            _temp = __import__('MG5aMC_PLUGIN.%s' % module, globals(), locals(), fcts, -1)
        except ImportError:
            raise MadGraph5Error, error_msg

So

On 11 Jul 2019, at 23:27, Zachary Marshall <<email address hidden><mailto:<email address hidden>>> wrote:

Question #681979 on MadGraph5_aMC@NLO changed:
https://answers.launchpad.net/mg5amcnlo/+question/681979

Zachary Marshall gave more information on the question:
Sorry, I should add: hat tip to Philipp Windischhofer for the
suggestion!

--
You received this question notification because you are an answer
contact for MadGraph5_aMC@NLO.

Thanks!