Can Cython compile exe?

I know what the Keaton goal is. This is for writing compiled C extensions in Python to speed up your code. What I would like to know (and cannot find using my google-fu) is that Cython can somehow compile into an executable format, as it already seems to break Python code into C.

I already use Py2Exe, which is just a packer, but I'm interested in using it to compile to something a little harder to unzip (everything that is packed with Py2EXE can basically just be extracted using 7zip, which I don't want)

It seems if this is not possible, my next alternative is simply to compile all my code and load it as a module, and then a package that uses py2exe at least to get most of my code into a compiled form, right?

+39
python compilation cython
Apr 05 '10 at 23:34
source share
2 answers

Basically, it seems possible to do something like what you want, according to the Embedding Pyrex HOWTO . (Pyrex is actually a previous generation of Cython.)

Hmm ... this title offers a better search than I first tried: "Embedding cython" leads to this page , which sounds the way you want.

+28
Apr 05 2018-10-05T00:
source share

Here is the cython embed wiki page

Assuming you installed python on C:\Python31 and you want to use Microsoft Compiler.

smalltest1.py is the file you want to compile.

test.exe is the name of the executable file.

You need to set environment variables for cl .

 C:\Python31\python.exe C:\Python31\Scripts\cython.py smalltest1.py --embed cl.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 
+38
Apr 30 '10 at 9:12
source share



All Articles