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." + ) + cmd_opts.add_option(cmdoptions.build_dir()) @@ -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, ) 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 @@ 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, user=use_user_site, @@ -524,6 +524,7 @@ pycompile=pycompile, isolated=self.isolated, warn_script_location=warn_script_location, + strip_file_prefix=strip_file_prefix, ) # Things valid for sdists @@ -924,7 +925,7 @@ 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, pycompile=True, scheme=None, isolated=False, prefix=None, - warn_script_location=True): + warn_script_location=True, strip_file_prefix=None): """Install a wheel""" if not scheme: @@ -507,7 +507,12 @@ writer.writerow(row) for f in generated: 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)) + writer.writerow((final_path, digest, length)) + for f in installed: writer.writerow((installed[f], '', '')) shutil.move(temp_record, record)