Exemplo n.º 1
0
 def test_pythonpackage_pick_python_cmd(self):
     """Test pick_python_cmd function from pythonpackage.py."""
     from easybuild.easyblocks.generic.pythonpackage import pick_python_cmd
     self.assertTrue(pick_python_cmd() is not None)
     self.assertTrue(pick_python_cmd(2) is not None)
     self.assertTrue(pick_python_cmd(2, 6) is not None)
     self.assertTrue(pick_python_cmd(123, 456) is None)
Exemplo n.º 2
0
 def test_pythonpackage_pick_python_cmd(self):
     """Test pick_python_cmd function from pythonpackage.py."""
     from easybuild.easyblocks.generic.pythonpackage import pick_python_cmd
     self.assertTrue(pick_python_cmd() is not None)
     self.assertTrue(pick_python_cmd(2) is not None)
     self.assertTrue(pick_python_cmd(2, 6) is not None)
     self.assertTrue(pick_python_cmd(123, 456) is None)
    def prepare_step(self, *args, **kwargs):
        """Prepare for installing bundle of Python packages."""
        super(Bundle, self).prepare_step(*args, **kwargs)

        python_root = get_software_root('Python')
        if python_root is None:
            raise EasyBuildError("Python not included as dependency!")

        # when system Python is used, the first 'python' command in $PATH will not be $EBROOTPYTHON/bin/python,
        # since $EBROOTPYTHON is set to just 'Python' in that case
        # (see handling of allow_system_deps in EasyBlock.prepare_step)
        if which('python') == os.path.join(python_root, 'bin', 'python'):
            # if we're using a proper Python dependency, let det_pylibdir use 'python' like it does by default
            python_cmd = None
        else:
            # since det_pylibdir will use 'python' by default as command to determine Python lib directory,
            # we need to intervene when the system Python is used, by specifying version requirements
            # to pick_python_cmd so the right 'python' command is used;
            # if we're using the system Python and no Python version requirements are specified,
            # use major/minor version of Python being used in this EasyBuild session (as we also do in PythonPackage)
            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]

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

        self.pylibdir = det_pylibdir(python_cmd=python_cmd)