diff options
author | Pearu Peterson <pearu.peterson@gmail.com> | 2007-05-19 19:44:42 +0000 |
---|---|---|
committer | Pearu Peterson <pearu.peterson@gmail.com> | 2007-05-19 19:44:42 +0000 |
commit | 02df1be4949d7583a662bca6c0fe61d7afc334a7 (patch) | |
tree | ad1a1e051c32810640d9c8613bdad50275ea0de6 /numpy/distutils | |
parent | 0168bce06a2d0266a2d337a2f587ec1327d19fb4 (diff) | |
download | numpy-02df1be4949d7583a662bca6c0fe61d7afc334a7.tar.gz |
Clean up and completed (hopefully) MSVC support.
Diffstat (limited to 'numpy/distutils')
-rw-r--r-- | numpy/distutils/ccompiler.py | 1 | ||||
-rw-r--r-- | numpy/distutils/command/build_ext.py | 36 | ||||
-rw-r--r-- | numpy/distutils/command/config.py | 14 |
3 files changed, 42 insertions, 9 deletions
diff --git a/numpy/distutils/ccompiler.py b/numpy/distutils/ccompiler.py index 059fd0ec4..b3c131316 100644 --- a/numpy/distutils/ccompiler.py +++ b/numpy/distutils/ccompiler.py @@ -288,6 +288,7 @@ def CCompiler_get_version(self, force=0, ok_status=[0]): replace_method(CCompiler, 'get_version', CCompiler_get_version) def CCompiler_cxx_compiler(self): + if self.compiler_type=='msvc': return self cxx = copy(self) cxx.compiler_so = [cxx.compiler_cxx[0]] + cxx.compiler_so[1:] if sys.platform.startswith('aix') and 'ld_so_aix' in cxx.linker_so[0]: diff --git a/numpy/distutils/command/build_ext.py b/numpy/distutils/command/build_ext.py index 6cc7ce5bd..93bb3464a 100644 --- a/numpy/distutils/command/build_ext.py +++ b/numpy/distutils/command/build_ext.py @@ -391,6 +391,33 @@ class build_ext (old_build_ext): def _libs_with_msvc_and_fortran(self, fcompiler, c_libraries, c_library_dirs): if fcompiler is None: return + + for libname in c_libraries: + if libname.startswith('msvc'): continue + fileexists = False + for libdir in c_library_dirs or []: + libfile = os.path.join(libdir,'%s.lib' % (libname)) + if os.path.isfile(libfile): + fileexists = True + break + if fileexists: continue + # make g77-compiled static libs available to MSVC + fileexists = False + for libdir in c_library_dirs: + libfile = os.path.join(libdir,'lib%s.a' % (libname)) + if os.path.isfile(libfile): + # copy libname.a file to name.lib so that MSVC linker + # can find it + libfile2 = os.path.join(self.build_temp, libname + '.lib') + copy_file(libfile, libfile2) + if self.build_temp not in c_library_dirs: + c_library_dirs.append(self.build_temp) + fileexists = True + break + if fileexists: continue + log.warn('could not find library %r in directories %s' \ + % (libname, c_library_dirs)) + # Always use system linker when using MSVC compiler. f_lib_dirs = [] for dir in fcompiler.library_dirs: @@ -404,17 +431,16 @@ class build_ext (old_build_ext): c_library_dirs.extend(f_lib_dirs) # make g77-compiled static libs available to MSVC - lib_added = False for lib in fcompiler.libraries: - if not lib.startswith('msvcr'): + if not lib.startswith('msvc'): c_libraries.append(lib) p = combine_paths(f_lib_dirs, 'lib' + lib + '.a') if p: dst_name = os.path.join(self.build_temp, lib + '.lib') - copy_file(p[0], dst_name) - if not lib_added: + if not os.path.isfile(dst_name): + copy_file(p[0], dst_name) + if self.build_temp not in c_library_dirs: c_library_dirs.append(self.build_temp) - lib_added = True return def get_source_files (self): diff --git a/numpy/distutils/command/config.py b/numpy/distutils/command/config.py index 0d13d8e53..090c639a3 100644 --- a/numpy/distutils/command/config.py +++ b/numpy/distutils/command/config.py @@ -72,23 +72,29 @@ class config(old_config): if libname not in libraries: libraries.append(libname) for libname in libraries: - if libname.startswith('msvcr'): continue + if libname.startswith('msvc'): continue fileexists = False for libdir in library_dirs or []: libfile = os.path.join(libdir,'%s.lib' % (libname)) if os.path.isfile(libfile): fileexists = True break - if fileexists: - continue + if fileexists: continue # make g77-compiled static libs available to MSVC + fileexists = False for libdir in library_dirs: libfile = os.path.join(libdir,'lib%s.a' % (libname)) if os.path.isfile(libfile): # copy libname.a file to name.lib so that MSVC linker # can find it - copy_file(libfile, os.path.join(libdir,'%s.lib' % (libname))) + libfile2 = os.path.join(libdir,'%s.lib' % (libname)) + copy_file(libfile, libfile2) + self.temp_files.append(libfile2) + fileexists = True break + if fileexists: continue + log.warn('could not find library %r in directories %s' \ + % (libname, library_dirs)) return self._wrap_method(old_config._link,lang, (body, headers, include_dirs, libraries, library_dirs, lang)) |