From b4bb2eee144fd99bcbda14aac4416df4f46e19c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Domen=20Ko=C5=BEar?= Date: Mon, 23 Nov 2015 18:36:57 +0100 Subject: [PATCH] Support also pip install -e --prefix --- pip/req/req_install.py | 10 ++++++++-- tests/functional/test_install.py | 30 +++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/pip/req/req_install.py b/pip/req/req_install.py index 51bf4a7f2..f8f5b73fe 100644 --- a/pip/req/req_install.py +++ b/pip/req/req_install.py @@ -795,7 +795,8 @@ exec(compile( def install(self, install_options, global_options=[], root=None, prefix=None): if self.editable: - self.install_editable(install_options, global_options) + self.install_editable( + install_options, global_options, prefix=prefix) return if self.is_wheel: version = pip.wheel.wheel_version(self.source_dir) @@ -929,12 +930,17 @@ exec(compile( rmtree(self._temp_build_dir) self._temp_build_dir = None - def install_editable(self, install_options, global_options=()): + def install_editable(self, install_options, + global_options=(), prefix=None): logger.info('Running setup.py develop for %s', self.name) if self.isolated: global_options = list(global_options) + ["--no-user-cfg"] + if prefix: + prefix_param = ['--prefix={0}'.format(prefix)] + install_options = list(install_options) + prefix_param + with indent_log(): # FIXME: should we do --install-headers here too? cwd = self.source_dir diff --git a/tests/functional/test_install.py b/tests/functional/test_install.py index 596bbdcc6..fa39fe7ce 100644 --- a/tests/functional/test_install.py +++ b/tests/functional/test_install.py @@ -494,7 +494,7 @@ def test_install_package_with_prefix(script, data): prefix_path = script.scratch_path / 'prefix' result = script.pip( 'install', '--prefix', prefix_path, '-f', data.find_links, - '--no-index', 'simple==1.0', + '--no-binary', 'simple', '--no-index', 'simple==1.0', ) if hasattr(sys, "pypy_version_info"): @@ -507,6 +507,34 @@ def test_install_package_with_prefix(script, data): assert install_path in result.files_created, str(result) +def test_install_editable_with_prefix(script): + # make a dummy project + pkga_path = script.scratch_path / 'pkga' + pkga_path.mkdir() + pkga_path.join("setup.py").write(textwrap.dedent(""" + from setuptools import setup + setup(name='pkga', + version='0.1') + """)) + + site_packages = os.path.join( + 'prefix', 'lib', 'python{0}'.format(pyversion), 'site-packages') + + # make sure target path is in PYTHONPATH + pythonpath = script.scratch_path / site_packages + pythonpath.makedirs() + script.environ["PYTHONPATH"] = pythonpath + + # install pkga package into the absolute prefix directory + prefix_path = script.scratch_path / 'prefix' + result = script.pip( + 'install', '--editable', pkga_path, '--prefix', prefix_path) + + # assert pkga is installed at correct location + install_path = script.scratch / site_packages / 'pkga.egg-link' + assert install_path in result.files_created, str(result) + + def test_install_package_conflict_prefix_and_user(script, data): """ Test installing a package using pip install --prefix --user errors out