Set all module __file__ and __cached__ attributes to an absolute path
()
| 104 | |
| 105 | |
| 106 | def abs_paths(): |
| 107 | """Set all module __file__ and __cached__ attributes to an absolute path""" |
| 108 | for m in set(sys.modules.values()): |
| 109 | loader_module = None |
| 110 | try: |
| 111 | loader_module = m.__loader__.__module__ |
| 112 | except AttributeError: |
| 113 | try: |
| 114 | loader_module = m.__spec__.loader.__module__ |
| 115 | except AttributeError: |
| 116 | pass |
| 117 | if loader_module not in {'_frozen_importlib', '_frozen_importlib_external'}: |
| 118 | continue # don't mess with a PEP 302-supplied __file__ |
| 119 | try: |
| 120 | m.__file__ = os.path.abspath(m.__file__) |
| 121 | except (AttributeError, OSError, TypeError): |
| 122 | pass |
| 123 | try: |
| 124 | m.__cached__ = os.path.abspath(m.__cached__) |
| 125 | except (AttributeError, OSError, TypeError): |
| 126 | pass |
| 127 | |
| 128 | |
| 129 | def removeduppaths(): |