()
| 180 | |
| 181 | |
| 182 | def find_python_dll(): |
| 183 | # We can't do much here: |
| 184 | # - find it in the virtualenv (sys.prefix) |
| 185 | # - find it in python main dir (sys.base_prefix, if in a virtualenv) |
| 186 | # - in system32, |
| 187 | # - ortherwise (Sxs), I don't know how to get it. |
| 188 | stems = [sys.prefix] |
| 189 | if sys.base_prefix != sys.prefix: |
| 190 | stems.append(sys.base_prefix) |
| 191 | |
| 192 | sub_dirs = ['', 'lib', 'bin'] |
| 193 | # generate possible combinations of directory trees and sub-directories |
| 194 | lib_dirs = [] |
| 195 | for stem in stems: |
| 196 | for folder in sub_dirs: |
| 197 | lib_dirs.append(os.path.join(stem, folder)) |
| 198 | |
| 199 | # add system directory as well |
| 200 | if 'SYSTEMROOT' in os.environ: |
| 201 | lib_dirs.append(os.path.join(os.environ['SYSTEMROOT'], 'System32')) |
| 202 | |
| 203 | # search in the file system for possible candidates |
| 204 | major_version, minor_version = tuple(sys.version_info[:2]) |
| 205 | implementation = sys.implementation.name |
| 206 | if implementation == 'cpython': |
| 207 | dllname = f'python{major_version}{minor_version}.dll' |
| 208 | elif implementation == 'pypy': |
| 209 | dllname = f'libpypy{major_version}.{minor_version}-c.dll' |
| 210 | else: |
| 211 | dllname = f'Unknown platform {implementation}' |
| 212 | print("Looking for %s" % dllname) |
| 213 | for folder in lib_dirs: |
| 214 | dll = os.path.join(folder, dllname) |
| 215 | if os.path.exists(dll): |
| 216 | return dll |
| 217 | |
| 218 | raise ValueError("%s not found in %s" % (dllname, lib_dirs)) |
| 219 | |
| 220 | def dump_table(dll): |
| 221 | st = subprocess.check_output(["objdump.exe", "-p", dll]) |
no test coverage detected