[Numpy-svn] r6380 - branches/coremath/numpy/core

numpy-svn at scipy.org numpy-svn at scipy.org
Wed Feb 18 12:23:22 EST 2009


Author: cdavid
Date: 2009-02-18 11:23:16 -0600 (Wed, 18 Feb 2009)
New Revision: 6380

Modified:
   branches/coremath/numpy/core/setup.py
Log:
Put all sizeofs checks ending up in config.h in a separate function.

Modified: branches/coremath/numpy/core/setup.py
===================================================================
--- branches/coremath/numpy/core/setup.py	2009-02-18 17:22:51 UTC (rev 6379)
+++ branches/coremath/numpy/core/setup.py	2009-02-18 17:23:16 UTC (rev 6380)
@@ -112,6 +112,43 @@
         if st:
             moredefs.append(name_to_defsymb("decl_%s" % f))
 
+def check_types(config, ext, build_dir):
+    private_defines = []
+    public_defines = []
+
+    config_cmd = config.get_config_cmd()
+
+    # Check we have the python header (-dev* packages on Linux)
+    result = config_cmd.check_header('Python.h')
+    if not result:
+        raise SystemError(
+                "Cannot compiler 'Python.h'. Perhaps you need to "\
+                "install python-dev|python-devel.")
+
+    # Check basic types sizes
+    for type in ('short', 'int', 'long', 'float', 'double', 'long double'):
+        res = config_cmd.check_type_size(type)
+        if res >= 0:
+            private_defines.append(('SIZEOF_%s' % sym2def(type), '%d' % res))
+
+    for type in ('Py_intptr_t',):
+        res = config_cmd.check_type_size(type, headers=["Python.h"])
+        if res >= 0:
+            private_defines.append(('SIZEOF_%s' % sym2def(type), '%d' % res))
+
+    # We check declaration AND type because that's how distutils does it.
+    if config_cmd.check_decl('PY_LONG_LONG', headers=['Python.h']):
+        st = config_cmd.check_type_size('PY_LONG_LONG',  headers=['Python.h'])
+        assert not st == 0
+        private_defines.append(('SIZEOF_%s' % sym2def('PY_LONG_LONG'), '%d' % res))
+
+    if not config_cmd.check_decl('CHAR_BIT', headers=['Python.h']):
+        raise RuntimeError(
+            "Config wo CHAR_BIT is not supported"\
+            ", please contact the maintainers")
+
+    return private_defines, public_defines
+
 def sym2def(symbol):
     define = symbol.replace(' ', '_')
     return define.upper()
@@ -139,39 +176,10 @@
             os.makedirs(dir)
         if newer(__file__,target):
             config_cmd = config.get_config_cmd()
-            moredefs = []
-
             log.info('Generating %s',target)
 
-            # Check we have the python header (-dev* packages on Linux)
-            result = config_cmd.check_header('Python.h')
-            if not result:
-                raise SystemError(
-                        "Cannot compiler 'Python.h'. Perhaps you need to "\
-                        "install python-dev|python-devel.")
+            moredefs, ignored = check_types(config, ext, build_dir)
 
-            # Check basic types sizes
-            for type in ('short', 'int', 'long', 'float', 'double', 'long double'):
-                res = config_cmd.check_type_size(type)
-                if res >= 0:
-                    moredefs.append(('SIZEOF_%s' % sym2def(type), '%d' % res))
-
-            for type in ('Py_intptr_t',):
-                res = config_cmd.check_type_size(type, headers=["Python.h"])
-                if res >= 0:
-                    moredefs.append(('SIZEOF_%s' % sym2def(type), '%d' % res))
-
-            # We check declaration AND type because that's how distutils does it.
-            if config_cmd.check_decl('PY_LONG_LONG', headers=['Python.h']):
-                st = config_cmd.check_type_size('PY_LONG_LONG',  headers=['Python.h'])
-                assert not st == 0
-                moredefs.append(('SIZEOF_%s' % sym2def('PY_LONG_LONG'), '%d' % st))
-
-            if not config_cmd.check_decl('CHAR_BIT', headers=['Python.h']):
-                raise RuntimeError(
-                    "Config wo CHAR_BIT is not supported"\
-                    ", please contact the maintainers")
-
             # Testing the C math library
             mathlibs = []
             tc = testcode_mathlib()




More information about the Numpy-svn mailing list