[pypy-svn] r61544 - pypy/trunk/pypy/lib/app_test/ctypes_tests

afa at codespeak.net afa at codespeak.net
Wed Feb 4 11:33:31 CET 2009


Author: afa
Date: Wed Feb  4 11:33:30 2009
New Revision: 61544

Modified:
   pypy/trunk/pypy/lib/app_test/ctypes_tests/_ctypes_test.c
   pypy/trunk/pypy/lib/app_test/ctypes_tests/conftest.py
Log:
Use out platform package to compile the _ctypes_test shared library
Tests in ctypes_test begin to pass on Windows


Modified: pypy/trunk/pypy/lib/app_test/ctypes_tests/_ctypes_test.c
==============================================================================
--- pypy/trunk/pypy/lib/app_test/ctypes_tests/_ctypes_test.c	(original)
+++ pypy/trunk/pypy/lib/app_test/ctypes_tests/_ctypes_test.c	Wed Feb  4 11:33:30 2009
@@ -1,8 +1,9 @@
-#ifdef MS_WIN32
+#if defined(_MSC_VER) || defined(__CYGWIN__)
 #include <windows.h>
+#define MS_WIN32
 #endif
 
-#if defined(MS_WIN32) || defined(__CYGWIN__)
+#if defined(MS_WIN32)
 #define EXPORT(x) __declspec(dllexport) x
 #else
 #define EXPORT(x) x

Modified: pypy/trunk/pypy/lib/app_test/ctypes_tests/conftest.py
==============================================================================
--- pypy/trunk/pypy/lib/app_test/ctypes_tests/conftest.py	(original)
+++ pypy/trunk/pypy/lib/app_test/ctypes_tests/conftest.py	Wed Feb  4 11:33:30 2009
@@ -1,39 +1,19 @@
 import py
-import os, sys
-
+import sys
 
 def compile_so_file():
-    from distutils.dist import Distribution
-    from distutils.extension import Extension
-    from distutils.ccompiler import get_default_compiler
+    from pypy.translator.platform import platform
+    from pypy.translator.tool.cbuild import ExternalCompilationInfo
     udir = py.test.ensuretemp('_ctypes_test')
     cfile = py.magic.autopath().dirpath().join("_ctypes_test.c")
-    saved_environ = os.environ.items()
-    olddir = udir.chdir()
-    try:
-        attrs = {
-            'name': "_ctypes_test",
-            'ext_modules': [
-                Extension("_ctypes_test", [str(cfile)]),
-                ],
-            'script_name': 'setup.py',
-            'script_args': ['-q', 'build_ext', '--inplace'],
-            }
-        dist = Distribution(attrs)
-        if not dist.parse_command_line():
-            raise ValueError, "distutils cmdline parse error"
-        dist.run_commands()
-    finally:
-        olddir.chdir()
-        for key, value in saved_environ:
-            if os.environ.get(key) != value:
-                os.environ[key] = value
 
     if sys.platform == 'win32':
-        so_ext = '.dll'
+        libraries = ['oleaut32']
     else:
-        so_ext = '.so'
-    return udir.join('_ctypes_test' + so_ext)
+        libraries = []
+    eci = ExternalCompilationInfo(libraries=libraries)
 
+    return platform.compile([cfile], eci, str(udir.join('_ctypes_test')),
+                            standalone=False)
 
 sofile = compile_so_file()



More information about the Pypy-commit mailing list