#!/usr/bin/python """ Code under GPL, (c) Luc Stepniewski Using instructions from Bill Woodward, on http://groups.google.com/group/turbogears/msg/24bf35000bfe01f4 Will reinstall all the dependencies of TurboGears on your system. ATTENTION: This code will erase some of your modules, *please* pay attention to what this code does, You are responsible for executing this code. I am in no way responsible in the eventual case where this code erases all of your hard disk. """ import os, glob, shutil, sys packageList = ['CherryPy-*', 'cherry*', 'FormEncode-*', 'SQLObject-*', 'kid-*', 'TestGear-*', 'nose-*', 'PasteDeploy-*', 'PasteScript-*', 'PyProtocols-*', 'RuleDispatch-*', 'TurboGears-*'] # Order of thirdPartyDir is important thirdPartyDir = ['formencode', 'kid', 'sqlobject', 'cherrypy'] pythonPath = '/usr/lib/python2.4/site-packages' # Change this to the location of your svn repository turboGearsTrunk = '/home/foobar/work/SVN/TURBOGEARS/trunk' ######### Nothing to be changed after this line ############################ if not os.path.exists(turboGearsTrunk): print "The specified path (%s) does not exist" % turboGearsTrunk print "You have to set the path to your local svn in the variable turboGearsTrunk" sys.exit(1) print "will remove the following directories from your system:" print [glob.glob(os.path.join(pythonPath,package)) for package in packageList] print "Are you sure? [y/N]" if raw_input() != 'y': sys.exit(1) # Fist, remove the packages for package in packageList: for fileNDir in glob.glob(os.path.join(pythonPath,package)): print "Will remove directory",fileNDir if os.path.isdir(fileNDir): shutil.rmtree(fileNDir) else: os.remove(fileNDir) # Remove TurboGears.egg-info try: shutil.rmtree(os.path.join(turboGearsTrunk,'TurboGears.egg-info')) except: pass # Reinstall the TurboGears.egg-info directory os.chdir(turboGearsTrunk) os.system('python setup.py egg_info') # Install all the third-party packages thirdpartyBaseDir = os.path.join(turboGearsTrunk,'thirdparty') for p in thirdPartyDir: chemin = os.path.join(thirdpartyBaseDir, p) if os.path.exists(os.path.join(chemin,'setup.py')): print "Will install package", p os.chdir(chemin) if p == 'cherrypy': f = open(os.path.join(chemin,'setup.py'),'r') data = f.readlines() f.close() f = open(os.path.join(chemin,'setup.py'),'w') for line in data: if line == 'from distutils.core import setup\n': f.write('from setuptools import setup\n') else: f.write(line) f.close() # Install it os.system('python setup.py install') # Install RuleDispatch from PJE's website, as it is not yet found on CheeseShop os.system('easy_install -Zf http://peak.telecommunity.com/snapshots/ RuleDispatch') # Finally install TurboGears itself os.chdir(turboGearsTrunk) os.system('python setup.py install')