diff --git a/CHANGELOG.md b/CHANGELOG.md index 247f964b74fe57c70dd2cd44f7ba87a5706ef2d3..2002533a3d13ca4d501e7e2681beb233d72a9133 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ # FSL base project changelog +## 2109.0 (Monday 13th September 2021) + + - Added an extra unit test. + + ## 2108.3 (Friday 13th August 2021) - Fix to the `Makefile`, as `$FSLDIR/doc/fsl.css` was not being installed. diff --git a/share/fsl/sbin/createFSLWrapper b/share/fsl/sbin/createFSLWrapper index 8eefbe873615ddfb73a854b2016be5d1c292189b..5ad8a0bcf86c81184272ed0ca464b8c1ebaea075 100755 --- a/share/fsl/sbin/createFSLWrapper +++ b/share/fsl/sbin/createFSLWrapper @@ -8,6 +8,9 @@ # executables that are installed into the FSL conda environment (for example, # python, pip, tcl, etc). # +# This script is intended to be called by the post-link.sh script of the conda +# recipe for each FSL project that provides executable commands. +# # This script should only be invoked when FSL is being installed via the # fslinstaller script - it is not intended to be used when individual FSL # projects are explicitly installed into a custom conda environment. @@ -16,9 +19,6 @@ # FSL_CREATE_WRAPPER_SCRIPTS variables are set appropriately before creating # the FSL conda environment. # -# This script is intended to be called by the post-link.sh script of the conda -# recipe for each FSL project that provides executable commands. -# # Wrapper scripts will only be created if the following conditions are met: # # - The $FSLDIR and $PREFIX environment variables are set, and @@ -41,6 +41,17 @@ # characters. Depending on where FSL is installed, it may not be possible # to have a shebang line pointing to $FSLDIR/bin/python which does not # exceed 127 characters. +# +# Wrapper scripts are created for *all* FSL commands, including FSL TCL GUI +# commands (e.g. "fsl", "Flirt", "Flirt_gui", etc). FSL TCL GUIs are called +# (e.g.) "<Command>" om Linux, but "<Command>_gui" on macOS, because macOS +# file systems are usually case-sensitive. +# +# To work around this, and to not accidentally create a link called <Command> +# to <command>, the FSL package post link scripts should only specify +# "<Command>_gui", and *not* "<Command>". This script will create a wrapper +# script for the appropriate variant ("<Command>_gui" on macOS, or "<Command>" +# on Linux). # Names of all executables for which wrapper # scripts are to be created are passed as @@ -67,15 +78,10 @@ fi for script in $targets; do sourceScript="${PREFIX}/bin/$script" - # FSL GUIs are called (e.g.) <Command> om Linux, - # but <Command>_gui on macOS, because macOS file - # systems are usually case-sensitive. To work - # around this (and to not accidentally create a - # link called <Command> to <command>), the FSL - # package post link scripts only specify - # <Command>_gui. Here, we remove the _gui suffix - # if no source file exists (in which we are - # likely running on Linux) + # Wrapper script for a FSL TCL GUI - here, we + # remove the _gui suffix if no source file + # exists (in which we are likely running on + # Linux). if [[ "$script" == *"_gui" ]] && [ ! -f "$sourceScript" ]; then script=${script/_gui/} sourceScript="${PREFIX}/bin/$script" diff --git a/tests/test_create_remove_wrapper.py b/tests/test_create_remove_wrapper.py index 6170f778c8ce6163d602ce7970093c600437398d..5ee92a74e649d07e77ca86e24835872d02a8fb98 100755 --- a/tests/test_create_remove_wrapper.py +++ b/tests/test_create_remove_wrapper.py @@ -276,6 +276,35 @@ def test_create_gui_wrappers(): assert not op.exists(wrapper) +def test_create_wrappers_no_handle_gui_wrappers(): + """Tests creation of wrappers for FSL commands which might end with "_gui", + and for which no special handling should take place (see + test_create_gui_wrappers above). + """ + scripts = {'fsl' : 'fsl', + 'fsl_gui' : 'fsl_gui'} + + with temp_fsldir() as (fsldir, wrapperdir): + for target in scripts.values(): + touch(op.join(fsldir, 'bin', target)) + + for wrappers in it.permutations(scripts.keys()): + args = ' '.join(wrappers) + run(f'{CREATE_WRAPPER} {args}') + + for arg in wrappers: + target = scripts[arg] + wrapper = op.join(wrapperdir, target) + assert op.exists(wrapper) + assert get_called_command(wrapper) == scripts[arg] + + run(f'{REMOVE_WRAPPER} {args}') + for arg in wrappers: + target = scripts[arg] + wrapper = op.join(wrapperdir, target) + assert not op.exists(wrapper) + + if __name__ == '__main__': # base dir can be speecified on command line if len(sys.argv) > 1: