Skip to content

Commit

Permalink
Pull complicated error inside the 'if python' block, where req_py_maj…
Browse files Browse the repository at this point in the history
…ver and req_py_minver are guaranteed to be defined
  • Loading branch information
Caspar van Leeuwen committed Sep 5, 2024
1 parent 54beed9 commit 0e6f795
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions easybuild/easyblocks/generic/pythonpackage.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,8 +498,6 @@ def prepare_python(self):
python = os.path.join(python_root, 'bin', 'python')
self.log.debug("Retaining 'python' command for Python dependency: %s", python)

req_py_majver = None
req_py_minver = None
if python is None:
# if no Python version requirements are specified,
# use major/minor version of Python being used in this EasyBuild session
Expand All @@ -513,19 +511,24 @@ 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:
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 EasyConfigs "
"(req_py_majver = %s, req_py_minver = %s)", req_py_majver, req_py_minver
)
# 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 EasyConfigs "
"(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:
raise EasyBuildError("Failed to pick Python command to use")
self.log.warning("No Python command found!")
else:
self.log.warning("No Python command found!")
self.python_cmd = python
self.log.info("Python command being used: %s", self.python_cmd)


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

0 comments on commit 0e6f795

Please sign in to comment.