Cython: Is it possible to put everything into one independent executable?

Created on 14 Mar 2018  路  7Comments  路  Source: cython/cython

Hello iv'e just finished a pyside2 project and now i want to distribute it to windows users and other linux users in an easy to run package. I was thinking cython would allow me to compile everything into one executable which i could then give to the user for easy install(except perhaps pyside2 which is too big i assume and i should instead bundle so the user could just update the smaller binary on next update).

Is this something that is possible with cython? Could you please give me some directions on how i can achieve this as C and compiling is not my strong suit.

So far iv'e gotten the app to run with -embed but i see it linking to /usr/share/usr/lib/libpython3.6m.so.1.0 and i suppose i have to get it to link to libpython3.6m.so.1.0 in the same directory? The other issue is to get it to link to the same folder for libraries or include all the other libraries i need into the binary. How can i accomplish this.

Thank you for your thoughts.

duplicate

Most helpful comment

I've put a short tutorial in https://github.com/mobiusklein/cython_pyinstaller_example.

Do note that using Cython and PyInstaller for obfuscation isn't very strong, and will only slow down a determined individual.

All 7 comments

At the moment, due to how the python language works, it's possible to embed the python interpreter into the final executable, but not external libraries. You might want to look for a tool designed for this like pyinstaller or py2exe.

edit: What do you mean with embedding the python interpreter? I thought it just linked to the python interpreter on a users system and if it can't find one the app won't run?

Ah. Ok. Iv'e actually tried pyinstaller and it creates some kind of binary blob but i think it's not as well "hidden" as with cython?

Could you tell me how to combine cython with pyinstaller so that pyinstaller finds all the required libraries and then i will have cython compile the main binary and have it use the libraries that pyinstaller have provided for me(these are in the same folder)?

Sorry, i'm not too familier with pyinstaller. I'm just familiar with using cython. I suppose you would like to create a package with a setup.py and build the cython extensions inside. After that I don't really know, I've never tried it. I just got this info from the cython wiki.

Is your goal purely to obfuscate your code, or to make a distributable bundle for your program that doesn't require your user to install Python?

Well, preferably both.

I've put a short tutorial in https://github.com/mobiusklein/cython_pyinstaller_example.

Do note that using Cython and PyInstaller for obfuscation isn't very strong, and will only slow down a determined individual.

Closing as duplicate of #2011.

Was this page helpful?
0 / 5 - 0 ratings