diff options
author | Pearu Peterson <pearu.peterson@gmail.com> | 2007-07-25 21:47:16 +0000 |
---|---|---|
committer | Pearu Peterson <pearu.peterson@gmail.com> | 2007-07-25 21:47:16 +0000 |
commit | 468e6532a29e6302986a75cfe19eca7670c5a460 (patch) | |
tree | 7c2275f0c5c5ee3e271773ed592516e0e79b95d9 /numpy/distutils | |
parent | 1f4f410baef0547e26dc68d1ea3c60d140602a15 (diff) | |
download | numpy-468e6532a29e6302986a75cfe19eca7670c5a460.tar.gz |
More fixes for building scipy with Mingw32 compilers.
Diffstat (limited to 'numpy/distutils')
-rw-r--r-- | numpy/distutils/command/build_clib.py | 6 | ||||
-rw-r--r-- | numpy/distutils/command/build_ext.py | 12 | ||||
-rw-r--r-- | numpy/distutils/command/config.py | 3 | ||||
-rw-r--r-- | numpy/distutils/exec_command.py | 8 | ||||
-rw-r--r-- | numpy/distutils/fcompiler/__init__.py | 28 | ||||
-rw-r--r-- | numpy/distutils/fcompiler/gnu.py | 5 | ||||
-rw-r--r-- | numpy/distutils/system_info.py | 5 |
7 files changed, 49 insertions, 18 deletions
diff --git a/numpy/distutils/command/build_clib.py b/numpy/distutils/command/build_clib.py index 5e6e45300..0d49d7ee8 100644 --- a/numpy/distutils/command/build_clib.py +++ b/numpy/distutils/command/build_clib.py @@ -77,7 +77,8 @@ class build_clib(old_build_clib): verbose=self.verbose, dry_run=self.dry_run, force=self.force, - requiref90='f90' in languages) + requiref90='f90' in languages, + c_compiler=self.compiler) if self.compiler is not None: self.fcompiler.customize(self.distribution) @@ -146,7 +147,8 @@ class build_clib(old_build_clib): verbose=self.verbose, dry_run=self.dry_run, force=self.force, - requiref90=requiref90) + requiref90=requiref90, + c_compiler=self.compiler) if fcompiler is not None: dist = self.distribution base_config_fc = dist.get_option_dict('config_fc').copy() diff --git a/numpy/distutils/command/build_ext.py b/numpy/distutils/command/build_ext.py index 63cfec4c4..9277f9393 100644 --- a/numpy/distutils/command/build_ext.py +++ b/numpy/distutils/command/build_ext.py @@ -84,10 +84,10 @@ class build_ext (old_build_ext): clibs = {} if build_clib is not None: for libname,build_info in build_clib.libraries or []: - if clibs.has_key(libname): + if clibs.has_key(libname) and clibs[libname]!=build_info: log.warn('library %r defined more than once,'\ - ' overwriting build_info %r with %r.' \ - % (libname, clibs[libname], build_info)) + ' overwriting build_info\n%s... \nwith\n%s...' \ + % (libname, `clibs[libname]`[:300], `build_info`[:300])) clibs[libname] = build_info # .. and distribution libraries: for libname,build_info in self.distribution.libraries or []: @@ -174,7 +174,8 @@ class build_ext (old_build_ext): verbose=self.verbose, dry_run=self.dry_run, force=self.force, - requiref90=False) + requiref90=False, + c_compiler=self.compiler) fcompiler = self._f77_compiler if fcompiler: ctype = fcompiler.compiler_type @@ -196,7 +197,8 @@ class build_ext (old_build_ext): verbose=self.verbose, dry_run=self.dry_run, force=self.force, - requiref90=True) + requiref90=True, + c_compiler = self.compiler) fcompiler = self._f90_compiler if fcompiler: ctype = fcompiler.compiler_type diff --git a/numpy/distutils/command/config.py b/numpy/distutils/command/config.py index 52bb31071..11d630993 100644 --- a/numpy/distutils/command/config.py +++ b/numpy/distutils/command/config.py @@ -27,7 +27,8 @@ class config(old_config): from numpy.distutils.fcompiler import FCompiler, new_fcompiler if not isinstance(self.fcompiler, FCompiler): self.fcompiler = new_fcompiler(compiler=self.fcompiler, - dry_run=self.dry_run, force=1) + dry_run=self.dry_run, force=1, + c_compiler=self.compiler) if self.fcompiler is not None: self.fcompiler.customize(self.distribution) if self.fcompiler.get_version(): diff --git a/numpy/distutils/exec_command.py b/numpy/distutils/exec_command.py index 1ec7aaaa1..034dd307a 100644 --- a/numpy/distutils/exec_command.py +++ b/numpy/distutils/exec_command.py @@ -122,11 +122,16 @@ def test_splitcmdline(): ############################################################ -def find_executable(exe, path=None): +def find_executable(exe, path=None, _cache={}): """Return full path of a executable or None. Symbolic links are not followed. """ + key = exe, path + try: + return _cache[key] + except KeyError: + pass log.debug('find_executable(%r)' % exe) orig_exe = exe @@ -160,6 +165,7 @@ def find_executable(exe, path=None): f_ext = realpath(f_ext) if os.path.isfile(f_ext) and os.access(f_ext, os.X_OK): log.good('Found executable %s' % f_ext) + _cache[key] = f_ext return f_ext log.warn('Could not locate executable %s' % orig_exe) diff --git a/numpy/distutils/fcompiler/__init__.py b/numpy/distutils/fcompiler/__init__.py index 2c92b585c..5763ffd86 100644 --- a/numpy/distutils/fcompiler/__init__.py +++ b/numpy/distutils/fcompiler/__init__.py @@ -203,6 +203,10 @@ class FCompiler(CCompiler): 'compiler_fix', 'linker_so', 'linker_exe', 'archiver', 'ranlib'] + # This will be set by new_fcompiler when called in + # command/{build_ext.py, build_clib.py, config.py} files. + c_compiler = None + def __init__(self, *args, **kw): CCompiler.__init__(self, *args, **kw) self.distutils_vars = self.distutils_vars.clone(self._environment_hook) @@ -599,6 +603,8 @@ class FCompiler(CCompiler): def library_option(self, lib): return "-l" + lib def library_dir_option(self, dir): + if ' ' in dir and dir[0] not in '"\'': + return '-L"%s"' % (dir) return "-L" + dir def link(self, target_desc, objects, @@ -716,13 +722,15 @@ def load_all_fcompiler_classes(): def _find_existing_fcompiler(compiler_types, osname=None, platform=None, - requiref90=False): + requiref90=False, + c_compiler=None): from numpy.distutils.core import get_distribution dist = get_distribution(always=True) for compiler_type in compiler_types: v = None try: - c = new_fcompiler(plat=platform, compiler=compiler_type) + c = new_fcompiler(plat=platform, compiler=compiler_type, + c_compiler=c_compiler) c.customize(dist) v = c.get_version() if requiref90 and c.compiler_f90 is None: @@ -732,7 +740,8 @@ def _find_existing_fcompiler(compiler_types, log.warn('Trying %r compiler as suggested by %r ' 'compiler for f90 support.' % (compiler_type, new_compiler)) - c = new_fcompiler(plat=platform, compiler=new_compiler) + c = new_fcompiler(plat=platform, compiler=new_compiler, + c_compiler=c_compiler) c.customize(dist) v = c.get_version() if v is not None: @@ -763,7 +772,8 @@ def available_fcompilers_for_platform(osname=None, platform=None): matching_compiler_types.append('gnu') return matching_compiler_types -def get_default_fcompiler(osname=None, platform=None, requiref90=False): +def get_default_fcompiler(osname=None, platform=None, requiref90=False, + c_compiler=None): """Determine the default Fortran compiler to use for the given platform.""" matching_compiler_types = available_fcompilers_for_platform(osname, @@ -771,7 +781,8 @@ def get_default_fcompiler(osname=None, platform=None, requiref90=False): compiler_type = _find_existing_fcompiler(matching_compiler_types, osname=osname, platform=platform, - requiref90=requiref90) + requiref90=requiref90, + c_compiler=c_compiler) return compiler_type def new_fcompiler(plat=None, @@ -779,7 +790,8 @@ def new_fcompiler(plat=None, verbose=0, dry_run=0, force=0, - requiref90=False): + requiref90=False, + c_compiler = None): """Generate an instance of some FCompiler subclass for the supplied platform/compiler combination. """ @@ -787,7 +799,8 @@ def new_fcompiler(plat=None, if plat is None: plat = os.name if compiler is None: - compiler = get_default_fcompiler(plat, requiref90=requiref90) + compiler = get_default_fcompiler(plat, requiref90=requiref90, + c_compiler=c_compiler) if compiler in fcompiler_class: module_name, klass, long_description = fcompiler_class[compiler] elif compiler in fcompiler_aliases: @@ -802,6 +815,7 @@ def new_fcompiler(plat=None, return None compiler = klass(verbose=verbose, dry_run=dry_run, force=force) + compiler.c_compiler = c_compiler return compiler def show_fcompilers(dist=None): diff --git a/numpy/distutils/fcompiler/gnu.py b/numpy/distutils/fcompiler/gnu.py index dcb2723f6..569c0932a 100644 --- a/numpy/distutils/fcompiler/gnu.py +++ b/numpy/distutils/fcompiler/gnu.py @@ -151,7 +151,10 @@ class GnuFCompiler(FCompiler): if g2c is not None: opt.append(g2c) - if sys.platform == 'win32': + c_compiler = self.c_compiler + if sys.platform == 'win32' and c_compiler and \ + c_compiler.compiler_type=='msvc': + # the following code is not needed (read: breaks) when using MinGW # in case want to link F77 compiled code with MSVC opt.append('gcc') runtime_lib = msvc_runtime_library() diff --git a/numpy/distutils/system_info.py b/numpy/distutils/system_info.py index d78cc10b0..7a1373442 100644 --- a/numpy/distutils/system_info.py +++ b/numpy/distutils/system_info.py @@ -416,7 +416,8 @@ class system_info: if self.verbosity>0 and flag: for k,v in res.items(): v = str(v) - if k=='sources' and len(v)>200: v = v[:60]+' ...\n... '+v[-60:] + if k in ['sources','libraries'] and len(v)>270: + v = v[:120]+'...\n...\n...'+v[-120:] log.info(' %s = %s', k, v) log.info('') @@ -1394,6 +1395,7 @@ class blas_src_info(system_info): srotmg zdrot cdotu daxpy drotm idamax scopy sscal zdscal crotg dcabs1 drotmg isamax sdot sswap zrotg cscal dcopy dscal izamax snrm2 zaxpy zscal csrot ddot dswap sasum srot zcopy zswap + scabs1 ''' blas2 = ''' cgbmv chpmv ctrsv dsymv dtrsv sspr2 strmv zhemv ztpmv cgemv @@ -1412,6 +1414,7 @@ class blas_src_info(system_info): sources = [os.path.join(src_dir,f+'.f') \ for f in (blas1+blas2+blas3).split()] #XXX: should we check here actual existence of source files? + sources = [f for f in sources if os.path.isfile(f)] info = {'sources':sources,'language':'f77'} self.set_info(**info) |