[Numpy-svn] r4159 - in branches/numpy.scons: . numpy/distutils/scons numpy/scons_fake numpy/scons_fake/tests

numpy-svn at scipy.org numpy-svn at scipy.org
Tue Oct 9 11:24:33 EDT 2007


Author: cdavid
Date: 2007-10-09 10:24:09 -0500 (Tue, 09 Oct 2007)
New Revision: 4159

Added:
   branches/numpy.scons/numpy/distutils/scons/custom_builders.py
   branches/numpy.scons/numpy/distutils/scons/numpyenv.py
   branches/numpy.scons/numpy/scons_fake/hellomodule.c
   branches/numpy.scons/numpy/scons_fake/tests/test_spam.py
Modified:
   branches/numpy.scons/
   branches/numpy.scons/numpy/distutils/scons/__init__.py
   branches/numpy.scons/numpy/scons_fake/SConstruct
   branches/numpy.scons/numpy/scons_fake/__init__.py
Log:
Refactor distutils.scons module, get some code from separate numpy.scons project


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

   + timestamp: 2007-10-10 00:21:08.450999975 +0900
committer: david <david at david-laptop>
properties: 
	branch-nick: numpy.scons

Name: bzr:file-ids
   - numpy/distutils/scons/libinfo.py	libinfo.py-20071009093303-550dnrlqoermhxvl-1
numpy/distutils/scons/extension_scons.py	extension_scons.py-20071009093253-tzixdx7w5zen0j57-2
numpy/distutils/scons/libinfo_scons.py	libinfo_scons.py-20071009093303-550dnrlqoermhxvl-2
numpy/distutils/scons/utils.py	utils.py-20071009093305-fhqfd6xjru0te58v-1
numpy/distutils/scons/extension.py	extension.py-20071009093253-tzixdx7w5zen0j57-1

   + numpy/scons_fake/hellomodule.c	hellomodule.c-20071009151603-naqbhw7952s3b5pl-1
numpy/scons_fake/tests/test_spam.py	test_spam.py-20071009151607-wobzeu6ne1916j3p-1
numpy/distutils/scons/numpyenv.py	numpyenv.py-20071009151555-cl8a4vlu5xp3pzsg-1
numpy/distutils/scons/custom_builders.py	custom_builders.py-20071009151552-c0fhgo48e2t0lha6-1

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
3755 david at ar.media.kyoto-u.ac.jp-20070924112351-pnnho638cohz6lj1
3756 david at david-laptop-20070924153247-yftud00bynilxv69
3757 david at david-laptop-20070924163545-pish34x9fq2h66aj
3758 david at david-laptop-20070924164633-iiyygcaw81ji3n34
3759 david at david-laptop-20070924170201-y14v2yzikdpvamfp
3760 david at david-laptop-20070924171208-5bmitorzf49d1aa2
3761 david at david-laptop-20070925014444-ns9v90gotnxt39mq
3769 david at david-laptop-20070925145952-4osi81tvch7v6luj
3773 david at ar.media.kyoto-u.ac.jp-20070926073429-2kdc6yf1o210aer0
3774 david at ar.media.kyoto-u.ac.jp-20070926084356-938djoytjap90rmo
3775 david at ar.media.kyoto-u.ac.jp-20070926085329-3gquq3gu2k8rgzb0
3776 david at ar.media.kyoto-u.ac.jp-20071009084906-9kradhwpu7su633x
3777 david at ar.media.kyoto-u.ac.jp-20071009093339-q5nf5me6ikdi48k6

   + 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
3756 david at david-laptop-20070924153247-yftud00bynilxv69
3757 david at david-laptop-20070924163545-pish34x9fq2h66aj
3758 david at david-laptop-20070924164633-iiyygcaw81ji3n34
3759 david at david-laptop-20070924170201-y14v2yzikdpvamfp
3760 david at david-laptop-20070924171208-5bmitorzf49d1aa2
3761 david at david-laptop-20070925014444-ns9v90gotnxt39mq
3769 david at david-laptop-20070925145952-4osi81tvch7v6luj
3773 david at ar.media.kyoto-u.ac.jp-20070926073429-2kdc6yf1o210aer0
3774 david at ar.media.kyoto-u.ac.jp-20070926084356-938djoytjap90rmo
3775 david at ar.media.kyoto-u.ac.jp-20070926085329-3gquq3gu2k8rgzb0
3776 david at ar.media.kyoto-u.ac.jp-20071009084906-9kradhwpu7su633x
3777 david at ar.media.kyoto-u.ac.jp-20071009093339-q5nf5me6ikdi48k6
3778 david at david-laptop-20071009152108-xh5cltii0h6zjk9b


Modified: branches/numpy.scons/numpy/distutils/scons/__init__.py
===================================================================
--- branches/numpy.scons/numpy/distutils/scons/__init__.py	2007-10-09 09:43:24 UTC (rev 4158)
+++ branches/numpy.scons/numpy/distutils/scons/__init__.py	2007-10-09 15:24:09 UTC (rev 4159)
@@ -1,155 +1,9 @@
-from os.path import join as pjoin
-import os.path
-import ConfigParser
-import sys
+from numpyenv import GetNumpyEnvironment, GetNumpyOptions
+from libinfo_scons import NumpyCheckLib
 
-from SCons.Options import Options
-from SCons.Tool import Tool, FindTool, FindAllTools
-from SCons.Environment import Environment
-from SCons.Script import BuildDir, Help
-from SCons.Util import is_List
-
-from default import tool_list
-
-def pyplat2sconsplat():
-    # XXX: should see how env['PLATFORM'] is defined
-    if sys.platform[:5] == 'linux':
-        return 'posix'
-    else:
-        return sys.platform
-
-DEF_LINKERS, DEF_C_COMPILERS, DEF_CXX_COMPILERS, DEF_ASSEMBLERS, \
-DEF_FORTRAN_COMPILERS, DEF_ARS, DEF_OTHER_TOOLS = tool_list(pyplat2sconsplat())
 # XXX: all this should be put in another files eventually once it is getting in
 # shape
 
-def NumpySharedLibrary(env, target, source, *args, **kw):
-    """This builder is the same than SharedLibrary, except for the fact that it
-    takes into account build dir info passed by distutils, and put the target at
-    the right location in distutils build directory for correct installation."""
-    source = [pjoin(env['build_dir'], i) for i in source]
-    # XXX: why target is a list ? It is always true ?
-    lib = env.SharedLibrary("$build_dir/%s" % target[0], source, *args, **kw)
-
-    inst_lib = env.Install("$distutils_installdir", lib)
-    return lib, inst_lib
-	
-	
-def NumpyCTypes(env, target, source, *args, **kw):
-    """This builder is essentially the same than SharedLibrary, but should be
-    used for libraries which will only be used through ctypes.
-
-    In particular, it does not install .exp/.lib files on windows. """
-    source = [pjoin(env['build_dir'], i) for i in source]
-    # XXX: why target is a list ? It is always true ?
-    # XXX: handle cases where SHLIBPREFIX is in args
-    lib = env.SharedLibrary("$build_dir/%s" % target[0], 
-                            source, 
-                            SHLIBPREFIX = '', 
-                            *args, 
-                            **kw)
-    lib = [i for i in lib if not (str(i).endswith('.exp') or str(i).endswith('.lib')) ]
-    inst_lib = env.Install("$distutils_installdir", lib)
-    return lib, inst_lib
-
-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)', 
-             pjoin('build', 'scons'))
-    opts.Add('distutils_libdir', 
-             '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', '')
-    opts.Add('cc_opt_path', 'path of the C compiler set in cc_opt', '')
-    return opts
-
-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)
-    # We set tools to an empty list, to be sure that the custom options are
-    # given first. We have to 
-    env = Environment(options = opts, tools = [])
-
-    # Setting dirs according to command line options
-    env.AppendUnique(build_dir = pjoin(env['build_prefix']))
-    env.AppendUnique(distutils_installdir = pjoin(env['distutils_libdir'], 
-                                                  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:
-            if len(env['cc_opt_path']) > 0:
-                if env['cc_opt'] == 'intelc':
-                    # Intel Compiler SCons.Tool has a special way to set the
-                    # path, o 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).
-                    t = Tool(env['cc_opt'])
-                    t(env) 
-                    if sys.platform == 'win32':
-                        env['ENV']['PATH'] += ';%s' % env['cc_opt_path']
-                    else:
-                        env['ENV']['PATH'] += ':%s' % env['cc_opt_path']
-        except EnvironmentError, e:
-            # scons could not understand cc_opt (bad name ?)
-            raise AssertionError("SCONS: Could not initialize tool ? Error is %s" % \
-                                 str(e))
-    else:
-        t = Tool(FindTool(DEF_C_COMPILERS))
-        t(env)
-
-    # ========================================================================
-    # Adding default tools for the one we do not customize: mingw is special
-    # according to scons, don't ask me why, but this does not work as expected
-    # for this tool.
-    if not env['cc_opt'] == 'mingw':
-        for i in [DEF_LINKERS, DEF_CXX_COMPILERS, DEF_ASSEMBLERS, 
-                  DEF_FORTRAN_COMPILERS]:
-            t = FindTool(i, env) or i[0]
-            Tool(t)(env)
-			
-    for t in FindAllTools(DEF_OTHER_TOOLS, env):
-        Tool(t)(env)
-
-    #print env.Dump()
-    #print Environment().Dump('TOOLS')
-    # Adding custom builder
-    env['BUILDERS']['NumpySharedLibrary'] = NumpySharedLibrary
-    env['BUILDERS']['NumpyCTypes'] = NumpyCTypes
-
-    # Setting build directory according to command line option
-    if len(env['src_dir']) > 0:
-        BuildDir(env['build_dir'], env['src_dir'])
-    else:
-        BuildDir(env['build_dir'], '.')
-
-    # Generate help (if calling scons directly during debugging, this could be useful)
-    Help(opts.GenerateHelpText(env))
-
-    # Getting the config options from *.cfg files
-    config = get_config()
-    env['NUMPYCONFIG'] = config
-
-    return env
-
 def _get_empty(dict, key):
     print "++++++ Deprecated, do not use _get_empty +++++++++"
     try:
@@ -161,97 +15,3 @@
     """This convert one entry in a section of .cfg file to something usable in
     scons."""
     pass
-
-def NumpyCheckLib(context, section, libs, symbol = None):
-    #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-    # This is really preliminary, and needs a lot of love before being in good
-    # shape !!!!!
-    #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-    # XXX: handle env var
-
-    # XXX: handle extension in arg list
-    extension = '.c'
-    # XXX: handle symbol
-    src = """
-int main(int argc, char** argv)
-{
-    return 0;
-}"""
-
-    # Make sure libs is a list of libs:
-    if not is_List(libs):
-        libs = [libs]
-
-    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')
-            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:
-        lastLIBS = context.AppendLIBS(libs)
-        res = context.TryLink(src, extension)
-        if not res:
-            context.env.Replace(LIBS = lastLIBS) 
-    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
-    from numpy.distutils.system_info import get_standard_file
-
-    section = 'DEFAULT'
-    defaults = {}
-    defaults['libraries'] = ''
-    defaults['library_dirs'] = os.pathsep.join(default_lib_dirs)
-    defaults['include_dirs'] = os.pathsep.join(default_include_dirs)
-    defaults['src_dirs'] = os.pathsep.join(default_src_dirs)
-    cp = ConfigParser.ConfigParser(defaults)
-    files = []
-    files.extend(get_standard_file('.numpy-site.cfg'))
-    files.extend(get_standard_file('site.cfg'))
-
-    def parse_config_files():
-        cp.read(files)
-        if not cp.has_section(section):
-            cp.add_section(section)
-
-    parse_config_files()
-    return cp

Added: branches/numpy.scons/numpy/distutils/scons/custom_builders.py
===================================================================
--- branches/numpy.scons/numpy/distutils/scons/custom_builders.py	2007-10-09 09:43:24 UTC (rev 4158)
+++ branches/numpy.scons/numpy/distutils/scons/custom_builders.py	2007-10-09 15:24:09 UTC (rev 4159)
@@ -0,0 +1,44 @@
+from os.path import join as pjoin
+
+from SCons.Environment import Environment
+
+def NumpySharedLibrary(env, target, source, *args, **kw):
+    """This builder is the same than SharedLibrary, except for the fact that it
+    takes into account build dir info passed by distutils, and put the target at
+    the right location in distutils build directory for correct installation."""
+    source = [pjoin(env['build_dir'], i) for i in source]
+    # XXX: why target is a list ? It is always true ?
+    lib = env.SharedLibrary("$build_dir/%s" % target[0], source, *args, **kw)
+
+    inst_lib = env.Install("$distutils_installdir", lib)
+    return lib, inst_lib
+	
+def NumpyPythonExtension(env, target, source, *args, **kw):
+    """This builder is the same than PythonExtension, except for the fact that it
+    takes into account build dir info passed by distutils, and put the target at
+    the right location in distutils build directory for correct installation."""
+    source = [pjoin(env['build_dir'], i) for i in source]
+    # XXX: why target is a list ? It is always true ?
+    lib = env.PythonExtension("$build_dir/%s" % target[0], source, *args, **kw)
+
+    inst_lib = env.Install("$distutils_installdir", lib)
+    return lib, inst_lib
+	
+	
+def NumpyCtypes(env, target, source, *args, **kw):
+    """This builder is essentially the same than SharedLibrary, but should be
+    used for libraries which will only be used through ctypes.
+
+    In particular, it does not install .exp/.lib files on windows. """
+    source = [pjoin(env['build_dir'], i) for i in source]
+    # XXX: why target is a list ? It is always true ?
+    # XXX: handle cases where SHLIBPREFIX is in args
+    lib = env.SharedLibrary("$build_dir/%s" % target[0], 
+                            source, 
+                            SHLIBPREFIX = '', 
+                            *args, 
+                            **kw)
+    lib = [i for i in lib if not (str(i).endswith('.exp') or str(i).endswith('.lib')) ]
+    inst_lib = env.Install("$distutils_installdir", lib)
+    return lib, inst_lib
+

Added: branches/numpy.scons/numpy/distutils/scons/numpyenv.py
===================================================================
--- branches/numpy.scons/numpy/distutils/scons/numpyenv.py	2007-10-09 09:43:24 UTC (rev 4158)
+++ branches/numpy.scons/numpy/distutils/scons/numpyenv.py	2007-10-09 15:24:09 UTC (rev 4159)
@@ -0,0 +1,124 @@
+# Last Changed: .
+from os.path import join as pjoin
+import sys
+
+from SCons.Options import Options
+from SCons.Environment import Environment
+from SCons.Tool import Tool, FindTool, FindAllTools
+from SCons.Script import BuildDir, Help
+
+from default import tool_list
+from custom_builders import NumpySharedLibrary, NumpyCtypes, NumpyPythonExtension
+from libinfo import get_config
+from extension_scons import PythonExtension
+
+def pyplat2sconsplat():
+    # XXX: should see how env['PLATFORM'] is defined
+    if sys.platform[:5] == 'linux':
+        return 'posix'
+    else:
+        return sys.platform
+
+DEF_LINKERS, DEF_C_COMPILERS, DEF_CXX_COMPILERS, DEF_ASSEMBLERS, \
+DEF_FORTRAN_COMPILERS, DEF_ARS, DEF_OTHER_TOOLS = tool_list(pyplat2sconsplat())
+
+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)', 
+             pjoin('build', 'scons'))
+    opts.Add('distutils_libdir', 
+             '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', '')
+    opts.Add('cc_opt_path', 'path of the C compiler set in cc_opt', '')
+    return opts
+
+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)
+    # We set tools to an empty list, to be sure that the custom options are
+    # given first. We have to 
+    env = Environment(options = opts, tools = [])
+
+    # Setting dirs according to command line options
+    env.AppendUnique(build_dir = pjoin(env['build_prefix']))
+    env.AppendUnique(distutils_installdir = pjoin(env['distutils_libdir'], 
+                                                  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:
+            if len(env['cc_opt_path']) > 0:
+                if env['cc_opt'] == 'intelc':
+                    # Intel Compiler SCons.Tool has a special way to set the
+                    # path, o 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).
+                    t = Tool(env['cc_opt'])
+                    t(env) 
+                    if sys.platform == 'win32':
+                        env['ENV']['PATH'] += ';%s' % env['cc_opt_path']
+                    else:
+                        env['ENV']['PATH'] += ':%s' % env['cc_opt_path']
+        except EnvironmentError, e:
+            # scons could not understand cc_opt (bad name ?)
+            raise AssertionError("SCONS: Could not initialize tool ? Error is %s" % \
+                                 str(e))
+    else:
+        t = Tool(FindTool(DEF_C_COMPILERS))
+        t(env)
+
+    # ========================================================================
+    # Adding default tools for the one we do not customize: mingw is special
+    # according to scons, don't ask me why, but this does not work as expected
+    # for this tool.
+    if not env['cc_opt'] == 'mingw':
+        for i in [DEF_LINKERS, DEF_CXX_COMPILERS, DEF_ASSEMBLERS, 
+                  DEF_FORTRAN_COMPILERS]:
+            t = FindTool(i, env) or i[0]
+            Tool(t)(env)
+			
+    for t in FindAllTools(DEF_OTHER_TOOLS, env):
+        Tool(t)(env)
+
+    #print env.Dump()
+    #print Environment().Dump('TOOLS')
+    # Adding custom builder
+    env['BUILDERS']['NumpySharedLibrary'] = NumpySharedLibrary
+    env['BUILDERS']['NumpyCtypes'] = NumpyCtypes
+    env['BUILDERS']['PythonExtension'] = PythonExtension
+    env['BUILDERS']['NumpyPythonExtension'] = NumpyPythonExtension
+
+    # Setting build directory according to command line option
+    if len(env['src_dir']) > 0:
+        BuildDir(env['build_dir'], env['src_dir'])
+    else:
+        BuildDir(env['build_dir'], '.')
+
+    # Generate help (if calling scons directly during debugging, this could be useful)
+    Help(opts.GenerateHelpText(env))
+
+    # Getting the config options from *.cfg files
+    config = get_config()
+    env['NUMPYCONFIG'] = config
+
+    return env
+

Modified: branches/numpy.scons/numpy/scons_fake/SConstruct
===================================================================
--- branches/numpy.scons/numpy/scons_fake/SConstruct	2007-10-09 09:43:24 UTC (rev 4158)
+++ branches/numpy.scons/numpy/scons_fake/SConstruct	2007-10-09 15:24:09 UTC (rev 4159)
@@ -6,13 +6,12 @@
 config = env.Configure(custom_tests = {'NumpyCheckLib' : NumpyCheckLib})
 config.CheckHeader('stdio.h')
 config.CheckLib('c', 'printf')
-#config.NumpyCheckLib('sndfile', 'sndfile', 'sf_open')
-config.NumpyCheckLib('bmeps', 'bmeps')
-config.NumpyCheckLib('atlas', ['atlas', 'f77blas', 'cblas'])
+config.NumpyCheckLib(libs = 'sndfile', symbols = 'sf_open', section = 'sndfile')
 config.Finish()
 
 source = ['foo.c']
 import sys
 if sys.platform == 'win32':
     env.AppendUnique(CPPDEFINES = 'WIN32')
-env.NumpyCTypes('foo', source)
+env.NumpyCtypes('foo', source)
+env.NumpyPythonExtension('spam', 'hellomodule.c')

Modified: branches/numpy.scons/numpy/scons_fake/__init__.py
===================================================================
--- branches/numpy.scons/numpy/scons_fake/__init__.py	2007-10-09 09:43:24 UTC (rev 4158)
+++ branches/numpy.scons/numpy/scons_fake/__init__.py	2007-10-09 15:24:09 UTC (rev 4159)
@@ -1,6 +1,7 @@
 from foo_py import foo
+from spam import system
 
-__all__ = ['foo']
+__all__ = ['foo', 'system']
 def test(level=1, verbosity=1):
     from numpy.testing import NumpyTest
     return NumpyTest().test(level, verbosity)

Added: branches/numpy.scons/numpy/scons_fake/hellomodule.c
===================================================================
--- branches/numpy.scons/numpy/scons_fake/hellomodule.c	2007-10-09 09:43:24 UTC (rev 4158)
+++ branches/numpy.scons/numpy/scons_fake/hellomodule.c	2007-10-09 15:24:09 UTC (rev 4159)
@@ -0,0 +1,25 @@
+#include <Python.h>
+
+static PyObject *
+spam_system(PyObject *self, PyObject *args)
+{
+    const char *command;
+    int sts;
+
+    if (!PyArg_ParseTuple(args, "s", &command))
+        return NULL;
+    sts = system(command);
+    return Py_BuildValue("i", sts);
+}
+
+static PyMethodDef SpamMethods[] = {
+    {"system",  spam_system, METH_VARARGS,
+     "Execute a shell command."},
+    {NULL, NULL, 0, NULL}        /* Sentinel */
+};
+
+PyMODINIT_FUNC
+initspam(void)
+{
+    (void) Py_InitModule("spam", SpamMethods);
+}

Added: branches/numpy.scons/numpy/scons_fake/tests/test_spam.py
===================================================================
--- branches/numpy.scons/numpy/scons_fake/tests/test_spam.py	2007-10-09 09:43:24 UTC (rev 4158)
+++ branches/numpy.scons/numpy/scons_fake/tests/test_spam.py	2007-10-09 15:24:09 UTC (rev 4159)
@@ -0,0 +1,10 @@
+from numpy.testing import *
+
+from numpy.scons_fake import spam
+
+class test_ra(NumpyTestCase):
+    def test(self):
+        spam.system('dir')
+
+if __name__ == "__main__":
+    NumpyTest('numpy.scons_fake.foo').run()




More information about the Numpy-svn mailing list