commit aefacbb76661520415a1c35028f2984e70cfe0bf Author: Slavek Kabrda Date: Fri Nov 29 13:24:58 2013 +0100 Allow stripping given prefix from wheel RECORD files diff --git a/pip/commands/install.py b/pip/commands/install.py index 1693d01..0287c06 100644 --- a/pip/commands/install.py +++ b/pip/commands/install.py @@ -137,6 +137,14 @@ class InstallCommand(Command): "directory.") cmd_opts.add_option( + '--strip-file-prefix', + dest='strip_file_prefix', + metavar='prefix', + default=None, + help="Strip given prefix from script paths in wheel RECORD." + ) + + cmd_opts.add_option( "--compile", action="store_true", dest="compile", @@ -345,6 +353,7 @@ class InstallCommand(Command): install_options, global_options, root=options.root_path, + strip_file_prefix=options.strip_file_prefix, ) reqs = sorted( requirement_set.successfully_installed, diff --git a/pip/req/req_install.py b/pip/req/req_install.py index 3ae306d..c171130 100644 --- a/pip/req/req_install.py +++ b/pip/req/req_install.py @@ -615,15 +615,19 @@ exec(compile(open(__file__).read().replace('\\r\\n', '\\n'), __file__, 'exec')) else: return True - def install(self, install_options, global_options=[], root=None): + def install(self, install_options, global_options=[], root=None, strip_file_prefix=None): if self.editable: self.install_editable(install_options, global_options) return if self.is_wheel: 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, + strip_file_prefix=strip_file_prefix + ) self.install_succeeded = True return @@ -844,14 +848,15 @@ exec(compile(open(__file__).read().replace('\\r\\n', '\\n'), __file__, 'exec')) 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, strip_file_prefix=None): move_wheel_files( self.name, self.req, wheeldir, user=self.use_user_site, home=self.target_dir, root=root, pycompile=self.pycompile, isolated=self.isolated, + strip_file_prefix=strip_file_prefix, ) def get_dist(self): diff --git a/pip/wheel.py b/pip/wheel.py index fa3e270..3a366d0 100644 --- a/pip/wheel.py +++ b/pip/wheel.py @@ -136,7 +136,7 @@ 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, strip_file_prefix=None): """Install a wheel""" if not scheme: @@ -357,6 +357,8 @@ if __name__ == '__main__': writer.writerow(row) for f in generated: h, l = rehash(f) + if strip_file_prefix and f.startswith(strip_file_prefix): + f = os.path.join(os.sep, os.path.relpath(f, strip_file_prefix)) writer.writerow((f, h, l)) for f in installed: writer.writerow((installed[f], '', ''))