Skip to content

Commit

Permalink
Add REQUESTED support to install_wheel
Browse files Browse the repository at this point in the history
  • Loading branch information
sbidoul committed Apr 12, 2020
1 parent 8cca170 commit 7945819
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/pip/_internal/operations/install/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ def install_unpacked_wheel(
pycompile=True, # type: bool
warn_script_location=True, # type: bool
direct_url=None, # type: Optional[DirectUrl]
requested=False, # type: bool
):
# type: (...) -> None
"""Install a wheel.
Expand Down Expand Up @@ -580,6 +581,13 @@ def is_entrypoint_wrapper(name):
replace(direct_url_file.name, direct_url_path)
generated.append(direct_url_path)

# Record the REQUESTED file
if requested:
requested_path = os.path.join(dest_info_dir, 'REQUESTED')
with open(requested_path, "w"):
pass
generated.append(requested_path)

# Record details of all files installed
record_path = os.path.join(dest_info_dir, 'RECORD')
with open(record_path, **csv_io_kwargs('r')) as record_file:
Expand All @@ -604,6 +612,7 @@ def install_wheel(
warn_script_location=True, # type: bool
_temp_dir_for_testing=None, # type: Optional[str]
direct_url=None, # type: Optional[DirectUrl]
requested=False, # type: bool
):
# type: (...) -> None
with TempDirectory(
Expand All @@ -619,4 +628,5 @@ def install_wheel(
pycompile=pycompile,
warn_script_location=warn_script_location,
direct_url=direct_url,
requested=requested,
)
13 changes: 13 additions & 0 deletions tests/unit/test_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,19 @@ def test_std_install(self, data, tmpdir):
)
self.assert_installed()

def test_std_install_requested(self, data, tmpdir):
self.prep(data, tmpdir)
wheel.install_wheel(
self.name,
self.wheelpath,
scheme=self.scheme,
req_description=str(self.req),
requested=True,
)
self.assert_installed()
requested_path = os.path.join(self.dest_dist_info, 'REQUESTED')
assert os.path.isfile(requested_path)

def test_std_install_with_direct_url(self, data, tmpdir):
"""Test that install_wheel creates direct_url.json metadata when
provided with a direct_url argument. Also test that the RECORDS
Expand Down

0 comments on commit 7945819

Please sign in to comment.