How to programmatically access a Python package's dependencies?
Question: I am trying to access a PyPI package's dependencies (i.e. its install_requires
metadata). This information does not seem to be available from either the JSON
or XMLRPC APIs. The [documentation](https://wiki.python.org/moin/PyPIXmlRpc)
for the XMLRPC API says that the `release_data` method should return a dict
with a `requires` key, but I am not seeing 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\'s 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 another way I can get a package's dependencies without installing the
package?


Answer: The only way I know to extract dependencies from pypi is to:

  1. Download package and extract it to some directory
  2. Run `setup.py egg_info`
  3. Parse generated `requires.txt`

for flask 0.10.1 it will be

    
    
    Werkzeug>=0.7
    Jinja2>=2.4
    itsdangerous>=0.21
    

