Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cython static link with python runtime?

I have a Python script for python 2.7, say this:

print("Hello World!")

Next I turn this into C using:

python cython.py --embed helloworld.py

And then I try to compile it statically:

gcc -IC:\Python27\include -LC:\Python27\libs helloworld.c -Wl,-Bstatic -lpython27
  -Wl,-Bdynamic

But gcc just creates a binary that uses the python27.dll runtime. How can I create a binary that statically links to the runtime?

like image 248
orlp Avatar asked Nov 27 '11 23:11

orlp


1 Answers

If you are working from Linux or OS X, you can use my engine's builder tool, Schafer, which has a "bare" mode which will just build Python statically (for all supported platforms, including Windows), along with several standard modules, and it will also "cythonize" and embed your sources into it as well. If this doesn't fit your bill, you still can get ideas from the source on what it takes to do what you want to accomplish.

like image 113
gabomdq Avatar answered Sep 23 '22 01:09

gabomdq