hpy icon indicating copy to clipboard operation
hpy copied to clipboard

Problem with adding a Python file next to the universal extension to make it importable

Open paugier opened this issue 3 years ago • 13 comments

Some Python compilers (for example Cython in pure Python mode and Pythran) use the priority to an extension when importing a module. When importing foo, if foo.py and foo.so exist, foo.so is imported.

With some Python compiler, the developer code in Python in a file foo.py and call a Python compiler to generate an extension foo.so. Under the hood, a .c or .cpp is created and compiled. In Python, importing foo uses the extension because Python prioritizes the extension.

This mechanism seems to be incompatible with the way HPy works by now (adding a Python file with the same name as the extension). Therefore, it would be better to find another way to make universal extensions importable. In particular, the standard behavior to prioritize an universal extension over a Python file should be obtained.

I realize that this is not a high priority problem for HPy! But I think it is worth mentioning the issue.

paugier avatar Apr 09 '21 17:04 paugier