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

numpy-svn at scipy.org numpy-svn at scipy.org
Mon Apr 30 18:11:13 EDT 2007


Author: cookedm
Date: 2007-04-30 17:11:03 -0500 (Mon, 30 Apr 2007)
New Revision: 3732

Added:
   branches/distutils-revamp/tests/test_fcompiler_gnu.py
Modified:
   branches/distutils-revamp/
   branches/distutils-revamp/ccompiler.py
   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/cpuinfo.py
   branches/distutils-revamp/fcompiler/__init__.py
   branches/distutils-revamp/fcompiler/gnu.py
   branches/distutils-revamp/fcompiler/ibm.py
   branches/distutils-revamp/fcompiler/intel.py
   branches/distutils-revamp/interactive.py
   branches/distutils-revamp/misc_util.py
   branches/distutils-revamp/system_info.py
Log:
[distutils-revamp branch] Merged revisions 3485-3731 via svnmerge from 
http://svn.scipy.org/svn/numpy/trunk/numpy/distutils

........
  r3501 | stefan | 2007-01-08 16:56:54 -0500 (Mon, 08 Jan 2007) | 2 lines
  
  Whitespace cleanup.
........
  r3520 | timl | 2007-01-25 23:16:37 -0500 (Thu, 25 Jan 2007) | 1 line
  
  remove some remaining references to scipy. fixes #428
........
  r3521 | rkern | 2007-01-26 19:35:17 -0500 (Fri, 26 Jan 2007) | 1 line
  
  Generalize the setting of MACOSX_DEPLOYMENT_TARGET.
........
  r3523 | rkern | 2007-01-30 14:18:06 -0500 (Tue, 30 Jan 2007) | 1 line
  
  Revert semi-intelligent handling of MACOSX_DEPLOYMENT_TARGET to work around broken MacPorts Python.
........
  r3538 | edschofield | 2007-02-04 19:24:42 -0500 (Sun, 04 Feb 2007) | 2 lines
  
  Fixed detection of Core2 CPUs (scipy ticket #349)
........
  r3549 | stefan | 2007-02-18 16:02:46 -0500 (Sun, 18 Feb 2007) | 2 lines
  
  Fix docstrings for loading with DocFileSuite.
........
  r3563 | pearu | 2007-02-28 08:12:06 -0500 (Wed, 28 Feb 2007) | 1 line
  
  Added support for xml Fortran V10 compiler (needs testing).
........
  r3564 | pearu | 2007-02-28 13:32:18 -0500 (Wed, 28 Feb 2007) | 1 line
  
  Fixing xlf compiler for AIX with 9.x and 10.x version support (needs testing and checking that xlf 8.x compilers are still detected)
........
  r3568 | pearu | 2007-03-02 11:49:00 -0500 (Fri, 02 Mar 2007) | 1 line
  
  Applying info from Hans-Joachim Ehlers to improve xlf compiler support (on AIX using lslpp to determine compiler version).
........
  r3569 | timl | 2007-03-04 05:47:08 -0500 (Sun, 04 Mar 2007) | 1 line
  
  add a delete flag to make_svn_version_py to allow the __svn_version.py to not be deleted
........
  r3598 | rkern | 2007-03-25 19:12:00 -0400 (Sun, 25 Mar 2007) | 1 line
  
  Make the gfortran version matching regex accept gfortran 4.3 on OS X
........
  r3615 | cookedm | 2007-03-29 17:37:58 -0400 (Thu, 29 Mar 2007) | 1 line
  
  cpuinfo: Nocona is a PentiumIV, not 686. Fixes #438
........
  r3636 | cookedm | 2007-04-01 16:32:07 -0400 (Sun, 01 Apr 2007) | 2 lines
  
  Make numpy.get_include() and numpy.get_numarray_include() not pull in numpy.distutils.
........
  r3658 | cookedm | 2007-04-04 08:56:47 -0400 (Wed, 04 Apr 2007) | 2 lines
  
  Fix for making Fortran extensions on AIX.
........
  r3660 | rkern | 2007-04-04 13:25:29 -0400 (Wed, 04 Apr 2007) | 1 line
  
  Fix #491
........
  r3664 | cookedm | 2007-04-04 14:10:30 -0400 (Wed, 04 Apr 2007) | 2 lines
  
  Really fix linking with Fortran on AIX
........
  r3715 | rkern | 2007-04-15 00:38:59 -0400 (Sun, 15 Apr 2007) | 1 line
  
  Fix command dependencies for build_ext. This should fix a number of problems where the full 'build_src build_clib build_ext' chain of commands needed to be specified.
........
  r3716 | rkern | 2007-04-15 00:46:07 -0400 (Sun, 15 Apr 2007) | 1 line
  
  Add another place to check for configuration, namely ~/.numpy-site.cfg, to help automatic installation where one can't edit the source checkout. I've added the alternate name to make it hidden because that's just considerate.
........
  r3723 | cookedm | 2007-04-22 16:57:58 -0400 (Sun, 22 Apr 2007) | 9 lines
  
  Better version handling for gnu and intel Fortran compilers
  
  - gnu compilers check if the version is >= 4, in which case it's gfortran
  - add a test file for gnu compiler check
  - simplify version matching on intel compilers to be more flexible
  - add FCompiler.find_executables so that subclasses can find executables
    at .customize() time, instead of when the class is created.
........
  r3724 | cookedm | 2007-04-22 17:12:57 -0400 (Sun, 22 Apr 2007) | 14 lines
  
  Some distutils work:
  
  - Add better support for C++ in numpy.distutils. Instead of munging the
    C compiler command, build_clib and build_ext call the new
    Compiler.cxx_compiler() method to get a version of the compiler suitable for
    C++ (this also takes care of the special needs of AIX).
  - If config_fc is specified in the Extension definition, merge that info
    instead of replacing it (otherwise, the name of the Fortran compiler is
    overwritten). This is done at the key level (ex., compiler options are
    replaced instead of appended).
  - clean up compiler.py a bit
  - clean up linking in build_ext
........
  r3726 | oliphant | 2007-04-24 15:15:33 -0400 (Tue, 24 Apr 2007) | 1 line
  
  Add patch to system_info for building with MKL on Win32 #504
........
  r3731 | rkern | 2007-04-30 12:29:51 -0400 (Mon, 30 Apr 2007) | 1 line
  
  Fix typo.
........



Property changes on: branches/distutils-revamp
___________________________________________________________________
Name: svnmerge-integrated
   - /branches/distutils-revamp:1-2756 /trunk/numpy/distutils:1-3484
   + /branches/distutils-revamp:1-2756 /trunk/numpy/distutils:1-3731

Modified: branches/distutils-revamp/ccompiler.py
===================================================================
--- branches/distutils-revamp/ccompiler.py	2007-04-30 16:29:51 UTC (rev 3731)
+++ branches/distutils-revamp/ccompiler.py	2007-04-30 22:11:03 UTC (rev 3732)
@@ -8,9 +8,9 @@
 from distutils.sysconfig import customize_compiler
 from distutils.version import LooseVersion
 
-import log
-from exec_command import exec_command
-from misc_util import cyg2win32, is_sequence, mingw32
+from numpy.distutils import log
+from numpy.distutils.exec_command import exec_command
+from numpy.distutils.misc_util import cyg2win32, is_sequence, mingw32
 from distutils.spawn import _nt_quote_args
 
 # hack to set compiler optimizing options. Needs to integrated with something.
@@ -21,6 +21,10 @@
     distutils.sysconfig._config_vars['OPT'] = '-Wall -g -O0'
 #distutils.sysconfig._init_posix = _new_init_posix
 
+def replace_method(klass, method_name, func):
+    m = new.instancemethod(func, None, klass)
+    setattr(klass, method_name, m)
+
 # Using customized CCompiler.spawn.
 def CCompiler_spawn(self, cmd, display=None):
     if display is None:
@@ -37,8 +41,9 @@
         print o
         raise DistutilsExecError,\
               'Command "%s" failed with exit status %d' % (cmd, s)
-CCompiler.spawn = new.instancemethod(CCompiler_spawn,None,CCompiler)
 
+replace_method(CCompiler, 'spawn', CCompiler_spawn)
+
 def CCompiler_object_filenames(self, source_filenames, strip_dir=0, output_dir=''):
     if output_dir is None:
         output_dir = ''
@@ -63,8 +68,7 @@
         obj_names.append(obj_name)
     return obj_names
 
-CCompiler.object_filenames = new.instancemethod(CCompiler_object_filenames,
-                                                None,CCompiler)
+replace_method(CCompiler, 'object_filenames', CCompiler_object_filenames)
 
 def CCompiler_compile(self, sources, output_dir=None, macros=None,
                       include_dirs=None, debug=0, extra_preargs=None,
@@ -114,7 +118,7 @@
     # Return *all* object filenames, not just the ones we just built.
     return objects
 
-CCompiler.compile = new.instancemethod(CCompiler_compile,None,CCompiler)
+replace_method(CCompiler, 'compile', CCompiler_compile)
 
 def CCompiler_customize_cmd(self, cmd):
     """ Customize compiler using distutils command.
@@ -139,8 +143,7 @@
         self.set_link_objects(cmd.link_objects)
     return
 
-CCompiler.customize_cmd = new.instancemethod(\
-    CCompiler_customize_cmd,None,CCompiler)
+replace_method(CCompiler, 'customize_cmd', CCompiler_customize_cmd)
 
 def _compiler_to_string(compiler):
     props = []
@@ -179,10 +182,8 @@
         print _compiler_to_string(self)
         print '*'*80
 
-CCompiler.show_customization = new.instancemethod(\
-    CCompiler_show_customization,None,CCompiler)
+replace_method(CCompiler, 'show_customization', CCompiler_show_customization)
 
-
 def CCompiler_customize(self, dist, need_cxx=0):
     # See FCompiler.customize for suggested usage.
     log.info('customize %s' % (self.__class__.__name__))
@@ -192,7 +193,7 @@
         # not valid for C++ code, only for C.  Remove it if it's there to
         # avoid a spurious warning on every compilation.  All the default
         # options used by distutils can be extracted with:
-        
+
         # from distutils import sysconfig
         # sysconfig.get_config_vars('CC', 'CXX', 'OPT', 'BASECFLAGS',
         # 'CCSHARED', 'LDSHARED', 'SO')
@@ -200,10 +201,10 @@
             self.compiler_so.remove('-Wstrict-prototypes')
         except (AttributeError, ValueError):
             pass
-        
+
         if hasattr(self,'compiler') and self.compiler[0].find('cc')>=0:
             if not self.compiler_cxx:
-                if self.compiler[0][:3] == 'gcc':
+                if self.compiler[0].startswith('gcc'):
                     a, b = 'gcc', 'g++'
                 else:
                     a, b = 'cc', 'c++'
@@ -215,10 +216,23 @@
             log.warn('Missing compiler_cxx fix for '+self.__class__.__name__)
     return
 
-CCompiler.customize = new.instancemethod(\
-    CCompiler_customize,None,CCompiler)
+replace_method(CCompiler, 'customize', CCompiler_customize)
 
-def simple_version_match(pat=r'[-.\d]+', ignore=None, start=''):
+def simple_version_match(pat=r'[-.\d]+', ignore='', start=''):
+    """
+    Simple matching of version numbers, for use in CCompiler and FCompiler
+    classes.
+
+    :Parameters:
+        pat : regex matching version numbers.
+        ignore : false or regex matching expressions to skip over.
+        start : false or regex matching the start of where to start looking
+                for version numbers.
+
+    :Returns:
+        A function that is appropiate to use as the .version_match
+        attribute of a CCompiler class.
+    """
     def matcher(self, version_string):
         pos = 0
         if start:
@@ -271,15 +285,26 @@
     self.version = version
     return version
 
-CCompiler.get_version = new.instancemethod(\
-    CCompiler_get_version,None,CCompiler)
+replace_method(CCompiler, 'get_version', CCompiler_get_version)
 
+def CCompiler_cxx_compiler(self):
+    cxx = copy(self)
+    cxx.compiler_so = [cxx.compiler_cxx[0]] + cxx.compiler_so[1:]
+    if sys.platform.startswith('aix') and 'ld_so_aix' in cxx.linker_so[0]:
+        # AIX needs the ld_so_aix script included with Python
+        cxx.linker_so = [cxx.linker_so[0]] + cxx.compiler_cxx[0] \
+                        + cxx.linker_so[2:]
+    else:
+        cxx.linker_so = [cxx.compiler_cxx[0]] + cxx.linker_so[1:]
+    return cxx
+
+replace_method(CCompiler, 'cxx_compiler', CCompiler_cxx_compiler)
+
 compiler_class['intel'] = ('intelccompiler','IntelCCompiler',
                            "Intel C Compiler for 32-bit applications")
 compiler_class['intele'] = ('intelccompiler','IntelItaniumCCompiler',
                            "Intel C Itanium Compiler for Itanium-based applications")
-ccompiler._default_compilers = ccompiler._default_compilers \
-                               + (('linux.*','intel'),('linux.*','intele'))
+ccompiler._default_compilers += (('linux.*','intel'),('linux.*','intele'))
 
 if sys.platform == 'win32':
     compiler_class['mingw32'] = ('mingw32ccompiler', 'Mingw32CCompiler',

Modified: branches/distutils-revamp/command/build_clib.py
===================================================================
--- branches/distutils-revamp/command/build_clib.py	2007-04-30 16:29:51 UTC (rev 3731)
+++ branches/distutils-revamp/command/build_clib.py	2007-04-30 22:11:03 UTC (rev 3732)
@@ -129,10 +129,13 @@
 
             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))
-                fcompiler.customize(config_fc)
+                         % (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')
@@ -163,19 +166,15 @@
 
             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,
@@ -191,7 +190,7 @@
                                             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:

Modified: branches/distutils-revamp/command/build_ext.py
===================================================================
--- branches/distutils-revamp/command/build_ext.py	2007-04-30 16:29:51 UTC (rev 3731)
+++ branches/distutils-revamp/command/build_ext.py	2007-04-30 22:11:03 UTC (rev 3732)
@@ -137,7 +137,7 @@
 
         macros = []
 
-        if check_for_f90_modules:
+        if fmodule_sources:
             module_build_dir = os.path.join(
                 self.build_temp,os.path.dirname(
                 self.get_ext_filename(fullname)))
@@ -159,8 +159,7 @@
                                           extra_postargs=extra_postargs,
                                           depends=ext.depends)
 
-        if check_for_f90_modules \
-               and fcompiler.module_dir_switch is None:
+        if fmodule_sources and fcompiler.module_dir_switch is None:
             for f in glob('*.mod'):
                 if f in existing_modules:
                     continue
@@ -258,17 +257,15 @@
         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
 
         fcompiler, f_objects = self.get_fortran_objects(ext,
                                                         f_sources,
@@ -281,10 +278,7 @@
             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']
         c_libraries = []
@@ -318,38 +312,31 @@
             if cxx_sources:
                 # XXX: Which linker should be used, Fortran or C++?
                 log.warn('mixing Fortran and C++ is untested')
-            link = fcompiler.link_shared_object
+            linker = fcompiler.link_shared_object
             language = ext.language or 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)
+        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)
 
-        try:
-            self.compiler.linker_so[0] = old_linker_so_0
-        except:
-            pass
-
-        return
-
     def _libs_with_msvc_and_fortran(self, c_libraries, c_library_dirs):
         # Always use system linker when using MSVC compiler.
         f_lib_dirs = []

Modified: branches/distutils-revamp/command/build_src.py
===================================================================
--- branches/distutils-revamp/command/build_src.py	2007-04-30 16:29:51 UTC (rev 3731)
+++ branches/distutils-revamp/command/build_src.py	2007-04-30 22:11:03 UTC (rev 3732)
@@ -15,7 +15,9 @@
 except ImportError:
     have_pyrex = False
 
-import numpy.f2py
+# this import can't be done here, as it uses numpy stuff only available
+# after it's installed
+#import numpy.f2py
 from numpy.distutils import log
 from numpy.distutils.misc_util import fortran_ext_match, \
      appendpath, is_string, is_sequence
@@ -438,6 +440,7 @@
             if (self.force or newer_group(depends, target_file,'newer')) \
                    and not skip_f2py:
                 log.info("f2py: %s" % (source))
+                import numpy.f2py
                 numpy.f2py.run_main(f2py_options
                                     + ['--build-dir',target_dir,source])
             else:
@@ -456,6 +459,7 @@
                    and not skip_f2py:
                 log.info("f2py:> %s" % (target_file))
                 self.mkpath(target_dir)
+                import numpy.f2py
                 numpy.f2py.run_main(f2py_options + ['--lower',
                                                 '--build-dir',target_dir]+\
                                 ['-m',ext_name]+f_sources)
@@ -476,6 +480,7 @@
             extension.include_dirs.append(self.build_src)
 
         if not skip_f2py:
+            import numpy.f2py
             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')

Modified: branches/distutils-revamp/command/config_compiler.py
===================================================================
--- branches/distutils-revamp/command/config_compiler.py	2007-04-30 16:29:51 UTC (rev 3731)
+++ branches/distutils-revamp/command/config_compiler.py	2007-04-30 22:11:03 UTC (rev 3732)
@@ -1,4 +1,3 @@
-
 import sys
 import copy
 import distutils.core

Modified: branches/distutils-revamp/cpuinfo.py
===================================================================
--- branches/distutils-revamp/cpuinfo.py	2007-04-30 16:29:51 UTC (rev 3731)
+++ branches/distutils-revamp/cpuinfo.py	2007-04-30 22:11:03 UTC (rev 3732)
@@ -5,7 +5,7 @@
 Copyright 2002 Pearu Peterson all rights reserved,
 Pearu Peterson <pearu at cens.ioc.ee>
 Permission to use, modify, and distribute this software is given under the
-terms of the SciPy (BSD style) license.  See LICENSE.txt that came with
+terms of the NumPy (BSD style) license.  See LICENSE.txt that came with
 this distribution for specifics.
 
 Note:  This should be merged into proc at some point.  Perhaps proc should
@@ -185,8 +185,13 @@
         return self.is_PentiumIV() and self.has_sse3()
 
     def _is_Nocona(self):
-        return self.is_PentiumIV() and self.is_64bit()
+        return self.is_64bit() and self.is_PentiumIV()
 
+    def _is_Core2(self):
+        return self.is_64bit() and self.is_Intel() and \
+               re.match(r'.*?Core\(TM\)2\b', \
+                        self.info[0]['model name']) is not None
+
     def _is_Itanium(self):
         return re.match(r'.*?Itanium\b',
                         self.info[0]['family']) is not None

Modified: branches/distutils-revamp/fcompiler/__init__.py
===================================================================
--- branches/distutils-revamp/fcompiler/__init__.py	2007-04-30 16:29:51 UTC (rev 3731)
+++ branches/distutils-revamp/fcompiler/__init__.py	2007-04-30 22:11:03 UTC (rev 3732)
@@ -16,7 +16,7 @@
 except NameError:
     from sets import Set as set
 
-from distutils.sysconfig import get_config_var
+from distutils.sysconfig import get_config_var, get_python_lib
 from distutils.fancy_getopt import FancyGetopt
 from distutils.errors import DistutilsModuleError,DistutilsArgError,\
      DistutilsExecError,CompileError,LinkError,DistutilsPlatformError
@@ -40,7 +40,7 @@
 
     Methods that subclasses may redefine:
 
-        get_version_cmd(), get_linker_so(), get_version()
+        find_executables(), get_version_cmd(), get_linker_so(), get_version()
         get_flags(), get_flags_opt(), get_flags_arch(), get_flags_debug()
         get_flags_f77(), get_flags_opt_f77(), get_flags_arch_f77(),
         get_flags_debug_f77(), get_flags_f90(), get_flags_opt_f90(),
@@ -438,7 +438,14 @@
         linker_so = self.command_vars.linker_so
         if linker_so:
             linker_so_flags = to_list(self.flag_vars.linker_so)
-            self.set_executables(linker_so=[linker_so]+linker_so_flags)
+            if sys.platform.startswith('aix'):
+                python_lib = get_python_lib(standard_lib=1)
+                ld_so_aix = os.path.join(python_lib, 'config', 'ld_so_aix')
+                python_exp = os.path.join(python_lib, 'config', 'python.exp')
+                linker_so = [ld_so_aix, linker_so, '-bI:'+python_exp]
+            else:
+                linker_so = [linker_so]
+            self.set_executables(linker_so=linker_so+linker_so_flags)
 
         linker_exe = self.command_vars.linker_exe
         if linker_exe:

Modified: branches/distutils-revamp/fcompiler/gnu.py
===================================================================
--- branches/distutils-revamp/fcompiler/gnu.py	2007-04-30 16:29:51 UTC (rev 3731)
+++ branches/distutils-revamp/fcompiler/gnu.py	2007-04-30 22:11:03 UTC (rev 3732)
@@ -1,11 +1,9 @@
-
 import re
 import os
 import sys
 import warnings
 
 from numpy.distutils.cpuinfo import cpu
-from numpy.distutils.ccompiler import simple_version_match
 from numpy.distutils.fcompiler import FCompiler
 from numpy.distutils.exec_command import exec_command
 from numpy.distutils.misc_util import mingw32, msvc_runtime_library
@@ -13,11 +11,34 @@
 compilers = ['GnuFCompiler', 'Gnu95FCompiler']
 
 class GnuFCompiler(FCompiler):
-
     compiler_type = 'gnu'
     description = 'GNU Fortran 77 compiler'
-    version_match = simple_version_match(start=r'GNU Fortran (?!95)')
 
+    def gnu_version_match(self, version_string):
+        """Handle the different versions of GNU fortran compilers"""
+        m = re.match(r'GNU Fortran', version_string)
+        if not m:
+            return None
+        m = re.match(r'GNU Fortran\s+95.*?([0-9-.]+)', version_string)
+        if m:
+            return ('gfortran', m.group(1))
+        m = re.match(r'GNU Fortran.*?([0-9-.]+)', version_string)
+        if m:
+            v = m.group(1)
+            if v.startswith('0') or v.startswith('2') or v.startswith('3'):
+                # the '0' is for early g77's
+                return ('g77', v)
+            else:
+                # at some point in the 4.x series, the ' 95' was dropped
+                # from the version string
+                return ('gfortran', v)
+
+    def version_match(self, version_string):
+        v = self.gnu_version_match(version_string)
+        if not v or v[0] != 'g77':
+            return None
+        return v[1]
+
     # 'g77 --version' results
     # SunOS: GNU Fortran (GCC 3.2) 3.2 20020814 (release)
     # Debian: GNU Fortran (GCC) 3.3.3 20040110 (prerelease) (Debian)
@@ -62,13 +83,19 @@
 
     def get_flags_linker_so(self):
         opt = self.linker_so[1:]
-        if sys.platform == 'darwin':
-            target = os.environ.get('MACOSX_DEPLOYMENT_TARGET', '10.3')
+        if sys.platform=='darwin':
+            # MACOSX_DEPLOYMENT_TARGET must be at least 10.3. This is
+            # a reasonable default value even when building on 10.4 when using
+            # the official Python distribution and those derived from it (when
+            # not broken).
+            target = os.environ.get('MACOSX_DEPLOYMENT_TARGET', None)
+            if target is None or target == '':
+                target = '10.3'
             major, minor = target.split('.')
             if int(minor) < 3:
                 minor = '3'
                 warnings.warn('Environment variable '
-                    'MACOSX_DEPLOYMENT_TARGET reset to 10.3')
+                    'MACOSX_DEPLOYMENT_TARGET reset to %s.%s' % (major, minor))
             os.environ['MACOSX_DEPLOYMENT_TARGET'] = '%s.%s' % (major,
                 minor)
 
@@ -189,6 +216,8 @@
                 # there's also: athlon-tbird, athlon-4, athlon-xp
             elif cpu.is_Nocona():
                 march_opt = '-march=nocona'
+            elif cpu.is_Core2():
+                march_opt = '-march=nocona'
             elif cpu.is_Prescott():
                 march_opt = '-march=prescott'
             elif cpu.is_PentiumIV():
@@ -209,6 +238,10 @@
         if gnu_ver >= '3.4.4':
             if cpu.is_PentiumM():
                 march_opt = '-march=pentium-m'
+        # Future:
+        # if gnu_ver >= '4.3':
+        #    if cpu.is_Core2():
+        #        march_opt = '-march=core2'
 
         # Note: gcc 3.2 on win32 has breakage with -march specified
         if '3.1.1' <= gnu_ver <= '3.4' and sys.platform=='win32':
@@ -234,22 +267,31 @@
         return opt
 
 class Gnu95FCompiler(GnuFCompiler):
-
     compiler_type = 'gnu95'
     description = 'GNU Fortran 95 compiler'
-    version_match = simple_version_match(start='GNU Fortran 95')
 
+    def version_match(self, version_string):
+        v = self.gnu_version_match(version_string)
+        if not v or v[0] != 'gfortran':
+            return None
+        return v[1]
+
     # 'gfortran --version' results:
+    # XXX is the below right?
     # Debian: GNU Fortran 95 (GCC 4.0.3 20051023 (prerelease) (Debian 4.0.2-3))
+    #         GNU Fortran 95 (GCC) 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)
     # OS X: GNU Fortran 95 (GCC) 4.1.0
     #       GNU Fortran 95 (GCC) 4.2.0 20060218 (experimental)
+    #       GNU Fortran (GCC) 4.3.0 20070316 (experimental)
 
     possible_executables = ['gfortran', 'f95']
     executables = {
         'version_cmd'  : ["<F90>", "--version"],
-        'compiler_f77' : [None, "-Wall", "-ffixed-form", "-fno-second-underscore"],
+        'compiler_f77' : [None, "-Wall", "-ffixed-form",
+                          "-fno-second-underscore"],
         'compiler_f90' : [None, "-Wall", "-fno-second-underscore"],
-        'compiler_fix' : [None, "-Wall", "-ffixed-form", "-fno-second-underscore"],
+        'compiler_fix' : [None, "-Wall", "-ffixed-form",
+                          "-fno-second-underscore"],
         'linker_so'    : ["<F90>", "-Wall"],
         'archiver'     : ["ar", "-cr"],
         'ranlib'       : ["ranlib"],

Modified: branches/distutils-revamp/fcompiler/ibm.py
===================================================================
--- branches/distutils-revamp/fcompiler/ibm.py	2007-04-30 16:29:51 UTC (rev 3731)
+++ branches/distutils-revamp/fcompiler/ibm.py	2007-04-30 22:11:03 UTC (rev 3732)
@@ -3,7 +3,9 @@
 import sys
 
 from numpy.distutils.fcompiler import FCompiler
+from numpy.distutils.exec_command import exec_command, find_executable
 from distutils import log
+from distutils.sysconfig import get_python_lib
 
 compilers = ['IBMFCompiler']
 
@@ -11,10 +13,10 @@
 
     compiler_type = 'ibm'
     description = 'IBM XL Fortran Compiler'
-    version_pattern =  r'xlf\(1\)\s*IBM XL Fortran (Advanced Edition |)Version (?P<version>[^\s*]*)'
-
+    version_pattern =  r'(xlf\(1\)\s*|)IBM XL Fortran ((Advanced Edition |)Version |Enterprise Edition V)(?P<version>[^\s*]*)'
+    #IBM XL Fortran Enterprise Edition V10.1 for AIX \nVersion: 10.01.0000.0004
     executables = {
-        'version_cmd'  : ["<F77>"],
+        'version_cmd'  : ["<F77>", "-qversion"],
         'compiler_f77' : ["xlf"],
         'compiler_fix' : ["xlf90", "-qfixed"],
         'compiler_f90' : ["xlf90"],
@@ -25,8 +27,19 @@
 
     def get_version(self,*args,**kwds):
         version = FCompiler.get_version(self,*args,**kwds)
+
+        if version is None and sys.platform.startswith('aix'):
+            # use lslpp to find out xlf version
+            lslpp = find_executable('lslpp')
+            xlf = find_executable('xlf')
+            if os.path.exists(xlf) and os.path.exists(lslpp):
+                s,o = exec_command(lslpp + ' -Lc xlfcmp')
+                m = re.search('xlfcmp:(?P<version>\d+([.]\d+)+)', o)
+                if m: version = m.group('version')
+
         xlf_dir = '/etc/opt/ibmcmp/xlf'
         if version is None and os.path.isdir(xlf_dir):
+            # linux:
             # If the output of xlf does not contain version info
             # (that's the case with xlf 8.1, for instance) then
             # let's try another method:
@@ -54,7 +67,10 @@
         version = self.get_version(ok_status=[0,40])
         if version is not None:
             import tempfile
-            xlf_cfg = '/etc/opt/ibmcmp/xlf/%s/xlf.cfg' % version
+            if sys.platform.startswith('aix'):
+                xlf_cfg = '/etc/xlf.cfg'
+            else:
+                xlf_cfg = '/etc/opt/ibmcmp/xlf/%s/xlf.cfg' % version
             new_cfg = tempfile.mktemp()+'_xlf.cfg'
             log.info('Creating '+new_cfg)
             fi = open(xlf_cfg,'r')

Modified: branches/distutils-revamp/fcompiler/intel.py
===================================================================
--- branches/distutils-revamp/fcompiler/intel.py	2007-04-30 16:29:51 UTC (rev 3731)
+++ branches/distutils-revamp/fcompiler/intel.py	2007-04-30 22:11:03 UTC (rev 3732)
@@ -1,3 +1,6 @@
+# -*- encoding: iso-8859-1 -*-
+# above encoding b/c there's a non-ASCII character in the sample output
+# of intele
 # http://developer.intel.com/software/products/compilers/flin/
 
 import os
@@ -4,18 +7,22 @@
 import sys
 
 from numpy.distutils.cpuinfo import cpu
+from numpy.distutils.ccompiler import simple_version_match
 from numpy.distutils.fcompiler import FCompiler, dummy_fortran_file
 
 compilers = ['IntelFCompiler', 'IntelVisualFCompiler',
              'IntelItaniumFCompiler', 'IntelItaniumVisualFCompiler',
              'IntelEM64TFCompiler']
 
+def intel_version_match(type):
+    # Match against the important stuff in the version string
+    return simple_version_match(start=r'Intel.*?Fortran.*?%s.*?Version' % (type,))
+
 class IntelFCompiler(FCompiler):
 
     compiler_type = 'intel'
     description = 'Intel Fortran Compiler for 32-bit apps'
-    version_pattern = r'Intel\(R\) Fortran Compiler for 32-bit '\
-                      'applications, Version (?P<version>[^\s*]*)'
+    version_match = intel_version_match('32-bit')
 
 
     possible_executables = ['ifort', 'ifc']
@@ -78,10 +85,9 @@
 class IntelItaniumFCompiler(IntelFCompiler):
     compiler_type = 'intele'
     description = 'Intel Fortran Compiler for Itanium apps'
-    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*]*)'
 
+    version_match = intel_version_match('Itanium')
+
 #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.
@@ -104,8 +110,7 @@
     compiler_type = 'intelem'
     description = 'Intel Fortran Compiler for EM64T-based apps'
 
-    version_pattern = r'Intel\(R\) Fortran Compiler for Intel\(R\) EM64T-based '\
-                      'applications, Version (?P<version>[^\s*]*)'
+    version_match = intel_version_match('EM64T-based')
 
     possible_executables = ['ifort', 'efort', 'efc']
 
@@ -126,13 +131,15 @@
             opt.extend(['-tpp7', '-xW'])
         return opt
 
+# Is there no difference in the version string between the above compilers
+# and the Visual compilers?
+
 class IntelVisualFCompiler(FCompiler):
-
     compiler_type = 'intelv'
     description = 'Intel Visual Fortran Compiler for 32-bit apps'
-    version_pattern = r'Intel\(R\) Fortran Compiler for 32-bit applications, '\
-                      'Version (?P<version>[^\s*]*)'
 
+    version_match = intel_version_match('32-bit')
+
     ar_exe = 'lib.exe'
     fc_exe = 'ifl'
 
@@ -181,13 +188,11 @@
         return opt
 
 class IntelItaniumVisualFCompiler(IntelVisualFCompiler):
-
     compiler_type = 'intelev'
     description = 'Intel Visual Fortran Compiler for Itanium apps'
-    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*]*)'
 
+    version_match = intel_version_match('Itanium')
+
     fc_exe = 'efl' # XXX this is a wild guess
     ar_exe = IntelVisualFCompiler.ar_exe
 

Modified: branches/distutils-revamp/interactive.py
===================================================================
--- branches/distutils-revamp/interactive.py	2007-04-30 16:29:51 UTC (rev 3731)
+++ branches/distutils-revamp/interactive.py	2007-04-30 22:11:03 UTC (rev 3732)
@@ -1,4 +1,3 @@
-
 import os
 import sys
 from pprint import pformat
@@ -12,7 +11,7 @@
     for a in ['name']:
         print 'os.%s = %s' % (a,pformat(getattr(os,a)))
     if hasattr(os,'uname'):
-        print 'system,node,release,version,machine = ',os.uname()    
+        print 'system,node,release,version,machine = ',os.uname()
 
 def show_environ(*args):
     for k,i in os.environ.items():
@@ -29,7 +28,7 @@
 def show_tasks(argv,ccompiler,fcompiler):
     print """\
 
-Tasks: 
+Tasks:
   i       - Show python/platform/machine information
   ie      - Show environment information
   c       - Show C compilers information
@@ -65,7 +64,7 @@
     if s:
         argv[1:] = splitcmdline(s)
     return
-    
+
 def interactive_sys_argv(argv):
     print '='*72
     print 'Starting interactive session'
@@ -186,4 +185,3 @@
 
     print '-'*72
     return argv
-

Modified: branches/distutils-revamp/misc_util.py
===================================================================
--- branches/distutils-revamp/misc_util.py	2007-04-30 16:29:51 UTC (rev 3731)
+++ branches/distutils-revamp/misc_util.py	2007-04-30 22:11:03 UTC (rev 3732)
@@ -962,9 +962,9 @@
         return
 
     def add_numarray_include_dirs(self):
-	import numpy.numarray.util as nnu
-	self.add_include_dirs(*nnu.get_numarray_include_dirs())
-	
+        import numpy.numarray.util as nnu
+        self.add_include_dirs(*nnu.get_numarray_include_dirs())
+
     def add_headers(self,*files):
         """ Add installable headers to configuration.
         Argument(s) can be either
@@ -1294,7 +1294,7 @@
 
         return version
 
-    def make_svn_version_py(self):
+    def make_svn_version_py(self, delete=True):
         """ Generate package __svn_version__.py file from SVN revision number,
         it will be removed after python exits but will be available
         when sdist, etc commands are executed.
@@ -1302,30 +1302,32 @@
         If __svn_version__.py existed before, nothing is done.
         """
         target = njoin(self.local_path,'__svn_version__.py')
-        if os.path.isfile(target):
+        revision = self._get_svn_revision(self.local_path)
+        if os.path.isfile(target) or revision is None:
             return
-        def generate_svn_version_py():
-            if not os.path.isfile(target):
-                revision = self._get_svn_revision(self.local_path)
-                assert revision is not None,'hmm, why I am not inside SVN tree???'
-                version = str(revision)
-                self.info('Creating %s (version=%r)' % (target,version))
-                f = open(target,'w')
-                f.write('version = %r\n' % (version))
-                f.close()
+        else:
+            def generate_svn_version_py():
+                if not os.path.isfile(target):
+                    version = str(revision)
+                    self.info('Creating %s (version=%r)' % (target,version))
+                    f = open(target,'w')
+                    f.write('version = %r\n' % (version))
+                    f.close()
 
-            import atexit
-            def rm_file(f=target,p=self.info):
-                try: os.remove(f); p('removed '+f)
-                except OSError: pass
-                try: os.remove(f+'c'); p('removed '+f+'c')
-                except OSError: pass
-            atexit.register(rm_file)
+                import atexit
+                def rm_file(f=target,p=self.info):
+                    if delete:
+                        try: os.remove(f); p('removed '+f)
+                        except OSError: pass
+                        try: os.remove(f+'c'); p('removed '+f+'c')
+                        except OSError: pass
 
-            return target
+                atexit.register(rm_file)
 
-        self.add_data_files(('', generate_svn_version_py()))
+                return target
 
+            self.add_data_files(('', generate_svn_version_py()))
+
     def make_config_py(self,name='__config__'):
         """ Generate package __config__.py file containing system_info
         information used during building the package.
@@ -1360,14 +1362,7 @@
     include_dirs = Configuration.numpy_include_dirs[:]
     if not include_dirs:
         import numpy
-        if numpy.show_config is None:
-            # running from numpy_core source directory
-            include_dirs.append(njoin(os.path.dirname(numpy.__file__),
-                                             'core', 'include'))
-        else:
-            # using installed numpy core headers
-            import numpy.core as core
-            include_dirs.append(njoin(os.path.dirname(core.__file__), 'include'))
+        include_dirs = [ numpy.get_include() ]
     # else running numpy/core/setup.py
     return include_dirs
 

Modified: branches/distutils-revamp/system_info.py
===================================================================
--- branches/distutils-revamp/system_info.py	2007-04-30 16:29:51 UTC (rev 3731)
+++ branches/distutils-revamp/system_info.py	2007-04-30 22:11:03 UTC (rev 3732)
@@ -58,7 +58,7 @@
 The file 'site.cfg' is looked for in
 
 1) Directory of main setup.py file being run.
-2) Home directory of user running the setup.py file (Not implemented yet)
+2) Home directory of user running the setup.py file as ~/.numpy-site.cfg
 3) System wide directory (location of this file...)
 
 The first one found is used to get system configuration options The
@@ -104,7 +104,7 @@
 Copyright 2002 Pearu Peterson all rights reserved,
 Pearu Peterson <pearu at cens.ioc.ee>
 Permission to use, modify, and distribute this software is given under the
-terms of the SciPy (BSD style) license.  See LICENSE.txt that came with
+terms of the NumPy (BSD style) license.  See LICENSE.txt that came with
 this distribution for specifics.
 
 NO WARRANTY IS EXPRESSED OR IMPLIED.  USE AT YOUR OWN RISK.
@@ -349,7 +349,9 @@
         defaults['src_dirs'] = os.pathsep.join(default_src_dirs)
         defaults['search_static_first'] = str(self.search_static_first)
         self.cp = ConfigParser.ConfigParser(defaults)
-        self.files = get_standard_file('site.cfg')
+        self.files = []
+        self.files.extend(get_standard_file('.numpy-site.cfg'))
+        self.files.extend(get_standard_file('site.cfg'))
         self.parse_config_files()
         self.search_static_first = self.cp.getboolean(self.section,
                                                       'search_static_first')
@@ -809,9 +811,12 @@
         info = {}
         dict_append(info,**mkl)
         dict_append(info,
-                    libraries = ['pthread'],
                     define_macros=[('SCIPY_MKL_H',None)],
                     include_dirs = incl_dirs)
+        if sys.platform == 'win32':
+            pass # win32 has no pthread library
+        else:
+            dict_append(info, libraries=['pthread'])
         self.set_info(**info)
 
 class lapack_mkl_info(mkl_info):
@@ -820,7 +825,11 @@
         mkl = get_info('mkl')
         if not mkl:
             return
-        lapack_libs = self.get_libs('lapack_libs',['mkl_lapack32','mkl_lapack64'])
+        if sys.platform == 'win32':
+            lapack_libs = self.get_libs('lapack_libs',['mkl_lapack'])
+        else:
+            lapack_libs = self.get_libs('lapack_libs',['mkl_lapack32','mkl_lapack64'])
+            
         info = {'libraries': lapack_libs}
         dict_append(info,**mkl)
         self.set_info(**info)
@@ -1114,7 +1123,7 @@
     if _cached_atlas_version.has_key(key):
         return _cached_atlas_version[key]
     c = cmd_config(Distribution())
-    atlas_version = None  
+    atlas_version = None
     try:
         s, o = c.get_output(atlas_version_c_text,
                             libraries=libraries, library_dirs=library_dirs)

Copied: branches/distutils-revamp/tests/test_fcompiler_gnu.py (from rev 3731, trunk/numpy/distutils/tests/test_fcompiler_gnu.py)




More information about the Numpy-svn mailing list