test_capi:test_get_hashed_dir
from importlib.util import spec_from_file_location, module_from_spec
import os
try:
import cpyext
except ImportError:
pass # no 'cpyext', but we still have to define e.g. awaitType
else:
import _pypy_testcapi
cfile = '_testcapimodule.c'
thisdir = os.path.dirname(__file__)
output_dir = _pypy_testcapi.get_hashed_dir(os.path.join(thisdir, cfile))
modfile = '_testcapi' + _pypy_testcapi._get_c_extension_suffix()
spec = spec_from_file_location('_testcapi',
os.path.join(thisdir, modfile))
try:
> module_from_spec(spec)
../build/lib_pypy/_testcapi.py:17:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
spec = ModuleSpec(name='_testcapi', loader=<_frozen_importlib_external.ExtensionFileLoader object at 0x000000000c7f4090>, origin='/build_dir/pypy-c-jit-linux-x86-64/build/lib_pypy/_testcapi.pypy312-pp73-x86_64-linux-gnu.so')
> ???
<frozen importlib._bootstrap>:813:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <_frozen_importlib_external.ExtensionFileLoader object at 0x000000000c7f4090>
spec = ModuleSpec(name='_testcapi', loader=<_frozen_importlib_external.ExtensionFileLoader object at 0x000000000c7f4090>, origin='/build_dir/pypy-c-jit-linux-x86-64/build/lib_pypy/_testcapi.pypy312-pp73-x86_64-linux-gnu.so')
> ???
<builtin>/frozen importlib._bootstrap_external:1293:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
f = <built-in function create_dynamic>
args = (ModuleSpec(name='_testcapi', loader=<_frozen_importlib_external.ExtensionFileLoader object at 0x000000000c7f4090>, origin='/build_dir/pypy-c-jit-linux-x86-64/build/lib_pypy/_testcapi.pypy312-pp73-x86_64-linux-gnu.so'),)
kwds = {}
> ???
E ImportError: /build_dir/pypy-c-jit-linux-x86-64/build/lib_pypy/_testcapi.pypy312-pp73-x86_64-linux-gnu.so: cannot open shared object file: No such file or directory
<frozen importlib._bootstrap>:488: ImportError
During handling of the above exception, another exception occurred:
self = <distutils.unixccompiler.UnixCCompiler object at 0x000000000c7f4020>
obj = '/build_dir/pypy-c-jit-linux-x86-64/build/lib_pypy/build_dir/pypy-c-jit-linux-x86-64/build/lib_pypy/_testcapimodule.o'
src = '/build_dir/pypy-c-jit-linux-x86-64/build/lib_pypy/_testcapimodule.c'
ext = '.c'
cc_args = ['-fPIC', '-Wimplicit-function-declaration', '-O0', '-g3', '-I/build_dir/pypy-c-jit-linux-x86-64/build/include/pypy3.12', '-c']
extra_postargs = []
pp_opts = ['-I/build_dir/pypy-c-jit-linux-x86-64/build/include/pypy3.12']
def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
compiler_so = compiler_fixup(self.compiler_so, cc_args + extra_postargs)
try:
> self.spawn(compiler_so + cc_args + [src, '-o', obj] + extra_postargs)
pypy-venv/lib/pypy3.12/site-packages/setuptools/_distutils/unixccompiler.py:188:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <distutils.unixccompiler.UnixCCompiler object at 0x000000000c7f4020>
cmd = ['gcc', '-pthread', '-DNDEBUG', '-O2', '-fPIC', '-fPIC', ...], kwargs = {}
def spawn(self, cmd, **kwargs):
> spawn(cmd, dry_run=self.dry_run, **kwargs)
pypy-venv/lib/pypy3.12/site-packages/setuptools/_distutils/ccompiler.py:1041:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cmd = '/opt/rh/devtoolset-10/root/usr/bin/gcc', search_path = 1, verbose = 0
dry_run = 0
env = {'AUDITWHEEL_ARCH': 'x86_64', 'AUDITWHEEL_PLAT': 'manylinux2014_x86_64', 'AUDITWHEEL_POLICY': 'manylinux2014', 'DEVTOOLSET_ROOTPATH': '/opt/rh/devtoolset-10/root', ...}
def spawn(cmd, search_path=1, verbose=0, dry_run=0, env=None): # noqa: C901
"""Run another program, specified as a command list 'cmd', in a new process.
'cmd' is just the argument list for the new process, ie.
cmd[0] is the program to run and cmd[1:] are the rest of its arguments.
There is no way to run a program with a name different from that of its
executable.
If 'search_path' is true (the default), the system's executable
search path will be used to find the program; otherwise, cmd[0]
must be the exact path to the executable. If 'dry_run' is true,
the command will not actually be run.
Raise DistutilsExecError if running the program fails in any way; just
return on success.
"""
# cmd is documented as a list, but just in case some code passes a tuple
# in, protect our %-formatting code against horrible death
cmd = list(cmd)
log.info(subprocess.list2cmdline(cmd))
if dry_run:
return
if search_path:
executable = find_executable(cmd[0])
if executable is not None:
cmd[0] = executable
env = env if env is not None else dict(os.environ)
if sys.platform == 'darwin':
from distutils.util import MACOSX_VERSION_VAR, get_macosx_target_ver
macosx_target_ver = get_macosx_target_ver()
if macosx_target_ver:
env[MACOSX_VERSION_VAR] = macosx_target_ver
try:
proc = subprocess.Popen(cmd, env=env)
proc.wait()
exitcode = proc.returncode
except OSError as exc:
if not DEBUG:
cmd = cmd[0]
raise DistutilsExecError(f"command {cmd!r} failed: {exc.args[-1]}") from exc
if exitcode:
if not DEBUG:
cmd = cmd[0]
> raise DistutilsExecError(f"command {cmd!r} failed with exit code {exitcode}")
E distutils.errors.DistutilsExecError: command '/opt/rh/devtoolset-10/root/usr/bin/gcc' failed with exit code 1
pypy-venv/lib/pypy3.12/site-packages/setuptools/_distutils/spawn.py:68: DistutilsExecError
During handling of the above exception, another exception occurred:
@pytest.mark.skipif(sys.implementation.name != 'pypy', reason='pypy only')
def test_get_hashed_dir():
import sys
> from lib_pypy import _testcapi
../build/extra_tests/test_capi.py:7:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../build/lib_pypy/_testcapi.py:25: in <module>
mod = _pypy_testcapi.compile_shared(cfile, '_testcapi', thisdir)
../build/lib_pypy/_pypy_testcapi.py:78: in compile_shared
res = compiler.compile([os.path.join(thisdir, csource)],
pypy-venv/lib/pypy3.12/site-packages/setuptools/_distutils/ccompiler.py:600: in compile
self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <distutils.unixccompiler.UnixCCompiler object at 0x000000000c7f4020>
obj = '/build_dir/pypy-c-jit-linux-x86-64/build/lib_pypy/build_dir/pypy-c-jit-linux-x86-64/build/lib_pypy/_testcapimodule.o'
src = '/build_dir/pypy-c-jit-linux-x86-64/build/lib_pypy/_testcapimodule.c'
ext = '.c'
cc_args = ['-fPIC', '-Wimplicit-function-declaration', '-O0', '-g3', '-I/build_dir/pypy-c-jit-linux-x86-64/build/include/pypy3.12', '-c']
extra_postargs = []
pp_opts = ['-I/build_dir/pypy-c-jit-linux-x86-64/build/include/pypy3.12']
def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
compiler_so = compiler_fixup(self.compiler_so, cc_args + extra_postargs)
try:
self.spawn(compiler_so + cc_args + [src, '-o', obj] + extra_postargs)
except DistutilsExecError as msg:
> raise CompileError(msg)
E distutils.errors.CompileError: command '/opt/rh/devtoolset-10/root/usr/bin/gcc' failed with exit code 1
pypy-venv/lib/pypy3.12/site-packages/setuptools/_distutils/unixccompiler.py:190: CompileError
builder: pypy-c-jit-linux-x86-64 build #11848+
test: test_capi:test_get_hashed_dir