Created
May 6, 2014 10:57
-
-
Save jbub/6ac4524f2d5ae3bb6571 to your computer and use it in GitHub Desktop.
Returns a list of all packages, each package has info about which package requires it and also its requirements.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import pkg_resources | |
packages = {} | |
for pkg in pkg_resources.working_set: | |
packages[pkg.key.lower()] = { | |
'requires': [req.project_name.lower() for req in pkg.requires()], | |
'required_by': [], | |
} | |
for pkg, data in packages.items(): | |
for req in data['requires']: | |
packages[req]['required_by'].append(pkg) | |
print json.dumps(packages, indent=4) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment