[docs]defread(self)->bytes:fqn=os.path.abspath(os.path.normpath(self.filename))ifnotos.path.exists(fqn):raiseexceptions.InvalidDistribution("No such file: %s"%fqn)iffqn.endswith(".exe"):archive=zipfile.ZipFile(fqn)names=archive.namelist()defread_file(name:str)->bytes:returnarchive.read(name)else:raiseexceptions.InvalidDistribution("Not a known archive format for file: %s"%fqn)try:tuples=[x.split("/")forxinnamesifx.endswith((".egg-info","PKG-INFO"))]schwarz=sorted((len(x),x)forxintuples)forpathin[x[1]forxinschwarz]:candidate="/".join(path)data=read_file(candidate)ifb"Metadata-Version"indata:returndatafinally:archive.close()raiseexceptions.InvalidDistribution("No PKG-INFO/.egg-info in archive: %s"%fqn)