[Distutils] Getting dependecies of package from PyPiJSON

Nick Coghlan ncoghlan at gmail.com
Fri Jul 21 06:17:11 EDT 2017


On 21 July 2017 at 19:39, Krzysiek Płachno <krzysiekplachno at gmail.com> wrote:
> Guys! Thanks a lot for all your responses and willingness to help!
>
> Yesterday I noticed this `requires_dist` in response for Requests package.
> But actually it was the only one that had this field populated from many
> packages that I asked API for. So this cannot be reliable way of getting
> dependecies.
>
> So if not using pip, the only way to get dependencies is from built
> packages: .whl and .egg.
> So in .egg it'd be: EGG_INFO/requires.txt and in .whl :
> <packageName-version>.dist-info/metadata.json, right?

For wheel archives, the JSON format technically isn't stable yet (and
wheel generators aren't required to include it), so the file you want
is {distribution}-{version}.dist-info/METADATA, and specifically the
"Requires-Dist" entries

The relevant specifications:

METADATA file: https://www.python.org/dev/peps/pep-0345/#requires-dist-multiple-use
Requires-Dist values: https://www.python.org/dev/peps/pep-0508/
Wheel format: https://www.python.org/dev/peps/pep-0427/
Draft JSON metadata format: https://www.python.org/dev/peps/pep-0426/

There's no interoperability spec for the egg format, but the
setuptools docs have pretty good documentation for it:
https://setuptools.readthedocs.io/en/latest/formats.html#dependency-metadata

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Distutils-SIG mailing list