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:

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.