Created
March 3, 2012 00:11
-
-
Save DrSkippy/1962761 to your computer and use it in GitHub Desktop.
Python easy_install package list and update
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
#!/usr/bin/env python | |
from setuptools.command.easy_install import main as install | |
from pkg_resources import Environment, working_set | |
import sys | |
# From | |
# http://pyinsci.blogspot.com/2007/07/updating-all-your-eggs.html | |
# | |
#Packages managed by setuptools | |
plist = [dist.key for dist in working_set] | |
def autoUp(): | |
for p in Environment(): | |
try: | |
install(['-U', '-v']+[p]) | |
except: | |
print "Update of %s failed!"%p | |
print "Done!" | |
def stepUp(): | |
for p in Environment(): | |
a = raw_input("updating %s, confirm? (y/n)"%p) | |
if a =='y': | |
try: | |
install(['-U']+[p]) | |
except: | |
print "Update of %s failed!"%p | |
else: | |
print "Skipping %s"%p | |
print "Done!" | |
print "You have %s packages currently managed through Easy_install"%len(plist) | |
print plist | |
ans = raw_input('Do you want to update them... (N)ot at all, (O)ne-by-one, (A)utomatically (without prompting)') | |
if ans == 'N': | |
sys.exit() | |
elif ans == 'O': | |
stepUp() | |
elif ans == 'A': | |
autoUp() | |
else: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment