hpyproject / hpy

HPy: a better API for Python
https://hpyproject.org
MIT License
1.02k stars 52 forks source link

missing tests for _load_bootstrap #453

Closed mattip closed 8 months ago

mattip commented 8 months ago

I thought I was done implementing everything for PyPy but when I tried the numpy-hpy fork I see I did not implement _load_bootstrap. Are there tests that use it?

mattip commented 8 months ago

I guess a test that builds a hpy extension module, say mytest.hpy0-pypy39-pp73.so, and then writes out the import shim mytest.py:

def __bootstrap__():

    from sys import modules
    from os import environ
    from pkg_resources import resource_filename
    from hpy.universal import _load_bootstrap
    ext_filepath = resource_filename(__name__, 'mytest.hpy0-pypy39-pp73.so')
    m = _load_bootstrap('_multiarray_tests', __name__, __package__, ext_filepath,
                        __loader__, __spec__, environ)
    modules[__name__] = m

__bootstrap__()

and then imports this.

fangerer commented 8 months ago

You are right, there are no tests for _load_bootstrap. Most likely because we didn't have any tests for the generated stub as well. But yes, we should have tests for it. I'll add some.

mattip commented 8 months ago

While there are no explicit tests for _load_bootstrap, the hpy_distutils tests check that a module can be loaded, and this exercises the functionality. I skipped those tests in the untranslated mode, but now that I am running the post-translation tests as well I see it is used. Closing.