[Numpy-svn] r3485 - in branches/distutils-revamp: . command fcompiler

numpy-svn at scipy.org numpy-svn at scipy.org
Tue Dec 12 23:16:19 CST 2006


Author: cookedm
Date: 2006-12-12 23:16:09 -0600 (Tue, 12 Dec 2006)
New Revision: 3485

Modified:
   branches/distutils-revamp/
   branches/distutils-revamp/ccompiler.py
   branches/distutils-revamp/command/
   branches/distutils-revamp/command/build_clib.py
   branches/distutils-revamp/command/build_ext.py
   branches/distutils-revamp/command/build_src.py
   branches/distutils-revamp/command/config_compiler.py
   branches/distutils-revamp/core.py
   branches/distutils-revamp/fcompiler/
   branches/distutils-revamp/fcompiler/__init__.py
   branches/distutils-revamp/fcompiler/g95.py
   branches/distutils-revamp/fcompiler/gnu.py
   branches/distutils-revamp/fcompiler/intel.py
   branches/distutils-revamp/fcompiler/nag.py
   branches/distutils-revamp/misc_util.py
   branches/distutils-revamp/system_info.py
Log:
[distutils-rework] Merged revisions 2922,2924-3484 via svnmerge from 
http://svn.scipy.org/svn/numpy/trunk/numpy/distutils

Biggest problem in merging was appropiately choosing a f90 compiler in
build_clib and build_ext.

........
  r2979 | cookedm | 2006-08-08 17:16:05 -0400 (Tue, 08 Aug 2006) | 1 line
  
  fix #234: IntelVisualFCompiler is broken
........
  r3014 | stefan | 2006-08-14 06:05:22 -0400 (Mon, 14 Aug 2006) | 2 lines
  
  Ignore *.pyc files [for Albert Strasheim].
........
  r3061 | oliphant | 2006-08-24 16:07:59 -0400 (Thu, 24 Aug 2006) | 1 line
  
  update g95 version pattern
........
  r3138 | rkern | 2006-09-08 12:56:50 -0400 (Fri, 08 Sep 2006) | 1 line
  
  Fix #198
........
  r3164 | oliphant | 2006-09-15 17:06:47 -0400 (Fri, 15 Sep 2006) | 1 line
  
  Fix subversion number getting for 1.4 clients.  Also works for pre 1.4 clients.
........
  r3165 | oliphant | 2006-09-15 17:13:09 -0400 (Fri, 15 Sep 2006) | 1 line
  
  Fix when svnversion is not present.
........
  r3166 | oliphant | 2006-09-15 17:18:33 -0400 (Fri, 15 Sep 2006) | 1 line
  
  Small code re-org in _get_svn_revision
........
  r3228 | cookedm | 2006-09-28 07:23:18 -0400 (Thu, 28 Sep 2006) | 1 line
  
  For the MKL library, define the macro SCIPY_MKL_H
........
  r3240 | rkern | 2006-10-02 12:41:47 -0400 (Mon, 02 Oct 2006) | 1 line
  
  Add .dylib as a valid OS X shared library extension.
........
  r3290 | pearu | 2006-10-08 05:30:17 -0400 (Sun, 08 Oct 2006) | 1 line
  
  numpy.distutils: use language flag or source file extension to select default f77 or f90 compiler.
........
  r3291 | pearu | 2006-10-08 05:38:12 -0400 (Sun, 08 Oct 2006) | 1 line
  
  numpy.distutils: fixed bug.
........
  r3302 | pearu | 2006-10-10 16:27:23 -0400 (Tue, 10 Oct 2006) | 1 line
  
  Improved is_free_format.
........
  r3371 | pearu | 2006-10-19 18:03:23 -0400 (Thu, 19 Oct 2006) | 1 line
  
  Add Intel Itanium compiler 9.x support (needs testing).
........
  r3372 | oliphant | 2006-10-19 18:55:23 -0400 (Thu, 19 Oct 2006) | 1 line
  
  Fix missing comment characters in intel.py.  Check for None in .reshape and .resize
........
  r3430 | stefan | 2006-11-04 16:19:03 -0500 (Sat, 04 Nov 2006) | 2 lines
  
  Fix typo.
........
  r3450 | pearu | 2006-11-19 15:56:57 -0500 (Sun, 19 Nov 2006) | 1 line
  
  Skip interactive mode when using script_args argument.
........
  r3467 | oliphant | 2006-12-01 23:34:25 -0500 (Fri, 01 Dec 2006) | 1 line
  
  Try updating version command for NAG compiler.
........



Property changes on: branches/distutils-revamp
___________________________________________________________________
Name: svnmerge-integrated
   - /branches/distutils-revamp:1-2756 /trunk/numpy/distutils:1-2921,2923
   + /branches/distutils-revamp:1-2756 /trunk/numpy/distutils:1-3484
Name: svn:ignore
   + *.pyc


Modified: branches/distutils-revamp/ccompiler.py
===================================================================
--- branches/distutils-revamp/ccompiler.py	2006-12-12 01:07:51 UTC (rev 3484)
+++ branches/distutils-revamp/ccompiler.py	2006-12-13 05:16:09 UTC (rev 3485)
@@ -198,7 +198,7 @@
         # 'CCSHARED', 'LDSHARED', 'SO')
         try:
             self.compiler_so.remove('-Wstrict-prototypes')
-        except ValueError:
+        except (AttributeError, ValueError):
             pass
         
         if hasattr(self,'compiler') and self.compiler[0].find('cc')>=0:


Property changes on: branches/distutils-revamp/command
___________________________________________________________________
Name: svn:ignore
   + *.pyc


Modified: branches/distutils-revamp/command/build_clib.py
===================================================================
--- branches/distutils-revamp/command/build_clib.py	2006-12-12 01:07:51 UTC (rev 3484)
+++ branches/distutils-revamp/command/build_clib.py	2006-12-13 05:16:09 UTC (rev 3485)
@@ -9,6 +9,11 @@
 from numpy.distutils.misc_util import filter_sources, has_f_sources,\
      has_cxx_sources, all_strings, get_lib_source_files, is_sequence
 
+try:
+    set
+except NameError:
+    from sets import Set as set
+
 class build_clib(old_build_clib):
 
     description = "build C/C++/F libraries used by Python extensions"
@@ -24,29 +29,41 @@
 
     def finalize_options(self):
         old_build_clib.finalize_options(self)
-        self.set_undefined_options('build_ext',
+        self._languages = None
+        self.set_undefined_options('config_fc',
                                    ('fcompiler', 'fcompiler'))
 
+    def get_languages(self):
+        """Return a set of language names used in this library.
+        Valid language names are 'c', 'f77', and 'f90'.
+
+        Note that this has a side effect of running 'build_src'.
+        """
+        if self._languages is None:
+            languages = set()
+            for (lib_name, build_info) in self.libraries:
+                if not all_strings(build_info.get('sources',[])):
+                    self.run_command('build_src')
+                l = build_info.get('language',None)
+                if l:
+                    languages.add(l)
+            self._languages = languages
+        return self._languages
+
     def have_f_sources(self):
-        for (lib_name, build_info) in self.libraries:
-            if has_f_sources(build_info.get('sources',[])):
-                return True
-        return False
+        l = self.get_languages()
+        return 'f90' in l or 'f77' in l
 
     def have_cxx_sources(self):
-        for (lib_name, build_info) in self.libraries:
-            if has_cxx_sources(build_info.get('sources',[])):
-                return True
-        return False
+        l = self.get_languages()
+        return 'c' in l
 
     def run(self):
         if not self.libraries:
             return
 
         # Make sure that library sources are complete.
-        for (lib_name, build_info) in self.libraries:
-            if not all_strings(build_info.get('sources',[])):
-                self.run_command('build_src')
+        languages = self.get_languages()
 
         from distutils.ccompiler import new_compiler
         self.compiler = new_compiler(compiler=self.compiler,
@@ -63,6 +80,11 @@
         self.compiler.show_customization()
 
         if self.have_f_sources():
+            cf = self.get_finalized_command('config_fc')
+            if 'f90' in languages:
+                self.fcompiler = cf.get_f90_compiler()
+            else:
+                self.fcompiler = cf.get_f77_compiler()
             libraries = self.libraries
             self.libraries = None
             self.fcompiler.customize_cmd(self)
@@ -111,10 +133,12 @@
                          'for fortran compiler: %s' \
                          % (config_fc))
                 from numpy.distutils.fcompiler import new_fcompiler
+                requiref90 = build_info.get('language','c')=='f90'
                 fcompiler = new_fcompiler(compiler=self.fcompiler.compiler_type,
                                           verbose=self.verbose,
                                           dry_run=self.dry_run,
-                                          force=self.force)
+                                          force=self.force,
+                                          requiref90=requiref90)
                 fcompiler.customize(config_fc)
 
             macros = build_info.get('macros')

Modified: branches/distutils-revamp/command/build_ext.py
===================================================================
--- branches/distutils-revamp/command/build_ext.py	2006-12-12 01:07:51 UTC (rev 3484)
+++ branches/distutils-revamp/command/build_ext.py	2006-12-13 05:16:09 UTC (rev 3485)
@@ -75,8 +75,15 @@
                     need_f_compiler = True
                     break
 
+        requiref90 = False
+        if need_f_compiler:
+            for ext in self.extensions:
+                if getattr(ext,'language','c')=='f90':
+                    requiref90 = True
+                    break
+
         # Determine if C++ compiler is needed.
-        need_cxx_compiler = 0
+        need_cxx_compiler = False
         for ext in self.extensions:
             if has_cxx_sources(ext.sources):
                 need_cxx_compiler = True
@@ -96,6 +103,11 @@
 
         # Initialize Fortran/C++ compilers if needed.
         if need_f_compiler:
+            cf = self.get_finalized_command('config_fc')
+            if requiref90:
+                self.fcompiler = cf.get_f90_compiler()
+            else:
+                self.fcompiler = cf.get_f77_compiler()
             if self.fcompiler.get_version():
                 self.fcompiler.customize_cmd(self)
                 self.fcompiler.show_customization()
@@ -343,7 +355,7 @@
         # make g77-compiled static libs available to MSVC
         lib_added = False
         for lib in self.fcompiler.libraries:
-            if not lib.startswtih('msvcr'):
+            if not lib.startswith('msvcr'):
                 c_libraries.append(lib)
                 p = combine_paths(f_lib_dirs, 'lib' + lib + '.a')
                 if p:

Modified: branches/distutils-revamp/command/build_src.py
===================================================================
--- branches/distutils-revamp/command/build_src.py	2006-12-12 01:07:51 UTC (rev 3484)
+++ branches/distutils-revamp/command/build_src.py	2006-12-13 05:16:09 UTC (rev 3485)
@@ -438,7 +438,8 @@
             if (self.force or newer_group(depends, target_file,'newer')) \
                    and not skip_f2py:
                 log.info("f2py: %s" % (source))
-                f2py.run_main(f2py_options + ['--build-dir',target_dir,source])
+                numpy.f2py.run_main(f2py_options
+                                    + ['--build-dir',target_dir,source])
             else:
                 log.debug("  skipping '%s' f2py interface (up-to-date)" % (source))
         else:
@@ -455,7 +456,7 @@
                    and not skip_f2py:
                 log.info("f2py:> %s" % (target_file))
                 self.mkpath(target_dir)
-                f2py.run_main(f2py_options + ['--lower',
+                numpy.f2py.run_main(f2py_options + ['--lower',
                                                 '--build-dir',target_dir]+\
                                 ['-m',ext_name]+f_sources)
             else:
@@ -475,7 +476,7 @@
             extension.include_dirs.append(self.build_src)
 
         if not skip_f2py:
-            d = os.path.dirname(f2py.__file__)
+            d = os.path.dirname(numpy.f2py.__file__)
             source_c = os.path.join(d,'src','fortranobject.c')
             source_h = os.path.join(d,'src','fortranobject.h')
             if newer(source_c,target_c) or newer(source_h,target_h):

Modified: branches/distutils-revamp/command/config_compiler.py
===================================================================
--- branches/distutils-revamp/command/config_compiler.py	2006-12-12 01:07:51 UTC (rev 3484)
+++ branches/distutils-revamp/command/config_compiler.py	2006-12-13 05:16:09 UTC (rev 3485)
@@ -2,6 +2,7 @@
 import sys
 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
 
@@ -76,7 +77,28 @@
                            verbose=self.distribution.verbose)
         fc.customize(self.distribution)
         self.fcompiler = fc
+        if self.fcompiler.compiler_f90 is not None:
+            self.f90compiler = fc
+        else:
+            self.f90compiler = None
         log.info('%s (%s)' % (fc.description, fc.get_version()))
 
     def run(self):
         pass
+
+    def get_f77_compiler(self):
+        if self.fcompiler.compiler_f77 is None:
+            raise DistutilsSetupError("could not find a Fortran 77 compiler")
+        return self.fcompiler
+
+    def get_f90_compiler(self):
+        if self.f90compiler is not None:
+            return self.f90compiler
+        if self.fcompiler.compiler_f90 is None:
+            fc = new_fcompiler(compiler=self.fcompiler,
+                               verbose=self.distribution.verbose,
+                               requiref90=True)
+            if fc is None:
+                raise DistutilsSetupError("could not find a Fortran 90 compiler")
+            self.f90compiler = fc
+            return fc

Modified: branches/distutils-revamp/core.py
===================================================================
--- branches/distutils-revamp/core.py	2006-12-12 01:07:51 UTC (rev 3484)
+++ branches/distutils-revamp/core.py	2006-12-13 05:16:09 UTC (rev 3485)
@@ -117,7 +117,7 @@
 
 def setup(**attr):
 
-    if len(sys.argv)<=1:
+    if len(sys.argv)<=1 and not attr.get('script_args',[]):
         from interactive import interactive_sys_argv
         import atexit
         atexit.register(_exit_interactive_session)


Property changes on: branches/distutils-revamp/fcompiler
___________________________________________________________________
Name: svn:ignore
   + *.pyc


Modified: branches/distutils-revamp/fcompiler/__init__.py
===================================================================
--- branches/distutils-revamp/fcompiler/__init__.py	2006-12-12 01:07:51 UTC (rev 3484)
+++ branches/distutils-revamp/fcompiler/__init__.py	2006-12-13 05:16:09 UTC (rev 3485)
@@ -49,7 +49,7 @@
     DON'T call these methods (except get_version) after
     constructing a compiler instance or inside any other method.
     All methods, except get_version_cmd() and get_flags_version(), may
-    call get_version() method.
+    call the get_version() method.
 
     After constructing a compiler instance, always call customize(dist=None)
     method that finalizes compiler construction and makes the following
@@ -171,6 +171,11 @@
             if e not in self.executables:
                 self.executables[e] = None
 
+    # If compiler does not support compiling Fortran 90 then it can
+    # suggest using another compiler. For example, gnu would suggest
+    # gnu95 compiler type when there are F90 sources.
+    suggested_f90_compiler = None
+
     ######################################################################
     ## Methods that subclasses may redefine. But don't call these methods!
     ## They are private to FCompiler class and may return unexpected
@@ -471,14 +476,14 @@
             flavor = ':f90'
             compiler = self.compiler_f90
             if compiler is None:
-                raise DistutilsExecError, 'f90 not supported by '\
-                      +self.__class__.__name__
+                raise DistutilsExecError, 'f90 not supported by %s needed for %s'\
+                      % (self.__class__.__name__,src)
         else:
             flavor = ':fix'
             compiler = self.compiler_fix
             if compiler is None:
-                raise DistutilsExecError, 'f90 (fixed) not supported by '\
-                      +self.__class__.__name__
+                raise DistutilsExecError, 'f90 (fixed) not supported by %s needed for %s'\
+                      % (self.__class__.__name__,src)
         if self.object_switch[-1]==' ':
             o_args = [self.object_switch.strip(),obj]
         else:
@@ -642,7 +647,8 @@
                                                         klass,
                                                         klass.description)
 
-def _find_existing_fcompiler(compiler_types, osname=None, platform=None):
+def _find_existing_fcompiler(compiler_types, osname=None, platform=None,
+                             requiref90=False):
     from numpy.distutils.core import get_distribution
     dist = get_distribution(always=True)
     for compiler_type in compiler_types:
@@ -651,6 +657,21 @@
             c = new_fcompiler(plat=platform, compiler=compiler_type)
             c.customize(dist)
             v = c.get_version()
+            if requiref90 and c.compiler_f90 is None:
+                v = None
+                new_compiler = c.suggested_f90_compiler
+                if new_compiler:
+                    log.warn('Trying %r compiler as suggested by %r '
+                             'compiler for f90 support.' % (compiler,
+                                                            new_compiler))
+                    c = new_fcompiler(plat=platform, compiler=new_compiler)
+                    c.customize(dist)
+                    v = c.get_version()
+                    if v is not None:
+                        compiler_type = new_compiler
+            if requiref90 and c.compiler_f90 is None:
+                raise ValueError('%s does not support compiling f90 codes, '
+                                 'skipping.' % (c.__class__.__name__))
         except DistutilsModuleError:
             pass
         except CompilerNotFound:
@@ -659,7 +680,7 @@
             return compiler_type
     return None
 
-def get_default_fcompiler(osname=None, platform=None):
+def get_default_fcompiler(osname=None, platform=None, requiref90=False):
     """Determine the default Fortran compiler to use for the given platform."""
     if osname is None:
         osname = os.name
@@ -673,14 +694,16 @@
         matching_compiler_types.append('gnu')
     compiler_type =  _find_existing_fcompiler(matching_compiler_types,
                                               osname=osname,
-                                              platform=platform)
+                                              platform=platform,
+                                              requiref90=requiref90)
     return compiler_type
 
 def new_fcompiler(plat=None,
                   compiler=None,
                   verbose=0,
                   dry_run=0,
-                  force=0):
+                  force=0,
+                  requiref90=False):
     """Generate an instance of some FCompiler subclass for the supplied
     platform/compiler combination.
     """
@@ -688,7 +711,7 @@
     if plat is None:
         plat = os.name
     if compiler is None:
-        compiler = get_default_fcompiler(plat)
+        compiler = get_default_fcompiler(plat, requiref90=requiref90)
     try:
         module_name, klass, long_description = fcompiler_class[compiler]
     except KeyError:
@@ -774,7 +797,8 @@
 _has_f_header = re.compile(r'-[*]-\s*fortran\s*-[*]-',re.I).search
 _has_f90_header = re.compile(r'-[*]-\s*f90\s*-[*]-',re.I).search
 _has_fix_header = re.compile(r'-[*]-\s*fix\s*-[*]-',re.I).search
-_free_f90_start = re.compile(r'[^c*]\s*[^\s\d\t]',re.I).match
+_free_f90_start = re.compile(r'[^c*!]\s*[^\s\d\t]',re.I).match
+
 def is_free_format(file):
     """Check if file is in free format Fortran."""
     # f90 allows both fixed and free format, assuming fixed unless
@@ -782,16 +806,17 @@
     result = 0
     f = open(file,'r')
     line = f.readline()
-    n = 15 # the number of non-comment lines to scan for hints
+    n = 10000 # the number of non-comment lines to scan for hints
     if _has_f_header(line):
         n = 0
     elif _has_f90_header(line):
         n = 0
         result = 1
     while n>0 and line:
-        if line[0]!='!':
+        line = line.rstrip()
+        if line and line[0]!='!':
             n -= 1
-            if (line[0]!='\t' and _free_f90_start(line[:5])) or line[-2:-1]=='&':
+            if (line[0]!='\t' and _free_f90_start(line[:5])) or line[-1:]=='&':
                 result = 1
                 break
         line = f.readline()

Modified: branches/distutils-revamp/fcompiler/g95.py
===================================================================
--- branches/distutils-revamp/fcompiler/g95.py	2006-12-12 01:07:51 UTC (rev 3484)
+++ branches/distutils-revamp/fcompiler/g95.py	2006-12-13 05:16:09 UTC (rev 3485)
@@ -12,11 +12,15 @@
 
     compiler_type = 'g95'
     description = 'G95 Fortran Compiler'
-    version_pattern = r'G95 \((GCC (?P<gccversion>[\d.]+)|.*?) \(g95!\) (?P<version>.*)\).*'
 
+#    version_pattern = r'G95 \((GCC (?P<gccversion>[\d.]+)|.*?) \(g95!\) (?P<version>.*)\).*'
     # $ g95 --version
     # G95 (GCC 4.0.3 (g95!) May 22 2006)
 
+    version_pattern = r'G95 \((GCC (?P<gccversion>[\d.]+)|.*?) \(g95 (?P<version>.*)!\) (?P<date>.*)\).*'
+    # $ g95 --version
+    # G95 (GCC 4.0.3 (g95 0.90!) Aug 22 2006)
+
     executables = {
         'version_cmd'  : ["<F90>", "--version"],
         'compiler_f77' : ["g95", "-ffixed-form"],

Modified: branches/distutils-revamp/fcompiler/gnu.py
===================================================================
--- branches/distutils-revamp/fcompiler/gnu.py	2006-12-12 01:07:51 UTC (rev 3484)
+++ branches/distutils-revamp/fcompiler/gnu.py	2006-12-13 05:16:09 UTC (rev 3485)
@@ -29,7 +29,7 @@
     executables = {
         'version_cmd'  : [None, "--version"],
         'compiler_f77' : [None, "-g", "-Wall","-fno-second-underscore"],
-        'compiler_f90' : None,
+        'compiler_f90' : None, # Use --fcompiler=gnu95 for f90 codes
         'compiler_fix' : None,
         'linker_so'    : [None, "-g", "-Wall"],
         'archiver'     : ["ar", "-cr"],
@@ -51,6 +51,8 @@
 
     g2c = 'g2c'
 
+    suggested_f90_compiler = 'gnu95'
+
     #def get_linker_so(self):
     #    # win32 linking should be handled by standard linker
     #    # Darwin g77 cannot be used as a linker.
@@ -279,3 +281,6 @@
     compiler = GnuFCompiler()
     compiler.customize()
     print compiler.get_version()
+    compiler = Gnu95FCompiler()
+    compiler.customize()
+    print compiler.get_version()

Modified: branches/distutils-revamp/fcompiler/intel.py
===================================================================
--- branches/distutils-revamp/fcompiler/intel.py	2006-12-12 01:07:51 UTC (rev 3484)
+++ branches/distutils-revamp/fcompiler/intel.py	2006-12-13 05:16:09 UTC (rev 3485)
@@ -78,10 +78,15 @@
 class IntelItaniumFCompiler(IntelFCompiler):
     compiler_type = 'intele'
     description = 'Intel Fortran Compiler for Itanium apps'
-    version_pattern = r'Intel\(R\) Fortran 90 Compiler Itanium\(TM\) Compiler'\
-                      ' for the Itanium\(TM\)-based applications,'\
-                      ' Version (?P<version>[^\s*]*)'
+    version_pattern = r'Intel\(R\) Fortran (90 Compiler Itanium\(TM\)|Itanium\(R\)) Compiler'\
+                      ' for (the Itanium\(TM\)|Itanium\(R\))-based applications(,|)'\
+                      '\s+Version (?P<version>[^\s*]*)'
 
+#Intel(R) Fortran Itanium(R) Compiler for Itanium(R)-based applications
+#Version 9.1    Build 20060928 Package ID: l_fc_c_9.1.039
+#Copyright (C) 1985-2006 Intel Corporation.  All rights reserved.
+#30 DAY EVALUATION LICENSE
+
     possible_executables = ['ifort', 'efort', 'efc']
 
     executables = {
@@ -130,9 +135,6 @@
 
     ar_exe = 'lib.exe'
     fc_exe = 'ifl'
-    if sys.platform=='win32':
-        from distutils.msvccompiler import MSVCCompiler
-        ar_exe = MSVCCompiler().lib
 
     executables = {
         'version_cmd'  : ['<F77>', "-FI -V -c %(fname)s.f -o %(fname)s.o" \
@@ -182,9 +184,9 @@
 
     compiler_type = 'intelev'
     description = 'Intel Visual Fortran Compiler for Itanium apps'
-    version_pattern = r'Intel\(R\) Fortran 90 Compiler Itanium\(TM\) Compiler'\
-                      ' for the Itanium\(TM\)-based applications,'\
-                      ' Version (?P<version>[^\s*]*)'
+    version_pattern = r'Intel\(R\) Fortran (90 Compiler Itanium\(TM\)|Itanium\(R\)) Compiler'\
+                      ' for (the Itanium\(TM\)|Itanium\(R\))-based applications(,|)'\
+                      '\s+Version (?P<version>[^\s*]*)'
 
     fc_exe = 'efl' # XXX this is a wild guess
     ar_exe = IntelVisualFCompiler.ar_exe

Modified: branches/distutils-revamp/fcompiler/nag.py
===================================================================
--- branches/distutils-revamp/fcompiler/nag.py	2006-12-12 01:07:51 UTC (rev 3484)
+++ branches/distutils-revamp/fcompiler/nag.py	2006-12-13 05:16:09 UTC (rev 3485)
@@ -29,7 +29,11 @@
     def get_flags_opt(self):
         return ['-O4']
     def get_flags_arch(self):
-        return ['-target=native']
+        version = self.get_version()
+        if version < '5.1':
+            return ['-target=native']
+        else:
+            return ['']
     def get_flags_debug(self):
         return ['-g','-gline','-g90','-nan','-C']
 

Modified: branches/distutils-revamp/misc_util.py
===================================================================
--- branches/distutils-revamp/misc_util.py	2006-12-12 01:07:51 UTC (rev 3484)
+++ branches/distutils-revamp/misc_util.py	2006-12-13 05:16:09 UTC (rev 3485)
@@ -19,7 +19,7 @@
            'get_dependencies', 'is_local_src_dir', 'get_ext_source_files',
            'get_script_files', 'get_lib_source_files', 'get_data_files',
            'dot_join', 'get_frame', 'minrelpath','njoin',
-           'is_sequence', 'is_string', 'as_list', 'gpaths']
+           'is_sequence', 'is_string', 'as_list', 'gpaths', 'get_language']
 
 def allpath(name):
     "Convert a /-separated pathname to one using the OS's path separator."
@@ -308,6 +308,18 @@
     else:
         return [seq]
 
+def get_language(sources):
+    """ Determine language value (c,f77,f90) from sources """
+    language = 'c'
+    for source in sources:
+        if isinstance(source, str):
+            if f90_ext_match(source):
+                language = 'f90'
+                break
+            elif fortran_ext_match(source):
+                language = 'f77'
+    return language
+
 def has_f_sources(sources):
     """ Return True if sources contains Fortran files """
     for source in sources:
@@ -1008,6 +1020,10 @@
         ext_args['name'] = dot_join(self.name,name)
         ext_args['sources'] = sources
 
+        language = ext_args.get('language',None)
+        if language is None:
+            ext_args['language'] = get_language(sources)
+
         if ext_args.has_key('extra_info'):
             extra_info = ext_args['extra_info']
             del ext_args['extra_info']
@@ -1066,11 +1082,16 @@
           include_dirs
           extra_compiler_args
           f2py_options
+          language
         """
         build_info = copy.copy(build_info)
         name = name #+ '__OF__' + self.name
         build_info['sources'] = sources
 
+        language = build_info.get('language',None)
+        if language is None:
+            build_info['language'] = get_language(sources)
+
         self._fix_paths_dict(build_info)
 
         self.libraries.append((name,build_info))
@@ -1191,14 +1212,32 @@
     def _get_svn_revision(self,path):
         """ Return path's SVN revision number.
         """
-        entries = njoin(path,'.svn','entries')
         revision = None
+        m = None
+        try:
+            sin, sout = os.popen4('svnversion')
+            m = re.match(r'(?P<revision>\d+)', sout.read())
+        except:
+            pass
+        if m:
+            revision = int(m.group('revision'))
+            return revision
+        if sys.platform=='win32' and os.environ.get('SVN_ASP_DOT_NET_HACK',None):
+            entries = njoin(path,'_svn','entries')
+        else:
+            entries = njoin(path,'.svn','entries')
         if os.path.isfile(entries):
             f = open(entries)
-            m = re.search(r'revision="(?P<revision>\d+)"',f.read())
+            fstr = f.read()
             f.close()
-            if m:
-                revision = int(m.group('revision'))
+            if fstr[:5] == '<?xml':  # pre 1.4
+                m = re.search(r'revision="(?P<revision>\d+)"',fstr)
+                if m:
+                    revision = int(m.group('revision'))
+            else:  # non-xml entries file --- check to be sure that
+                m = re.search(r'dir[\n\r]+(?P<revision>\d+)', fstr)
+                if m:
+                    revision = int(m.group('revision'))
         return revision
 
     def get_version(self, version_file=None, version_variable=None):
@@ -1351,7 +1390,11 @@
 def dict_append(d, **kws):
     for k, v in kws.items():
         if d.has_key(k):
-            d[k].extend(v)
+            ov = d[k]
+            if isinstance(ov,str):
+                d[k] = v
+            else:
+                d[k].extend(v)
         else:
             d[k] = v
 

Modified: branches/distutils-revamp/system_info.py
===================================================================
--- branches/distutils-revamp/system_info.py	2006-12-12 01:07:51 UTC (rev 3484)
+++ branches/distutils-revamp/system_info.py	2006-12-13 05:16:09 UTC (rev 3485)
@@ -502,6 +502,8 @@
             exts = [so_ext] + static_exts
         if sys.platform == 'cygwin':
             exts.append('.dll.a')
+        if sys.platform == 'darwin':
+            exts.append('.dylib')
         return exts
 
     def check_libs(self,lib_dir,libs,opt_libs =[]):
@@ -806,7 +808,10 @@
             return
         info = {}
         dict_append(info,**mkl)
-        dict_append(info,libraries = ['pthread'], include_dirs = incl_dirs)
+        dict_append(info,
+                    libraries = ['pthread'],
+                    define_macros=[('SCIPY_MKL_H',None)],
+                    include_dirs = incl_dirs)
         self.set_info(**info)
 
 class lapack_mkl_info(mkl_info):



More information about the Numpy-svn mailing list