Building your own bootloader for PyInstaller is often required to avoid seeing virus scanners (falsely) report your executable as infected. Some anti-virus vendors have included snippets of PyInstaller code in their virus definitions. Look around the internet for “PyInstaller virus” and you will get lots of hits such as here, here, and here. In order to fix such issues for two projects I maintain, NodeMCU PyFlasher and ThingPulse App Fairy, I finally bit the bullet and built my own Windows bootloader for PyInstaller. These are my public mental notes of the steps required.
The main entry point should be the PyInstaller documentation on building bootloaders. For some reason I turned to it only after I had followed some other recipe.
- Download Build Tools for Visual Studio 2019 from Microsoft.
- Run the
vs_BuildTools.exedownloaded in the previous step.
- Select “C++ build tools”. Switch to the “Individual components” tab and select “Windows Universal CRT SDK” in the addition to the components already selected.
- Install/upgrade setuptools: $
pip install setuptools --upgrade
- Remove any PyInstaller installation you might already have: $
pip uninstall PyInstaller
- Clone the PyInstaller repository from GitHub:
$ git clone https://github.com/pyinstaller/pyinstaller
- Checkout the latest version, 4.2 as of today:
$ git checkout v4.2
- Build the bootloader in its directory:
$ cd bootloader && python ./waf distclean all
- Go back to the PyInstaller root dir and install it:
$ cd .. && python setup.py install
Building your own bootloader is no guarantee the executable PyInstaller is considered virus-free. However, it is the best you can do.
One thought on “Build a bootloader for PyInstaller”
This procedure worked for me and instructions are easier to follow than those at pyinstaller.