[Cython] Shared Cython runtime

Stefan Behnel stefan_ml at behnel.de
Wed Apr 10 08:57:48 CEST 2013


Nikita Nemkin, 10.04.2013 08:44:
> On Wed, 10 Apr 2013 11:24:33 +0600, Stefan Behnel wrote:
>> The problem is not which value to use. The problem is that the shared
>> library pathname is not known at init time, except inside of the loader,
>> and it doesn't tell us about it. In the specific case of a meta-module,
>> it won't even be set before *all* init functions of the submodules were
>> called and the main init function terminates.
>>
>> Which is a really bad situation, because it means that even though the main
>> module will eventually have its __file__ set by the loader, it has no way
>> to propagate it to the submodules anymore. So they won't have their
>> __file__ property set at all.
>>
>> Just in case someone missed it, here's the bug URL once again:
>>
>> http://bugs.python.org/issue13429
>>
>> Cython can fix up stuff related to the FQMN and sys.modules (and it does
>> that already), but can't do anything about the file path. That makes
>> things like resource loading rather annoying.
>>
>> BTW, here's also the python-dev discussion on the topic:
>>
>> http://thread.gmane.org/gmane.comp.python.devel/135764
>>
>> Maybe that discussion should be revived and this use case added to it.
> 
> Well, here is the workaround Cython can use:
> https://gist.github.com/nnemkin/5352088
> (Warning: I haven't fully tested it yet).

Interesting. Looks like that could help here, yes. Do you know if it also
works for statically linked binaries? (i.e. would it return the name of the
executable in that case?)

Stefan



More information about the cython-devel mailing list