conda_recipe_manager.fetcher.api.pypi

Description:

Library that provides tooling for pulling information from the publicly available PyPi API. API Docs: https://warehouse.pypa.io/api-reference/json.html#

Functions

fetch_package_metadata(package)

Fetches and validates package metadata from the PyPi API.

fetch_package_version_metadata(package, version)

Fetches and validates package metadata (at a specific version) from the PyPi API.

Classes

PackageInfo(description, ...)

Represents information stored in the "info"-keyed object found in both GET request types.

PackageMetadata(info, releases)

Class that represents all the metadata about a Package

VersionMetadata(md5, sha256, filename, ...)

Represents information stored in the object found in the "urls" or "releases/<version>" keys.

Exceptions

ApiException(message)

Generic exception indicating an unrecoverable failure of this API.

exception conda_recipe_manager.fetcher.api.pypi.ApiException(message: str)[source]

Bases: BaseApiException

Generic exception indicating an unrecoverable failure of this API. See the base class for more context.

add_note()

Exception.add_note(note) -- add a note to the exception

with_traceback()

Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self.

args
class conda_recipe_manager.fetcher.api.pypi.PackageInfo(description: str | None, description_content_type: str | None, docs_url: str | None, license: str | None, name: str, package_url: str, project_url: str, homepage_url: str | None, source_url: str | None, release_url: str, requires_python: str | None, summary: str | None, version: str, source_metadata: VersionMetadata)[source]

Bases: object

Represents information stored in the "info"-keyed object found in both GET request types.

Notes

  • This object contains a subset of all provided fields. We only focus on what we need

  • null set to a string parameter -> empty string, ""

  • We remove/flatten the info key as the PackageMetadata class will normalizes output between the two endpoints

  • We only store the VersionMetadata for variants labeled source as we don't care about PyPi's wheel packaging

static get_schema(requires_releases: bool) dict[str, dict[str, SchemaDetails] | list[SchemaDetails] | str | int | bool | None][source]

Returns a JSON schema used to validate JSON responses.

Parameters:

requires_releases -- Depending on the endpoint used, the API will optionally return information about every release/package version. Setting this to "True" will require the releases property

Returns:

JSON schema for a packaging info

description: str | None
description_content_type: str | None
docs_url: str | None
homepage_url: str | None
license: str | None
name: str
package_url: str
project_url: str
release_url: str
requires_python: str | None
source_metadata: VersionMetadata
source_url: str | None
summary: str | None
version: str
class conda_recipe_manager.fetcher.api.pypi.PackageMetadata(info: PackageInfo, releases: dict[str, VersionMetadata])[source]

Bases: object

Class that represents all the metadata about a Package

info: PackageInfo
releases: dict[str, VersionMetadata]
class conda_recipe_manager.fetcher.api.pypi.VersionMetadata(md5: str, sha256: str, filename: str, python_version: str, size: int, upload_time: datetime, url: str)[source]

Bases: object

Represents information stored in the object found in the "urls" or "releases/<version>" keys. This block contains version info.

This object contains a subset of all the provided fields. We only focus on what we need.

Notes

  • The digest object is flattened into a variable named per hashing algorithm.

static get_schema() dict[str, dict[str, SchemaDetails] | list[SchemaDetails] | str | int | bool | None][source]

Returns a JSON schema used to validate JSON responses.

Returns:

JSON schema for a packaging info

filename: str
md5: str
python_version: str
sha256: str
size: int
upload_time: datetime
url: str
conda_recipe_manager.fetcher.api.pypi.fetch_package_metadata(package: str) PackageMetadata[source]

Fetches and validates package metadata from the PyPi API.

Parameters:

package -- Name of the package

Raises:

ApiException -- If there is an unrecoverable issue with the API

conda_recipe_manager.fetcher.api.pypi.fetch_package_version_metadata(package: str, version: str) PackageMetadata[source]

Fetches and validates package metadata (at a specific version) from the PyPi API.

Parameters:
  • package -- Name of the package

  • version -- Version of the package

Raises:

ApiException -- If there is an unrecoverable issue with the API