Esempio n. 1
0
def _set_up_virtualenv(venv_name, tmp_dir, req,
                       include_packages, system_site_packages,
                       pypi_index_url, python_interpreter, verbose):
    """Create a virtualenv with the specified options and the default packages
    specified in configuration. Then run `pip install -r [requirements file]`.
    """
    venv = VirtualenvProxy(
        os.path.join(tmp_dir, venv_name),
        system_site_packages=system_site_packages,
        pypi_index_url=pypi_index_url,
        python_interpreter=python_interpreter,
        verbose=verbose
    )

    packages = ["pyleus=={0}".format(__version__)]
    if include_packages is not None:
        packages += include_packages

    for package in packages:
        venv.install_package(package)

    if req is not None:
        venv.install_from_requirements(req)

    _remove_pyleus_base_jar(venv)

    return venv
Esempio n. 2
0
def _set_up_virtualenv(venv_name, tmp_dir, req, include_packages,
                       system_site_packages, pypi_index_url,
                       python_interpreter, verbose):
    """Create a virtualenv with the specified options and the default packages
    specified in configuration. Then run `pip install -r [requirements file]`.
    """
    venv = VirtualenvProxy(os.path.join(tmp_dir, venv_name),
                           system_site_packages=system_site_packages,
                           pypi_index_url=pypi_index_url,
                           python_interpreter=python_interpreter,
                           verbose=verbose)

    packages = ["pyleus=={0}".format(__version__)]
    if include_packages is not None:
        packages += include_packages

    for package in packages:
        venv.install_package(package)

    if req is not None:
        venv.install_from_requirements(req)

    _remove_pyleus_base_jar(venv)

    return venv
Esempio n. 3
0
class TestVirtualenvProxyMethods(object):

    @pytest.fixture(autouse=True)
    @mock.patch.object(__builtin__, 'open', autospec=True)
    @mock.patch.object(VirtualenvProxy, '_create_virtualenv', autospec=True)
    def setup_virtualenv(self, mock_create, mock_open):
        self.venv = VirtualenvProxy(VENV_PATH,
                                    pypi_index_url=PYPI_URL,
                                    verbose=False)

    @mock.patch.object(virtualenv_proxy, '_exec_shell_cmd', autospec=True)
    def test_install_package(self, mock_cmd):
        self.venv.install_package("Ninja==7.7.7")
        mock_cmd.assert_called_once_with(
            [
                "{0}/bin/pip".format(VENV_PATH), "install", "Ninja==7.7.7",
                "-i", PYPI_URL,
                '--use-wheel',
            ],
            stdout=self.venv._out_stream,
            stderr=self.venv._err_stream,
            err_msg=mock.ANY
        )

    @mock.patch.object(virtualenv_proxy, '_exec_shell_cmd', autospec=True)
    def test_install_from_requirements(self, mock_cmd):
        self.venv.install_from_requirements("foo.txt")
        mock_cmd.assert_called_once_with(
            [
                "{0}/bin/pip".format(VENV_PATH), "install",
                "-r", "foo.txt",
                "-i", PYPI_URL,
                '--use-wheel',
            ],
            stdout=self.venv._out_stream,
            stderr=self.venv._err_stream,
            err_msg=mock.ANY
        )
Esempio n. 4
0
class TestVirtualenvProxyMethods(object):

    @pytest.fixture(autouse=True)
    @mock.patch.object(builtins, 'open', autospec=True)
    @mock.patch.object(VirtualenvProxy, '_create_virtualenv', autospec=True)
    def setup_virtualenv(self, mock_create, mock_open):
        self.venv = VirtualenvProxy(VENV_PATH,
                                    pypi_index_url=PYPI_URL,
                                    verbose=False)

    @mock.patch.object(virtualenv_proxy, '_exec_shell_cmd', autospec=True)
    def test_install_package(self, mock_cmd):
        self.venv.install_package("Ninja==7.7.7")
        mock_cmd.assert_called_once_with(
            [
                "{0}/bin/pip".format(VENV_PATH), "install", "Ninja==7.7.7",
                "-i", PYPI_URL,
                '--use-wheel',
            ],
            stdout=self.venv._out_stream,
            stderr=self.venv._err_stream,
            err_msg=mock.ANY
        )

    @mock.patch.object(virtualenv_proxy, '_exec_shell_cmd', autospec=True)
    def test_install_from_requirements(self, mock_cmd):
        self.venv.install_from_requirements("foo.txt")
        mock_cmd.assert_called_once_with(
            [
                "{0}/bin/pip".format(VENV_PATH), "install",
                "-r", "foo.txt",
                "-i", PYPI_URL,
                '--use-wheel',
            ],
            stdout=self.venv._out_stream,
            stderr=self.venv._err_stream,
            err_msg=mock.ANY
        )