def__boot():importsys,imp,os,os.pathPYTHONPATH=os.environ.get('PYTHONPATH')ifPYTHONPATHisNoneor(sys.platform=='win32'andnotPYTHONPATH):PYTHONPATH=[]else:PYTHONPATH=PYTHONPATH.split(os.pathsep)pic=getattr(sys,'path_importer_cache',{})stdpath=sys.path[len(PYTHONPATH):]mydir=os.path.dirname(__file__)#print "searching",stdpath,sys.pathforiteminstdpath:ifitem==mydirornotitem:continue# skip if current dir. on Windows, or my own directoryimporter=pic.get(item)ifimporterisnotNone:loader=importer.find_module('site')ifloaderisnotNone:# This should actually reload the current moduleloader.load_module('site')breakelse:try:stream,path,descr=imp.find_module('site',[item])exceptImportError:continueifstreamisNone:continuetry:# This should actually reload the current moduleimp.load_module('site',stream,path,descr)finally:stream.close()breakelse:raiseImportError("Couldn't find the real 'site' module")#print "loaded", __file__known_paths=dict([(makepath(item)[1],1)foriteminsys.path])# 2.2 compoldpos=getattr(sys,'__egginsert',0)# save old insertion positionsys.__egginsert=0# and reset the current oneforiteminPYTHONPATH:addsitedir(item)sys.__egginsert+=oldpos# restore effective old positiond,nd=makepath(stdpath[0])insert_at=Nonenew_path=[]foriteminsys.path:p,np=makepath(item)ifnp==ndandinsert_atisNone:# We've hit the first 'system' path entry, so added entries go hereinsert_at=len(new_path)ifnpinknown_pathsorinsert_atisNone:new_path.append(item)else:# new path after the insert point, back-insert itnew_path.insert(insert_at,item)insert_at+=1sys.path[:]=new_pathif__name__=='site':__boot()del__boot