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

numpy-svn@scip... numpy-svn@scip...
Sat Sep 22 06:55:42 CDT 2007


Author: cdavid
Date: 2007-09-22 06:55:05 -0500 (Sat, 22 Sep 2007)
New Revision: 4077

Added:
   branches/numpy.scons/numpy/distutils/scons/__init__.py
   branches/numpy.scons/numpy/scons_fake/__init__.py
Modified:
   branches/numpy.scons/
   branches/numpy.scons/numpy/scons_fake/SConstruct
   branches/numpy.scons/numpy/scons_fake/foo.c
Log:
Make scons_fake a ctype example


Property changes on: branches/numpy.scons
___________________________________________________________________
Name: bzr:revision-info
   - timestamp: 2007-09-22 19:16:56.497999907 +0900
committer: david <david@david-laptop>
properties: 
	branch-nick: numpy.scons

   + timestamp: 2007-09-22 20:37:08.022000074 +0900
committer: david <david@david-laptop>
properties: 
	branch-nick: numpy.scons

Name: bzr:file-ids
   - 
   + numpy/scons_fake/__init__.py	__init__.py-20070922113634-7m61zd3x0182bwro-1
numpy/distutils/scons/__init__.py	__init__.py-20070922113607-9hdtgj7ooqldhu4w-1

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

   + 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


Added: branches/numpy.scons/numpy/distutils/scons/__init__.py
===================================================================
--- branches/numpy.scons/numpy/distutils/scons/__init__.py	2007-09-22 11:54:36 UTC (rev 4076)
+++ branches/numpy.scons/numpy/distutils/scons/__init__.py	2007-09-22 11:55:05 UTC (rev 4077)
@@ -0,0 +1,45 @@
+from os.path import join as pjoin
+import os.path
+
+from SCons.Options import Options
+from SCons.Environment import Environment
+from SCons.Script import BuildDir
+
+
+def NumpySharedLibrary(env, target, source, *args, **kw):
+    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 GetNumpyOptions(args):
+    """Call this with args=ARGUMENTS to take into account command line args."""
+    opts = Options(None, args)
+    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'))
+
+    return opts
+
+def GetNumpyEnvironment(args):
+    """Call this with args = ARGUMENTS."""
+    opts = GetNumpyOptions(args)
+    env = Environment(options = opts)
+    env.AppendUnique(build_dir = pjoin(env['build_prefix']))
+    env.AppendUnique(distutils_installdir = pjoin(env['distutils_libdir'], 
+                                                  env['pkg_name']))
+
+    env['BUILDERS']['NumpySharedLibrary'] = NumpySharedLibrary
+    print env['src_dir']
+    if len(env['src_dir']) > 0:
+        BuildDir(env['build_dir'], env['src_dir'])
+    else:
+        BuildDir(env['build_dir'], '.')
+
+    return env

Modified: branches/numpy.scons/numpy/scons_fake/SConstruct
===================================================================
--- branches/numpy.scons/numpy/scons_fake/SConstruct	2007-09-22 11:54:36 UTC (rev 4076)
+++ branches/numpy.scons/numpy/scons_fake/SConstruct	2007-09-22 11:55:05 UTC (rev 4077)
@@ -1,30 +1,12 @@
 # vim:syntax=python
-from os.path import join as pjoin
-import os.path
+from numpy.distutils.scons import GetNumpyEnvironment
 
-opts = Options()
-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'))
+env = GetNumpyEnvironment(ARGUMENTS)
 
-env = Environment(options = opts)
-env.AppendUnique(build_dir = pjoin(env['build_prefix'], env['pkg_name'].replace('.', os.path.sep)))
-env.AppendUnique(distutils_installdir = pjoin(env['distutils_libdir'], env['pkg_name'].replace('.', os.path.sep)))
+config = env.Configure()
+config.CheckHeader('stdio.h')
+config.CheckLib('c', 'printf')
+config.Finish()
 
-def NumpySharedLibrary(env, target, source, *args, **kw):
-    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
-
-env['BUILDERS']['NumpySharedLibrary'] = NumpySharedLibrary
-if len(env['src_dir']) > 0:
-    BuildDir(env['build_dir'], env['src_dir'])
-else:
-    BuildDir(env['build_dir'], '.')
-
 source = ['foo.c']
 env.NumpySharedLibrary('foo', source)

Added: branches/numpy.scons/numpy/scons_fake/__init__.py
===================================================================
--- branches/numpy.scons/numpy/scons_fake/__init__.py	2007-09-22 11:54:36 UTC (rev 4076)
+++ branches/numpy.scons/numpy/scons_fake/__init__.py	2007-09-22 11:55:05 UTC (rev 4077)
@@ -0,0 +1,6 @@
+from numpy.ctypeslib import load_library
+
+_FOO = load_library("libfoo.so", __file__)
+def foo():
+    _FOO.foo()
+    

Modified: branches/numpy.scons/numpy/scons_fake/foo.c
===================================================================
--- branches/numpy.scons/numpy/scons_fake/foo.c	2007-09-22 11:54:36 UTC (rev 4076)
+++ branches/numpy.scons/numpy/scons_fake/foo.c	2007-09-22 11:55:05 UTC (rev 4077)
@@ -1,4 +1,6 @@
+#include <stdio.h>
+
 int foo(void)
 {
-        return 0;
+        printf("hello\n");
 }



More information about the Numpy-svn mailing list