cztomczak / cefpython

Python bindings for the Chromium Embedded Framework (CEF)
Other
3.03k stars 470 forks source link

Example of packaging app using Cython compiler #407

Open cztomczak opened 6 years ago

cztomczak commented 6 years ago

Cython repo: https://github.com/cython/cython

Packagers like PyInstaller, Py2exe and cx_Freeze can package app into an executable, however they do not provide good security for source codes. Sources when using these packagers are protected by compiling them to bytecode, but that bytecode can be easily converted into original almost complete source codes with only code comments removed. All variables names, functions names, modules, strings, everything can be seen as in original code. PyInstaller provides an additional security by setting a secret cipher that allows to encrypt bytecode compiled code, however this is only security by obscurity and can be easily broken as well.

The only viable options to better protect sources codes are:

  1. Use Cython to compile .py files to .pyd/.so modules (real binaries) and only then package app using e.g. PyInstaller.
  2. Use Nuitka compiler which can both protect sources and also package app into executable (Issue #396).

See also related issues labeled with: packaging .

cztomczak commented 6 years ago

Cython can also be used to create .exe module. The --embed flag can do that when calling Cython. Cython can also integrate multiple modules. See:

  1. Issue in Cython tracker to simplify compilation of complete applications: https://github.com/cython/cython/issues/2011
  2. Post by Stefan Behnel: https://groups.google.com/d/msg/cython-users/9uQfPteBXMA/P7oSnPkNCAAJ
  3. Cython docs: http://docs.cython.org/en/latest/src/reference/compilation.html#integrating-multiple-modules