diff --git a/src/pip/_internal/operations/install/wheel.py b/src/pip/_internal/operations/install/wheel.py index 0b3fbe2ffc2..37361d6602c 100644 --- a/src/pip/_internal/operations/install/wheel.py +++ b/src/pip/_internal/operations/install/wheel.py @@ -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. @@ -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: @@ -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( @@ -619,4 +628,5 @@ def install_wheel( pycompile=pycompile, warn_script_location=warn_script_location, direct_url=direct_url, + requested=requested, ) diff --git a/tests/unit/test_wheel.py b/tests/unit/test_wheel.py index fc719e8905e..bc455f26412 100644 --- a/tests/unit/test_wheel.py +++ b/tests/unit/test_wheel.py @@ -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