python-pip/pip-1.5rc1-allow-stripping-...

104 lines
3.9 KiB
Diff

commit aefacbb76661520415a1c35028f2984e70cfe0bf
Author: Slavek Kabrda <bkabrda@redhat.com>
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(
'--prefix',
dest='prefix_path',
metavar='dir',
@@ -345,6 +353,7 @@ class InstallCommand(Command):
global_options,
root=options.root_path,
prefix=options.prefix_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,17 +615,21 @@ exec(compile(open(__file__).read().replace('\\r\\n', '\\n'), __file__, 'exec'))
else:
return True
- def install(self, install_options, global_options=[], root=None,
- prefix=None):
+ def install(self, install_options, global_options=[], root=None, prefix=None, strip_file_prefix=None):
if self.editable:
self.install_editable(
install_options, global_options, prefix=prefix)
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, prefix=prefix)
+ self.move_wheel_files(
+ self.source_dir,
+ root=root,
+ prefix=prefix,
+ strip_file_prefix=strip_file_prefix
+ )
self.install_succeeded = True
return
@@ -844,15 +848,16 @@ 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, prefix=None):
+ def move_wheel_files(self, wheeldir, root=None, prefix=None, strip_file_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,
+ 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, prefix=None):
+ pycompile=True, scheme=None, isolated=False, prefix=None, 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], '', ''))