mainframe.pypi

Minimal client over PyPI JSON API.

Attributes

Exceptions

PackageNotFoundError

Raised when a package version is not found on PyPI.

Classes

Distribution

A single downloadable file (e.g. an sdist or wheel) for a release.

PackageMetadata

The subset of PyPI package metadata that mainframe uses.

Info

The info object of the PyPI JSON response (only the fields we read).

JSONResponse

The shape of the PyPI JSON response, limited to what we parse.

PyPIClient

A minimal synchronous client for the PyPI JSON API.

Module Contents

mainframe.pypi.PYPI_BASE_URL = 'https://pypi.org/pypi'[source]
exception mainframe.pypi.PackageNotFoundError(name: str, version: str)[source]

Bases: Exception

Raised when a package version is not found on PyPI.

name[source]
version[source]
class mainframe.pypi.Distribution(/, **data: Any)[source]

Bases: pydantic.BaseModel

A single downloadable file (e.g. an sdist or wheel) for a release.

url: str[source]
class mainframe.pypi.PackageMetadata(/, **data: Any)[source]

Bases: pydantic.BaseModel

The subset of PyPI package metadata that mainframe uses.

name: str[source]
version: str[source]
distributions: list[Distribution][source]
class mainframe.pypi.Info(/, **data: Any)[source]

Bases: pydantic.BaseModel

The info object of the PyPI JSON response (only the fields we read).

name: str[source]
version: str[source]
class mainframe.pypi.JSONResponse(/, **data: Any)[source]

Bases: pydantic.BaseModel

The shape of the PyPI JSON response, limited to what we parse.

info: Info[source]
urls: list[Distribution] = None[source]
class mainframe.pypi.PyPIClient(http_client: httpx.Client)[source]

A minimal synchronous client for the PyPI JSON API.

http_client[source]
get_package_metadata(name: str, version: str) PackageMetadata[source]

Fetch metadata for a specific version of a package.

Parameters:
  • name – The package name.

  • version – The package version.

Returns:

The metadata for the requested package.

Raises:

PackageNotFoundError – If the package or version does not exist on PyPI.