packaging API reference
84 public APIs from packaging (pypa/packaging) — 31 classes, 19 functions, 34 methods. Signatures extracted by static analysis of the actual source.
Repository: pypa/packaging
| Kind | Count |
|---|---|
| Classes | 31 |
| Functions | 19 |
| Methods | 34 |
API list
class
src.packaging._elffile.ELFFileRepresentation of an ELF executable.
method
src.packaging._elffile.ELFFile.interpreter() -> str | NoneThe path recorded in the ``PT_INTERP`` section header.
func
src.packaging._manylinux.platform_tags(archs:Sequence[str]) -> Iterator[str]Generate manylinux tags compatible to the current platform.
func
src.packaging._musllinux.platform_tags(archs:Sequence[str]) -> Iterator[str]Generate musllinux tags compatible to the current platform.
class
src.packaging._ranges.BoundaryKindWhere a boundary marker sits in the version ordering.
class
src.packaging._ranges.BoundaryVersionA point on the version line between two real PEP 440 versions.
class
src.packaging._ranges.LowerBoundLower bound of a version range.
class
src.packaging._ranges.UpperBoundUpper bound of a version range.
func
src.packaging._ranges.bounds_for_spec(op:str, version_str:str, version:Version) -> list[Interval]Ranges for one specifier's ``(op, version_str)``.
func
src.packaging._ranges.matches_bounds_only(ranges:Sequence[Interval], version:Version) -> boolWhether ``version`` falls within any of ``ranges``.
func
src.packaging._ranges.ranges_are_prerelease_only(ranges:Sequence[Interval]) -> boolTrue when every range in *ranges* contains only pre-releases.
func
src.packaging._ranges.trim_release(release:tuple[int, ...]) -> tuple[int, ...]Strip trailing zeros from a release tuple for normalized comparison.
func
src.packaging._ranges.wildcard_ranges(op:str, base:Version) -> list[Interval]Ranges for ==V.* and !=V.*.
class
src.packaging._tokenizer.ParserSyntaxErrorThe provided source text could not be parsed correctly.
class
src.packaging._tokenizer.TokenizerContext-sensitive token parsing.
method
src.packaging._tokenizer.Tokenizer.check(name:str, *peek:bool=False) -> boolCheck whether the next token has the provided name.
method
src.packaging._tokenizer.Tokenizer.consume(name:str) -> NoneMove beyond provided token name, if at current position.
method
src.packaging._tokenizer.Tokenizer.raise_syntax_error(message:str, *span_start:int | None=None, *span_end:int | None=None) -> NoReturnRaise ParserSyntaxError at the given position.
method
src.packaging._tokenizer.Tokenizer.read() -> TokenConsume the next token and return it.
class
src.packaging.dependency_groups.CyclicDependencyGroupThe dependency group includes form a cycle.
class
src.packaging.dependency_groups.DependencyGroupIncludeA reference to another dependency group by name.
class
src.packaging.dependency_groups.DependencyGroupResolverA resolver for Dependency Group data.
method
src.packaging.dependency_groups.DependencyGroupResolver.resolve(group:str) -> tuple[Requirement, ...]Resolve a dependency group to a list of requirements.
class
src.packaging.direct_url.ArchiveInfoThe archive information of a :class:`DirectUrl`.
class
src.packaging.direct_url.DirInfoThe local directory information of a :class:`DirectUrl`.
class
src.packaging.direct_url.DirectUrlA class representing a direct URL.
method
src.packaging.direct_url.DirectUrl.from_dict(d:Mapping[str, Any]) -> SelfCreate and validate a DirectUrl instance from a JSON dictionary.
class
src.packaging.direct_url.DirectUrlValidationErrorRaised when when input data is not spec-compliant.
class
src.packaging.direct_url.VcsInfoThe version control information of a :class:`DirectUrl`.
class
src.packaging.markers.MarkerRepresents a parsed dependency marker expression.
method
src.packaging.markers.Marker.evaluate(environment:Mapping[str, str | AbstractSet[str]] | None=None, context:EvaluateContext='metadata') -> boolEvaluate a marker.
class
src.packaging.markers.UndefinedComparisonRaised when evaluating an unsupported marker comparison.
class
src.packaging.metadata.InvalidMetadataA metadata field contains invalid data.
class
src.packaging.metadata.MetadataRepresentation of distribution metadata.
method
src.packaging.metadata.Metadata.as_rfc822() -> RFC822MessageReturn an RFC822 message with the metadata.
method
src.packaging.metadata.Metadata.from_email(data:bytes | str, *validate:bool=True) -> MetadataParse metadata from email headers.
method
src.packaging.metadata.Metadata.from_raw(data:RawMetadata, *validate:bool=True) -> MetadataCreate an instance from :class:`RawMetadata`.
class
src.packaging.metadata.RawMetadataA dictionary of raw core metadata.
func
src.packaging.metadata.parse_email(data:bytes | str) -> tuple[RawMetadata, dict[str, list[str]]]Parse a distribution's metadata stored as email headers (e.g.
class
src.packaging.pylock.PylockA class representing a pylock file.
method
src.packaging.pylock.Pylock.from_dict(d:Mapping[str, Any]) -> SelfCreate and validate a Pylock instance from a TOML dictionary.
method
src.packaging.pylock.Pylock.to_dict() -> Mapping[str, Any]Convert the Pylock instance to a TOML dictionary.
method
src.packaging.pylock.Pylock.validate() -> NoneValidate the Pylock instance against the specification.
class
src.packaging.pylock.PylockSelectErrorBase exception for errors raised by :meth:`Pylock.select`.
class
src.packaging.pylock.PylockUnsupportedVersionErrorRaised when encountering an unsupported `lock_version`.
class
src.packaging.pylock.PylockValidationErrorRaised when when input data is not spec-compliant.
func
src.packaging.pylock.is_valid_pylock_path(path:Path) -> boolCheck if the given path is a valid pylock file path.
class
src.packaging.requirements.RequirementParse a requirement.
class
src.packaging.specifiers.SpecifierThis class abstracts handling of version specifiers.
method
src.packaging.specifiers.Specifier.operator() -> strThe operator of this specifier.
method
src.packaging.specifiers.Specifier.version() -> strThe version of this specifier.
class
src.packaging.specifiers.SpecifierSetThis class abstracts handling of a set of version specifiers.
method
src.packaging.specifiers.SpecifierSet.is_disjoint(other:SpecifierSet) -> boolReturn whether this set and other share no matching versions.
class
src.packaging.tags.TagA representation of the tag triple for a wheel.
method
src.packaging.tags.Tag.abi() -> strThe supported ABI.
method
src.packaging.tags.Tag.interpreter() -> strThe interpreter name, e.g.
method
src.packaging.tags.Tag.platform() -> strThe OS/platform.
class
src.packaging.tags.TooManyTagsErrorRaised when a compressed tag set exceeds the configured limit.
func
src.packaging.tags.android_platforms(api_level:int | None=None, abi:str | None=None) -> Iterator[str]Yields the :attr:`~Tag.platform` tags for Android.
func
src.packaging.tags.interpreter_name() -> strReturns the name of the running interpreter.
func
src.packaging.tags.interpreter_version(*warn:bool=False) -> strReturns the running interpreter's version.
func
src.packaging.tags.ios_platforms(version:AppleVersion | None=None, multiarch:str | None=None) -> Iterator[str]Yields the :attr:`~Tag.platform` tags for iOS.
func
src.packaging.tags.mac_platforms(version:AppleVersion | None=None, arch:str | None=None) -> Iterator[str]Yields the :attr:`~Tag.platform` tags for macOS.
func
src.packaging.tags.parse_tag(tag:str, *validate_order:bool=False, *limit:int | None=None) -> frozenset[Tag]Parses the provided tag (e.g.
func
src.packaging.utils.canonicalize_version(version:Version | str, *strip_trailing_zero:bool=True) -> strReturn a canonical form of a version as a string.
func
src.packaging.utils.is_normalized_name(name:str) -> boolCheck if a name is a normalized project name (i.e.
class
src.packaging.version.InvalidVersionRaised when a version string is not a valid version.
class
src.packaging.version.VersionThis class abstracts handling of a project's versions.
method
src.packaging.version.Version.base_version() -> strThe "base version" of the version.
method
src.packaging.version.Version.dev() -> int | NoneThe development number of the version.
method
src.packaging.version.Version.epoch() -> intThe epoch of the version.
method
src.packaging.version.Version.is_devrelease() -> boolWhether this version is a development release.
method
src.packaging.version.Version.is_postrelease() -> boolWhether this version is a post-release.
method
src.packaging.version.Version.is_prerelease() -> boolWhether this version is a pre-release.
method
src.packaging.version.Version.local() -> str | NoneThe local version segment of the version.
method
src.packaging.version.Version.major() -> intThe first item of :attr:`release` or ``0`` if unavailable.
method
src.packaging.version.Version.micro() -> intThe third item of :attr:`release` or ``0`` if unavailable.
method
src.packaging.version.Version.minor() -> intThe second item of :attr:`release` or ``0`` if unavailable.
method
src.packaging.version.Version.post() -> int | NoneThe post-release number of the version.
method
src.packaging.version.Version.pre() -> tuple[Literal['a', 'b', 'rc'], int] | NoneThe pre-release segment of the version.
method
src.packaging.version.Version.public() -> strThe public portion of the version.
method
src.packaging.version.Version.release() -> tuple[int, ...]The components of the "release" segment of the version.
func
src.packaging.version.normalize_pre(letter:str) -> strNormalize the pre-release segment of a version string.
func
src.packaging.version.parse(version:str) -> VersionParse the given version string.
About this data
These signatures were extracted from the public source of pypa/packaging
using Python's ast module. Argument names, default values,
type annotations and return types are taken verbatim from the code.
Implementation bodies are never stored. See
how it works for details.