def load_dependencies(req, history=None):
if history is None:<EOL><INDENT>history = set()<EOL><DEDENT>dist = pkg_resources.get_distribution(req)<EOL>spec = dict(<EOL>requirement=str(req),<EOL>resolved=str(dist),<EOL>)<EOL>if req not in history:<EOL><INDENT>history.add(req)<EOL>extras = parse_extras(req)<EOL>depends = [<EOL>load_dependencies(dep, history=history)<EOL>for dep in dist.requires(extras=extras)<EOL>]<EOL>if depends:<EOL><INDENT>spec.update(depends=depends)<EOL><DEDENT><DEDENT>return spec<EOL>
Load the dependency tree as a Python object tree,
suitable for JSON serialization.

>>> deps = load_dependencies('jaraco.packaging')
>>> import json
>>> doc = json.dumps(deps)