pip - Get long description of uninstalled package?
pip
does not provide this functionality. Hovewer, 1. there is a cool package named yolk
that can query PyPI repositories for metadata of available packages. 2. PyPI offers a JSON API that can be queried with a tool of your choice.
1. yolk
Install it with
$ pip2 install yolk
or
$ pip3 install yolk3k
python2
users, beware:
Looks like the original yolk
package has now an issue with querying the PyPI packages. It may be due to the recent move of the repository from https://pypi.python.org to https://pypi.org; unfortunately, yolk
is pretty old and was not updated for several years now. If you happen to have python2.7
, use yolk3k
as it's compatible with python2.7
:
$ pip2.7 uninstall -y yolk && pip2.7 install yolk3k
(Thanks to @AnneTheAgile for the hint, see this comment)
Query complete metadata of a package (no matter if installed or not):
$ yolk -M pytest
maintainer:
docs_url: None
requires_python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*
maintainer_email:
cheesecake_code_kwalitee_id: None
keywords: test unittest
package_url: http://pypi.python.org/pypi/pytest
author: Holger Krekel, Bruno Oliveira, Ronny Pfannschmidt, Floris Bruynooghe, Brianna Laugher, Florian Bruhin and others
author_email:
download_url:
platform: unix
version: 3.5.0
cheesecake_documentation_id: None
_pypi_hidden: False
description:
... # here comes the long README contents
release_url: http://pypi.python.org/pypi/pytest/3.5.0
downloads: {'last_month': 0, 'last_week': 0, 'last_day': 0}
_pypi_ordering: 69
requires_dist: ['py (>=1.5.0)', 'six (>=1.10.0)', 'setuptools', 'attrs (>=17.4.0)', 'more-itertools (>=4.0.0)', 'pluggy (<0.7,>=0.5)', 'funcsigs; python_version < "3.0"', 'colorama; sys_platform == "win32"']
classifiers: ['Development Status :: 6 - Mature', 'Intended Audience :: Developers', 'License :: OSI Approved :: MIT License', 'Operating System :: MacOS :: MacOS X', 'Operating System :: Microsoft :: Windows', 'Operating System :: POSIX', 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Topic :: Software Development :: Libraries', 'Topic :: Software Development :: Testing', 'Topic :: Utilities']
name: pytest
bugtrack_url: https://github.com/pytest-dev/pytest/issues
license: MIT license
summary: pytest: simple powerful testing with Python
home_page: http://pytest.org
cheesecake_installability_id: None
Query only selected metadata fields:
$ yolk -M pytest -f author,requires_python
requires_python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*
author: Holger Krekel, Bruno Oliveira, Ronny Pfannschmidt, Floris Bruynooghe, Brianna Laugher, Florian Bruhin and others
Now you know how to get the package description:
$ yolk -M pkgname -f long_description
2. Query PyPI's JSON API
The above example with curl
+ jq
:
$ curl -sH "accept: application/json" https://pypi.org/pypi/pytest/json | jq -r '.info.author, .info.requires_python'
Holger Krekel, Bruno Oliveira, Ronny Pfannschmidt, Floris Bruynooghe, Brianna Laugher, Florian Bruhin and others
>=3.5
Print all package metadata:
$ curl -sH "accept: application/json" https://pypi.org/pypi/pytest/json | jq -r '.info | keys[] as $key | "\($key): \(.[$key])"'
author: Holger Krekel, Bruno Oliveira, Ronny Pfannschmidt, Floris Bruynooghe, Brianna Laugher, Florian Bruhin and others
author_email:
bugtrack_url: null
...