r/Python • • 6d ago

Discussion PyInstaller on Windows: does code signing stop Smart App Control blocking the DLLs?

I ship a desktop app with a python backend frozen with pyinstaller, currently unsigned. Two problems on Windows:

  • SmartScreen "Windows protected your PC" on every fresh download
  • worse: on some users' machines Smart App Control blocks the bundled .pyd/.dll files ("An Application Control policy has blocked this file") and the app just dies on startup

I'm about to pay for signing, and the part I can't find a straight answer on is the pyinstaller side:

  1. Is signing the main exe enough, or do you have to sign every .pyd and .dll inside the bundle (incl. python3xx.dll and third party wheels) before freezing?
  2. Has anyone seen Smart App Control actually stop blocking after signing, or does it still flag new files until reputation builds?
  3. onefile vs onedir, does it matter here? onefile extracts to temp, which feels like exactly what SAC hates.

If you've been through this, what did your build pipeline end up looking like?

42 Upvotes

36 comments sorted by

View all comments

Show parent comment

1

u/Ishannaik 3d ago

onefile breaking a subprocess call of itself is a nasty one to hit, good to know standalone n the installer avoided it. was it relaunching via sys.executable that broke, or the temp extraction getting cleaned up under the child process?

1

u/sausix 3d ago

I could have fixed it. I'm running a sub component of the code as another process. It's possible with onefile too but it would be a special handling just for a temporary use case. Standalone builds do startup faster. I'll create an auto update anyway so an installer will be enough.

Nuitka has special handling for this. Didn't dig into it yet. argv[0] and sys.executable get changed I think.

I used Popen on argv[0] and that worked on running on source code and on standalone.

I've read about onefile versions fill up RAM on many starts due to their extractions. Don't remember if it was PyInstaller or Nuitka. I recommended my testers to not use the onefile and now stopped building it.

2

u/Ishannaik 3d ago

popen on argv[0] working for both source and standalone is a neat trick, way less fragile than guessing what sys.executable ends up pointing at in each mode. the ram filling up from repeated extractions would be reason enough on its own to keep testers off onefile tbh