Skip to content

Instantly share code, notes, and snippets.

@papaben
Last active September 14, 2016 21:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save papaben/4cf9d7a37259ab2a2a9dab1194a62788 to your computer and use it in GitHub Desktop.
Save papaben/4cf9d7a37259ab2a2a9dab1194a62788 to your computer and use it in GitHub Desktop.
Figure out which of your pip requirements depend on another
#! /usr/bin/env python
# Be sure to execute this with your virtualenv activated
from pip._vendor import pkg_resources
import sys
# The name of the pip package
# TODO error checking (when this is no longer a gist)
dependency = sys.argv[1]
for p in pkg_resources.working_set.by_key.values():
for pr in p.requires():
if str(pr).startswith(dependency):
print("Dependency for {} in {}".format(dependency, p))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment