the full code is here:
https://gist.github.com/661480
simplest use is:
$ ./cythonrun some.pyx
which will use setup tools to build the .so, then import the module
and run a main() if it exists.
the rectangle example in cython docs looks like:
$ ./cythonrun --cpp -lstdc++ rectangle.pyx
which will find any .cpp files in the same dir in rectangle.pyx and
include them as source files. they can also be specified explicitly
as:
$ ./cythonrun --cpp -lstdc++ rectangle.pyx Rectangle.cpp
other options:
--time will time the import and running of main()
-v will show the output from distutils setup()
-i/-I can be used to specify includes.
it re-cythonizes and rebuilds every time even if it doesn't need to.
i'm glad to hear any feedback or ways to make it better.
-brent
Nice.
> the full code is here:
> https://gist.github.com/661480
>
> simplest use is:
>
> $ ./cythonrun some.pyx
>
> which will use setup tools to build the .so, then import the module
> and run a main() if it exists.
Have you looked at the embedding support? If you run Cython with the
--embed option, it will generate a C file with a main() function that
initialises and executes the CPython interpreter and then runs the module
main code (i.e. the "if __name__ == '__main__'" trick works).
I think that's better than calling an explicit main() method.
Stefan
ah, cool. how does one tell cython to --embed inside setup() ?
> Stefan
>
i tried:
ext.pyrex_directives = {'embed': True}
but it doesn't seem to work.
>
>> Stefan
>>
>
Hmm, I don't think that would work. distutils isn't made to build programs,
it's meant to build Python modules. There is an example under Demos/embed,
though.
Stefan