2016-05-17 14:57:08 +00:00
|
|
|
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
|
2014-04-07 10:26:27 +00:00
|
|
|
|
2016-05-17 14:57:08 +00:00
|
|
|
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(-)
|
2014-04-07 10:26:27 +00:00
|
|
|
|
|
|
|
diff --git a/pip/commands/install.py b/pip/commands/install.py
|
2016-05-17 14:57:08 +00:00
|
|
|
index 7ddde93..e31bd3e 100644
|
2014-04-07 10:26:27 +00:00
|
|
|
--- a/pip/commands/install.py
|
|
|
|
+++ b/pip/commands/install.py
|
2016-05-17 14:57:08 +00:00
|
|
|
@@ -137,6 +137,14 @@ class InstallCommand(RequirementCommand):
|
2015-01-15 13:05:55 +00:00
|
|
|
"directory.")
|
2014-04-07 10:26:27 +00:00
|
|
|
|
|
|
|
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-05-17 14:57:08 +00:00
|
|
|
@@ -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
|
2016-05-17 14:57:08 +00:00
|
|
|
index 9e9fbbb..47f263f 100644
|
2015-01-15 13:05:55 +00:00
|
|
|
--- a/pip/req/req_install.py
|
|
|
|
+++ b/pip/req/req_install.py
|
2016-05-17 14:57:08 +00:00
|
|
|
@@ -818,8 +818,7 @@ class InstallRequirement(object):
|
2015-01-15 13:05:55 +00:00
|
|
|
else:
|
|
|
|
return True
|
2014-04-07 10:26:27 +00:00
|
|
|
|
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):
|
2014-04-07 10:26:27 +00:00
|
|
|
if self.editable:
|
2016-02-22 10:35:39 +00:00
|
|
|
self.install_editable(
|
|
|
|
install_options, global_options, prefix=prefix)
|
2016-05-17 14:57:08 +00:00
|
|
|
@@ -828,7 +827,12 @@ class InstallRequirement(object):
|
2014-04-07 10:26:27 +00:00
|
|
|
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)
|
2014-04-07 10:26:27 +00:00
|
|
|
+ self.move_wheel_files(
|
|
|
|
+ self.source_dir,
|
|
|
|
+ root=root,
|
2016-02-22 10:35:39 +00:00
|
|
|
+ prefix=prefix,
|
2014-04-07 10:26:27 +00:00
|
|
|
+ strip_file_prefix=strip_file_prefix
|
|
|
|
+ )
|
|
|
|
self.install_succeeded = True
|
|
|
|
return
|
|
|
|
|
2016-05-17 14:57:08 +00:00
|
|
|
@@ -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
|
2014-04-07 10:26:27 +00:00
|
|
|
|
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):
|
2014-04-07 10:26:27 +00:00
|
|
|
move_wheel_files(
|
|
|
|
self.name, self.req, wheeldir,
|
|
|
|
user=self.use_user_site,
|
2016-05-17 14:57:08 +00:00
|
|
|
@@ -1030,6 +1034,7 @@ class InstallRequirement(object):
|
2016-02-22 10:35:39 +00:00
|
|
|
prefix=prefix,
|
2014-04-07 10:26:27 +00:00
|
|
|
pycompile=self.pycompile,
|
2015-01-15 13:05:55 +00:00
|
|
|
isolated=self.isolated,
|
2014-04-07 10:26:27 +00:00
|
|
|
+ strip_file_prefix=strip_file_prefix,
|
|
|
|
)
|
|
|
|
|
2015-01-15 13:05:55 +00:00
|
|
|
def get_dist(self):
|
2014-04-07 10:26:27 +00:00
|
|
|
diff --git a/pip/wheel.py b/pip/wheel.py
|
2016-05-17 14:57:08 +00:00
|
|
|
index b257d76..6d78ce6 100644
|
2014-04-07 10:26:27 +00:00
|
|
|
--- a/pip/wheel.py
|
|
|
|
+++ b/pip/wheel.py
|
2016-05-17 14:57:08 +00:00
|
|
|
@@ -238,7 +238,7 @@ def get_entrypoints(filename):
|
2014-04-07 10:26:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
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):
|
2014-04-07 10:26:27 +00:00
|
|
|
"""Install a wheel"""
|
|
|
|
|
2014-05-25 22:10:27 +00:00
|
|
|
if not scheme:
|
2016-05-17 14:57:08 +00:00
|
|
|
@@ -522,7 +522,11 @@ if __name__ == '__main__':
|
2014-04-07 10:26:27 +00:00
|
|
|
writer.writerow(row)
|
|
|
|
for f in generated:
|
|
|
|
h, l = rehash(f)
|
2016-05-17 14:57:08 +00:00
|
|
|
- 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))
|
2014-04-07 10:26:27 +00:00
|
|
|
for f in installed:
|
|
|
|
writer.writerow((installed[f], '', ''))
|
2016-05-17 14:57:08 +00:00
|
|
|
shutil.move(temp_record, record)
|
|
|
|
--
|
|
|
|
2.5.5
|
|
|
|
|