Obscuring Python source from end users

Sturla Molden sturla.molden at gmail.com
Mon Sep 29 16:51:33 CEST 2014


Steven D'Aprano <steve+comp.lang.python at pearwood.info> wrote:

> Another possibility is to distribute your modules inside a zip file. See
> here:
> 
> https://mail.python.org/pipermail/python-list/2014-July/675506.html
> 
> Such zip files are not just runnable, but also importable. Depending on your
> Excel requirements, you might need a tiny driver script as above.

It should also be possible to temper with the zipimport module to allow a
'scrambled' zip file. That makes it harder for users to access the code by
unpacking the zip file.

py2exe will collect pyc files into a single zip file and import that. It
does not need a driver script because it embeds the Python interpreter in
an executable. 

Yet another option is to compile the Python code with Cython and distribute
everything as compiled pyd files.

Sturla




More information about the Python-list mailing list