Closed mssalvatore closed 1 year ago
A number of plugin frameworks exist, but none that address conflicting dependencies from plugins
We could probably use any framework as long as the plugins handle loading of the dependencies themselves, e.g., by “vendoring” dependencies
Other option: Use setup tools to install the plugin and complain about dependency problems Either way, the dependencies are pushed to the plugins, but the first option would allow otherwise conflicting dependencies to exist in different plugins
A project called python-localimport provides a context manager that allows importing from a directory
PEP582 proposes the use of a __pypackages__
directory which is automatically activated for .py
files, but would only work for the script that is executed. The pythonloc
and piploc
executables support this PEP
A comment on a QGIS issue outlines one approach to venturing dependencies
Due to the way that python's importer imports modules, it appears that the following three methods are viable solutions:
import a
to import plugin.a
, and store the imported modules in sys.modules with the qualified nameA little bit about importing:
import
does the following:
sys.modules
. If so, it simply returns that moduleimport a.b.c
) is split into its components. It ensures that parent packages have been imported already. So, it will first import a
, then b
, then c
We have a promising prototype in progress, but it needs the following improvements:
import a.b
it needs to be converted to the plugin namespace. So the Finder for plugin1 will convert it to plugin1.a.b
. However, if plugin2 also has an a.b
, then it may have the opportunity to load plugin2.a.b
instead. Since the importer stops after one success, it will have mistakenly loaded the dependency for the other plugin.__file__
field in the globals
parameter
Spike
Objective
Infection Monkey needs to support plugins that have conflicting dependencies. Determine if there's an existing plugin framework or other solution that makes this possible, or develop a plan and prototype for achieving this.
Scope