Skip to content

Fix start up code to also call freeze_support() on macOS when frozen so native macOS executables work #3250

@ichard26

Description

@ichard26

I broke the native macOS executables. The build for 22.8.0 failed since the executable failed the basic sanity checks pre-upload

Usage: black_macos [OPTIONS] SRC ...
Try 'black_macos -h' for help.

Error: No such option: --multiprocessing-fork
Usage: black_macos [OPTIONS] SRC ...
Try 'black_macos -h' for help.

Usage: black_macos [OPTIONS] SRC ...
Try 'black_macos -h' for help.

Error: No such option: --multiprocessing-fork
Error: No such option: --multiprocessing-fork
error: cannot format src/black/__main__.py: A process in the process pool was terminated abruptly while the future was running or pending.
error: cannot format src/black/files.py: A process in the process pool was terminated abruptly while the future was running or pending.

When I first submitted #3211 I checked how the stdlib guards the freeze_support() call and copied it:

So as far as I understand from reading the code, macOS should not need freeze_support() to work with PyInstaller, but apparently it does. Anyway let's fix this by including macOS in the OS check I guess.

black/src/black/__init__.py

Lines 1377 to 1384 in 2018e66

def patched_main() -> None:
if sys.platform == "win32" and getattr(sys, "frozen", False):
from multiprocessing import freeze_support
freeze_support()
patch_click()
main()

Metadata

Metadata

Assignees

No one assigned

    Labels

    C: packagingInstallation and packaging of BlackT: bugSomething isn't working
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions