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