def _check_installable(self) -> None: if not (self.path.joinpath("setup.py").exists() or self.path.joinpath("pyproject.toml").exists()): raise RequirementError( f"The local path '{self.path}' is not installable.") result = SetupReader.read_from_directory( self.path.absolute().as_posix()) self.name = result["name"]
def get_metadata(self, allow_all_wheels: bool = True, raising: bool = False) -> Optional[Metadata]: """Get the metadata of the candidate. For editable requirements, egg info are produced, otherwise a wheel is built. If raising is True, error will pop when the package fails to build. """ if self.metadata is not None: return self.metadata ireq = self.ireq if self.link and not ireq.link: ireq.link = self.link try: built = self.environment.build(ireq, self.hashes, allow_all_wheels) except BuildError: if raising: raise termui.logger.warn( "Failed to build package, try parsing project files.") meta_dict = SetupReader.read_from_directory( ireq.unpacked_source_directory) meta_dict.update(summary="UNKNOWN") meta_dict["requires_python"] = meta_dict.pop( "python_requires", None) self.metadata = Namespace(**meta_dict) else: if self.req.editable: if not self.req.is_local_dir and not self.req.is_vcs: raise RequirementError( "Editable installation is only supported for " "local directory and VCS location.") sdist = get_sdist(built) self.metadata = sdist.metadata if sdist else None else: # It should be a wheel path. self.wheel = Wheel(built) self.metadata = self.wheel.metadata if not self.name: self.name = self.metadata.name self.req.name = self.name if not self.version: self.version = self.metadata.version self.link = ireq.link return self.metadata