def build_wheel_editable( name: str, backend: Pep517HookCaller, metadata_directory: str, tempd: str, ) -> Optional[str]: """Build one InstallRequirement using the PEP 660 build process. Returns path to wheel if successfully built. Otherwise, returns None. """ assert metadata_directory is not None try: logger.debug("Destination directory: %s", tempd) runner = runner_with_spinner_message( f"Building editable for {name} (pyproject.toml)") with backend.subprocess_runner(runner): try: wheel_name = backend.build_editable( tempd, metadata_directory=metadata_directory, ) except HookMissing as e: logger.error( "Cannot build editable %s because the build " "backend does not have the %s hook", name, e, ) return None except Exception: logger.error("Failed building editable for %s", name) return None return os.path.join(tempd, wheel_name)
def build_wheel_pep517( name: str, backend: Pep517HookCaller, metadata_directory: str, tempd: str, ) -> Optional[str]: """Build one InstallRequirement using the PEP 517 build process. Returns path to wheel if successfully built. Otherwise, returns None. """ assert metadata_directory is not None try: logger.debug("Destination directory: %s", tempd) runner = runner_with_spinner_message( f"Building wheel for {name} (pyproject.toml)") with backend.subprocess_runner(runner): wheel_name = backend.build_wheel( tempd, metadata_directory=metadata_directory, ) except Exception: logger.error("Failed building wheel for %s", name) return None return os.path.join(tempd, wheel_name)
def generate_editable_metadata( build_env: BuildEnvironment, backend: Pep517HookCaller, details: str ) -> str: """Generate metadata using mechanisms described in PEP 660. Returns the generated metadata directory. """ metadata_tmpdir = TempDirectory(kind="modern-metadata", globally_managed=True) metadata_dir = metadata_tmpdir.path with build_env: # Note that Pep517HookCaller implements a fallback for # prepare_metadata_for_build_wheel/editable, so we don't have to # consider the possibility that this hook doesn't exist. runner = runner_with_spinner_message( "Preparing editable metadata (pyproject.toml)" ) with backend.subprocess_runner(runner): try: distinfo_dir = backend.prepare_metadata_for_build_editable(metadata_dir) except InstallationSubprocessError as error: raise MetadataGenerationFailed(package_details=details) from error return os.path.join(metadata_dir, distinfo_dir)
def load_pyproject_toml(self) -> None: """Load the pyproject.toml file. After calling this routine, all of the attributes related to PEP 517 processing for this requirement have been set. In particular, the use_pep517 attribute can be used to determine whether we should follow the PEP 517 or legacy (setup.py) code path. """ pyproject_toml_data = load_pyproject_toml(self.use_pep517, self.pyproject_toml_path, self.setup_py_path, str(self)) if pyproject_toml_data is None: self.use_pep517 = False return self.use_pep517 = True requires, backend, check, backend_path = pyproject_toml_data self.requirements_to_check = check self.pyproject_requires = requires self.pep517_backend = Pep517HookCaller(self.unpacked_source_directory, backend, backend_path=backend_path, python_executable=os.getenv( 'PIP_PYTHON_PATH', sys.executable))
def load_pyproject_toml(self): """Load the pyproject.toml file. After calling this routine, all of the attributes related to PEP 517 processing for this requirement have been set. In particular, the use_pep517 attribute can be used to determine whether we should follow the PEP 517 or legacy (setup.py) code path. """ pep517_data = load_pyproject_toml(self.use_pep517, self.pyproject_toml, self.setup_py, str(self)) if pep517_data is None: self.use_pep517 = False else: self.use_pep517 = True requires, backend, check = pep517_data self.requirements_to_check = check self.pyproject_requires = requires self.pep517_backend = Pep517HookCaller(self.setup_py_dir, backend)
def load_pyproject_toml(self): # type: () -> None """Load the pyproject.toml file. After calling this routine, all of the attributes related to PEP 517 processing for this requirement have been set. In particular, the use_pep517 attribute can be used to determine whether we should follow the PEP 517 or legacy (setup.py) code path. """ pep517_data = load_pyproject_toml( self.use_pep517, self.pyproject_toml, self.setup_py, str(self) ) if pep517_data is None: self.use_pep517 = False else: self.use_pep517 = True requires, backend, check = pep517_data self.requirements_to_check = check self.pyproject_requires = requires self.pep517_backend = Pep517HookCaller(self.setup_py_dir, backend) # Use a custom function to call subprocesses self.spin_message = "" def runner(cmd, cwd=None, extra_environ=None): with open_spinner(self.spin_message) as spinner: call_subprocess( cmd, cwd=cwd, extra_environ=extra_environ, show_stdout=False, spinner=spinner ) self.spin_message = "" self.pep517_backend._subprocess_runner = runner