|
|
82235d4 |
diff --git a/src/pip/_internal/commands/install.py b/src/pip/_internal/commands/install.py
|
|
|
bbe9e6d |
index 1c244d2..4b07ec0 100644
|
|
|
82235d4 |
--- a/src/pip/_internal/commands/install.py
|
|
|
82235d4 |
+++ b/src/pip/_internal/commands/install.py
|
|
|
bbe9e6d |
@@ -109,6 +109,14 @@ class InstallCommand(RequirementCommand):
|
|
Marcel Plch |
2e7f501 |
default=None,
|
|
Marcel Plch |
2e7f501 |
help="Installation prefix where lib, bin and other top-level "
|
|
Marcel Plch |
2e7f501 |
"folders are placed")
|
|
Marcel Plch |
2e7f501 |
+ cmd_opts.add_option(
|
|
Matej Stuchlik |
638c2fb |
+ '--strip-file-prefix',
|
|
Matej Stuchlik |
638c2fb |
+ dest='strip_file_prefix',
|
|
Matej Stuchlik |
638c2fb |
+ metavar='prefix',
|
|
Matej Stuchlik |
638c2fb |
+ default=None,
|
|
Matej Stuchlik |
638c2fb |
+ help="Strip given prefix from script paths in wheel RECORD."
|
|
Matej Stuchlik |
638c2fb |
+ )
|
|
Matej Stuchlik |
638c2fb |
+
|
|
Orion Poplawski |
cdcedea |
|
|
Marcel Plch |
2e7f501 |
cmd_opts.add_option(cmdoptions.build_dir())
|
|
Matej Stuchlik |
638c2fb |
|
|
|
bbe9e6d |
@@ -391,6 +399,7 @@ class InstallCommand(RequirementCommand):
|
|
Marcel Plch |
2e7f501 |
pycompile=options.compile,
|
|
Marcel Plch |
2e7f501 |
warn_script_location=warn_script_location,
|
|
Marcel Plch |
2e7f501 |
use_user_site=options.use_user_site,
|
|
Marcel Plch |
2e7f501 |
+ strip_file_prefix=options.strip_file_prefix,
|
|
Marcel Plch |
2e7f501 |
)
|
|
Matej Stuchlik |
638c2fb |
|
|
Marcel Plch |
2e7f501 |
lib_locations = get_lib_location_guesses(
|
|
|
82235d4 |
diff --git a/src/pip/_internal/req/req_install.py b/src/pip/_internal/req/req_install.py
|
|
|
bbe9e6d |
index a4834b0..d21530a 100644
|
|
|
82235d4 |
--- a/src/pip/_internal/req/req_install.py
|
|
|
82235d4 |
+++ b/src/pip/_internal/req/req_install.py
|
|
|
bbe9e6d |
@@ -431,7 +431,8 @@ class InstallRequirement(object):
|
|
|
bbe9e6d |
prefix=None, # type: Optional[str]
|
|
|
bbe9e6d |
warn_script_location=True, # type: bool
|
|
|
bbe9e6d |
use_user_site=False, # type: bool
|
|
|
bbe9e6d |
- pycompile=True # type: bool
|
|
|
bbe9e6d |
+ pycompile=True, # type: bool
|
|
|
bbe9e6d |
+ strip_file_prefix=None # type: Optional[str]
|
|
|
bbe9e6d |
):
|
|
|
bbe9e6d |
# type: (...) -> None
|
|
Matej Stuchlik |
638c2fb |
move_wheel_files(
|
|
|
bbe9e6d |
@@ -443,6 +444,7 @@ class InstallRequirement(object):
|
|
Marcel Plch |
2e7f501 |
pycompile=pycompile,
|
|
Matej Stuchlik |
f50907e |
isolated=self.isolated,
|
|
Marcel Plch |
2e7f501 |
warn_script_location=warn_script_location,
|
|
Matej Stuchlik |
638c2fb |
+ strip_file_prefix=strip_file_prefix,
|
|
Matej Stuchlik |
638c2fb |
)
|
|
Matej Stuchlik |
638c2fb |
|
|
Marcel Plch |
2e7f501 |
# Things valid for sdists
|
|
|
bbe9e6d |
@@ -894,7 +896,8 @@ class InstallRequirement(object):
|
|
|
bbe9e6d |
prefix=None, # type: Optional[str]
|
|
|
bbe9e6d |
warn_script_location=True, # type: bool
|
|
|
bbe9e6d |
use_user_site=False, # type: bool
|
|
|
bbe9e6d |
- pycompile=True # type: bool
|
|
|
bbe9e6d |
+ pycompile=True, # type: bool
|
|
|
bbe9e6d |
+ strip_file_prefix=None # type: Optional[str]
|
|
|
bbe9e6d |
):
|
|
|
bbe9e6d |
# type: (...) -> None
|
|
Marcel Plch |
2e7f501 |
global_options = global_options if global_options is not None else []
|
|
|
bbe9e6d |
@@ -911,6 +914,7 @@ class InstallRequirement(object):
|
|
Marcel Plch |
2e7f501 |
self.source_dir, root=root, prefix=prefix, home=home,
|
|
Marcel Plch |
2e7f501 |
warn_script_location=warn_script_location,
|
|
Marcel Plch |
2e7f501 |
use_user_site=use_user_site, pycompile=pycompile,
|
|
Marcel Plch |
2e7f501 |
+ strip_file_prefix=strip_file_prefix,
|
|
Marcel Plch |
2e7f501 |
)
|
|
Marcel Plch |
2e7f501 |
self.install_succeeded = True
|
|
Marcel Plch |
2e7f501 |
return
|
|
|
82235d4 |
diff --git a/src/pip/_internal/wheel.py b/src/pip/_internal/wheel.py
|
|
|
bbe9e6d |
index 700b180..3655bd4 100644
|
|
|
82235d4 |
--- a/src/pip/_internal/wheel.py
|
|
|
82235d4 |
+++ b/src/pip/_internal/wheel.py
|
|
|
bbe9e6d |
@@ -265,6 +265,7 @@ def get_csv_rows_for_installed(
|
|
|
bbe9e6d |
changed, # type: set
|
|
|
bbe9e6d |
generated, # type: List[str]
|
|
|
bbe9e6d |
lib_dir, # type: str
|
|
|
bbe9e6d |
+ strip_file_prefix=None, # type: Optional[str]
|
|
|
bbe9e6d |
):
|
|
|
bbe9e6d |
# type: (...) -> List[InstalledCSVRow]
|
|
|
bbe9e6d |
installed_rows = [] # type: List[InstalledCSVRow]
|
|
|
bbe9e6d |
@@ -282,7 +283,11 @@ def get_csv_rows_for_installed(
|
|
|
bbe9e6d |
installed_rows.append(tuple(row))
|
|
|
bbe9e6d |
for f in generated:
|
|
|
bbe9e6d |
digest, length = rehash(f)
|
|
|
bbe9e6d |
- installed_rows.append((normpath(f, lib_dir), digest, str(length)))
|
|
|
bbe9e6d |
+ final_path = normpath(f, lib_dir)
|
|
|
bbe9e6d |
+ if strip_file_prefix and final_path.startswith(strip_file_prefix):
|
|
|
bbe9e6d |
+ final_path = os.path.join(os.sep,
|
|
|
bbe9e6d |
+ os.path.relpath(final_path, strip_file_prefix))
|
|
|
bbe9e6d |
+ installed_rows.append((final_path, digest, str(length)))
|
|
|
bbe9e6d |
for f in installed:
|
|
|
bbe9e6d |
installed_rows.append((installed[f], '', ''))
|
|
|
bbe9e6d |
return installed_rows
|
|
|
bbe9e6d |
@@ -299,7 +304,8 @@ def move_wheel_files(
|
|
|
bbe9e6d |
scheme=None, # type: Optional[Mapping[str, str]]
|
|
|
bbe9e6d |
isolated=False, # type: bool
|
|
|
bbe9e6d |
prefix=None, # type: Optional[str]
|
|
|
bbe9e6d |
- warn_script_location=True # type: bool
|
|
|
bbe9e6d |
+ warn_script_location=True, # type: bool
|
|
|
bbe9e6d |
+ strip_file_prefix=None # type: Optional[str]
|
|
|
bbe9e6d |
):
|
|
|
bbe9e6d |
# type: (...) -> None
|
|
Matej Stuchlik |
638c2fb |
"""Install a wheel"""
|
|
|
bbe9e6d |
@@ -598,6 +604,7 @@ if __name__ == '__main__':
|
|
|
bbe9e6d |
outrows = get_csv_rows_for_installed(
|
|
|
bbe9e6d |
reader, installed=installed, changed=changed,
|
|
|
bbe9e6d |
generated=generated, lib_dir=lib_dir,
|
|
|
bbe9e6d |
+ strip_file_prefix=strip_file_prefix
|
|
|
bbe9e6d |
)
|
|
|
bbe9e6d |
writer = csv.writer(record_out)
|
|
|
bbe9e6d |
# Sort to simplify testing.
|