Create a single executable from a pure Python code with Cython

Primary purpose of Cython is may not be creating an executable from a Python source, there's a very useful option in Cython to creates executables, so that my users will feel like it's native executable here's my simple python program
print "Hello World!"
print "Hello Again"
First step: Covert my Python code to C code using
cython --embed -o hello.c hello.pyx
Second step: Compile and link generated C code to Python and it dependency libraries statically (some common libraries dynamically)
gcc -v -Os -I /usr/include/python3.5m -o app hello.c \
 -Wl,-Bstatic -lpython3.5m -lz -lexpat -Wl,-Bdynamic -lpthread -lm -lutil -ldl
Final step : Test the application and see dependencies output of program
$ ./app 
Hello World!
Hello Again
output of ldd
 ldd app 
 linux-vdso.so.1 =>  (0x00007fff6932a000)
 libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f65bae7f000)
 libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f65bab76000)
 libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007f65ba973000)
 libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f65ba76f000)
 libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f65ba3a5000)
 /lib64/ld-linux-x86-64.so.2 (0x00007f65bb09c000)
I am really not sure whether this program can run not a Linux system completely not having python, But I believe it would

Comments

Popular posts from this blog

Consuming a RESTful Web Service with C++ using QT libraries

How to develop CXF based JAX-WS with WSO2 Developer Studio

Quick Start Apache Stratos from EC2 images