From 411e255ad3fa82fcb47d7fb5a66664f37c3fb9e3 Mon Sep 17 00:00:00 2001 From: Paul McCarthy <pauldmccarthy@gmail.com> Date: Thu, 30 Dec 2021 15:41:37 +0000 Subject: [PATCH] RF: Handle FSLDIR=child env --- share/fsl/sbin/update_fsl_package | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/share/fsl/sbin/update_fsl_package b/share/fsl/sbin/update_fsl_package index 141d402..5ff0899 100755 --- a/share/fsl/sbin/update_fsl_package +++ b/share/fsl/sbin/update_fsl_package @@ -88,9 +88,24 @@ def conda(cmd : str, capture_output=True, **kwargs) -> str: Keyword arguments are passed through to subprocess.run. """ + fsldir = os.environ['FSLDIR'] condabin = op.join(fsldir, 'bin', 'conda') + # If FSLDIR is a child env, we won't be able + # to find the conda executable. In this case, + # we have to assume that we can call "conda". + candidates = [ + op.join(fsldir, 'bin', 'conda'), + op.join(fsldir, 'condabin', 'conda'), + ] + + for condabin in candidates: + if op.exists(condabin): + break + else: + condabin = 'conda' + log.debug(f'Running {condabin} {cmd}') kwargs['check'] = False -- GitLab