Esempio n. 1
0
def test_install_python_bin():
    """Should create the right python executables and links"""
    tmp_virtualenv = tempfile.mkdtemp()
    try:
        home_dir, lib_dir, inc_dir, bin_dir = virtualenv.path_locations(
            tmp_virtualenv)
        virtualenv.install_python(home_dir, lib_dir, inc_dir, bin_dir, False,
                                  False)

        if virtualenv.IS_WIN:
            required_executables = ["python.exe", "pythonw.exe"]
        else:
            py_exe_no_version = "python"
            py_exe_version_major = "python%s" % sys.version_info[0]
            py_exe_version_major_minor = "python{}.{}".format(
                sys.version_info[0], sys.version_info[1])
            required_executables = [
                py_exe_no_version, py_exe_version_major,
                py_exe_version_major_minor
            ]

        for pth in required_executables:
            assert os.path.exists(os.path.join(
                bin_dir, pth)), "%s should exist in bin_dir" % pth
        if not virtualenv.IS_JYTHON:
            assert os.path.exists(inc_dir)
        root_inc_dir = os.path.join(home_dir, "include")
        assert not os.path.islink(root_inc_dir)
    finally:
        shutil.rmtree(tmp_virtualenv)
Esempio n. 2
0
def test_install_python_bin():
    """Should create the right python executables and links"""
    tmp_virtualenv = tempfile.mkdtemp()
    try:
        home_dir, lib_dir, inc_dir, bin_dir = \
                                virtualenv.path_locations(tmp_virtualenv)
        virtualenv.install_python(home_dir, lib_dir, inc_dir, bin_dir, False,
                                  False)

        if virtualenv.is_win:
            required_executables = ['python.exe', 'pythonw.exe']
        else:
            py_exe_no_version = 'python'
            py_exe_version_major = 'python%s' % sys.version_info[0]
            py_exe_version_major_minor = 'python%s.%s' % (sys.version_info[0],
                                                          sys.version_info[1])
            required_executables = [
                py_exe_no_version, py_exe_version_major,
                py_exe_version_major_minor
            ]

        for pth in required_executables:
            assert os.path.exists(os.path.join(bin_dir, pth)), \
                   ("%s should exist in bin_dir" % pth)
    finally:
        shutil.rmtree(tmp_virtualenv)
Esempio n. 3
0
def create_env():
    if env_exists():
        raise Exception('Virtual environment already exists.')

    log('Creating virtual environment...')

    home_dir, lib_dir, inc_dir, bin_dir = venv.path_locations(ENV_PATH)
    python_loc = venv.install_python(
        home_dir,
        lib_dir,
        inc_dir,
        bin_dir,
        site_packages=False,
        clear=False,
        symlink=True
    )

    python_abs_loc = os.path.abspath(python_loc)

    venv.install_activate(home_dir, bin_dir)
    venv.install_wheel(['setuptools', 'pip'], python_abs_loc, None)
    venv.install_distutils(home_dir)

    log('Installing requirements...')
    req_cmd = '{0}/bin/pip install {1}'.format(
        ENV_PATH,
        get_config().requirements
    )
    execute_under_env(req_cmd)

    log('Virtual environment created!')
Esempio n. 4
0
def create_env():
    if env_exists():
        raise Exception('Virtual environment already exists.')

    log('Creating virtual environment...')

    home_dir, lib_dir, inc_dir, bin_dir = venv.path_locations(ENV_PATH)
    python_loc = venv.install_python(home_dir,
                                     lib_dir,
                                     inc_dir,
                                     bin_dir,
                                     site_packages=False,
                                     clear=False,
                                     symlink=True)

    python_abs_loc = os.path.abspath(python_loc)

    venv.install_activate(home_dir, bin_dir)
    venv.install_wheel(['setuptools', 'pip'], python_abs_loc, None)
    venv.install_distutils(home_dir)

    log('Installing requirements...')
    req_cmd = '{0}/bin/pip install {1}'.format(ENV_PATH,
                                               get_config().requirements)
    execute_under_env(req_cmd)

    log('Virtual environment created!')
Esempio n. 5
0
def test_install_python_bin():
    """Should create the right python executables and links"""
    tmp_virtualenv = tempfile.mkdtemp()
    try:
        home_dir, lib_dir, inc_dir, bin_dir = virtualenv.path_locations(tmp_virtualenv)
        virtualenv.install_python(home_dir, lib_dir, inc_dir, bin_dir, False, False)

        if virtualenv.is_win:
            required_executables = ["python.exe", "pythonw.exe"]
        else:
            py_exe_no_version = "python"
            py_exe_version_major = "python%s" % sys.version_info[0]
            py_exe_version_major_minor = "python%s.%s" % (sys.version_info[0], sys.version_info[1])
            required_executables = [py_exe_no_version, py_exe_version_major, py_exe_version_major_minor]

        for pth in required_executables:
            assert os.path.exists(os.path.join(bin_dir, pth)), "%s should " "exist in bin_dir" % pth
    finally:
        shutil.rmtree(tmp_virtualenv)
Esempio n. 6
0
def test_install_python_symlinks():
    """Should create the right symlinks in bin_dir"""
    tmp_virtualenv = tempfile.mkdtemp()
    try:
        home_dir, lib_dir, inc_dir, bin_dir = \
                                virtualenv.path_locations(tmp_virtualenv)
        virtualenv.install_python(home_dir, lib_dir, inc_dir, bin_dir, False,
                                  False)

        py_exe_no_version = 'python'
        py_exe_version_major = 'python%s' % sys.version_info[0]
        py_exe_version_major_minor = 'python%s.%s' % (
            sys.version_info[0], sys.version_info[1])
        required_executables = [ py_exe_no_version, py_exe_version_major,
                         py_exe_version_major_minor ]

        for pth in required_executables:
            assert os.path.exists(os.path.join(bin_dir, pth)), ("%s should "
                            "exist in bin_dir" % pth)
    finally:
        shutil.rmtree(tmp_virtualenv)
Esempio n. 7
0
def test_install_python_bin():
    """Should create the right python executables and links"""
    tmp_virtualenv = tempfile.mkdtemp()
    try:
        home_dir, lib_dir, inc_dir, bin_dir = virtualenv.path_locations(tmp_virtualenv)
        virtualenv.install_python(home_dir, lib_dir, inc_dir, bin_dir, False, False)

        if virtualenv.IS_WIN:
            required_executables = ["python.exe", "pythonw.exe"]
        else:
            py_exe_no_version = "python"
            py_exe_version_major = "python%s" % sys.version_info[0]
            py_exe_version_major_minor = "python{}.{}".format(sys.version_info[0], sys.version_info[1])
            required_executables = [py_exe_no_version, py_exe_version_major, py_exe_version_major_minor]

        for pth in required_executables:
            assert os.path.exists(os.path.join(bin_dir, pth)), "%s should exist in bin_dir" % pth
        if not virtualenv.IS_JYTHON:
            assert os.path.exists(inc_dir)
        root_inc_dir = os.path.join(home_dir, "include")
        assert not os.path.islink(root_inc_dir)
    finally:
        shutil.rmtree(tmp_virtualenv)
Esempio n. 8
0
    def build(self):
        print('Building Python Virtual Environment: {0}...'.format(self.uuid))
        home_dir, lib_dir, inc_dir, bin_dir = venv.path_locations(
            self._env_path)

        self._python = os.path.abspath(venv.install_python(
            home_dir, lib_dir, inc_dir, bin_dir, site_packages=False,
            clear=False, symlink=True))

        venv.install_wheel(['setuptools', 'pip'], self._python, None)
        venv.install_distutils(home_dir)

        print('Build complete!')
        return self._python
Esempio n. 9
0
 def reinstall(self):
     home_dir, lib_dir, inc_dir, bin_dir = virtualenv.path_locations(
         self.root_path)
     virtualenv.install_python(home_dir, lib_dir, inc_dir, bin_dir,
                               False, True)
     self.install()
Esempio n. 10
0
 def reinstall(self):
     home_dir, lib_dir, inc_dir, bin_dir = virtualenv.path_locations(
         self.root_path)
     virtualenv.install_python(home_dir, lib_dir, inc_dir, bin_dir, False,
                               True)
     self.install()