Skip to content
Snippets Groups Projects
Commit c0b8c237 authored by Paul McCarthy's avatar Paul McCarthy :mountain_bicyclist:
Browse files

RF: Add support for pythonw scripts to createFSLWrapper

parent 1dfe1085
No related branches found
No related tags found
1 merge request!18Detect pythonw scripts
...@@ -85,27 +85,29 @@ for script in $targets; do ...@@ -85,27 +85,29 @@ for script in $targets; do
# Figure out whether this is a python # Figure out whether this is a python
# executable or some other type of # executable or some other type of
# executable. We search for these strings # executable.
# in source file headers to ID them as id=$(head -c 1024 "$sourceScript" | grep -e '^#!.*pythonw\?$')
# python scripts. We need to check both
# match "#!/usr/bin/env python" and
# "#!<fsldir>/bin/python...", because
# conda might generate one or the other
# in different scenarios.
id1=$(head -c 1024 "$sourceScript" | grep "#!/usr/bin/env python")
id2=$(head -c 1024 "$sourceScript" | grep "#!${FSLDIR%/}/bin/python")
# Non-python executable - use a # Non-python executable - use
# pass-through script # a pass-through script
if [ -z "$id1" ] && [ -z "$id2" ]; then if [ -z "$id" ]; then
echo "#!/usr/bin/env bash" > "$targetScript" echo "#!/usr/bin/env bash" > "$targetScript"
echo "$FSLDIR/bin/$script "'"$@"' >> "$targetScript" echo "$FSLDIR/bin/$script "'"$@"' >> "$targetScript"
else else
# Python executable - run it via # Python executable - run it via
# $FSLDIR/bin/python in isolated mode # $FSLDIR/bin/python[w] in isolated
echo "#!/usr/bin/env bash" > "$targetScript" # mode. Under macOS, GUI apps are
echo "$FSLDIR/bin/python -I $sourceScript "'"$@"' >> "$targetScript" # invoked with pythonw, so we need
# to preserve the interpreter.
if [[ "$id" == *"pythonw" ]]; then
interp="pythonw"
else
interp="python"
fi
echo "#!/usr/bin/env bash" > "$targetScript"
echo "${FSLDIR}/bin/${interp} -I $sourceScript "'"$@"' >> "$targetScript"
fi fi
# Preserve file permissions # Preserve file permissions
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment