francis, 31.10.2012 18:00:
> On 10/31/2012 05:39 PM, Stefan Behnel wrote:
>> I've written a setup.py script that compiles most of the
>> stdlib. For the latest developer sources of Py3.4, I managed to compile
>> 612 out of 620 modules so far. Pretty cool if you ask me. The rest fails
>> due to compiler crashes. 8-]
>
> is it possible (or far away) to make it generate a static compiled version
> of the stdlib together with a C-Extension? The idea is the I would like to
> have line and branch coverage of a Python C-extension by using gcc-coverage
> (gcov). AFAIN to be able to use gcov for that, the extension module has to
> be compiled statically: means in that case the interpreter, the tests
> (written in python with unittest) and the C-extension itself. I wonder if
> that can be achieved with cython
Yes, that's totally doable. In fact, we already do most of this in our
"cython_freeze" tool, although that rather targets executable main
programs. Worth taking a look.
Incidentally, I've recently discussed this with Martin von Löwis and we'd
both like to eventually see a couple of modules linked in as a build
option, above all the new importlib bootstrap module. That would provide an
advanced replacement for the original Python "freeze" tool.
Basically, all you need is some glue code that automatically registers the
statically linked extension modules with the Python runtime at startup.
CPython has the so-called "inittab" mechanism for that, which it also uses
for its current built-in modules. The actual list of modules, and in fact
the complete C glue code, could obviously be generated automatically from
the list of potentially required modules that the Python "freeze" tool
spits out.
Stefan