How to programmatically access Python package dependencies?

I am trying to access PyPI package dependencies (i.e. install_requires metadata). This information does not seem to be available from either the JSON API or XMLRPC. The documentation for the XMLRPC API says that the method release_datashould return a dict with the key requires, but I do not see this when I use the API.

>>> import xmlrpclib
>>> client = xmlrpclib.ServerProxy('http://pypi.python.org/pypi')
>>> info = client.release_data('Flask', '0.10.1')
>>> 'requires' in info
False
>>> info
{'_pypi_hidden': False,
 '_pypi_ordering': 17,
 'author': 'Armin Ronacher',
 'author_email': 'armin.ronacher@active-4.com',
 'bugtrack_url': None,
 'cheesecake_code_kwalitee_id': None,
 'cheesecake_documentation_id': None,
 'cheesecake_installability_id': None,
 'classifiers': ['Development Status :: 4 - Beta',
  'Environment :: Web Environment',
  'Intended Audience :: Developers',
  'License :: OSI Approved :: BSD License',
  'Operating System :: OS Independent',
  'Programming Language :: Python',
  'Programming Language :: Python :: 3',
  'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
  'Topic :: Software Development :: Libraries :: Python Modules'],
 'description': 'Flask\n-----\n\nFlask is a microframework for Python based on Werkzeug, Jinja 2 and good\nintentions. And before you ask: It\ BSD licensed!\n\nFlask is Fun\n````````````\n\n.. code:: python\n\n    from flask import Flask\n    app = Flask(__name__)\n\n    @app.route("/")\n    def hello():\n        return "Hello World!"\n\n    if __name__ == "__main__":\n        app.run()\n\nAnd Easy to Setup\n`````````````````\n\n.. code:: bash\n\n    $ pip install Flask\n    $ python hello.py\n     * Running on http://localhost:5000/\n\nLinks\n`````\n\n* `website <http://flask.pocoo.org/>`_\n* `documentation <http://flask.pocoo.org/docs/>`_\n* `development version\n  <http://github.com/mitsuhiko/flask/zipball/master#egg=Flask-dev>`_',
 'docs_url': '',
 'download_url': 'UNKNOWN',
 'downloads': {'last_day': 4723, 'last_month': 267891, 'last_week': 64752},
 'home_page': 'http://github.com/mitsuhiko/flask/',
 'keywords': None,
 'license': 'BSD',
 'maintainer': None,
 'maintainer_email': None,
 'name': 'Flask',
 'package_url': 'http://pypi.python.org/pypi/Flask',
 'platform': 'any',
 'release_url': 'http://pypi.python.org/pypi/Flask/0.10.1',
 'requires_python': None,
 'stable_version': None,
 'summary': 'A microframework based on Werkzeug, Jinja2 and good intentions',
 'version': '0.10.1'}

Is there any other way to get package dependencies without installing a package?

+4
source share
1 answer

The only way to find out the dependencies on pypi is:

  • Download the package and extract it to some directory
  • Run setup.py egg_info
  • Created Parsing requires.txt

for flask 0.10.1 it will be

Werkzeug>=0.7
Jinja2>=2.4
itsdangerous>=0.21
+2
source

Source: https://habr.com/ru/post/1544657/


All Articles