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

numpy-svn at scipy.org numpy-svn at scipy.org
Mon Sep 24 07:38:14 EDT 2007


Author: cdavid
Date: 2007-09-24 06:37:58 -0500 (Mon, 24 Sep 2007)
New Revision: 4115

Modified:
   branches/numpy.scons/
   branches/numpy.scons/numpy/distutils/command/scons.py
   branches/numpy.scons/numpy/distutils/scons/__init__.py
   branches/numpy.scons/numpy/scons_fake/SConstruct
Log:
* Start implementing scons checker which take into account site.cfg files
* Intel compiler in non standard path better handled now



Property changes on: branches/numpy.scons
___________________________________________________________________
Name: bzr:revision-info
   - timestamp: 2007-09-24 17:30:08.612999916 +0900
committer: David Cournapeau <david at ar.media.kyoto-u.ac.jp>
properties: 
	branch-nick: numpy.scons

   + timestamp: 2007-09-24 20:23:51.194999933 +0900
committer: David Cournapeau <david at ar.media.kyoto-u.ac.jp>
properties: 
	branch-nick: numpy.scons

Name: bzr:file-ids
   - numpy/doc/example.py	4112 at 94b884b6-d6fd-0310-90d3-974f1d3f35e1:branches%2Fnumpy.scons:numpy%2Fdoc%2Fexample.py
numpy/doc/HOWTO_DOCUMENT.txt	4112 at 94b884b6-d6fd-0310-90d3-974f1d3f35e1:branches%2Fnumpy.scons:numpy%2Fdoc%2FHOWTO_DOCUMENT.txt
numpy/doc/html	4112 at 94b884b6-d6fd-0310-90d3-974f1d3f35e1:branches%2Fnumpy.scons:numpy%2Fdoc%2Fhtml
numpy/doc/html/epydoc.js	4112 at 94b884b6-d6fd-0310-90d3-974f1d3f35e1:branches%2Fnumpy.scons:numpy%2Fdoc%2Fhtml%2Fepydoc.js
numpy/doc/html/example-pysrc.html	4112 at 94b884b6-d6fd-0310-90d3-974f1d3f35e1:branches%2Fnumpy.scons:numpy%2Fdoc%2Fhtml%2Fexample-pysrc.html
numpy/doc/html/example-module.html	4112 at 94b884b6-d6fd-0310-90d3-974f1d3f35e1:branches%2Fnumpy.scons:numpy%2Fdoc%2Fhtml%2Fexample-module.html
numpy/doc/html/toc-everything.html	4112 at 94b884b6-d6fd-0310-90d3-974f1d3f35e1:branches%2Fnumpy.scons:numpy%2Fdoc%2Fhtml%2Ftoc-everything.html
numpy/doc/html/api-objects.txt	4112 at 94b884b6-d6fd-0310-90d3-974f1d3f35e1:branches%2Fnumpy.scons:numpy%2Fdoc%2Fhtml%2Fapi-objects.txt
numpy/doc/html/toc-example-module.html	4112 at 94b884b6-d6fd-0310-90d3-974f1d3f35e1:branches%2Fnumpy.scons:numpy%2Fdoc%2Fhtml%2Ftoc-example-module.html
numpy/doc/html/redirect.html	4112 at 94b884b6-d6fd-0310-90d3-974f1d3f35e1:branches%2Fnumpy.scons:numpy%2Fdoc%2Fhtml%2Fredirect.html
numpy/doc/html/identifier-index.html	4112 at 94b884b6-d6fd-0310-90d3-974f1d3f35e1:branches%2Fnumpy.scons:numpy%2Fdoc%2Fhtml%2Fidentifier-index.html
numpy/doc/html/index.html	4112 at 94b884b6-d6fd-0310-90d3-974f1d3f35e1:branches%2Fnumpy.scons:numpy%2Fdoc%2Fhtml%2Findex.html
numpy/doc/html/help.html	4112 at 94b884b6-d6fd-0310-90d3-974f1d3f35e1:branches%2Fnumpy.scons:numpy%2Fdoc%2Fhtml%2Fhelp.html
numpy/doc/html/frames.html	4112 at 94b884b6-d6fd-0310-90d3-974f1d3f35e1:branches%2Fnumpy.scons:numpy%2Fdoc%2Fhtml%2Fframes.html
numpy/doc/html/crarr.png	4112 at 94b884b6-d6fd-0310-90d3-974f1d3f35e1:branches%2Fnumpy.scons:numpy%2Fdoc%2Fhtml%2Fcrarr.png
numpy/doc/html/epydoc.css	4112 at 94b884b6-d6fd-0310-90d3-974f1d3f35e1:branches%2Fnumpy.scons:numpy%2Fdoc%2Fhtml%2Fepydoc.css
numpy/doc/html/module-tree.html	4112 at 94b884b6-d6fd-0310-90d3-974f1d3f35e1:branches%2Fnumpy.scons:numpy%2Fdoc%2Fhtml%2Fmodule-tree.html
numpy/doc/html/toc.html	4112 at 94b884b6-d6fd-0310-90d3-974f1d3f35e1:branches%2Fnumpy.scons:numpy%2Fdoc%2Fhtml%2Ftoc.html

   + 
Name: bzr:revision-id:v3-trunk0
   - 3737 david at david-laptop-20070920080908-n8pj8vmszdir3zoa
3738 david at david-laptop-20070920081509-58kkojgmml3t7jxs
3739 david at david-laptop-20070920081910-phlk1ujthksgpm0z
3740 david at david-laptop-20070920082641-bdhrt6eafeoli50i
3741 david at ar.media.kyoto-u.ac.jp-20070920130730-satdeppbh1k0bq2p
3743 david at ar.media.kyoto-u.ac.jp-20070921073742-vpv8pwv0j8fbd93m
3744 david at david-laptop-20070922101656-61kfi2faucemr2rl
3745 david at david-laptop-20070922113708-ror18thshang1cpu
3747 david at david-laptop-20070922140534-n9xsl096tjrzmct1
3749 david at david-laptop-20070922154007-usit009fr6vp377j
3750 david at david-laptop-20070923070011-leu2ozc2fy1q5cht
3751 david at david-laptop-20070924015925-dhsiao40jp7zsfp9
3752 david at ar.media.kyoto-u.ac.jp-20070924070657-nbw23j0ayan30cli
3753 david at ar.media.kyoto-u.ac.jp-20070924082918-i1lc1zikywi8czj4
3754 david at ar.media.kyoto-u.ac.jp-20070924083008-c0edtt8zs31yeh1q

   + 3737 david at david-laptop-20070920080908-n8pj8vmszdir3zoa
3738 david at david-laptop-20070920081509-58kkojgmml3t7jxs
3739 david at david-laptop-20070920081910-phlk1ujthksgpm0z
3740 david at david-laptop-20070920082641-bdhrt6eafeoli50i
3741 david at ar.media.kyoto-u.ac.jp-20070920130730-satdeppbh1k0bq2p
3743 david at ar.media.kyoto-u.ac.jp-20070921073742-vpv8pwv0j8fbd93m
3744 david at david-laptop-20070922101656-61kfi2faucemr2rl
3745 david at david-laptop-20070922113708-ror18thshang1cpu
3747 david at david-laptop-20070922140534-n9xsl096tjrzmct1
3749 david at david-laptop-20070922154007-usit009fr6vp377j
3750 david at david-laptop-20070923070011-leu2ozc2fy1q5cht
3751 david at david-laptop-20070924015925-dhsiao40jp7zsfp9
3752 david at ar.media.kyoto-u.ac.jp-20070924070657-nbw23j0ayan30cli
3753 david at ar.media.kyoto-u.ac.jp-20070924082918-i1lc1zikywi8czj4
3754 david at ar.media.kyoto-u.ac.jp-20070924083008-c0edtt8zs31yeh1q
3755 david at ar.media.kyoto-u.ac.jp-20070924112351-pnnho638cohz6lj1


Modified: branches/numpy.scons/numpy/distutils/command/scons.py
===================================================================
--- branches/numpy.scons/numpy/distutils/command/scons.py	2007-09-24 11:36:47 UTC (rev 4114)
+++ branches/numpy.scons/numpy/distutils/command/scons.py	2007-09-24 11:37:58 UTC (rev 4115)
@@ -9,13 +9,14 @@
 
 def dist2sconscc(compiler):
     """This converts the name passed to distutils to scons name convention (C
-    compiler).
+    compiler). The argument should be a CCompiler instance.
 
     Example:
-        --compiler=intel -> icc."""
-    # Geez, why does distutils has no common way to get the compiler name...
+        --compiler=intel -> intelc"""
     if compiler.compiler_type == 'msvc':
         return 'msvc'
+    elif compiler.compiler_type == 'intel':
+        return 'intelc'
     else:
         return compiler.compiler[0]
 

Modified: branches/numpy.scons/numpy/distutils/scons/__init__.py
===================================================================
--- branches/numpy.scons/numpy/distutils/scons/__init__.py	2007-09-24 11:36:47 UTC (rev 4114)
+++ branches/numpy.scons/numpy/distutils/scons/__init__.py	2007-09-24 11:37:58 UTC (rev 4115)
@@ -1,10 +1,12 @@
 from os.path import join as pjoin
 import os.path
+import ConfigParser
 
 from SCons.Options import Options
 from SCons.Tool import Tool
 from SCons.Environment import Environment
 from SCons.Script import BuildDir, Help
+#from SCons.Util import BuildDir, Help
 
 # XXX: all this should be put in another files eventually once it is getting in
 # shape
@@ -57,6 +59,8 @@
 
 def GetNumpyEnvironment(args):
     """Call this with args = ARGUMENTS."""
+    # XXX: I would prefer subclassing Environment, because we really expect
+    # some different behaviour than just Environment instances...
     opts = GetNumpyOptions(args)
     env = Environment(options = opts)
 
@@ -66,13 +70,26 @@
                                                   env['pkg_name']))
 
     # Setting tools according to command line options
+    # XXX: how to handle tools which are not in standard location ? Is adding
+    # the full path of the compiler enough ? (I am sure some compilers also
+    # need LD_LIBRARY_SHARED and other variables to be set, too....)
     if len(env['cc_opt']) > 0:
         try:
-            t = Tool(env['cc_opt'])
-            t(env) 
             if len(env['cc_opt_path']) > 0:
-                # XXX: what is the right way to add one directory in the PATH ?
-                env['ENV']['PATH'] += ':%s' % env['cc_opt_path']
+                if env['cc_opt'] == 'intelc':
+                    # Intel Compiler SCons.Tool has a special way to set the
+                    # path, so we use this one instead of changing
+                    # env['ENV']['PATH'].
+                    t = Tool(env['cc_opt'], 
+                             topdir = os.path.split(env['cc_opt_path'])[0])
+                    t(env) 
+                else:
+                    # XXX: what is the right way to add one directory in the
+                    # PATH ? (may not work on windows).
+                    env['ENV']['PATH'] += ':%s' % env['cc_opt_path']
+            else:
+                t = Tool(env['cc_opt'])
+                t(env) 
         except EnvironmentError, e:
             # scons could not understand cc_opt (bad name ?)
             raise AssertionError("SCONS: Could not initialize tool ? Error is %s" % \
@@ -91,13 +108,90 @@
     # Generate help (if calling scons directly during debugging, this could be useful)
     Help(opts.GenerateHelpText(env))
 
-    #print "setup.cfg abspath is %s" % pjoin(env['src_dir'], 'setup.cfg')
-    find_config_file()
+    # Getting the config options from *.cfg files
+    config = get_config()
+    env['NUMPYCONFIG'] = config
+
     return env
 
-def find_config_file(name = 'site.cfg'):
-    import ConfigParser
+def _get_empty(dict, key):
+    print "++++++ Deprecated, do not use _get_empty +++++++++"
+    try:
+        return dict[key]
+    except KeyError, e:
+        return []
 
+def NumpyCheckLib(context, section, libs, symbol = None):
+    #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+    # This is really preliminary, and needs a lot of love before being in good
+    # shape !!!!!
+    #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+    # XXX: handle extension in arg list
+    extension = '.c'
+    # XXX: handle symbol
+    src = """
+int main(int argc, char** argv)
+{
+    return 0;
+}"""
+    config = context.env['NUMPYCONFIG']
+    context.Message('Checking for library %s...' % libs)
+    if config.has_section(section):
+        #print "Checking %s from section %s" % (library, section)
+        try:
+            # XXX: handle list of directories here
+            # XXX: factorize this away
+            newLIBPATH = config.get(section, 'library_dirs') 
+            newCPPPATH = config.get(section, 'include_dirs') 
+            newLIBS = config.get(section, 'libraries') 
+            lastLIBPATH = _get_empty(context.env, 'LIBPATH')
+            lastLIBS = _get_empty(context.env, 'LIBS')
+            lastCPPPATH = _get_empty(context.env, 'CPPPATH')
+            # TODO: convert newLIBS to a list of libraries
+            # TODO: is library always a string, or can be a list ?
+            context.env.Append(LIBS = [libs], LIBPATH = [newLIBPATH])
+            res = context.TryLink(src, extension)
+            if not res:
+                context.env.Replace(LIBS = lastLIBS, 
+                                    LIBPATH = lastLIBPATH, 
+                                    CPPPATH = lastCPPPATH)
+        except ConfigParser.NoOptionError, e:
+            print "+++++++++++++++++++++++++++++++"
+            print e
+            print "+++++++++++++++++++++++++++++++"
+            res = 0
+    else:
+        lastLIBPATH = _get_empty(context.env, 'LIBPATH')
+        lastCPPPATH = _get_empty(context.env, 'CPPPATH')
+        lastLIBS = context.AppendLIBS([libs])
+        res = context.TryLink(src, extension)
+        if not res:
+            context.env.Replace(LIBS = lastLIBS, 
+                                LIBPATH = lastLIBPATH, 
+                                CPPPATH = lastCPPPATH)
+    return context.Result(res)
+
+def get_config():
+    """ This tries to read .cfg files in several locations, and merge its
+    information into a ConfigParser object for the first found file.
+    
+    Returns the ConfigParser instance. This copies the logic in system_info
+    from numpy.distutils."""
+    # Below is the feature we are copying from numpy.distutils:
+    # 
+    # 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 as ~/.numpy-site.cfg
+    # 3) System wide directory (location of this file...)
+
+    # The first one found is used to get system configuration options The
+    # format is that used by ConfigParser (i.e., Windows .INI style). The
+    # section DEFAULT has options that are the default for each section. The
+    # available sections are fftw, atlas, and x11. Appropiate defaults are
+    # used if nothing is specified.
+
     from numpy.distutils.system_info import default_lib_dirs
     from numpy.distutils.system_info import default_include_dirs
     from numpy.distutils.system_info import default_src_dirs
@@ -120,7 +214,4 @@
             cp.add_section(section)
 
     parse_config_files()
-    #print cp.sections()
-    #print dir(cp)
-    #print cp.get.__doc__
-    print cp.get('sndfile', 'include_dirs')
+    return cp

Modified: branches/numpy.scons/numpy/scons_fake/SConstruct
===================================================================
--- branches/numpy.scons/numpy/scons_fake/SConstruct	2007-09-24 11:36:47 UTC (rev 4114)
+++ branches/numpy.scons/numpy/scons_fake/SConstruct	2007-09-24 11:37:58 UTC (rev 4115)
@@ -1,12 +1,13 @@
 # vim:syntax=python
-from numpy.distutils.scons import GetNumpyEnvironment
+from numpy.distutils.scons import GetNumpyEnvironment, NumpyCheckLib
 
 env = GetNumpyEnvironment(ARGUMENTS)
 
-config = env.Configure()
+config = env.Configure(custom_tests = {'NumpyCheckLib' : NumpyCheckLib})
 config.CheckHeader('stdio.h')
 config.CheckLib('c', 'printf')
-config.CheckLib('sndfile', 'sf_open')
+#config.NumpyCheckLib('sndfile', 'sndfile', 'sf_open')
+config.NumpyCheckLib('bmeps', 'bmeps')
 config.Finish()
 
 source = ['foo.c']




More information about the Numpy-svn mailing list