hpyproject / hpy

HPy: a better API for Python

Home Page:https://hpyproject.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

missing tests for _load_bootstrap

mattip opened this issue · comments

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?

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.

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.

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.