Using PyInstaller with Acroname's BrainStem Development Kit

2022 June 19

If you are not familiar with PyInstaller it is an application that allows you to bundle a python file or project into a single executable by providing a fully encapsulated environment. The benefit being that you won't need to fuss with setting up a python environment.  Simply execute the application.

Many times pyinstaller can be excuited without any additional commands such as:

  • pyinstaller --onefile <python file>

However, there are situations when PyInstaller cannot detect the dependencies of certain modules. Acroname’s “brainstem” package is one of these cases.  The reason for this is because our Python API is a wrapper around our C API.  This means that there are external libraires that need to be taken into account when creating a self contained executable.

Luckily, PyInstaller has supplied a ton of options to handle these cases. Some of these options are:

  • --add-data < src;dest>
  • --add-binaries < src;dest>

These are great solutions but they require you know exactly where they are located and exactly where they should be placed. Acroname has used this solution for many years internally; however, there are better solutions such as:

  • --collect-all <module name>
  • --collect-binaries <module name>

Collect all is the most complete, but results in a larger executable and is not required for our package.  Based on the current behavior we recommend using the collect binaries option.

  • pyinstaller --onefile --collect-binaries <package name> <python_file>
  • pyinstaller --onefile --collect-binaries brainstem brainstem_example.py

For more information please use the following resources:

  • PyInstaller: https://pyinstaller.org/en/stable/index.html
  • Acronames BrainStem Development Kit: https://acroname.com/software/brainstem-development-kit
  • Acroname’s Python API Reference: https://acroname.com/reference/api/python/index.html

Add New Comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.
We are bots. Are you?