Factory build of python extensions conflicting with each other

I noticed an issue occurring during the factory build of python extensions where an extension may be installing new python packages which results in Slicer core python packages having their installed version modified. This may be with general tools like pip, setuptools, etc.

When this happens if impacts all extensions built afterwards which have to use modified versions of these packages. This makes it difficult to make sure a Slicer extension that includes additional python packages is going to be successful because it can’t expect that it will be using the same versions of the tools like pip and setuptools from Slicer core.

For example SlicerRadiomics was built after SlicerJupyter. SlicerJupyter installs a large set of python packages (CDash) where the build process says to install to a special location.

During the process it appears that setuptools is uninstalled but not reinstalled in the expected Slicer core location. This results in a SlicerRadiomics build error seemingly saying that there is no setuptools available to use (CDash)

I wonder if Slicer core external python projects should be re-run after each extension is built to make sure the extension is built against the expected versions in Slicer core. Or some other method to make sure that factory built extensions are not modifying the Slicer core build tree so that each subsequent factory built extension is built against the same version of the build tree.

This is a really important point @jamesobutler, thanks for bringing it up. A clean solution could be to copy the Slicer tree to a fresh directory so that each extension is installed and tested independently.

When an extension is built then it may rely on all extension that it depends on (recursively), so if we save the state then it may need to be a stack where we can push the state of the folder and then pop that state (instead of always just resetting the original state).

This may not require entire folder copying because pip can store all package versions in a string and then restore that state.

To follow-up on this, the SlicerJupyter extension has been updated to remove the use of --force-reinstall.