Message 323167 - Python tracker

Message323167

Author jdemeyer
Recipients brett.cannon, eric.snow, erik.bray, jdemeyer, ncoghlan, paul.moore, petr.viktorin, scoder, sth
Date 2018-08-05.17:41:47
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1533490907.51.0.56676864532.issue32797@psf.upfronthosting.co.za>
In-reply-to
Content
> 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.
History
Date User Action Args
2018-08-05 17:41:47jdemeyersetrecipients: + jdemeyer, brett.cannon, paul.moore, ncoghlan, scoder, petr.viktorin, erik.bray, eric.snow, sth
2018-08-05 17:41:47jdemeyersetmessageid: <1533490907.51.0.56676864532.issue32797@psf.upfronthosting.co.za>
2018-08-05 17:41:47jdemeyerlinkissue32797 messages
2018-08-05 17:41:47jdemeyercreate