From 3d28159a753be5b30eec863dd6cb094245ac60e2 Mon Sep 17 00:00:00 2001 From: JKBusse <48227459+JKBusse@users.noreply.github.com> Date: Thu, 16 Jul 2026 19:51:07 +0200 Subject: [PATCH] build(macos): add configurable target architecture for DMG builds Allow selecting macOS target architecture via NEGPY_MACOS_ARCH, pass through to PyInstaller target-arch, and align DMG filename/docs with selected architecture. --- CONTRIBUTING.md | 7 +++++++ README.md | 2 ++ build.py | 10 +++++++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d47fa5e5..ecf188d0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -118,3 +118,10 @@ To build the standalone application for your current OS: make build ``` This will trigger the Python backend build via PyInstaller. + +On macOS, you can choose the target architecture for the DMG build with `NEGPY_MACOS_ARCH`. +For an Intel build from a compatible macOS environment, run: + +```bash +NEGPY_MACOS_ARCH=x86_64 make build +``` diff --git a/README.md b/README.md index 8713eb25..c64e8e1a 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,8 @@ Since this is a free hobby project, I don't pay Apple or Microsoft ransom for th 2. Open Terminal and run: `xattr -cr /Applications/NegPy.app` (this gets rid of the warning). 3. Launch it. +If you build the DMG yourself on macOS, set `NEGPY_MACOS_ARCH=x86_64` for an Intel build or `NEGPY_MACOS_ARCH=arm64` for Apple Silicon. + **Scanner support** requires SANE via [Homebrew](https://brew.sh/): ``` brew install sane-backends diff --git a/build.py b/build.py index 3cf4a25e..4d750531 100644 --- a/build.py +++ b/build.py @@ -24,6 +24,11 @@ is_macos = system == "Darwin" is_linux = system == "Linux" + +def get_macos_target_arch(): + """Return the macOS target architecture for packaging.""" + return os.environ.get("NEGPY_MACOS_ARCH", platform.machine()) + # Basic PyInstaller arguments params = [ ENTRY_POINT, @@ -119,6 +124,9 @@ def collect_gphoto2_plugins() -> None: elif os.path.exists("media/icons/icon.png"): params.append("--icon=media/icons/icon.png") + macos_target_arch = get_macos_target_arch() + params.append(f"--target-arch={macos_target_arch}") + def package_linux(): """Package the built application into an AppImage.""" @@ -305,7 +313,7 @@ def package_macos(): """Package the built application into a DMG with Applications symlink.""" print(f"Packaging for macOS (DMG) version {VERSION}...") app_path = os.path.join("dist", f"{APP_NAME}.app") - dmg_name = f"{APP_NAME}-{VERSION}-macOS-{platform.machine()}.dmg" + dmg_name = f"{APP_NAME}-{VERSION}-macOS-{get_macos_target_arch()}.dmg" dmg_path = os.path.join("dist", dmg_name) temp_dmg_dir = os.path.join("dist", "dmg_temp")