diff options
Diffstat (limited to 'numpy/distutils/command')
-rw-r--r-- | numpy/distutils/command/build_clib.py | 38 | ||||
-rw-r--r-- | numpy/distutils/command/build_ext.py | 40 |
2 files changed, 28 insertions, 50 deletions
diff --git a/numpy/distutils/command/build_clib.py b/numpy/distutils/command/build_clib.py index f53c77ffb..51163c729 100644 --- a/numpy/distutils/command/build_clib.py +++ b/numpy/distutils/command/build_clib.py @@ -21,13 +21,11 @@ class build_clib(old_build_clib): def initialize_options(self): old_build_clib.initialize_options(self) self.fcompiler = None - return def finalize_options(self): old_build_clib.finalize_options(self) self.set_undefined_options('build_ext', ('fcompiler', 'fcompiler')) - return def have_f_sources(self): for (lib_name, build_info) in self.libraries: @@ -84,7 +82,6 @@ class build_clib(old_build_clib): self.fcompiler.show_customization() self.build_libraries(self.libraries) - return def get_source_files(self): self.check_library_list(self.libraries) @@ -94,8 +91,6 @@ class build_clib(old_build_clib): return filenames def build_libraries(self, libraries): - - for (lib_name, build_info) in libraries: # default compilers compiler = self.compiler @@ -109,8 +104,6 @@ class build_clib(old_build_clib): "a list of source filenames") % lib_name sources = list(sources) - - lib_file = compiler.library_filename(lib_name, output_dir=self.build_clib) @@ -124,9 +117,9 @@ class build_clib(old_build_clib): config_fc = build_info.get('config_fc',{}) if fcompiler is not None and config_fc: - log.info('using setup script specified config_fc '\ + log.info('using additional config_fc from setup script '\ 'for fortran compiler: %s' \ - % (config_fc)) + % (config_fc,)) from numpy.distutils.fcompiler import new_fcompiler requiref90 = build_info.get('language','c')=='f90' fcompiler = new_fcompiler(compiler=self.fcompiler.compiler_type, @@ -134,7 +127,10 @@ class build_clib(old_build_clib): dry_run=self.dry_run, force=self.force, requiref90=requiref90) - fcompiler.customize(config_fc) + dist = self.distribution + base_config_fc = dist.get_option_dict('config_fc').copy() + base_config_fc.update(config_fc) + fcompiler.customize(base_config_fc) macros = build_info.get('macros') include_dirs = build_info.get('include_dirs') @@ -165,19 +161,15 @@ class build_clib(old_build_clib): if cxx_sources: log.info("compiling C++ sources") - old_compiler = self.compiler.compiler_so[0] - self.compiler.compiler_so[0] = self.compiler.compiler_cxx[0] - - cxx_objects = compiler.compile(cxx_sources, - output_dir=self.build_temp, - macros=macros, - include_dirs=include_dirs, - debug=self.debug, - extra_postargs=extra_postargs) + cxx_compiler = compiler.cxx_compiler() + cxx_objects = cxx_compiler.compile(cxx_sources, + output_dir=self.build_temp, + macros=macros, + include_dirs=include_dirs, + debug=self.debug, + extra_postargs=extra_postargs) objects.extend(cxx_objects) - self.compiler.compiler_so[0] = old_compiler - if f_sources: log.info("compiling Fortran sources") f_objects = fcompiler.compile(f_sources, @@ -193,10 +185,8 @@ class build_clib(old_build_clib): debug=self.debug) clib_libraries = build_info.get('libraries',[]) - for lname,binfo in libraries: + for lname, binfo in libraries: if lname in clib_libraries: clib_libraries.extend(binfo[1].get('libraries',[])) if clib_libraries: build_info['libraries'] = clib_libraries - - return diff --git a/numpy/distutils/command/build_ext.py b/numpy/distutils/command/build_ext.py index 0e804e19e..466462c56 100644 --- a/numpy/distutils/command/build_ext.py +++ b/numpy/distutils/command/build_ext.py @@ -201,17 +201,15 @@ class build_ext (old_build_ext): if cxx_sources: log.info("compiling C++ sources") - old_compiler = self.compiler.compiler_so[0] - self.compiler.compiler_so[0] = self.compiler.compiler_cxx[0] + cxx_compiler = self.compiler.cxx_compiler() - c_objects += self.compiler.compile(cxx_sources, + c_objects += cxx_compiler.compile(cxx_sources, output_dir=output_dir, macros=macros, include_dirs=include_dirs, debug=self.debug, extra_postargs=extra_args, **kws) - self.compiler.compiler_so[0] = old_compiler check_for_f90_modules = not not fmodule_sources @@ -272,10 +270,7 @@ class build_ext (old_build_ext): objects.extend(ext.extra_objects) extra_args = ext.extra_link_args or [] - try: - old_linker_so_0 = self.compiler.linker_so[0] - except: - pass + linker = self.compiler.link_shared_object use_fortran_linker = getattr(ext,'language','c') in ['f77','f90'] \ and self.fcompiler is not None @@ -308,37 +303,30 @@ class build_ext (old_build_ext): if cxx_sources: # XXX: Which linker should be used, Fortran or C++? log.warn('mixing Fortran and C++ is untested') - link = self.fcompiler.link_shared_object + linker = self.fcompiler.link_shared_object language = ext.language or self.fcompiler.detect_language(f_sources) else: - link = self.compiler.link_shared_object + linker = self.compiler.link_shared_object if sys.version[:3]>='2.3': language = ext.language or self.compiler.detect_language(sources) else: language = ext.language if cxx_sources: - self.compiler.linker_so[0] = self.compiler.compiler_cxx[0] + linker = self.compiler.cxx_compiler().link_shared_object if sys.version[:3]>='2.3': kws = {'target_lang':language} else: kws = {} - link(objects, ext_filename, - libraries=self.get_libraries(ext) + c_libraries + clib_libraries, - library_dirs=ext.library_dirs + c_library_dirs + clib_library_dirs, - runtime_library_dirs=ext.runtime_library_dirs, - extra_postargs=extra_args, - export_symbols=self.get_export_symbols(ext), - debug=self.debug, - build_temp=self.build_temp,**kws) - - try: - self.compiler.linker_so[0] = old_linker_so_0 - except: - pass - - return + linker(objects, ext_filename, + libraries=self.get_libraries(ext) + c_libraries + clib_libraries, + library_dirs=ext.library_dirs+c_library_dirs+clib_library_dirs, + runtime_library_dirs=ext.runtime_library_dirs, + extra_postargs=extra_args, + export_symbols=self.get_export_symbols(ext), + debug=self.debug, + build_temp=self.build_temp,**kws) def _libs_with_msvc_and_fortran(self, c_libraries, c_library_dirs): # Always use system linker when using MSVC compiler. |