From b97d3293730e4d8be8cd6d476aaa0afa783cb2cf Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Mon, 6 Jan 2020 18:48:36 +0100 Subject: [PATCH] use major/minor version of Python command being used if req_py_majver/req_py_minver are not specified --- easybuild/easyblocks/generic/pythonpackage.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/easybuild/easyblocks/generic/pythonpackage.py b/easybuild/easyblocks/generic/pythonpackage.py index ed48957933..813d94a7df 100644 --- a/easybuild/easyblocks/generic/pythonpackage.py +++ b/easybuild/easyblocks/generic/pythonpackage.py @@ -211,8 +211,8 @@ def extra_options(extra_vars=None): 'download_dep_fail': [None, "Fail if downloaded dependencies are detected", CUSTOM], 'install_target': ['install', "Option to pass to setup.py", CUSTOM], 'pip_ignore_installed': [True, "Let pip ignore installed Python packages (i.e. don't remove them)", CUSTOM], - 'req_py_majver': [2, "Required major Python version (only relevant when using system Python)", CUSTOM], - 'req_py_minver': [6, "Required minor Python version (only relevant when using system Python)", CUSTOM], + 'req_py_majver': [None, "Required major Python version (only relevant when using system Python)", CUSTOM], + 'req_py_minver': [None, "Required minor Python version (only relevant when using system Python)", CUSTOM], 'sanity_pip_check': [False, "Run 'pip check' to ensure all required Python packages are installed", CUSTOM], 'runtest': [True, "Run unit tests.", CUSTOM], # overrides default 'unpack_sources': [True, "Unpack sources prior to build/install", CUSTOM], @@ -347,9 +347,9 @@ def set_pylibdirs(self): def prepare_python(self): """Python-specific preperations.""" + # pick 'python' command to use python = None - python_root = get_software_root('Python') # keep in mind that Python may be listed as an allowed system dependency, # so just checking Python root is not sufficient @@ -361,8 +361,17 @@ def prepare_python(self): self.log.debug("Retaining 'python' command for Python dependency: %s", python) if python is None: + # if no Python version requirements are specified, + # use major/minor version of Python being used in this EasyBuild session + req_py_majver = self.cfg['req_py_majver'] + if req_py_majver is None: + req_py_majver = sys.version_info[0] + req_py_minver = self.cfg['req_py_minver'] + if req_py_minver is None: + req_py_minver = sys.version_info[1] + # if using system Python, go hunting for a 'python' command that satisfies the requirements - python = pick_python_cmd(req_maj_ver=self.cfg['req_py_majver'], req_min_ver=self.cfg['req_py_minver']) + python = pick_python_cmd(req_maj_ver=req_py_majver, req_min_ver=req_py_minver) if python: self.python_cmd = python