Skip to main content

PyPI Simple Repository API client library

Project description

Project Status: Active — The project has reached a stable, usable state and is being actively developed. https://travis-ci.org/jwodder/pypi-simple.svg?branch=master https://codecov.io/gh/jwodder/pypi-simple/branch/master/graph/badge.svg https://img.shields.io/pypi/pyversions/pypi-simple.svg MIT License

GitHub | PyPI | Issues

pypi-simple is a client library for the Python Simple Repository API as specified in PEP 503. With it, you can query PyPI and other pip-compatible repositories for a list of their available projects and lists of each project’s available package files. The library also allows you to query package files for their project version, package type, file digests, requires_python string, and PGP signature URL.

Installation

Just use pip (You have pip, right?) to install pypi-simple and its dependencies:

pip install pypi-simple

Example

>>> from pypi_simple import PyPISimple
>>> client = PyPISimple()
>>> packages = client.get_project_files('requests')
>>> packages[0]
DistributionPackage(filename='requests-0.2.0.tar.gz', url='https://files.pythonhosted.org/packages/ba/bb/dfa0141a32d773c47e4dede1a617c59a23b74dd302e449cf85413fc96bc4/requests-0.2.0.tar.gz#sha256=813202ace4d9301a3c00740c700e012fb9f3f8c73ddcfe02ab558a8df6f175fd', project='requests', version='0.2.0', package_type='sdist', requires_python=None, has_sig=False)
>>> packages[0].filename
'requests-0.2.0.tar.gz'
>>> packages[0].url
'https://files.pythonhosted.org/packages/ba/bb/dfa0141a32d773c47e4dede1a617c59a23b74dd302e449cf85413fc96bc4/requests-0.2.0.tar.gz#sha256=813202ace4d9301a3c00740c700e012fb9f3f8c73ddcfe02ab558a8df6f175fd'
>>> packages[0].project
'requests'
>>> packages[0].version
'0.2.0'
>>> packages[0].package_type
'sdist'
>>> packages[0].get_digests()
{'sha256': '813202ace4d9301a3c00740c700e012fb9f3f8c73ddcfe02ab558a8df6f175fd'}

API

PyPISimple

A client for fetching package information from a Python simple package repository

PyPISimple(endpoint=pypi_simple.PYPI_SIMPLE_ENDPOINT)

Create a new PyPISimple object for querying the simple API instance at endpoint. The endpoint defaults to PyPI’s simple API at <https://pypi.org/simple/>.

client.get_projects()

Returns a generator of names of projects available in the repository. The names are not normalized.

client.get_project_files(project)

Returns a list of DistributionPackage objects representing all of the package files available in the repository for the given project.

When fetching the project’s information from the repository, a 404 response is treated the same as an empty page, resulting in an empty list. All other HTTP errors cause a requests.HTTPError to be raised.

client.get_project_url(project)

Returns the URL for the given project’s page in the repository.

DistributionPackage

Information about a versioned archived file from which a Python project release can be installed. DistributionPackage objects have the following attributes and method:

filename

The basename of the package file

url

The URL from which the package file can be downloaded

project

The name of the project (as extracted from the filename), or None if the filename cannot be parsed

version

The project version (as extracted from the filename), or None if the filename cannot be parsed

package_type

The type of the package, or None if the filename cannot be parsed. The recognized package types are:

  • 'dumb'

  • 'egg'

  • 'msi'

  • 'rpm'

  • 'sdist'

  • 'wheel'

  • 'wininst'

requires_python

An optional version specifier string declaring the Python version(s) in which the package can be installed

has_sig

Whether the package file is accompanied by a PGP signature file

sig_url

If has_sig is true, this equals the URL of the package file’s PGP signature file; otherwise, it equals None.

get_digests()

Extracts the hash digests from the package file’s URL and returns a dict mapping hash algorithm names to hex-encoded digest strings

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pypi-simple-0.3.0.tar.gz (21.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pypi_simple-0.3.0-py2.py3-none-any.whl (8.3 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pypi-simple-0.3.0.tar.gz.

File metadata

  • Download URL: pypi-simple-0.3.0.tar.gz
  • Upload date:
  • Size: 21.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/36.4.0 requests-toolbelt/0.8.0 tqdm/4.14.0 CPython/3.5.2

File hashes

Hashes for pypi-simple-0.3.0.tar.gz
Algorithm Hash digest
SHA256 bf309eea25099107445a226dfe84406f2fcd09b7b6709e426231d0e30d09d1a4
MD5 c6b809de049414a3b29c4df95059117b
BLAKE2b-256 e972edaf1e459e138bc5dd2ed66b78209df0e804254e812dd25049bf056248be

See more details on using hashes here.

File details

Details for the file pypi_simple-0.3.0-py2.py3-none-any.whl.

File metadata

  • Download URL: pypi_simple-0.3.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/36.4.0 requests-toolbelt/0.8.0 tqdm/4.14.0 CPython/3.5.2

File hashes

Hashes for pypi_simple-0.3.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 f2237e3b89850510b8655139810ce4558a48c47b6f3a28015ad53fc8c576f971
MD5 f11fb74d04b953602c9e95d7da20b63b
BLAKE2b-256 32ea6e96b70108571ad0e05b7f9b019dc0f89a91b0b3e3d33aee87bedcc3c0ea

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page