2018-11-22 12:26:40 +00:00
|
|
|
diff --git a/src/pip/_internal/commands/install.py b/src/pip/_internal/commands/install.py
|
|
|
|
index 6fc178f..1279d4a 100644
|
|
|
|
--- a/src/pip/_internal/commands/install.py
|
|
|
|
+++ b/src/pip/_internal/commands/install.py
|
|
|
|
@@ -115,6 +115,14 @@ class InstallCommand(RequirementCommand):
|
2018-07-23 15:22:50 +00:00
|
|
|
default=None,
|
|
|
|
help="Installation prefix where lib, bin and other top-level "
|
|
|
|
"folders are placed")
|
|
|
|
+ cmd_opts.add_option(
|
2014-04-07 10:26:27 +00:00
|
|
|
+ '--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())
|
2014-04-07 10:26:27 +00:00
|
|
|
|
2018-11-22 12:26:40 +00:00
|
|
|
@@ -364,6 +372,7 @@ class InstallCommand(RequirementCommand):
|
2018-07-23 15:22:50 +00:00
|
|
|
pycompile=options.compile,
|
|
|
|
warn_script_location=warn_script_location,
|
|
|
|
use_user_site=options.use_user_site,
|
|
|
|
+ strip_file_prefix=options.strip_file_prefix,
|
|
|
|
)
|
2014-04-07 10:26:27 +00:00
|
|
|
|
2018-07-23 15:22:50 +00:00
|
|
|
lib_locations = get_lib_location_guesses(
|
2018-11-22 12:26:40 +00:00
|
|
|
diff --git a/src/pip/_internal/req/req_install.py b/src/pip/_internal/req/req_install.py
|
|
|
|
index c2624fe..922d10c 100644
|
|
|
|
--- a/src/pip/_internal/req/req_install.py
|
|
|
|
+++ b/src/pip/_internal/req/req_install.py
|
|
|
|
@@ -370,7 +370,7 @@ class InstallRequirement(object):
|
2014-04-07 10:26:27 +00:00
|
|
|
|
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):
|
2014-04-07 10:26:27 +00:00
|
|
|
move_wheel_files(
|
|
|
|
self.name, self.req, wheeldir,
|
2018-07-23 15:22:50 +00:00
|
|
|
user=use_user_site,
|
2018-11-22 12:26:40 +00:00
|
|
|
@@ -380,6 +380,7 @@ class InstallRequirement(object):
|
2018-07-23 15:22:50 +00:00
|
|
|
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,
|
2014-04-07 10:26:27 +00:00
|
|
|
+ strip_file_prefix=strip_file_prefix,
|
|
|
|
)
|
|
|
|
|
2018-07-23 15:22:50 +00:00
|
|
|
# Things valid for sdists
|
2018-11-22 12:26:40 +00:00
|
|
|
@@ -743,7 +744,7 @@ class InstallRequirement(object):
|
2014-04-07 10:26:27 +00:00
|
|
|
|
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(
|
2018-11-22 12:26:40 +00:00
|
|
|
@@ -758,6 +759,7 @@ class InstallRequirement(object):
|
2018-07-23 15:22:50 +00:00
|
|
|
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
|
2018-11-22 12:26:40 +00:00
|
|
|
diff --git a/src/pip/_internal/wheel.py b/src/pip/_internal/wheel.py
|
|
|
|
index 5ce890e..c42d77a 100644
|
|
|
|
--- a/src/pip/_internal/wheel.py
|
|
|
|
+++ b/src/pip/_internal/wheel.py
|
|
|
|
@@ -206,7 +206,7 @@ def message_about_scripts_not_on_PATH(scripts):
|
2014-04-07 10:26:27 +00:00
|
|
|
|
|
|
|
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):
|
2014-04-07 10:26:27 +00:00
|
|
|
"""Install a wheel"""
|
|
|
|
|
2014-05-25 22:10:27 +00:00
|
|
|
if not scheme:
|
2018-11-22 12:26:40 +00:00
|
|
|
@@ -508,7 +508,11 @@ if __name__ == '__main__':
|
|
|
|
outrows.append(tuple(row))
|
2014-04-07 10:26:27 +00:00
|
|
|
for f in generated:
|
2018-07-23 15:22:50 +00:00
|
|
|
digest, length = rehash(f)
|
2018-11-22 12:26:40 +00:00
|
|
|
- outrows.append((normpath(f, lib_dir), digest, length))
|
2016-05-17 14:57:08 +00:00
|
|
|
+ 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-11-22 12:26:40 +00:00
|
|
|
+ outrows.append((final_path, digest, length))
|
2014-04-07 10:26:27 +00:00
|
|
|
for f in installed:
|
2018-11-22 12:26:40 +00:00
|
|
|
outrows.append((installed[f], '', ''))
|
|
|
|
for row in sorted(outrows):
|