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

Method _libs_with_msvc_and_fortran

numpy/distutils/command/build_ext.py:674–733  ·  view source on GitHub ↗
(self, fcompiler, c_libraries,
                                    c_library_dirs)

Source from the content-addressed store, hash-verified

672 return objects, libraries
673
674 def _libs_with_msvc_and_fortran(self, fcompiler, c_libraries,
675 c_library_dirs):
676 if fcompiler is None:
677 return
678
679 for libname in c_libraries:
680 if libname.startswith('msvc'):
681 continue
682 fileexists = False
683 for libdir in c_library_dirs or []:
684 libfile = os.path.join(libdir, '%s.lib' % (libname))
685 if os.path.isfile(libfile):
686 fileexists = True
687 break
688 if fileexists:
689 continue
690 # make g77-compiled static libs available to MSVC
691 fileexists = False
692 for libdir in c_library_dirs:
693 libfile = os.path.join(libdir, 'lib%s.a' % (libname))
694 if os.path.isfile(libfile):
695 # copy libname.a file to name.lib so that MSVC linker
696 # can find it
697 libfile2 = os.path.join(self.build_temp, libname + '.lib')
698 copy_file(libfile, libfile2)
699 if self.build_temp not in c_library_dirs:
700 c_library_dirs.append(self.build_temp)
701 fileexists = True
702 break
703 if fileexists:
704 continue
705 log.warn('could not find library %r in directories %s'
706 % (libname, c_library_dirs))
707
708 # Always use system linker when using MSVC compiler.
709 f_lib_dirs = []
710 for dir in fcompiler.library_dirs:
711 # correct path when compiling in Cygwin but with normal Win
712 # Python
713 if dir.startswith('/usr/lib'):
714 try:
715 dir = subprocess.check_output(['cygpath', '-w', dir])
716 except (OSError, subprocess.CalledProcessError):
717 pass
718 else:
719 dir = filepath_from_subprocess_output(dir)
720 f_lib_dirs.append(dir)
721 c_library_dirs.extend(f_lib_dirs)
722
723 # make g77-compiled static libs available to MSVC
724 for lib in fcompiler.libraries:
725 if not lib.startswith('msvc'):
726 c_libraries.append(lib)
727 p = combine_paths(f_lib_dirs, 'lib' + lib + '.a')
728 if p:
729 dst_name = os.path.join(self.build_temp, lib + '.lib')
730 if not os.path.isfile(dst_name):
731 copy_file(p[0], dst_name)

Callers 1

build_extensionMethod · 0.95

Calls 6

combine_pathsFunction · 0.90
startswithMethod · 0.80
warnMethod · 0.80
joinMethod · 0.45
check_outputMethod · 0.45

Tested by

no test coverage detected