2018-11-22 12:26:40 +00:00
|
|
|
diff --git a/src/pip/_internal/commands/install.py b/src/pip/_internal/commands/install.py
|
2019-03-06 10:04:14 +00:00
|
|
|
index 1c244d23..4b07ec0f 100644
|
2018-11-22 12:26:40 +00:00
|
|
|
--- a/src/pip/_internal/commands/install.py
|
|
|
|
+++ b/src/pip/_internal/commands/install.py
|
2019-02-13 10:56:20 +00:00
|
|
|
@@ -109,6 +109,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
|
|
|
|
2019-02-13 10:56:20 +00:00
|
|
|
@@ -391,6 +399,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
|
2019-03-06 10:04:14 +00:00
|
|
|
index a4834b00..d21530ac 100644
|
2018-11-22 12:26:40 +00:00
|
|
|
--- a/src/pip/_internal/req/req_install.py
|
|
|
|
+++ b/src/pip/_internal/req/req_install.py
|
2019-02-13 10:56:20 +00:00
|
|
|
@@ -431,7 +431,8 @@ class InstallRequirement(object):
|
|
|
|
prefix=None, # type: Optional[str]
|
|
|
|
warn_script_location=True, # type: bool
|
|
|
|
use_user_site=False, # type: bool
|
|
|
|
- pycompile=True # type: bool
|
|
|
|
+ pycompile=True, # type: bool
|
|
|
|
+ strip_file_prefix=None # type: Optional[str]
|
|
|
|
):
|
|
|
|
# type: (...) -> None
|
2014-04-07 10:26:27 +00:00
|
|
|
move_wheel_files(
|
2019-02-13 10:56:20 +00:00
|
|
|
@@ -443,6 +444,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
|
2019-02-13 10:56:20 +00:00
|
|
|
@@ -894,7 +896,8 @@ class InstallRequirement(object):
|
|
|
|
prefix=None, # type: Optional[str]
|
|
|
|
warn_script_location=True, # type: bool
|
|
|
|
use_user_site=False, # type: bool
|
|
|
|
- pycompile=True # type: bool
|
|
|
|
+ pycompile=True, # type: bool
|
|
|
|
+ strip_file_prefix=None # type: Optional[str]
|
|
|
|
):
|
|
|
|
# type: (...) -> None
|
2018-07-23 15:22:50 +00:00
|
|
|
global_options = global_options if global_options is not None else []
|
2019-02-13 10:56:20 +00:00
|
|
|
@@ -911,6 +914,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
|
2019-03-06 10:04:14 +00:00
|
|
|
index 67bcc7f7..6470576b 100644
|
2018-11-22 12:26:40 +00:00
|
|
|
--- a/src/pip/_internal/wheel.py
|
|
|
|
+++ b/src/pip/_internal/wheel.py
|
2019-02-13 10:56:20 +00:00
|
|
|
@@ -265,6 +265,7 @@ def get_csv_rows_for_installed(
|
|
|
|
changed, # type: set
|
|
|
|
generated, # type: List[str]
|
|
|
|
lib_dir, # type: str
|
|
|
|
+ strip_file_prefix=None, # type: Optional[str]
|
|
|
|
):
|
|
|
|
# type: (...) -> List[InstalledCSVRow]
|
2019-03-06 10:04:14 +00:00
|
|
|
"""
|
|
|
|
@@ -289,7 +290,11 @@ def get_csv_rows_for_installed(
|
2019-02-13 10:56:20 +00:00
|
|
|
installed_rows.append(tuple(row))
|
|
|
|
for f in generated:
|
|
|
|
digest, length = rehash(f)
|
|
|
|
- installed_rows.append((normpath(f, lib_dir), digest, str(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))
|
|
|
|
+ installed_rows.append((final_path, digest, str(length)))
|
|
|
|
for f in installed:
|
|
|
|
installed_rows.append((installed[f], '', ''))
|
|
|
|
return installed_rows
|
2019-03-06 10:04:14 +00:00
|
|
|
@@ -306,7 +311,8 @@ def move_wheel_files(
|
2019-02-13 10:56:20 +00:00
|
|
|
scheme=None, # type: Optional[Mapping[str, str]]
|
|
|
|
isolated=False, # type: bool
|
|
|
|
prefix=None, # type: Optional[str]
|
|
|
|
- warn_script_location=True # type: bool
|
|
|
|
+ warn_script_location=True, # type: bool
|
|
|
|
+ strip_file_prefix=None # type: Optional[str]
|
|
|
|
):
|
|
|
|
# type: (...) -> None
|
2014-04-07 10:26:27 +00:00
|
|
|
"""Install a wheel"""
|
2019-03-06 10:04:14 +00:00
|
|
|
@@ -605,6 +611,7 @@ if __name__ == '__main__':
|
2019-02-13 10:56:20 +00:00
|
|
|
outrows = get_csv_rows_for_installed(
|
|
|
|
reader, installed=installed, changed=changed,
|
|
|
|
generated=generated, lib_dir=lib_dir,
|
|
|
|
+ strip_file_prefix=strip_file_prefix
|
|
|
|
)
|
|
|
|
writer = csv.writer(record_out)
|
|
|
|
# Sort to simplify testing.
|