Skip to content
Back to top
View this page

# twine.package module

twine.package._safe_name(name: str) → str

  Convert an arbitrary string to a standard distribution name.

  Any runs of non-alphanumeric/. characters are replaced with a single ‘-‘.

  Copied from pkg_resources.safe_name for compatibility with warehouse. See https://github.com/pypa/twine/issues/743.

class twine.package.PackageMetadata
  metadata_version: str
  name: str
  version: str
  platform: List[str]
  summary: str
  description: str
  keywords: List[str]
  home_page: str
  author: str
  author_email: str
  license: str
  supported_platform: List[str]
  download_url: str
  classifiers: List[str]
  requires: List[str]
  provides: List[str]
  obsoletes: List[str]
  maintainer: str
  maintainer_email: str
  requires_dist: List[str]
  provides_dist: List[str]
  obsoletes_dist: List[str]
  requires_python: str
  requires_external: List[str]
  project_urls: Dict[str, str]
  description_content_type: str
  provides_extra: List[str]
  dynamic: List[str]
  license_expression: str
  license_file: List[str]
  comment: str
  pyversion: str
  filetype: str
  gpg_signature: Tuple[str, bytes]
  attestations: str
  sha256_digest: str
  blake2_256_digest: str

class twine.package.PackageFile
  __init__(filename: str, comment: str | None, metadata: RawMetadata, python_version: str, filetype: str) → None
  classmethod from_filename(filename: str, comment: str | None) → PackageFile
  metadata_dictionary() → PackageMetadata

    Merge multiple sources of metadata into a single dictionary.

    Includes values from filename, PKG-INFO, hashers, and signature.

  add_attestations(attestations: List[str]) → None
  add_gpg_signature(signature_filepath: str, signature_filename: str) → None
  sign(sign_with: str, identity: str | None) → None
  classmethod run_gpg(gpg_args: Tuple[str, ...]) → None

class twine.package.Hexdigest

  Hexdigest(sha2, blake2)

  sha2: str | None

    Alias for field number 0

  blake2: str | None

    Alias for field number 1

  static __new__(_cls, sha2: str | None, blake2: str | None)

    Create new instance of Hexdigest(sha2, blake2)

  _asdict()

    Return a new dict which maps field names to their values.

  _field_defaults = {}
  _fields = ('sha2', 'blake2')
  classmethod _make(iterable)

    Make a new Hexdigest object from a sequence or iterable

  _replace(**kwds)

    Return a new Hexdigest object replacing specified fields with new values

class twine.package.HashManager

  Manage our hashing objects for simplicity.

  This will also allow us to better test this logic.

  __init__(filename: str) → None

    Initialize our manager and hasher objects.

  _sha2_update(content: bytes) → None
  _sha2_hexdigest() → str | None
  _blake_update(content: bytes) → None
  _blake_hexdigest() → str | None
  hash() → None

    Hash the file contents.

  hexdigest() → Hexdigest

    Return the hexdigest for the file.