commit e87c83d95bb91acdca92202e94488ca51a70e059 Author: Domen Kožar Date: Mon Nov 16 17:39:44 2015 +0100 WIP diff --git a/pip/commands/install.py b/pip/commands/install.py index dbcf100..05d5a08 100644 --- a/pip/commands/install.py +++ b/pip/commands/install.py @@ -139,6 +139,13 @@ class InstallCommand(RequirementCommand): "directory.") cmd_opts.add_option( + '--prefix', + dest='prefix_path', + metavar='dir', + default=None, + help="Installation prefix where lib, bin and other top-level folders are placed") + + cmd_opts.add_option( "--compile", action="store_true", dest="compile", @@ -309,6 +316,7 @@ class InstallCommand(RequirementCommand): install_options, global_options, root=options.root_path, + prefix=options.prefix_path, ) reqs = sorted( requirement_set.successfully_installed, diff --git a/pip/locations.py b/pip/locations.py index 4e6f65d..43aeb1f 100644 --- a/pip/locations.py +++ b/pip/locations.py @@ -163,7 +163,7 @@ site_config_files = [ def distutils_scheme(dist_name, user=False, home=None, root=None, - isolated=False): + isolated=False, prefix=None): """ Return a distutils install scheme """ @@ -187,6 +187,8 @@ def distutils_scheme(dist_name, user=False, home=None, root=None, i.user = user or i.user if user: i.prefix = "" + else: + i.prefix = prefix or i.prefix i.home = home or i.home i.root = root or i.root i.finalize_options() diff --git a/pip/req/req_install.py b/pip/req/req_install.py index 7c5bf8f..6f80a18 100644 --- a/pip/req/req_install.py +++ b/pip/req/req_install.py @@ -792,7 +792,7 @@ exec(compile( else: return True - def install(self, install_options, global_options=[], root=None): + def install(self, install_options, global_options=[], root=None, prefix=None): if self.editable: self.install_editable(install_options, global_options) return @@ -800,7 +800,7 @@ exec(compile( version = pip.wheel.wheel_version(self.source_dir) pip.wheel.check_compatibility(version, self.name) - self.move_wheel_files(self.source_dir, root=root) + self.move_wheel_files(self.source_dir, root=root, prefix=prefix) self.install_succeeded = True return @@ -833,6 +833,8 @@ exec(compile( if root is not None: install_args += ['--root', root] + if prefix is not None: + install_args += ['--prefix', prefix] if self.pycompile: install_args += ["--compile"] @@ -988,12 +990,13 @@ exec(compile( def is_wheel(self): return self.link and self.link.is_wheel - def move_wheel_files(self, wheeldir, root=None): + def move_wheel_files(self, wheeldir, root=None, prefix=None): move_wheel_files( self.name, self.req, wheeldir, user=self.use_user_site, home=self.target_dir, root=root, + prefix=prefix, pycompile=self.pycompile, isolated=self.isolated, ) diff --git a/pip/wheel.py b/pip/wheel.py index 403f48b..14eb141 100644 --- a/pip/wheel.py +++ b/pip/wheel.py @@ -234,12 +234,12 @@ def get_entrypoints(filename): def move_wheel_files(name, req, wheeldir, user=False, home=None, root=None, - pycompile=True, scheme=None, isolated=False): + pycompile=True, scheme=None, isolated=False, prefix=None): """Install a wheel""" if not scheme: scheme = distutils_scheme( - name, user=user, home=home, root=root, isolated=isolated + name, user=user, home=home, root=root, isolated=isolated, prefix=prefix, ) if root_is_purelib(name, wheeldir):