I need something like the following:
pip showrequirements tensorflow
This would return something that allows me to parse the names of the required packages and the required versions:
astor>0.6, tensorboard>1.0.11, etc.
pip is getting this information in some form during the install and download command. I can see where it's happening in the code... but before I hack my way to using pip's internal code, is there any easy API or existing library that can do this?
edit: I cannot install the package to see this, so pip show won't work. One (hacky) solution is parsing the output of pip download.
Thanks!
Pip Check Command – Check Python Dependencies After Installation. Because pip doesn't currently address dependency issues on installation, the pip check command option can be used to verify that dependencies have been installed properly in your project. For example: $ pip check No broken requirements found.
pypi-mirror is a small script to generate a partial PyPI mirror. It relies on pip to do the most difficult part of the job (downloading a package and its dependencies).
A yanked release is a release that is always ignored by an installer, unless it is the only release that matches a version specifier (using either == or === ).
pip show <package_name>
will list the dependencies in the "Requires" section. See documentation.
Edit:
pip show
only works for installed packages. For uninstalled packages, PyPI has a JSON API.
For example:
import json
import requests
package_name = 'tensorflow'
url = 'https://pypi.python.org/pypi/' + str(package_name) + '/json'
data = requests.get(url).json()
print(data['info']['requires_dist'])
So there used to be a --no-install
flag in older version of pip, but no longer. pip show
will show you the "Requires" property, but only for packages installed in your environment (system or in your venv), where it seems you wanna check out requirements before you install. So, sadly, I think there's not a nice way to accomplish what you're looking for.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With