Upon installing an Extension from ExtensionManager, it appears that ~/.config/NA-MIC/Slicer-{revision}.ini file gets updated with new [LibraryPaths], AdditionalPaths, [PYTHONPATH], [PATH] even though I specify a different directory for Extensions installation path. Is there a way to compartmentalize where Slicer-{revision}.ini file will be written?
The use case is, I have my own Extensions at ~/.config/NA-MIC while there is a shared Extension path at ~/where/ever/it/is. Extensions installed at the latter directory are not found by a different user unless a Slicer-{revision}.ini exists in a shared directory.
I think in this case the easiest solution is to make a shell script that uses the --additional-module-paths command line argument to specify all the extensions.
To compartmentalize settings, you can rename the Slicer executable file (bin/SlicerApp-real). This will create custom .ini files completely independent from Slicer installations. You also need to update Application/path value in bin/SlicerLauncherSettings.ini file accordingly.
To have completely isolated, custom-branded applications, you can build Slicer from source using this template.
It’s a matter of taste, but there’s a tradeoff here between simplicity and automation. Personally, I think a script that has a lot of identical lines adding paths to the command line is easier to understand and maintain (especially if it’s nicely formatted with backslashes and indentation). There’s only so much that needs to be in such a script.
In the rest of the file, those paths appear multiple times in [LibraryPaths] section. Similar multiplicity exists in other sections i.e [PYTHONPATH] and [Paths]. So, when writing the shell script, can I omit multiplicity of paths? @pieper@lassoan
If you want to have a shared Slicer with extensions installed, you can also just copy all the extensions in lib\Slicer-4.11 folder. No need to modify any settings or paths.
If you don’t want to copy the files, you can just list the modules folders in the command line to start slicer.
I often have a small shell script to start up slicer with extensions under development and just point to their build directories.
Usage
Slicer [options]
Options
--launcher-help Display help
--launcher-version Show launcher version information
--launcher-verbose Verbose mode
--launch Specify the application to launch
--launcher-detach Launcher will NOT wait for the application to finish
--launcher-no-splash Hide launcher splash
--launcher-timeout Specify the time in second before the launcher kills the application. -1 means no timeout (default: -1)
--launcher-load-environment Specify the saved environment to load.
--launcher-dump-environment Launcher will print environment variables to be set, then exit
--launcher-show-set-environment-commands Launcher will print commands suitable for setting the parent environment (i.e. using 'eval' in a POSIX shell), then exit
--launcher-additional-settings Additional settings file to consider
--launcher-additional-settings-exclude-groups Comma separated list of settings groups that should NOT be overwritten by values in User and Additional settings. For example: General,Application,ExtraApplicationToLaunch
--launcher-ignore-user-additional-settings Ignore additional user settings
--launcher-generate-exec-wrapper-script Generate executable wrapper script allowing to set the environment
--launcher-generate-template Generate an example of setting file
--designer Start Qt designer using Slicer plugins
Unknown option: --
usage: bin/python-real [option] ... [-c cmd | -m mod | file | -] [arg] ...
Try `python -h' for more information.
Ah, right - the problem here is that --additional-module-paths is an argument of the application, not the launcher. But I see here you are wanting to launch bin/python-real .
Probably you want something more like this, where you use the app as a python environment to it has the extensions loaded.
Also not that if you don’t need to run the application (e.g., just run Python CLI modules) then you may be able to run Python scripts using PythonSlicer executable.
I have a similar question to this post. I want to make a minor modification to a Slicer Extension for another lab member to use. Is the best approach to build everything in a docker and package the extension modification? something like:
as long as the group all have a similar linux environment on a local machine should be ok?
I would recommend to send a pull request to the extension’s repository. Then not only that lab member but all other users can benefit from the change.
In general, “similar” build environment is not sufficient for achieving binary compatibility, but you can try and it may or may not work. To ensure binary compatibility, you need to have the exact same build environment, which is the easiest to achieve if you build on the same computer (physical or virtual machine or container).
thank you. i’ll try both. the modification is very much a hack that breaks other functionality a user might want. I need to give it some thought how to not break existing the calculation.