Skip to content

Commit 87c1453

Browse files
authored
Merge pull request #4365 from Flamefire/fix-findPythonDeps
fix `findPythonDeps.py` script when called with an absolute path to an easyconfig
2 parents b3bcb19 + cf0bd4f commit 87c1453

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

easybuild/scripts/findPythonDeps.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,11 @@ def run_cmd(arguments, action_desc, capture_stderr=True, **kwargs):
5555
extra_args['universal_newlines'] = True
5656
stderr = subprocess.STDOUT if capture_stderr else subprocess.PIPE
5757
p = subprocess.Popen(arguments, stdout=subprocess.PIPE, stderr=stderr, **extra_args)
58-
out, _ = p.communicate()
58+
out, err = p.communicate()
5959
if p.returncode != 0:
60-
raise RuntimeError('Failed to %s: %s' % (action_desc, out))
60+
if err:
61+
err = "\nSTDERR:\n" + err
62+
raise RuntimeError('Failed to %s: %s%s' % (action_desc, out, err))
6163
return out
6264

6365

@@ -171,20 +173,23 @@ def print_deps(package, verbose):
171173
capture_stderr=False,
172174
action_desc='Get missing dependencies'
173175
)
176+
excluded_dep = '(%s)' % os.path.basename(args.ec)
174177
missing_deps = [dep for dep in missing_dep_out.split('\n')
175-
if dep.startswith('*') and '(%s)' % args.ec not in dep
178+
if dep.startswith('*') and excluded_dep not in dep
176179
]
177180
if missing_deps:
178181
print('You need to install all modules on which %s depends first!' % args.ec)
179182
print('\n\t'.join(['Missing:'] + missing_deps))
180183
sys.exit(1)
181184

185+
# If the --ec argument is a (relative) existing path make it absolute so we can find it after the chdir
186+
ec_arg = os.path.abspath(args.ec) if os.path.exists(args.ec) else args.ec
182187
with temporary_directory() as tmp_dir:
183188
old_dir = os.getcwd()
184189
os.chdir(tmp_dir)
185190
if args.verbose:
186191
print('Running EasyBuild to get build environment')
187-
run_cmd(['eb', args.ec, '--dump-env', '--force'], action_desc='Dump build environment')
192+
run_cmd(['eb', ec_arg, '--dump-env', '--force'], action_desc='Dump build environment')
188193
os.chdir(old_dir)
189194

190195
cmd = "source %s/*.env && python %s '%s'" % (tmp_dir, sys.argv[0], args.package)

0 commit comments

Comments
 (0)