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