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

MNT: Adjust fslStartup test to support micromamba-based installations

parent ee2d9375
No related branches found
Tags 2501.0
1 merge request!71MNT: Adjust `fslStartup` test to support micromamba-based installations
Pipeline #26931 passed
#!/usr/bin/env fslpython
#Note this script requires a conda activate script to be on the PATH
# Note this script attempts to activate the $FSLDIR conda environment in
# order to compile the test_fslStartup.cc program. Therefore this script
# expects one of the following to be true:
#
# - A $FSLDIR/bin/activate script to be present
# - A $FSLDIR/bin/micromamba executable to be present
#
import os
import os.path as op
import shlex
import sys
import tempfile
......@@ -35,22 +42,38 @@ def run(cmd, ompthreads=None, blasthreads=None, fslskipglobal=None):
return result.stdout.strip().split('\n')[-1]
def main():
env = os.environ.copy()
activatePath = Path(f'''{env['FSLDIR']}/bin/activate''')
if not activatePath.is_file():
activatePath='activate'
def genActivateCommand():
fsldir = os.environ['FSLDIR']
mmbin = f'{fsldir}/bin/micromamba'
activate = f'{fsldir}/bin/activate'
if op.exists(mmbin):
return '; '.join([
f'eval $({mmbin} shell hook --shell posix)',
f'micromamba activate {fsldir}'])
outdir = Path(sys.argv[1])
elif op.exists(activate):
return f'source {activate} {fsldir}'
buildcmds = [f'''source {activatePath} $FSLDIR''',
'source $FSLDIR/etc/fslconf/fsl-devel.sh',
f'''cp Makefile test_fslStartup.cc {outdir}''',
f'''cd {outdir}''',
'make']
# hope that there's an activate script/func available
else:
return f'source activate {fsldir}'
def main():
fsldir = os.environ['FSLDIR']
outdir = Path(sys.argv[1])
buildcmds = [
genActivateCommand(),
f'source {fsldir}/etc/fslconf/fsl-devel.sh',
f'cp Makefile test_fslStartup.cc {outdir}',
f'cd {outdir}',
'make']
sp.run('; '.join(buildcmds), check=True, shell=True)
os.chdir(outdir)
os.chdir(outdir)
# Default behaviour should be: OMP multi-threaded, BLAS single threaded.
assert run('./test_fslStartup', 8, 8) == '8 1 8'
......
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