From 9c4c794bbebb5d66099b1ace51177985e37c00c6 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Thu, 26 Oct 2023 16:18:29 +0200 Subject: [PATCH 1/3] fix findPythonDeps when called with an absolute path to an EC `eb --missing` returns a list with filenames. So an absolute path passed to `--ec` isn't matched which leads to an error stating you should install the EasyConfig that you are trying to find the dependencies of. Fix by getting the filename/basename first. --- easybuild/scripts/findPythonDeps.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/easybuild/scripts/findPythonDeps.py b/easybuild/scripts/findPythonDeps.py index 663926a9d6..ef284a7e21 100755 --- a/easybuild/scripts/findPythonDeps.py +++ b/easybuild/scripts/findPythonDeps.py @@ -171,8 +171,9 @@ def print_deps(package, verbose): capture_stderr=False, action_desc='Get missing dependencies' ) + excluded_dep = '(%s)' % os.path.basename(args.ec) missing_deps = [dep for dep in missing_dep_out.split('\n') - if dep.startswith('*') and '(%s)' % args.ec not in dep + if dep.startswith('*') and excluded_dep not in dep ] if missing_deps: print('You need to install all modules on which %s depends first!' % args.ec) From dfe010283b132690fb2051180dfb8ecfe272b267 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Fri, 27 Oct 2023 09:14:59 +0200 Subject: [PATCH 2/3] Show stderr output on failing command even when not requested to be captured This helps diagnosing failures for e.g. `eb --missing` (called with `capture_stderr=False`) but which may print errors (e.g. failed parsing of some ECs) to stderr --- easybuild/scripts/findPythonDeps.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/easybuild/scripts/findPythonDeps.py b/easybuild/scripts/findPythonDeps.py index ef284a7e21..4f4200de09 100755 --- a/easybuild/scripts/findPythonDeps.py +++ b/easybuild/scripts/findPythonDeps.py @@ -55,9 +55,11 @@ def run_cmd(arguments, action_desc, capture_stderr=True, **kwargs): extra_args['universal_newlines'] = True stderr = subprocess.STDOUT if capture_stderr else subprocess.PIPE p = subprocess.Popen(arguments, stdout=subprocess.PIPE, stderr=stderr, **extra_args) - out, _ = p.communicate() + out, err = p.communicate() if p.returncode != 0: - raise RuntimeError('Failed to %s: %s' % (action_desc, out)) + if err: + err = "\nSTDERR:\n" + err + raise RuntimeError('Failed to %s: %s%s' % (action_desc, out, err)) return out From cf0bd4f2e68c2b5521dfb894c4e96dc820a179b9 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Fri, 27 Oct 2023 10:17:02 +0200 Subject: [PATCH 3/3] fix findPythonDeps when using a relative path as the `--ec` argument --- easybuild/scripts/findPythonDeps.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/easybuild/scripts/findPythonDeps.py b/easybuild/scripts/findPythonDeps.py index 4f4200de09..d6e496a048 100755 --- a/easybuild/scripts/findPythonDeps.py +++ b/easybuild/scripts/findPythonDeps.py @@ -182,12 +182,14 @@ def print_deps(package, verbose): print('\n\t'.join(['Missing:'] + missing_deps)) sys.exit(1) + # If the --ec argument is a (relative) existing path make it absolute so we can find it after the chdir + ec_arg = os.path.abspath(args.ec) if os.path.exists(args.ec) else args.ec with temporary_directory() as tmp_dir: old_dir = os.getcwd() os.chdir(tmp_dir) if args.verbose: print('Running EasyBuild to get build environment') - run_cmd(['eb', args.ec, '--dump-env', '--force'], action_desc='Dump build environment') + run_cmd(['eb', ec_arg, '--dump-env', '--force'], action_desc='Dump build environment') os.chdir(old_dir) cmd = "source %s/*.env && python %s '%s'" % (tmp_dir, sys.argv[0], args.package)