Create binary app from python source code using Cython |
![]() |
Sunday, 27 May 2012 | |
If we want to make our Python code runs faster we can compile it to a .so library and still run it from Python (yeah Python knows to do that) but what if we want to make a system executable binary file right from Python source code? This technique is also usefull to obfuscate/protect/encode Python source code. We cand o that by using Cython (first we install it): cd /usr/ports/lang/cython make install clean; rehash Then we will compile the following Python source code using Cython:
This will generate a C file called hello.c which we will then compile using GCC: gcc -I/usr/local/include/python2.7 -L/usr/local/lib -lpython2.7 hello.c -o hello And voila, we have our hello binary which we can run: ./hello |
< Prev | Next > |
---|