Open mattip opened 2 years ago
This is the code that implements the context for universal mode on CPython, I think -- i.e. it is never part of any HPy module. If it is somehow ending up in an HPy extension, then that is a mistake we should fix.
I see it when I am running tests on the 0.0.4 tag after adding PyErr_SetFromErrnoWithFilenameObjects
yesterday
pypypy -m pytest test/test_00_basic.py -x
@antocuni Do you know how to fix this on PyPy or what went wrong here?
@mattip HPy-for-PyPy is implemented in the pypy repo. The tests in this repo aren't meant to run on pypy. The tests you want to run are in <pypy repo>/extra_tests/hpy_tests
.
The use of CPython internals inside HPy code is problematic. Building in the universal mode should probably define the limited API.
No, I think there is a bit of confusion here. When we talk about HPy on CPython, there are two modules involved:
hpy/universal.cpython-38-x86_64-linux-gnu.so
(or similar): this is CPython-specific and will have to be recompiled for every version of CPython. We could in theory try to use the stable ABI for it, but is it worth? The module itself is very small and quick to compile, and we need to test hpy for every cpython version that we want to support anyway.Otherwise the universal binaries will not really be universal, they may fail on some versions of CPython.
I don't understand how. If your extension calls HPy_Dump
and you compile in universal mode, it will contain an opaque call to ctx->ctx_Dump()
and it will never see _PyObject_Dump()
(which is inside universal.cpython-38-x86_64-linux-gnu.so
and it's cpython-specific.
- So running tests here with PyPy/GraalPython should fail early
yes! I think we should:
add a compile-time check to e.g. hpy/devel/include/hpy/cpython/misc.h
which fails if we are compiling it with pypy, similar to this:
https://github.com/hpyproject/hpy/blob/38893482e7443fb9924b49d381a1f052b2525e96/hpy/universal/src/hpymodule.c#L16-L21
add an early check in our test suite which refuses to run tests on top of pypy (and probably graalpython)
- Will the complete test suite be in extra_tests/hpy_tests or only ones ported from here by hand?
There is a script which automatically copies all the vendored files from the hpy repo to the pypy repo, including the whole test suite: https://foss.heptapod.net/pypy/pypy/-/blob/branch/hpy-0.0.4/pypy/module/_hpy_universal/update_vendored.sh#L129
The use of CPython internals inside HPy code is problematic. Building in the universal mode should probably define the limited API. Otherwise the universal binaries will not really be universal, they may fail on some versions of CPython. For instance this code is problematic, https://github.com/hpyproject/hpy/blob/da2cefc422eb66ced05d6b4c020f0ffb1920781e/hpy/devel/src/runtime/ctx_object.c#L10-L17 and should probably have some kind of guard like