diff --git a/news/6222.bugfix b/news/6222.bugfix new file mode 100644 index 00000000000..6b1c5e7ef5f --- /dev/null +++ b/news/6222.bugfix @@ -0,0 +1 @@ +Fixes a bug that prevented installation of packages from source only if those packages depended on PEP 517 conform packages without a ``setup.py`` \ No newline at end of file diff --git a/src/pip/_internal/req/req_install.py b/src/pip/_internal/req/req_install.py index e0578875d7a..a4b79cac2e6 100644 --- a/src/pip/_internal/req/req_install.py +++ b/src/pip/_internal/req/req_install.py @@ -30,7 +30,7 @@ from pip._internal.utils.misc import ( _make_build_dir, ask_path_exists, backup_dir, call_subprocess, display_path, dist_in_site_packages, dist_in_usersite, ensure_dir, - get_installed_version, redact_password_from_url, rmtree, + get_installed_version, redact_password_from_url, rmtree, unpack_file, ) from pip._internal.utils.packaging import get_metadata from pip._internal.utils.setuptools_build import SETUPTOOLS_SHIM @@ -922,6 +922,18 @@ def install( self.install_succeeded = True return + if self.use_pep517: + self.install_use_pep517( + warn_script_location=warn_script_location, + use_user_site=use_user_site, + pycompile=pycompile, + prefix=prefix, + root=root, + home=home, + ) + self.install_succeed = True + return + # Extend the list of global and install options passed on to # the setup.py call with the ones from the requirements file. # Options specified in requirements file override those @@ -993,6 +1005,34 @@ def prepend_root(path): with open(inst_files_path, 'w') as f: f.write('\n'.join(new_lines) + '\n') + def install_use_pep517( + self, warn_script_location, use_user_site, pycompile, prefix, root, home + ): + with TempDirectory(kind='wheel') as wheel_dir, TempDirectory(kind='wheel') as build_dir: + wheel_name = self.build_wheel_use_pep517(build_dir.path) + unpack_file( + os.path.join(build_dir.path, wheel_name), + wheel_dir.path, + 'application/zip', + None + ) + version = wheel.wheel_version(wheel_dir.path) + wheel.check_compatibility(version, self.name) + self.move_wheel_files( + wheel_dir.path, root=root, prefix=prefix, home=home, + warn_script_location=warn_script_location, + use_user_site=use_user_site, pycompile=pycompile, + ) + return + + def build_wheel_use_pep517(self, output_directory): + self.spin_message = 'Building wheel for %s (PEP 517)' % (self.name,) + with self.build_env, indent_log(): + return self.pep517_backend.build_wheel( + output_directory, + metadata_directory=self.metadata_directory, + ) + def get_install_args( self, global_options, # type: Sequence[str]