Mercurial > repos > bcclaywell > argo_navis
comparison venv/lib/python2.7/site-packages/setuptools/site-patch.py @ 0:d67268158946 draft
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
| author | bcclaywell | 
|---|---|
| date | Mon, 12 Oct 2015 17:43:33 -0400 | 
| parents | |
| children | 
   comparison
  equal
  deleted
  inserted
  replaced
| -1:000000000000 | 0:d67268158946 | 
|---|---|
| 1 def __boot(): | |
| 2 import sys | |
| 3 import os | |
| 4 PYTHONPATH = os.environ.get('PYTHONPATH') | |
| 5 if PYTHONPATH is None or (sys.platform=='win32' and not PYTHONPATH): | |
| 6 PYTHONPATH = [] | |
| 7 else: | |
| 8 PYTHONPATH = PYTHONPATH.split(os.pathsep) | |
| 9 | |
| 10 pic = getattr(sys,'path_importer_cache',{}) | |
| 11 stdpath = sys.path[len(PYTHONPATH):] | |
| 12 mydir = os.path.dirname(__file__) | |
| 13 #print "searching",stdpath,sys.path | |
| 14 | |
| 15 for item in stdpath: | |
| 16 if item==mydir or not item: | |
| 17 continue # skip if current dir. on Windows, or my own directory | |
| 18 importer = pic.get(item) | |
| 19 if importer is not None: | |
| 20 loader = importer.find_module('site') | |
| 21 if loader is not None: | |
| 22 # This should actually reload the current module | |
| 23 loader.load_module('site') | |
| 24 break | |
| 25 else: | |
| 26 try: | |
| 27 import imp # Avoid import loop in Python >= 3.3 | |
| 28 stream, path, descr = imp.find_module('site',[item]) | |
| 29 except ImportError: | |
| 30 continue | |
| 31 if stream is None: | |
| 32 continue | |
| 33 try: | |
| 34 # This should actually reload the current module | |
| 35 imp.load_module('site',stream,path,descr) | |
| 36 finally: | |
| 37 stream.close() | |
| 38 break | |
| 39 else: | |
| 40 raise ImportError("Couldn't find the real 'site' module") | |
| 41 | |
| 42 #print "loaded", __file__ | |
| 43 | |
| 44 known_paths = dict([(makepath(item)[1],1) for item in sys.path]) # 2.2 comp | |
| 45 | |
| 46 oldpos = getattr(sys,'__egginsert',0) # save old insertion position | |
| 47 sys.__egginsert = 0 # and reset the current one | |
| 48 | |
| 49 for item in PYTHONPATH: | |
| 50 addsitedir(item) | |
| 51 | |
| 52 sys.__egginsert += oldpos # restore effective old position | |
| 53 | |
| 54 d, nd = makepath(stdpath[0]) | |
| 55 insert_at = None | |
| 56 new_path = [] | |
| 57 | |
| 58 for item in sys.path: | |
| 59 p, np = makepath(item) | |
| 60 | |
| 61 if np==nd and insert_at is None: | |
| 62 # We've hit the first 'system' path entry, so added entries go here | |
| 63 insert_at = len(new_path) | |
| 64 | |
| 65 if np in known_paths or insert_at is None: | |
| 66 new_path.append(item) | |
| 67 else: | |
| 68 # new path after the insert point, back-insert it | |
| 69 new_path.insert(insert_at, item) | |
| 70 insert_at += 1 | |
| 71 | |
| 72 sys.path[:] = new_path | |
| 73 | |
| 74 if __name__=='site': | |
| 75 __boot() | |
| 76 del __boot | 
