Check if an import library for the Python runtime already exists.
()
| 351 | raise ValueError("Unhandled arch %s" % arch) |
| 352 | |
| 353 | def _check_for_import_lib(): |
| 354 | """Check if an import library for the Python runtime already exists.""" |
| 355 | major_version, minor_version = tuple(sys.version_info[:2]) |
| 356 | |
| 357 | # patterns for the file name of the library itself |
| 358 | patterns = ['libpython%d%d.a', |
| 359 | 'libpython%d%d.dll.a', |
| 360 | 'libpython%d.%d.dll.a'] |
| 361 | |
| 362 | # directory trees that may contain the library |
| 363 | stems = [sys.prefix] |
| 364 | if hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix: |
| 365 | stems.append(sys.base_prefix) |
| 366 | elif hasattr(sys, 'real_prefix') and sys.real_prefix != sys.prefix: |
| 367 | stems.append(sys.real_prefix) |
| 368 | |
| 369 | # possible subdirectories within those trees where it is placed |
| 370 | sub_dirs = ['libs', 'lib'] |
| 371 | |
| 372 | # generate a list of candidate locations |
| 373 | candidates = [] |
| 374 | for pat in patterns: |
| 375 | filename = pat % (major_version, minor_version) |
| 376 | for stem_dir in stems: |
| 377 | for folder in sub_dirs: |
| 378 | candidates.append(os.path.join(stem_dir, folder, filename)) |
| 379 | |
| 380 | # test the filesystem to see if we can find any of these |
| 381 | for fullname in candidates: |
| 382 | if os.path.isfile(fullname): |
| 383 | # already exists, in location given |
| 384 | return (True, fullname) |
| 385 | |
| 386 | # needs to be built, preferred location given first |
| 387 | return (False, candidates[0]) |
| 388 | |
| 389 | def _build_import_library_amd64(): |
| 390 | out_exists, out_file = _check_for_import_lib() |
no test coverage detected