python-pip/allow-stripping-given-prefix-from-wheel-RECORD-files.patch

96 lines
4.1 KiB
Diff
Raw Normal View History

2016-11-18 21:31:08 +00:00
diff -up pip-9.0.1/pip/commands/install.py.orig pip-9.0.1/pip/commands/install.py
--- pip-9.0.1/pip/commands/install.py.orig 2016-11-06 11:49:45.000000000 -0700
+++ pip-9.0.1/pip/commands/install.py 2016-11-16 16:20:48.638906543 -0700
@@ -151,6 +151,14 @@ class InstallCommand(RequirementCommand)
2015-01-15 13:05:55 +00:00
"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(
2016-02-22 10:35:39 +00:00
'--prefix',
dest='prefix_path',
metavar='dir',
2016-11-18 21:31:08 +00:00
@@ -340,6 +348,7 @@ class InstallCommand(RequirementCommand)
2015-01-15 13:05:55 +00:00
global_options,
root=options.root_path,
2016-02-22 10:35:39 +00:00
prefix=options.prefix_path,
2015-01-15 13:05:55 +00:00
+ strip_file_prefix=options.strip_file_prefix,
)
2016-11-18 21:31:08 +00:00
possible_lib_locations = get_lib_location_guesses(
diff -up pip-9.0.1/pip/req/req_install.py.orig pip-9.0.1/pip/req/req_install.py
--- pip-9.0.1/pip/req/req_install.py.orig 2016-11-06 11:49:45.000000000 -0700
+++ pip-9.0.1/pip/req/req_install.py 2016-11-16 16:19:24.848336960 -0700
@@ -838,8 +838,7 @@ class InstallRequirement(object):
2015-01-15 13:05:55 +00:00
else:
return True
2016-02-22 10:35:39 +00:00
- 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:
2016-02-22 10:35:39 +00:00
self.install_editable(
install_options, global_options, prefix=prefix)
2016-11-18 21:31:08 +00:00
@@ -848,7 +847,12 @@ class InstallRequirement(object):
version = pip.wheel.wheel_version(self.source_dir)
pip.wheel.check_compatibility(version, self.name)
2016-02-22 10:35:39 +00:00
- self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
+ self.move_wheel_files(
+ self.source_dir,
+ root=root,
2016-02-22 10:35:39 +00:00
+ prefix=prefix,
+ strip_file_prefix=strip_file_prefix
+ )
self.install_succeeded = True
return
2016-11-18 21:31:08 +00:00
@@ -1053,7 +1057,7 @@ class InstallRequirement(object):
2015-01-15 13:05:55 +00:00
def is_wheel(self):
2015-06-04 09:47:42 +00:00
return self.link and self.link.is_wheel
2016-02-22 10:35:39 +00:00
- 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,
2016-11-18 21:31:08 +00:00
@@ -1062,6 +1066,7 @@ class InstallRequirement(object):
2016-02-22 10:35:39 +00:00
prefix=prefix,
pycompile=self.pycompile,
2015-01-15 13:05:55 +00:00
isolated=self.isolated,
+ strip_file_prefix=strip_file_prefix,
)
2015-01-15 13:05:55 +00:00
def get_dist(self):
2016-11-18 21:31:08 +00:00
diff -up pip-9.0.1/pip/wheel.py.orig pip-9.0.1/pip/wheel.py
--- pip-9.0.1/pip/wheel.py.orig 2016-11-06 11:49:45.000000000 -0700
+++ pip-9.0.1/pip/wheel.py 2016-11-16 16:19:24.848336960 -0700
@@ -238,7 +238,7 @@ def get_entrypoints(filename):
def move_wheel_files(name, req, wheeldir, user=False, home=None, root=None,
2016-02-22 10:35:39 +00:00
- pycompile=True, scheme=None, isolated=False, prefix=None):
+ pycompile=True, scheme=None, isolated=False, prefix=None, strip_file_prefix=None):
"""Install a wheel"""
2014-05-25 22:10:27 +00:00
if not scheme:
2016-11-18 21:31:08 +00:00
@@ -521,7 +521,11 @@ if __name__ == '__main__':
writer.writerow(row)
for f in generated:
h, l = rehash(f)
- writer.writerow((normpath(f, lib_dir), h, l))
+ final_path = normpath(f, lib_dir)
+ if strip_file_prefix and final_path.startswith(strip_file_prefix):
+ final_path = os.path.join(os.sep,
+ os.path.relpath(final_path, strip_file_prefix))
+ writer.writerow((final_path, h, l))
for f in installed:
writer.writerow((installed[f], '', ''))
shutil.move(temp_record, record)