Debian Codegraph @

lib_pypy/_ctypes_test_build.py

raw symbols SCIP
1 """
2 This will create the _ctypes_test c-extension module. Unlike _testcapi, the
3 extension cannot be wrapped with a _ctypes_test.py module since test.importlib
4 explicitly does a c-extension import
5 """
6 import imp
7 import os
8
9 try:
10 import cpyext
11 except ImportError:
12 raise RuntimeError("must have cpyext")
13 import _pypy_testcapi
14 cfile = '_ctypes_test.c'
15 thisdir = os.path.dirname(__file__)
16 output_dir = _pypy_testcapi.get_hashed_dir(os.path.join(thisdir, cfile))
17 try:
18 import _ctypes
19 except ImportError:
20 pass # obscure condition of _ctypes_test.py being imported by py.test
21 else:
22 _ctypes.PyObj_FromPtr = None
23 del _ctypes
24 try:
25 fp, filename, description = imp.find_module('_ctypes_test', path=[thisdir])
26 with fp:
27 imp.load_module('_ctypes_test', fp, filename, description)
28 except ImportError:
29 _pypy_testcapi.compile_shared('_ctypes_test.c', '_ctypes_test', thisdir)