Skip to content

Compiling Python Code (Pyinstaller)

Ryan Thomas edited this page Dec 5, 2023 · 9 revisions

PyInstaller Guide: Opening this issue to document possible options to use with pyinstaller until we get this nailed down.

Standard pyinstaller arguments for GUI application

--onefile --noconsole --icon=stormcloud.ico

Change name as it appears in task manager? (Untested)

--win-private-assemblies --name "Stormcloud Backup Engine"

Hidden imports from infi.systray library

--hidden-import pkg_resources --hidden-import infi.systray

Manifest file to require administrative permissions

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <assemblyIdentity version="1.0.0.0" name="Stormcloud.app"/>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
    <security>
      <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
        <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
      </requestedPrivileges>
    </security>
  </trustInfo>
</assembly>

Save as app.manifest and include the switch: --manifest app.manifest

All together

pyinstaller --onefile --noconsole --icon=stormcloud.ico --hidden-import pkg_resources --hidden-import infi.systray stormcloud.py

Compiling pyinstaller from source

We are still popping on 4 AVs that VirusTotal scans with (Cynet, McAfee-GW-Edition, DeepInstinct, and SecureAge). These are all pretty fringe/sucky AVs so we might just be able to ignore these unless we find a customer who is actually using one of them.

Here's what I managed to do on my system to get it to work:

  1. Nuke all Visual Studio related stuff (run visual studio installer, go to more -> uninstall, and remove everything)
  2. Re-download only the 2022 Visual Studio Build Tools (https://visualstudio.microsoft.com/downloads/ -> go to "Tools for Visual Studio" section -> "Build Tools for Visual Studio 2022"
  3. git clone the pyinstaller source to C:\PyInstaller
  4. cd C:\Pyinstaller\pyinstaller\bootloader
  5. python.exe ./waf distclean all
  6. I have no idea why, but running with distclean appears to find the cl.exe file associated with MSVC, if you run it without distclean, it will not find it.
  7. cd C:\Pyinstaller\pyinstaller
  8. pip install .
  9. If that works, it should add the pyinstaller EXE to your path
  10. Rebuild stormcloud
  11. Sign the code. If you are using cloudsigner, make sure to get it signed before you upload to VT. SSL.com appears to be doing a VirusTotal lookup for the file hash when you go to sign it and if it has popped on even a single AV eSigner will not sign it.
  12. Once signed, you can upload to VT.

VirusTotal for current versions

Clone this wiki locally