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

118 lines
4.5 KiB
Diff
Raw Normal View History

From 7b3991c99cd8bb9358e109901d4aa8f51269a87a Mon Sep 17 00:00:00 2001
From: Tomas Orsava <tomas.n@orsava.cz>
Date: Tue, 17 May 2016 16:40:37 +0200
Subject: [PATCH] Allow stripping given prefix from wheel RECORD files
Update of a previous patch [0] by Slavek Kabrda <bkabrda@redhat.com>.
Changes in the pip/wheel.py file in upstream prevented #2 hunk from being
applied cleanly.
[0] pip-1.5rc1-allow-stripping-prefix-from-wheel-RECORD-files.patch
---
pip/commands/install.py | 9 +++++++++
pip/req/req_install.py | 13 +++++++++----
pip/wheel.py | 8 ++++++--
3 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/pip/commands/install.py b/pip/commands/install.py
index 7ddde93..e31bd3e 100644
--- a/pip/commands/install.py
+++ b/pip/commands/install.py
@@ -137,6 +137,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',
@@ -315,6 +323,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,
)
reqs = sorted(
requirement_set.successfully_installed,
diff --git a/pip/req/req_install.py b/pip/req/req_install.py
index 9e9fbbb..47f263f 100644
2015-01-15 13:05:55 +00:00
--- a/pip/req/req_install.py
+++ b/pip/req/req_install.py
@@ -818,8 +818,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)
@@ -828,7 +827,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
@@ -1021,7 +1025,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,
@@ -1030,6 +1034,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):
diff --git a/pip/wheel.py b/pip/wheel.py
index b257d76..6d78ce6 100644
--- a/pip/wheel.py
+++ b/pip/wheel.py
@@ -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:
@@ -522,7 +522,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)
--
2.5.5