Search code examples
pythonpython-3.xcx-freeze

How to make cx_Freeze compile submodules into shared object (.so) files?


Background

  • I'm working for a company that is writing code to control television screens that will play advertisements downloaded via the internet.
  • My boss wants to compile the source code before we give it to the factory that will be manufacturing the screen-controller computers so that the code can't easily be copied / reverse-engineered.
  • My boss has decided that .pyc files are too easy to reverse-engineer, and would prefer to compile to binary(?) files, one type of which(?) seems to be .so files.
  • I'm now trying to use cx_Freeze to convert all of our source code to .so files.

Problem

When I run python setup.py build (the command that has cx_Freeze "compile" our app), it seems only the one file I designate as the "main" file gets converted to an .so file, while the rest of our source code is converted to .pyc. We want all of our code to be .so files.

What I've tried

  • I've tried going through the cx_Freeze documentation but don't see how to accomplish what we're trying to do.

Solution

  • It isn't possible.

    I emailed the creator of cx_Freeze (Anthony Tuininga) and this was his response:

    cx_Freeze doesn't have that capability. It puts all of its compiled Python code (.pyc files) into a zip file. Technically, there is a way to do so, but cx_Freeze doesn't do so. Since it involves a C compiler its more complex and prone to error.