Can Cython compile to an EXE?
Here's the wiki page on embedding cython
Assuming you installed python to C:\Python31
and you want to use Microsoft Compiler.
smalltest1.py
- is the file you want to compile.
test.exe
- name of the executable.
You need to set the environmental variables for cl
.
C:\Python31\python.exe C:\Python31\Scripts\cython.py smalltest1.py --embedcl.exe /nologo /Ox /MD /W3 /GS- /DNDEBUG -Ic:\Python31\include -Ic:\Python31\PC /Tcsmalltest1.c /link /OUT:"test.exe" /SUBSYSTEM:CONSOLE /MACHINE:X86 /LIBPATH:c:\Python31\libs /LIBPATH:c:\Python31\PCbuild
In principal it appears to be possible to do something like what you want, according to the Embedding Pyrex HOWTO. (Pyrex is effectively a previous generation of Cython.)
Hmm... that name suggests a better search than I first tried: "embedding cython" leads to this page which sounds like what you want.
I have successfully used the Cython & gcc to convert the *.py file to *.exe, with below batch file:
# build.batset PROJECT_NAME=testset PYTHON_DIR=C:\python27%PYTHON_DIR%\python -m cython --embed -o %PROJECT_NAME%.c %PROJECT_NAME%.pygcc -Os -I %PYTHON_DIR%\include -o %PROJECT_NAME%.exe %PROJECT_NAME%.c -lpython27 -lm -L %PYTHON_DIR%\libs