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

90 lines
4.0 KiB
Diff
Raw Normal View History

2018-07-23 15:22:50 +00:00
diff -ru pip-18.0/src/pip/_internal/commands/install.py pip-18.0_patched/src/pip/_internal/commands/install.py
--- pip-18.0/src/pip/_internal/commands/install.py 2018-07-20 06:10:48.000000000 +0200
+++ pip-18.0_patched/src/pip/_internal/commands/install.py 2018-07-23 16:49:39.085357813 +0200
@@ -110,6 +110,14 @@
default=None,
help="Installation prefix where lib, bin and other top-level "
"folders are placed")
+ 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."
+ )
+
2016-11-18 21:31:08 +00:00
2018-07-23 15:22:50 +00:00
cmd_opts.add_option(cmdoptions.build_dir())
2018-07-23 15:22:50 +00:00
@@ -345,6 +353,7 @@
pycompile=options.compile,
warn_script_location=warn_script_location,
use_user_site=options.use_user_site,
+ strip_file_prefix=options.strip_file_prefix,
)
2018-07-23 15:22:50 +00:00
lib_locations = get_lib_location_guesses(
diff -ru pip-18.0/src/pip/_internal/req/req_install.py pip-18.0_patched/src/pip/_internal/req/req_install.py
--- pip-18.0/src/pip/_internal/req/req_install.py 2018-07-22 07:14:20.000000000 +0200
+++ pip-18.0_patched/src/pip/_internal/req/req_install.py 2018-07-23 16:51:51.115943214 +0200
@@ -514,7 +514,7 @@
2018-07-23 15:22:50 +00:00
def move_wheel_files(self, wheeldir, root=None, home=None, prefix=None,
warn_script_location=True, use_user_site=False,
- pycompile=True):
+ pycompile=True, strip_file_prefix=None):
move_wheel_files(
self.name, self.req, wheeldir,
2018-07-23 15:22:50 +00:00
user=use_user_site,
@@ -524,6 +524,7 @@
pycompile=pycompile,
2015-01-15 13:05:55 +00:00
isolated=self.isolated,
2018-07-23 15:22:50 +00:00
warn_script_location=warn_script_location,
+ strip_file_prefix=strip_file_prefix,
)
2018-07-23 15:22:50 +00:00
# Things valid for sdists
@@ -924,7 +925,7 @@
2018-07-23 15:22:50 +00:00
def install(self, install_options, global_options=None, root=None,
home=None, prefix=None, warn_script_location=True,
- use_user_site=False, pycompile=True):
+ use_user_site=False, pycompile=True, strip_file_prefix=None):
global_options = global_options if global_options is not None else []
if self.editable:
self.install_editable(
@@ -939,6 +940,7 @@
self.source_dir, root=root, prefix=prefix, home=home,
warn_script_location=warn_script_location,
use_user_site=use_user_site, pycompile=pycompile,
+ strip_file_prefix=strip_file_prefix,
)
self.install_succeeded = True
return
diff -ru pip-18.0/src/pip/_internal/wheel.py pip-18.0_patched/src/pip/_internal/wheel.py
--- pip-18.0/src/pip/_internal/wheel.py 2018-07-17 10:26:00.000000000 +0200
+++ pip-18.0_patched/src/pip/_internal/wheel.py 2018-07-23 16:52:57.749238655 +0200
@@ -206,7 +206,7 @@
def move_wheel_files(name, req, wheeldir, user=False, home=None, root=None,
2018-07-23 15:22:50 +00:00
pycompile=True, scheme=None, isolated=False, prefix=None,
- warn_script_location=True):
+ warn_script_location=True, strip_file_prefix=None):
"""Install a wheel"""
2014-05-25 22:10:27 +00:00
if not scheme:
2018-07-23 15:22:50 +00:00
@@ -507,7 +507,12 @@
writer.writerow(row)
for f in generated:
2018-07-23 15:22:50 +00:00
digest, length = rehash(f)
- writer.writerow((normpath(f, lib_dir), digest, length))
+ 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))
2018-07-23 15:22:50 +00:00
+ writer.writerow((final_path, digest, length))
+
for f in installed:
writer.writerow((installed[f], '', ''))
shutil.move(temp_record, record)