[Numpy-svn] r3901 - in trunk/numpy/distutils: . command fcompiler

numpy-svn@scip... numpy-svn@scip...
Wed Jul 25 16:47:37 CDT 2007


Author: pearu
Date: 2007-07-25 16:47:16 -0500 (Wed, 25 Jul 2007)
New Revision: 3901

Modified:
   trunk/numpy/distutils/command/build_clib.py
   trunk/numpy/distutils/command/build_ext.py
   trunk/numpy/distutils/command/config.py
   trunk/numpy/distutils/exec_command.py
   trunk/numpy/distutils/fcompiler/__init__.py
   trunk/numpy/distutils/fcompiler/gnu.py
   trunk/numpy/distutils/system_info.py
Log:
More fixes for building scipy with Mingw32 compilers.

Modified: trunk/numpy/distutils/command/build_clib.py
===================================================================
--- trunk/numpy/distutils/command/build_clib.py	2007-07-25 11:42:39 UTC (rev 3900)
+++ trunk/numpy/distutils/command/build_clib.py	2007-07-25 21:47:16 UTC (rev 3901)
@@ -77,7 +77,8 @@
                                            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 @@
                                       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()

Modified: trunk/numpy/distutils/command/build_ext.py
===================================================================
--- trunk/numpy/distutils/command/build_ext.py	2007-07-25 11:42:39 UTC (rev 3900)
+++ trunk/numpy/distutils/command/build_ext.py	2007-07-25 21:47:16 UTC (rev 3901)
@@ -84,10 +84,10 @@
         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 @@
                                                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 @@
                                                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

Modified: trunk/numpy/distutils/command/config.py
===================================================================
--- trunk/numpy/distutils/command/config.py	2007-07-25 11:42:39 UTC (rev 3900)
+++ trunk/numpy/distutils/command/config.py	2007-07-25 21:47:16 UTC (rev 3901)
@@ -27,7 +27,8 @@
         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():

Modified: trunk/numpy/distutils/exec_command.py
===================================================================
--- trunk/numpy/distutils/exec_command.py	2007-07-25 11:42:39 UTC (rev 3900)
+++ trunk/numpy/distutils/exec_command.py	2007-07-25 21:47:16 UTC (rev 3901)
@@ -122,11 +122,16 @@
 
 ############################################################
 
-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 @@
                 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)

Modified: trunk/numpy/distutils/fcompiler/__init__.py
===================================================================
--- trunk/numpy/distutils/fcompiler/__init__.py	2007-07-25 11:42:39 UTC (rev 3900)
+++ trunk/numpy/distutils/fcompiler/__init__.py	2007-07-25 21:47:16 UTC (rev 3901)
@@ -203,6 +203,10 @@
                         '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 @@
     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 _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 @@
                     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 @@
         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 @@
     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 @@
                   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 @@
     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 @@
         return None
 
     compiler = klass(verbose=verbose, dry_run=dry_run, force=force)
+    compiler.c_compiler = c_compiler
     return compiler
 
 def show_fcompilers(dist=None):

Modified: trunk/numpy/distutils/fcompiler/gnu.py
===================================================================
--- trunk/numpy/distutils/fcompiler/gnu.py	2007-07-25 11:42:39 UTC (rev 3900)
+++ trunk/numpy/distutils/fcompiler/gnu.py	2007-07-25 21:47:16 UTC (rev 3901)
@@ -151,7 +151,10 @@
 
         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()

Modified: trunk/numpy/distutils/system_info.py
===================================================================
--- trunk/numpy/distutils/system_info.py	2007-07-25 11:42:39 UTC (rev 3900)
+++ trunk/numpy/distutils/system_info.py	2007-07-25 21:47:16 UTC (rev 3901)
@@ -416,7 +416,8 @@
         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 @@
         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 @@
         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)
 



More information about the Numpy-svn mailing list