Last active
August 29, 2015 14:02
-
-
Save regebro/c100b67779c758654f20 to your computer and use it in GitHub Desktop.
Prints the requirements of the current working set of packages. Requires setuptools.
This file contains 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
# -*- coding:utf-8 -*- | |
import pkg_resources | |
projects = set() | |
def print_requirements(distribution, lvl=-1): | |
lvl += 1 | |
dname = distribution.project_name.lower() | |
if dname in projects: | |
return | |
projects.add(dname) | |
print("Level %s: %2i" % (lvl, distribution.project_name)) | |
for requirement in distribution.requires(): | |
distro = pkg_resources.working_set.find(requirement) | |
print_requirements(distro, lvl) | |
if __name__ == '__main__': | |
for distribution in pkg_resources.working_set: | |
print_requirements(distribution) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
plz add some descriptions ... especially, for nobies like me :)