Created
January 24, 2013 05:14
-
-
Save jdunck/4617846 to your computer and use it in GitHub Desktop.
dirty groping for required module versions of an arbitrary python codebase.
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
| find . -iname '*.py' -type f | xargs grep 'import' | awk -F':' '{print $2}' | sed -E 's/ +$//g' | sed -E 's/^[ :tab:]+//g' | sort| uniq | python -c ' | |
| import sys | |
| for line in sys.stdin.readlines(): | |
| try: | |
| exec line | |
| except: | |
| print >> sys.stderr, "failed to exec %s" % line | |
| def ver(mod): | |
| for attempt in ["__version__", "VERSION", "__VERSION__"]: | |
| if hasattr(mod, attempt): | |
| return getattr(mod, attempt) | |
| return None | |
| for mod in sys.modules.keys(): | |
| this_ver = ver(sys.modules[mod]) | |
| if this_ver is None: | |
| print >>sys.stderr, mod, this_ver | |
| else: | |
| print mod, this_ver | |
| ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment