[Numpy-svn] r4185 - in branches/numpy.scons: . numpy/core

numpy-svn@scip... numpy-svn@scip...
Sun Oct 14 11:13:22 CDT 2007


Author: cdavid
Date: 2007-10-14 11:13:08 -0500 (Sun, 14 Oct 2007)
New Revision: 4185

Added:
   branches/numpy.scons/numpy/core/scons_support.py
Modified:
   branches/numpy.scons/
   branches/numpy.scons/numpy/core/SConstruct
Log:
more work on building numpy.core (but multiarray still does not build)


Property changes on: branches/numpy.scons
___________________________________________________________________
Name: bzr:revision-info
   - timestamp: 2007-10-13 13:38:39.881999969 +0900
committer: david <david@david-laptop>
properties: 
	branch-nick: numpy.scons

   + timestamp: 2007-10-13 21:33:19.999000072 +0900
committer: david <david@david-laptop>
properties: 
	branch-nick: numpy.scons

Name: bzr:file-ids
   - 
   + numpy/core/scons_support.py	scons_support.py-20071013123248-qlvhssvnl3nuey6c-1
numpy/core/code_generators/__init__.py	__init__.py-20071013094357-a11hri01e04cjkey-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
3745 david@david-laptop-20070922113708-ror18thshang1cpu
3747 david@david-laptop-20070922140534-n9xsl096tjrzmct1
3749 david@david-laptop-20070922154007-usit009fr6vp377j
3750 david@david-laptop-20070923070011-leu2ozc2fy1q5cht
3751 david@david-laptop-20070924015925-dhsiao40jp7zsfp9
3752 david@ar.media.kyoto-u.ac.jp-20070924070657-nbw23j0ayan30cli
3753 david@ar.media.kyoto-u.ac.jp-20070924082918-i1lc1zikywi8czj4
3754 david@ar.media.kyoto-u.ac.jp-20070924083008-c0edtt8zs31yeh1q
3755 david@ar.media.kyoto-u.ac.jp-20070924112351-pnnho638cohz6lj1
3756 david@david-laptop-20070924153247-yftud00bynilxv69
3757 david@david-laptop-20070924163545-pish34x9fq2h66aj
3758 david@david-laptop-20070924164633-iiyygcaw81ji3n34
3759 david@david-laptop-20070924170201-y14v2yzikdpvamfp
3760 david@david-laptop-20070924171208-5bmitorzf49d1aa2
3761 david@david-laptop-20070925014444-ns9v90gotnxt39mq
3769 david@david-laptop-20070925145952-4osi81tvch7v6luj
3773 david@ar.media.kyoto-u.ac.jp-20070926073429-2kdc6yf1o210aer0
3774 david@ar.media.kyoto-u.ac.jp-20070926084356-938djoytjap90rmo
3775 david@ar.media.kyoto-u.ac.jp-20070926085329-3gquq3gu2k8rgzb0
3776 david@ar.media.kyoto-u.ac.jp-20071009084906-9kradhwpu7su633x
3777 david@ar.media.kyoto-u.ac.jp-20071009093339-q5nf5me6ikdi48k6
3778 david@david-laptop-20071009152108-xh5cltii0h6zjk9b
3779 david@david-laptop-20071009154954-v5se05gbq60opo1z
3780 david@david-laptop-20071009223102-vz2sgf5i6pncxsd8
3781 david@david-laptop-20071009225259-13m6enwqk4w9uihe
3782 david@ar.media.kyoto-u.ac.jp-20071010021710-liz2jvw0ggbxrtgi
3783 david@ar.media.kyoto-u.ac.jp-20071010032218-8qzxvdmith85a056
3784 david@ar.media.kyoto-u.ac.jp-20071010032323-lgbxfd788h402kn0
3792 david@ar.media.kyoto-u.ac.jp-20071011033223-s14976refgeaw00h
3793 david@ar.media.kyoto-u.ac.jp-20071011033241-rrzlo2vu6w0tkdwf
3794 david@ar.media.kyoto-u.ac.jp-20071011071251-c5pxigyynpck262d
3795 david@ar.media.kyoto-u.ac.jp-20071012040323-8ka0mgkx1t8r9fcl
3796 david@ar.media.kyoto-u.ac.jp-20071012042801-44pmvc5o1u6p6wi7
3797 david@ar.media.kyoto-u.ac.jp-20071012071207-nfpsuyfoq0ooy7xf
3798 david@ar.media.kyoto-u.ac.jp-20071012073426-8o9tejzovgk7qzi4
3799 david@ar.media.kyoto-u.ac.jp-20071012074103-1fzviuk1sunv0b9n
3800 david@ar.media.kyoto-u.ac.jp-20071012074129-t5nu6f96wie8fd1y
3801 david@ar.media.kyoto-u.ac.jp-20071012100715-sq8hhctu5tynlx4m
3802 david@david-laptop-20071013043839-hc3yfsbn0t7gsuhe

   + 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
3751 david@david-laptop-20070924015925-dhsiao40jp7zsfp9
3752 david@ar.media.kyoto-u.ac.jp-20070924070657-nbw23j0ayan30cli
3753 david@ar.media.kyoto-u.ac.jp-20070924082918-i1lc1zikywi8czj4
3754 david@ar.media.kyoto-u.ac.jp-20070924083008-c0edtt8zs31yeh1q
3755 david@ar.media.kyoto-u.ac.jp-20070924112351-pnnho638cohz6lj1
3756 david@david-laptop-20070924153247-yftud00bynilxv69
3757 david@david-laptop-20070924163545-pish34x9fq2h66aj
3758 david@david-laptop-20070924164633-iiyygcaw81ji3n34
3759 david@david-laptop-20070924170201-y14v2yzikdpvamfp
3760 david@david-laptop-20070924171208-5bmitorzf49d1aa2
3761 david@david-laptop-20070925014444-ns9v90gotnxt39mq
3769 david@david-laptop-20070925145952-4osi81tvch7v6luj
3773 david@ar.media.kyoto-u.ac.jp-20070926073429-2kdc6yf1o210aer0
3774 david@ar.media.kyoto-u.ac.jp-20070926084356-938djoytjap90rmo
3775 david@ar.media.kyoto-u.ac.jp-20070926085329-3gquq3gu2k8rgzb0
3776 david@ar.media.kyoto-u.ac.jp-20071009084906-9kradhwpu7su633x
3777 david@ar.media.kyoto-u.ac.jp-20071009093339-q5nf5me6ikdi48k6
3778 david@david-laptop-20071009152108-xh5cltii0h6zjk9b
3779 david@david-laptop-20071009154954-v5se05gbq60opo1z
3780 david@david-laptop-20071009223102-vz2sgf5i6pncxsd8
3781 david@david-laptop-20071009225259-13m6enwqk4w9uihe
3782 david@ar.media.kyoto-u.ac.jp-20071010021710-liz2jvw0ggbxrtgi
3783 david@ar.media.kyoto-u.ac.jp-20071010032218-8qzxvdmith85a056
3784 david@ar.media.kyoto-u.ac.jp-20071010032323-lgbxfd788h402kn0
3792 david@ar.media.kyoto-u.ac.jp-20071011033223-s14976refgeaw00h
3793 david@ar.media.kyoto-u.ac.jp-20071011033241-rrzlo2vu6w0tkdwf
3794 david@ar.media.kyoto-u.ac.jp-20071011071251-c5pxigyynpck262d
3795 david@ar.media.kyoto-u.ac.jp-20071012040323-8ka0mgkx1t8r9fcl
3796 david@ar.media.kyoto-u.ac.jp-20071012042801-44pmvc5o1u6p6wi7
3797 david@ar.media.kyoto-u.ac.jp-20071012071207-nfpsuyfoq0ooy7xf
3798 david@ar.media.kyoto-u.ac.jp-20071012073426-8o9tejzovgk7qzi4
3799 david@ar.media.kyoto-u.ac.jp-20071012074103-1fzviuk1sunv0b9n
3800 david@ar.media.kyoto-u.ac.jp-20071012074129-t5nu6f96wie8fd1y
3801 david@ar.media.kyoto-u.ac.jp-20071012100715-sq8hhctu5tynlx4m
3802 david@david-laptop-20071013043839-hc3yfsbn0t7gsuhe
3803 david@david-laptop-20071013123319-vf4b7yhadz9nxasc


Modified: branches/numpy.scons/numpy/core/SConstruct
===================================================================
--- branches/numpy.scons/numpy/core/SConstruct	2007-10-13 04:41:10 UTC (rev 4184)
+++ branches/numpy.scons/numpy/core/SConstruct	2007-10-14 16:13:08 UTC (rev 4185)
@@ -1,16 +1,45 @@
 # Last Change: Fri Oct 12 07:00 PM 2007 J
 # vim:syntax=python
 import os
+from os.path import join as pjoin
+import sys
+
 from numpy.distutils.scons import GetNumpyEnvironment
 
 env = GetNumpyEnvironment(ARGUMENTS)
-config = env.NumpyConfigure()
 
 #--------------------------------
 # Checking SMP and thread options
 #--------------------------------
-# TODO
+# Python 2.3 causes a segfault when
+#  trying to re-acquire the thread-state
+#  which is done in error-handling
+#  ufunc code.  NPY_ALLOW_C_API and friends
+#  cause the segfault. So, we disable threading
+#  for now.
+if sys.version[:5] < '2.4.2':
+    nosmp = 1
+else:
+    # Perhaps a fancier check is in order here.
+    #  so that threads are only enabled if there
+    #  are actually multiple CPUS? -- but
+    #  threaded code can be nice even on a single
+    #  CPU so that long-calculating code doesn't
+    #  block.
+    try:
+        nosmp = os.environ['NPY_NOSMP']
+        nosmp = 1
+    except KeyError:
+        nosmp = 0
 
+config = env.NumpyConfigure()
+
+# TODO: check python extension can be built (in root or here ?)
+
+#--------------------------------
+# Checking configuration
+#--------------------------------
+
 #----------------------
 # Checking signal stuff
 #----------------------
@@ -51,4 +80,26 @@
 
 config.Finish()
 
-#print env.Dump('CPPDEFINES')
+#--------------------------
+# Generating multiarray API
+#--------------------------
+# TODO:
+from scons_support import do_generate_api, generate_api_emitter
+
+bld = Builder(action = do_generate_api, emitter = generate_api_emitter)
+env.Append(BUILDERS = {'GenerateApi' : bld})
+from os.path import join as pjoin
+multiarray_api = env.GenerateApi(pjoin(env['build_dir'], '__multiarray_api'), 
+    [pjoin(env['src_dir'], 'code_generators', 'array_api_order.txt'),
+    pjoin(env['src_dir'], 'code_generators', 'multiarray_api_order.txt')])
+
+config_header = env.Command(pjoin(env['build_dir'], 'config.h'), 
+                            pjoin(env['src_dir'], 'config.h.in'), 'cp $SOURCE $TARGET')
+# Build multiarray
+env.Append(CPPPATH = [pjoin(env['src_dir'], 'include'), env['build_dir']])
+multiarray_src = [
+    pjoin('src','scalartypes.inc.src'),
+    pjoin('src','arraytypes.inc.src'),
+    pjoin('src', 'multiarraymodule.c'),
+]
+#multiarray = env.NumpyPythonExtension('multiarray', source = multiarray_src)

Added: branches/numpy.scons/numpy/core/scons_support.py
===================================================================
--- branches/numpy.scons/numpy/core/scons_support.py	2007-10-13 04:41:10 UTC (rev 4184)
+++ branches/numpy.scons/numpy/core/scons_support.py	2007-10-14 16:13:08 UTC (rev 4185)
@@ -0,0 +1,97 @@
+from code_generators.generate_array_api import types, h_template, c_template
+import code_generators.genapi as genapi
+
+import SCons.Errors
+
+def do_generate_api(target, source, env):
+    """source has to be a sequence of OBJECT, MULTIARRAY txt files."""
+    h_file = str(target[0])
+    c_file = str(target[1])
+    t_file = str(target[2])
+
+    if not len(source) == 2:
+        # XXX
+        assert 0 == 1
+    OBJECT_API_ORDER = str(source[0])
+    MULTIARRAY_API_ORDER = str(source[1])
+    objectapi_list = genapi.get_api_functions('OBJECT_API',
+                                              OBJECT_API_ORDER)
+    multiapi_list = genapi.get_api_functions('MULTIARRAY_API',
+                                             MULTIARRAY_API_ORDER)
+    # API fixes for __arrayobject_api.h
+
+    fixed = 10
+    numtypes = len(types) + fixed
+    numobject = len(objectapi_list) + numtypes
+    nummulti = len(multiapi_list)
+    numtotal = numobject + nummulti
+
+    module_list = []
+    extension_list = []
+    init_list = []
+
+    # setup types
+    for k, atype in enumerate(types):
+        num = fixed + k
+        astr = "        (void *) &Py%sArrType_Type," % types[k]
+        init_list.append(astr)
+        astr = "static PyTypeObject Py%sArrType_Type;" % types[k]
+        module_list.append(astr)
+        astr = "#define Py%sArrType_Type (*(PyTypeObject *)PyArray_API[%d])" % \
+               (types[k], num)
+        extension_list.append(astr)
+
+    # set up object API
+    genapi.add_api_list(numtypes, 'PyArray_API', objectapi_list,
+                        module_list, extension_list, init_list)
+
+    # set up multiarray module API
+    genapi.add_api_list(numobject, 'PyArray_API', multiapi_list,
+                        module_list, extension_list, init_list)
+
+
+    # Write to header
+    fid = open(h_file, 'w')
+    s = h_template % ('\n'.join(module_list), '\n'.join(extension_list))
+    fid.write(s)
+    fid.close()
+
+    # Write to c-code
+    fid = open(c_file, 'w')
+    s = c_template % '\n'.join(init_list)
+    fid.write(s)
+    fid.close()
+
+    # write to documentation
+    fid = open(t_file, 'w')
+    fid.write('''
+===========
+Numpy C-API
+===========
+
+Object API
+==========
+''')
+    for func in objectapi_list:
+        fid.write(func.to_ReST())
+        fid.write('\n\n')
+    fid.write('''
+
+Multiarray API
+==============
+''')
+    for func in multiapi_list:
+        fid.write(func.to_ReST())
+        fid.write('\n\n')
+    fid.close()
+
+    return 0
+
+def generate_api_emitter(target, source, env):
+    """Returns the list of targets generated by the code generator for array api."""
+    base, ext = SCons.Util.splitext(str(target[0]))
+    h = base + '.h'
+    c = base + '.c'
+    txt = base + '.txt'
+    t = [h, c, txt]
+    return (t, source)



More information about the Numpy-svn mailing list