Skip to content

ENH: add module to PYTHONPATH during registration

Isaiah requested to merge github/fork/ihnorton/prepend_pythonpath into master

Allows python modules to depend on resources provided by other modules.

There are multiple stages in the module initialization process: registration, instantiation, and loading. Instantiation is when the scripted module is parsed, so any import dependencies must be resolveable at that time. However, instantiation is done alphabetically, with no dependency resolution -- because the module factory does not know anything about dependencies (the module itself supplies the dependencies function). Adding to PYTHONPATH during registration allows to import dependency-provided resources during instantiation.

ref: https://discourse.slicer.org/t/scripted-module-dependency-loaded-too-late-for-one-module-but-for-another-one-not/142

Merge request reports

Loading