Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix findPythonDeps.py script when called with an (absolute or relative) path to an easyconfig instead of a filename #4365

Merged
merged 3 commits into from
Oct 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions easybuild/scripts/findPythonDeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -171,20 +173,23 @@ 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)
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)
Expand Down
Loading