3 ms·
It would be a dream-come-true to be able to compile Python (or some kind of very-close Python) down to a static binary. I want to run it like a Go binary.
by fwsgonzo 6y ago
It would be a dream-come-true to be able to compile Python (or some kind of very-close Python) down to a static binary. I want to run it like a Go binary.
- colejohnson66 6y agoYou already could?[0] Or are you asking about something else? [0]: https://stackoverflow.com/questions/39913847/is-there-a-way-to-compile-a-python-application-into-static-binary https://stackoverflow.com/questions/39913847/is-there-a-way-...
- fwsgonzo 6y agoI looked into this and it seems like no, these are not static binaries at all. They dynamically load stuff, and cython seems to be embedding very specific headers, including linux specific ones (asm/errno.h). I tried to build using musl-gcc but it was too different. When I say build static like a Go binary, I mean that the binary contains everything, and is not allowed to dynamically load anything at all. Also, preferrably it doesn't need a C standard library, and does system calls manually.
- zbentley 6y ago> When I say build static like a Go binary, I mean that the binary contains everything, and is not allowed to dynamically load anything at all. Just code? Or are you talking about data (e.g. HTML files) too? A lot of python's ecosystem seems pretty built around the assumption that non-code assets won't be bundled into single files, so any magic single-file Python compiler would probably have to include the ability to distribute those assets separately with the executable. > preferrably it doesn't need a C standard library I don't believe that golang even meets this standard--not with default options, at least. Also, why? How often have dynamically linked libc version differences really been a challenge for you in production? > does system calls manually This is generally considered to be a bad idea. Golang has moved away from this on several platforms, and people are making noise about doing it on Linux, too. A minority of compiled languages opt to go to this route. Why do you want this?