> Now, though, we need a way for SageMath to get it working on releases up to and including 3.7, *without* any help from Cython or CPython
That's not really what I need. We already have a work-around in SageMath:
try:
from importlib.machinery import ExtensionFileLoader
except ImportError:
pass # Python 2
else:
del ExtensionFileLoader.get_source
So this issue is about finding a proper solution, which doesn't require a monkey-patch like the above. And I want it to work without any special support from the package, installing .pyx sources should "just work". This issue is not specific to SageMath, it's just that SageMath is the only project that I know which actually installs .pyx sources.
> Define a subclass of ExtensionModuleLoader [1] that overrides get_source() to also look for a ".pyx" file adjacent to the extension module.
As I mentioned before, get_source() cannot work because a single Cython module can have multiple sources. So whatever method is used to retrieve the Cython sources must know the filename; the module is not sufficient.
As you can see from the monkey-patch, not implementing get_source() at all works, but that's probably more or less by accident. I'm not sure to what extent that could be documented as the official way to look up a filename relative to sys.path entries. |