MCPcopy Create free account
hub / github.com/numpy/numpy / _build_import_library_x86

Function _build_import_library_x86

numpy/distutils/mingw32ccompiler.py:409–456  ·  view source on GitHub ↗

Build the import libraries for Mingw32-gcc on Windows

()

Source from the content-addressed store, hash-verified

407 subprocess.check_call(cmd)
408
409def _build_import_library_x86():
410 """ Build the import libraries for Mingw32-gcc on Windows
411 """
412 out_exists, out_file = _check_for_import_lib()
413 if out_exists:
414 log.debug('Skip building import library: "%s" exists', out_file)
415 return
416
417 lib_name = "python%d%d.lib" % tuple(sys.version_info[:2])
418 lib_file = os.path.join(sys.prefix, 'libs', lib_name)
419 if not os.path.isfile(lib_file):
420 # didn't find library file in virtualenv, try base distribution, too,
421 # and use that instead if found there. for Python 2.7 venvs, the base
422 # directory is in attribute real_prefix instead of base_prefix.
423 if hasattr(sys, 'base_prefix'):
424 base_lib = os.path.join(sys.base_prefix, 'libs', lib_name)
425 elif hasattr(sys, 'real_prefix'):
426 base_lib = os.path.join(sys.real_prefix, 'libs', lib_name)
427 else:
428 base_lib = '' # os.path.isfile('') == False
429
430 if os.path.isfile(base_lib):
431 lib_file = base_lib
432 else:
433 log.warn('Cannot build import library: "%s" not found', lib_file)
434 return
435 log.info('Building import library (ARCH=x86): "%s"', out_file)
436
437 from numpy.distutils import lib2def
438
439 def_name = "python%d%d.def" % tuple(sys.version_info[:2])
440 def_file = os.path.join(sys.prefix, 'libs', def_name)
441 nm_output = lib2def.getnm(
442 lib2def.DEFAULT_NM + [lib_file], shell=False)
443 dlist, flist = lib2def.parse_nm(nm_output)
444 with open(def_file, 'w') as fid:
445 lib2def.output_def(dlist, flist, lib2def.DEF_HEADER, fid)
446
447 dll_name = find_python_dll ()
448
449 cmd = ["dlltool",
450 "--dllname", dll_name,
451 "--def", def_file,
452 "--output-lib", out_file]
453 status = subprocess.check_output(cmd)
454 if status:
455 log.warn('Failed to build import library for gcc. Linking will fail.')
456 return
457
458#=====================================
459# Dealing with Visual Studio MANIFESTS

Callers 1

build_import_libraryFunction · 0.85

Calls 7

_check_for_import_libFunction · 0.85
openFunction · 0.85
find_python_dllFunction · 0.85
warnMethod · 0.80
infoMethod · 0.80
joinMethod · 0.45
check_outputMethod · 0.45

Tested by

no test coverage detected