Debian Codegraph @

lib_pypy/_testcapi.py

raw symbols SCIP
1 from importlib.util import spec_from_file_location, module_from_spec
2 import os
3
4 try:
5 import cpyext
6 except ImportError:
7 pass # no 'cpyext', but we still have to define e.g. awaitType
8 else:
9 import _pypy_testcapi
10 cfile = '_testcapimodule.c'
11 thisdir = os.path.dirname(__file__)
12 output_dir = _pypy_testcapi.get_hashed_dir(os.path.join(thisdir, cfile))
13 modfile = '_testcapi' + _pypy_testcapi._get_c_extension_suffix()
14 spec = spec_from_file_location('_testcapi',
15 os.path.join(thisdir, modfile))
16 try:
17 module_from_spec(spec)
18 except ImportError:
19 if os.name == 'nt':
20 # hack around finding compilers on win32
21 try:
22 import setuptools
23 except ImportError:
24 pass
25 mod = _pypy_testcapi.compile_shared(cfile, '_testcapi', thisdir)
26
27 class awaitType:
28 def __init__(self, iterator):
29 self._iterator = iterator
30 def __await__(self):
31 return self._iterator
32
33 # the hacks above have replaced this module with another, so we need
34 # to push the extra names into this other module too...
35 import _testcapi
36 _testcapi.awaitType = awaitType