Skip to content

Commit

Permalink
Merge pull request easybuilders#3430 from casparvl/fix_python_req_pyt…
Browse files Browse the repository at this point in the history
…honbundle

make sure to raise an error if `pick_python_cmd` returns False for Python bundles/packages
  • Loading branch information
bedroge authored Sep 6, 2024
2 parents cdc4930 + df1148c commit 020ca79
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
9 changes: 9 additions & 0 deletions easybuild/easyblocks/generic/pythonbundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,15 @@ def prepare_step(self, *args, **kwargs):

python_cmd = pick_python_cmd(req_maj_ver=req_py_majver, req_min_ver=req_py_minver)

# If pick_python_cmd didn't find a (system) Python command, we should raise an error
if python_cmd:
self.log.info("Python command being used: %s", python_cmd)
else:
raise EasyBuildError(
"Failed to pick Python command that satisfies requirements in the easyconfig "
"(req_py_majver = %s, req_py_minver = %s)", req_py_majver, req_py_minver
)

self.all_pylibdirs = get_pylibdirs(python_cmd=python_cmd)
self.pylibdir = self.all_pylibdirs[0]

Expand Down
20 changes: 15 additions & 5 deletions easybuild/easyblocks/generic/pythonpackage.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,13 +511,23 @@ def prepare_python(self):
# if using system Python, go hunting for a 'python' command that satisfies the requirements
python = pick_python_cmd(req_maj_ver=req_py_majver, req_min_ver=req_py_minver)

if python:
# Check if we have Python by now. If not, and if self.require_python, raise a sensible error
if python:
self.python_cmd = python
self.log.info("Python command being used: %s", self.python_cmd)
elif self.require_python:
if req_py_majver is not None or req_py_minver is not None:
raise EasyBuildError(
"Failed to pick Python command that satisfies requirements in the easyconfig "
"(req_py_majver = %s, req_py_minver = %s)", req_py_majver, req_py_minver
)
else:
raise EasyBuildError("Failed to pick Python command to use")
else:
self.log.warning("No Python command found!")
else:
self.python_cmd = python
self.log.info("Python command being used: %s", self.python_cmd)
elif self.require_python:
raise EasyBuildError("Failed to pick Python command to use")
else:
self.log.warning("No Python command found!")

if self.python_cmd:
# set Python lib directories
Expand Down

0 comments on commit 020ca79

Please sign in to comment.