Skip to content

Instantly share code, notes, and snippets.

@regebro
Last active August 29, 2015 14:02
Show Gist options
  • Save regebro/c100b67779c758654f20 to your computer and use it in GitHub Desktop.
Save regebro/c100b67779c758654f20 to your computer and use it in GitHub Desktop.
Prints the requirements of the current working set of packages. Requires setuptools.
# -*- 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)
@kmonsoor
Copy link

kmonsoor commented Jun 3, 2014

plz add some descriptions ... especially, for nobies like me :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment