Skip to content

Commit 7945819

Browse files
committed
Add REQUESTED support to install_wheel
1 parent 8cca170 commit 7945819

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/pip/_internal/operations/install/wheel.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ def install_unpacked_wheel(
292292
pycompile=True, # type: bool
293293
warn_script_location=True, # type: bool
294294
direct_url=None, # type: Optional[DirectUrl]
295+
requested=False, # type: bool
295296
):
296297
# type: (...) -> None
297298
"""Install a wheel.
@@ -580,6 +581,13 @@ def is_entrypoint_wrapper(name):
580581
replace(direct_url_file.name, direct_url_path)
581582
generated.append(direct_url_path)
582583

584+
# Record the REQUESTED file
585+
if requested:
586+
requested_path = os.path.join(dest_info_dir, 'REQUESTED')
587+
with open(requested_path, "w"):
588+
pass
589+
generated.append(requested_path)
590+
583591
# Record details of all files installed
584592
record_path = os.path.join(dest_info_dir, 'RECORD')
585593
with open(record_path, **csv_io_kwargs('r')) as record_file:
@@ -604,6 +612,7 @@ def install_wheel(
604612
warn_script_location=True, # type: bool
605613
_temp_dir_for_testing=None, # type: Optional[str]
606614
direct_url=None, # type: Optional[DirectUrl]
615+
requested=False, # type: bool
607616
):
608617
# type: (...) -> None
609618
with TempDirectory(
@@ -619,4 +628,5 @@ def install_wheel(
619628
pycompile=pycompile,
620629
warn_script_location=warn_script_location,
621630
direct_url=direct_url,
631+
requested=requested,
622632
)

tests/unit/test_wheel.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,19 @@ def test_std_install(self, data, tmpdir):
264264
)
265265
self.assert_installed()
266266

267+
def test_std_install_requested(self, data, tmpdir):
268+
self.prep(data, tmpdir)
269+
wheel.install_wheel(
270+
self.name,
271+
self.wheelpath,
272+
scheme=self.scheme,
273+
req_description=str(self.req),
274+
requested=True,
275+
)
276+
self.assert_installed()
277+
requested_path = os.path.join(self.dest_dist_info, 'REQUESTED')
278+
assert os.path.isfile(requested_path)
279+
267280
def test_std_install_with_direct_url(self, data, tmpdir):
268281
"""Test that install_wheel creates direct_url.json metadata when
269282
provided with a direct_url argument. Also test that the RECORDS

0 commit comments

Comments
 (0)