def build(self, build_dir: str, **kwargs): if not os.path.exists(build_dir): os.makedirs(build_dir, exist_ok=True) version = to_filename(safe_version(self.meta.version)) target = os.path.join( build_dir, "{}-{}.tar.gz".format(self.meta.project_name, version) ) tar = tarfile.open(target, mode="w:gz", format=tarfile.PAX_FORMAT) try: tar_dir = "{}-{}".format(self.meta.project_name, version) files_to_add = self.find_files_to_add(True) for relpath in files_to_add: if str(relpath) == "pyproject.toml": self._add_pyproject(tar, tar_dir) else: tar.add( relpath, arcname=os.path.join(tar_dir, str(relpath)), recursive=False, ) print(f" - Adding A{relpath}") fd, temp_name = tempfile.mkstemp(prefix="pkg-info") pkg_info = self.format_pkginfo(False).encode("utf-8") with open(fd, "wb") as f: f.write(pkg_info) tar.add( temp_name, arcname=os.path.join(tar_dir, "PKG-INFO"), recursive=False ) print(" - Adding PKG-INFO") finally: tar.close() return target
def meta_version(self) -> str: meta_version = self.meta.version if meta_version is None: return "0.0.0" return to_filename(safe_version(meta_version))
def __init__(self, location: Union[str, Path], config_settings: Optional[Mapping[str, Any]]) -> None: super().__init__(location, config_settings=config_settings) self.editables = EditableProject(to_filename(self.meta.project_name), self.location.as_posix())
def project_filename(self) -> str: if self.name is None: return "UNKNOWN" return to_filename(self.project_name)
def wheel_filename(self) -> str: name = to_filename(self.meta.project_name) version = to_filename(safe_version(self.meta.version)) return f"{name}-{version}-{self.tag}.whl"
def dist_info_name(self) -> str: name = to_filename(self.meta.project_name) version = to_filename(safe_version(self.meta.version)) return f"{name}-{version}.dist-info"