diff options
author | cookedm <cookedm@localhost> | 2007-05-21 13:15:45 +0000 |
---|---|---|
committer | cookedm <cookedm@localhost> | 2007-05-21 13:15:45 +0000 |
commit | 6ac33ee4e12b78b164a05046f7e029681f0e09a3 (patch) | |
tree | d5a4b6f27ff9e3d596bafdb4c93953d5431d0a40 /command/config_compiler.py | |
parent | b93a94b5e15d229e253353289c571c7a3142a642 (diff) | |
download | numpy-6ac33ee4e12b78b164a05046f7e029681f0e09a3.tar.gz |
[distutils-revamp] Merged revisions 3769-3794 via svnmerge from
http://svn.scipy.org/svn/numpy/trunk/numpy/distutils
........
r3775 | pearu | 2007-05-18 10:32:33 -0400 (Fri, 18 May 2007) | 1 line
build_src: introduced --swig and other related options (as in std distutils build_ext command), use --f2py-opts instead of --f2pyflags, improved error messages.
........
r3776 | pearu | 2007-05-18 12:41:44 -0400 (Fri, 18 May 2007) | 1 line
Extension modules and libraries are built with suitable compilers/linkers. Improved failure handling.
........
r3779 | pearu | 2007-05-18 13:33:15 -0400 (Fri, 18 May 2007) | 1 line
Fixed warnings on language changes.
........
r3780 | pearu | 2007-05-18 16:17:48 -0400 (Fri, 18 May 2007) | 1 line
unify config_fc, build_clib, build_ext commands --fcompiler options so that --fcompiler can be specified only once in a command line
........
r3781 | pearu | 2007-05-18 16:41:10 -0400 (Fri, 18 May 2007) | 1 line
added config to --fcompiler option unification method. introduced config_cc for unifying --compiler options.
........
r3782 | pearu | 2007-05-18 16:49:09 -0400 (Fri, 18 May 2007) | 1 line
Added --help-fcompiler option to build_ext command.
........
r3783 | pearu | 2007-05-18 17:00:17 -0400 (Fri, 18 May 2007) | 1 line
show less messages in --help-fcompiler
........
r3784 | pearu | 2007-05-18 17:25:23 -0400 (Fri, 18 May 2007) | 1 line
Added --fcompiler,--help-fcompiler options to build command parallel to --compiler,--help-compiler options.
........
r3785 | pearu | 2007-05-18 17:33:07 -0400 (Fri, 18 May 2007) | 1 line
Add descriptions to config_fc and config_cc commands.
........
r3786 | pearu | 2007-05-19 05:54:00 -0400 (Sat, 19 May 2007) | 1 line
Fix for win32 platform.
........
r3787 | pearu | 2007-05-19 06:23:16 -0400 (Sat, 19 May 2007) | 1 line
Fix fcompiler/compiler unification warning.
........
r3788 | pearu | 2007-05-19 11:20:48 -0400 (Sat, 19 May 2007) | 1 line
Fix atlas version detection when using MSVC compiler
........
r3789 | pearu | 2007-05-19 11:21:41 -0400 (Sat, 19 May 2007) | 1 line
Fix typo.
........
r3790 | pearu | 2007-05-19 11:24:20 -0400 (Sat, 19 May 2007) | 1 line
More typo fixes.
........
r3791 | pearu | 2007-05-19 13:01:39 -0400 (Sat, 19 May 2007) | 1 line
win32: fix install when build has been carried out earlier.
........
r3792 | pearu | 2007-05-19 15:44:42 -0400 (Sat, 19 May 2007) | 1 line
Clean up and completed (hopefully) MSVC support.
........
r3794 | cookedm | 2007-05-21 09:01:20 -0400 (Mon, 21 May 2007) | 1 line
minor cleanups in numpy.distutils (style mostly)
........
Diffstat (limited to 'command/config_compiler.py')
-rw-r--r-- | command/config_compiler.py | 158 |
1 files changed, 73 insertions, 85 deletions
diff --git a/command/config_compiler.py b/command/config_compiler.py index 611527dea..af99dbd32 100644 --- a/command/config_compiler.py +++ b/command/config_compiler.py @@ -1,80 +1,17 @@ import sys -import copy -import distutils.core from distutils.core import Command -from distutils.errors import DistutilsSetupError -from distutils import log -from numpy.distutils.fcompiler import show_fcompilers, new_fcompiler +from numpy.distutils import log -#XXX: Implement confic_cc for enhancing C/C++ compiler options. #XXX: Linker flags def show_fortran_compilers(_cache=[]): # Using cache to prevent infinite recursion - if _cache: - return + if _cache: return _cache.append(1) - show_fcompilers() - -class FCompilerProxy(object): - """ - A layer of indirection to simplify choosing the correct Fortran compiler. - - If need_f90(), f90(), or fortran(requiref90=True) is called at any time, - a Fortran 90 compiler is found and used for *all* Fortran sources, - including Fortran 77 sources. - """ - #XXX The ability to use a separate F77 compiler is likely not - # necessary: of all the compilers we support, only the 'gnu' - # compiler (g77) doesn't support F90, and everything else supports - # both. - - def __init__(self, compiler_type, distribution): - self._fcompiler = None - self._have_f77 = None - self._have_f90 = None - self._compiler_type = compiler_type - self.distribution = distribution - - def _set_fcompiler(self, requiref90=False): - fc = new_fcompiler(compiler=self._compiler_type, - dry_run=self.distribution.dry_run, - verbose=self.distribution.verbose, - requiref90=requiref90) - if fc is None: - raise DistutilsSetupError("could not find a Fortran compiler") - fc.customize(self.distribution) - self._fcompiler = fc - self._have_f77 = fc.compiler_f77 is not None - if requiref90: - self._have_f90 = fc.compiler_f90 is not None - log.info('%s (%s)' % (fc.description, fc.get_version())) - - def need_f77(self): - if self._fcompiler is None: - self._set_fcompiler(requiref90=False) - if not self._have_f77: - raise DistutilsSetupError("could not find a Fortran 77 compiler") - - def need_f90(self): - if self._fcompiler is None or self._have_f90 is None: - self._set_fcompiler(requiref90=True) - if not self._have_f90: - raise DistutilsSetupError("could not find a Fortran 90 compiler") - - def f77(self): - self.need_f77() - return copy.copy(self._fcompiler) - - def f90(self): - self.need_f90() - return copy.copy(self._fcompiler) - - def fortran(self, requiref90=False): - if requiref90: - return self.f90() - else: - return self.f77() + from numpy.distutils.fcompiler import show_fcompilers + import distutils.core + dist = distutils.core._setup_distribution + show_fcompilers(dist) class config_fc(Command): """ Distutils command to hold user specified options @@ -83,24 +20,19 @@ class config_fc(Command): config_fc command is used by the FCompiler.customize() method. """ + description = "specify Fortran 77/Fortran 90 compiler information" + user_options = [ ('fcompiler=',None,"specify Fortran compiler type"), ('f77exec=', None, "specify F77 compiler command"), ('f90exec=', None, "specify F90 compiler command"), ('f77flags=',None,"specify F77 compiler flags"), ('f90flags=',None,"specify F90 compiler flags"), - ('ldshared=',None,"shared-library linker command"), - ('ld=',None,"static library linker command"), - ('ar=',None,"archiver command (ar)"), - ('ranlib=',None,"ranlib command"), ('opt=',None,"specify optimization flags"), ('arch=',None,"specify architecture specific optimization flags"), ('debug','g',"compile with debugging information"), ('noopt',None,"compile without optimization"), ('noarch',None,"compile without arch-dependent optimization"), - ('fflags=',None,"extra flags for Fortran compiler"), - ('ldflags=',None,"linker flags"), - ('arflags=',None,"flags for ar"), ] help_options = [ @@ -116,21 +48,77 @@ class config_fc(Command): self.f90exec = None self.f77flags = None self.f90flags = None - self.ldshared = None - self.ld = None - self.ar = None - self.ranlib = None self.opt = None self.arch = None self.debug = None self.noopt = None self.noarch = None - self.fflags = None - self.ldflags = None - self.arflags = None def finalize_options(self): - self.fcompiler = FCompilerProxy(self.fcompiler, self.distribution) + log.info('unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options') + build_clib = self.get_finalized_command('build_clib') + build_ext = self.get_finalized_command('build_ext') + config = self.get_finalized_command('config') + build = self.get_finalized_command('build') + cmd_list = [self, config, build_clib, build_ext, build] + for a in ['fcompiler']: + l = [] + for c in cmd_list: + v = getattr(c,a) + if v is not None: + if not isinstance(v, str): v = v.compiler_type + if v not in l: l.append(v) + if not l: v1 = None + else: v1 = l[0] + if len(l)>1: + log.warn(' commands have different --%s options: %s'\ + ', using first in list as default' % (a, l)) + if v1: + for c in cmd_list: + if getattr(c,a) is None: setattr(c, a, v1) + + def run(self): + # Do nothing. + return + +class config_cc(Command): + """ Distutils command to hold user specified options + to C/C++ compilers. + """ + + description = "specify C/C++ compiler information" + + user_options = [ + ('compiler=',None,"specify C/C++ compiler type"), + ] + + def initialize_options(self): + self.compiler = None + + def finalize_options(self): + log.info('unifing config_cc, config, build_clib, build_ext, build commands --compiler options') + build_clib = self.get_finalized_command('build_clib') + build_ext = self.get_finalized_command('build_ext') + config = self.get_finalized_command('config') + build = self.get_finalized_command('build') + cmd_list = [self, config, build_clib, build_ext, build] + for a in ['compiler']: + l = [] + for c in cmd_list: + v = getattr(c,a) + if v is not None: + if not isinstance(v, str): v = v.compiler_type + if v not in l: l.append(v) + if not l: v1 = None + else: v1 = l[0] + if len(l)>1: + log.warn(' commands have different --%s options: %s'\ + ', using first in list as default' % (a, l)) + if v1: + for c in cmd_list: + if getattr(c,a) is None: setattr(c, a, v1) + return def run(self): - pass + # Do nothing. + return |