[Numpy-svn] r4109 - in branches/numpy.scons: . numpy/distutils numpy/distutils/command numpy/distutils/scons numpy/scons_fake

numpy-svn@scip... numpy-svn@scip...
Mon Sep 24 00:55:51 CDT 2007


Author: cdavid
Date: 2007-09-24 00:55:27 -0500 (Mon, 24 Sep 2007)
New Revision: 4109

Modified:
   branches/numpy.scons/
   branches/numpy.scons/numpy/distutils/ccompiler.py
   branches/numpy.scons/numpy/distutils/command/build_ext.py
   branches/numpy.scons/numpy/distutils/command/scons.py
   branches/numpy.scons/numpy/distutils/scons/__init__.py
   branches/numpy.scons/numpy/scons_fake/SConstruct
Log:
Starting to work on passing C compiler info


Property changes on: branches/numpy.scons
___________________________________________________________________
Name: bzr:revision-info
   - timestamp: 2007-09-23 00:40:07.401000023 +0900
committer: david <david@david-laptop>
properties: 
	branch-nick: numpy.scons

   + timestamp: 2007-09-23 16:00:11.173000097 +0900
committer: david <david@david-laptop>
properties: 
	branch-nick: numpy.scons

Name: bzr:revision-id:v3-trunk0
   - 3737 david@david-laptop-20070920080908-n8pj8vmszdir3zoa
3738 david@david-laptop-20070920081509-58kkojgmml3t7jxs
3739 david@david-laptop-20070920081910-phlk1ujthksgpm0z
3740 david@david-laptop-20070920082641-bdhrt6eafeoli50i
3741 david@ar.media.kyoto-u.ac.jp-20070920130730-satdeppbh1k0bq2p
3743 david@ar.media.kyoto-u.ac.jp-20070921073742-vpv8pwv0j8fbd93m
3744 david@david-laptop-20070922101656-61kfi2faucemr2rl
3745 david@david-laptop-20070922113708-ror18thshang1cpu
3747 david@david-laptop-20070922140534-n9xsl096tjrzmct1
3749 david@david-laptop-20070922154007-usit009fr6vp377j

   + 3737 david@david-laptop-20070920080908-n8pj8vmszdir3zoa
3738 david@david-laptop-20070920081509-58kkojgmml3t7jxs
3739 david@david-laptop-20070920081910-phlk1ujthksgpm0z
3740 david@david-laptop-20070920082641-bdhrt6eafeoli50i
3741 david@ar.media.kyoto-u.ac.jp-20070920130730-satdeppbh1k0bq2p
3743 david@ar.media.kyoto-u.ac.jp-20070921073742-vpv8pwv0j8fbd93m
3744 david@david-laptop-20070922101656-61kfi2faucemr2rl
3745 david@david-laptop-20070922113708-ror18thshang1cpu
3747 david@david-laptop-20070922140534-n9xsl096tjrzmct1
3749 david@david-laptop-20070922154007-usit009fr6vp377j
3750 david@david-laptop-20070923070011-leu2ozc2fy1q5cht


Modified: branches/numpy.scons/numpy/distutils/ccompiler.py
===================================================================
--- branches/numpy.scons/numpy/distutils/ccompiler.py	2007-09-23 20:49:11 UTC (rev 4108)
+++ branches/numpy.scons/numpy/distutils/ccompiler.py	2007-09-24 05:55:27 UTC (rev 4109)
@@ -364,6 +364,8 @@
               ("can't compile C/C++ code: unable to find class '%s' " +
                "in module '%s'") % (class_name, module_name)
     compiler = klass(None, dry_run, force)
+    #print "!!!!!!!!!!!!!!!!!!!!!"
+    #print "compiler class is %s, module_name is %s, compiler %s" % (klass, module_name, compiler.cc_exe)
     log.debug('new_compiler returns %s' % (klass))
     return compiler
 

Modified: branches/numpy.scons/numpy/distutils/command/build_ext.py
===================================================================
--- branches/numpy.scons/numpy/distutils/command/build_ext.py	2007-09-23 20:49:11 UTC (rev 4108)
+++ branches/numpy.scons/numpy/distutils/command/build_ext.py	2007-09-24 05:55:27 UTC (rev 4109)
@@ -76,10 +76,13 @@
                                      verbose=self.verbose,
                                      dry_run=self.dry_run,
                                      force=self.force)
+        print "self.compiler is %s, this gives us %s" % (compiler_type, self.compiler)
         self.compiler.customize(self.distribution)
         self.compiler.customize_cmd(self)
         self.compiler.show_customization()
 
+        print "======================"
+        print self.compiler.compiler
         # Create mapping of libraries built by build_clib:
         clibs = {}
         if build_clib is not None:

Modified: branches/numpy.scons/numpy/distutils/command/scons.py
===================================================================
--- branches/numpy.scons/numpy/distutils/command/scons.py	2007-09-23 20:49:11 UTC (rev 4108)
+++ branches/numpy.scons/numpy/distutils/command/scons.py	2007-09-24 05:55:27 UTC (rev 4109)
@@ -3,27 +3,63 @@
 from os.path import join as pjoin, dirname as pdirname
 
 #from distutils.core import build_py as old_build_py
-from distutils.command.build_ext import build_ext as old_build_py
+from numpy.distutils.command.build_ext import build_ext as old_build_ext
 from numpy.distutils.ccompiler import CCompiler
 
-# XXX: this is super ugly. The object/source filenames generations is handled
-# inside compiler classes and build_ext in distutils, so to get the same
-# convention, we derive scons command from build_ext instead of just Command.
-class scons(old_build_py):
+def dist2sconscc(compiler):
+    """This converts the name passed to distutils to scons name convention (C
+    compiler).
+
+    Example:
+        --compiler=intel -> icc."""
+    # Geez, why does distutils has no common way to get the compiler name...
+    if compiler.compiler_type == 'msvc':
+        #print dir(compiler)
+        return 'msvc'
+    else:
+        #print dir(compiler)
+        #print compiler.compiler[0]
+        return compiler.compiler[0]
+
+class scons(old_build_ext):
     description = "Scons builder"
-    user_options = []
+    #user_options = []
+    user_options = [('fcompiler=', None, "specify the Fortran compiler type"),
+                    ('compiler=', None, "specify the C compiler type")]
 
     def initialize_options(self):
-        old_build_py.initialize_options(self)
+        old_build_ext.initialize_options(self)
         pass
 
     def finalize_options(self):
-        old_build_py.finalize_options(self)
+        old_build_ext.finalize_options(self)
         if self.distribution.has_scons_scripts():
             print "Got it: scons scripts are %s" % self.distribution.scons_scripts
             self.scons_scripts = self.distribution.scons_scripts
         #        build_py = self.get_finalized_command('build_py')
-        #print "!!!!!!!!!!!!!!!!!!"
+        print "!!!!!!!!!!!!!!!!!!"
+        #from distutils.ccompiler import get_default_compiler
+        #import sys
+        #import os
+        #print get_default_compiler(sys.platform)
+        #print get_default_compiler(os.name)
+        #from numpy.distutils.ccompiler import compiler_class
+        #print compiler_class
+
+        # Try to get the same compiler than the ones used
+        compiler_type = self.compiler
+        # Initialize C compiler:
+        from distutils.ccompiler import new_compiler
+        #self.compiler = new_compiler(compiler=compiler_type,
+        #                             verbose=self.verbose,
+        #                             dry_run=self.dry_run,
+        #                             force=self.force)
+        self.compiler = new_compiler(compiler=compiler_type)
+
+        print "self.compiler is %s, this gives us %s" % (compiler_type, 
+                                                         dist2sconscc(self.compiler))
+        #print dir(new_compiler(self.compiler))
+        #print new_compiler(self.compiler).compiler
         #print self.build_temp
         #print self.build_lib
         #print self.package
@@ -36,6 +72,7 @@
             cmd = "scons -f " + i + ' -I. '
             cmd += ' src_dir=%s ' % pdirname(i)
             cmd += ' distutils_libdir=%s ' % pjoin(self.build_lib, pdirname(i))
+            cmd += ' cc_opt=%s ' % dist2sconscc(self.compiler)
             #print cmd
             st = os.system(cmd)
             if st:

Modified: branches/numpy.scons/numpy/distutils/scons/__init__.py
===================================================================
--- branches/numpy.scons/numpy/distutils/scons/__init__.py	2007-09-23 20:49:11 UTC (rev 4108)
+++ branches/numpy.scons/numpy/distutils/scons/__init__.py	2007-09-24 05:55:27 UTC (rev 4109)
@@ -2,9 +2,11 @@
 import os.path
 
 from SCons.Options import Options
+from SCons.Tool import Tool
 from SCons.Environment import Environment
-from SCons.Script import BuildDir
+from SCons.Script import BuildDir, Help
 
+from SCons.Errors import EnvironmentError
 
 def NumpySharedLibrary(env, target, source, *args, **kw):
     source = [pjoin(env['build_dir'], i) for i in source]
@@ -27,6 +29,7 @@
 def GetNumpyOptions(args):
     """Call this with args=ARGUMENTS to take into account command line args."""
     opts = Options(None, args)
+    # Add directories related info
     opts.Add('pkg_name', 'name of the package (including parent package if any)', '')
     opts.Add('src_dir', 'src dir relative to top called', '.')
     opts.Add('build_prefix', 'build prefix (NOT including the package name)', 
@@ -35,6 +38,8 @@
              'build dir for libraries of distutils (NOT including the package name)', 
              pjoin('build', 'lib'))
 
+    # Add compiler related info
+    opts.Add('cc_opt', 'name of C compiler', '')
     return opts
 
 def GetNumpyEnvironment(args):
@@ -45,6 +50,13 @@
     env.AppendUnique(distutils_installdir = pjoin(env['distutils_libdir'], 
                                                   env['pkg_name']))
 
+    if len(env['cc_opt']) > 0:
+        try:
+            t = Tool(env['cc_opt'])
+            t(env) 
+        except EnvironmentError, e:
+            # scons could not understand cc_opt (bad name ?)
+            raise AssertionError(e)
     env['BUILDERS']['NumpySharedLibrary'] = NumpySharedLibrary
     env['BUILDERS']['NumpyCTypes'] = NumpyCTypes
     print env['src_dir']
@@ -53,4 +65,6 @@
     else:
         BuildDir(env['build_dir'], '.')
 
+    Help(opts.GenerateHelpText(env))
+
     return env

Modified: branches/numpy.scons/numpy/scons_fake/SConstruct
===================================================================
--- branches/numpy.scons/numpy/scons_fake/SConstruct	2007-09-23 20:49:11 UTC (rev 4108)
+++ branches/numpy.scons/numpy/scons_fake/SConstruct	2007-09-24 05:55:27 UTC (rev 4109)
@@ -3,6 +3,7 @@
 
 env = GetNumpyEnvironment(ARGUMENTS)
 
+config = env.Configure()
 config.CheckHeader('stdio.h')
 config.CheckLib('c', 'printf')
 config.Finish()



More information about the Numpy-svn mailing list