Posts

Showing posts from 2017

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 (0x00007f65