I'm creating this gist because it has taken me far too long to find information on how to build python into an executable via cython. There are two key pieces of information you need after installing cython and a compiler: (I'll use gcc
for this example.)
- Compiler flags need to be linked via the
python3-config
command. - The
python3-config
command and thecython
command both need to be invoked with the--embed
flag.
For this exercise, we'll start with a file called hello.py
with the following contents:
print("Hello, World!")