Skip to content

Building

botrx555 edited this page Jul 14, 2026 · 3 revisions

Building the standalone apps

The standalone Mac/Windows apps are built with PyInstaller from m8raw2dng2_gui.py. Only the GUI is frozen; the CLI is the .py script itself and is not packaged. This page is for contributors rebuilding the binaries; users should just download them (see Installation).

Each build is per-platform and per-architecture - build on the target OS and CPU you want to ship for. There is no cross-compilation.

Prerequisites

Python 3.x, the runtime dependencies, and PyInstaller (macOS/Linux shown; on Windows use py -m pip):

python3 -m pip install -r requirements.txt
python3 -m pip install --upgrade pyinstaller

Icons live in assets/ (m8raw2dng2.icns for macOS, m8raw2dng2.ico for Windows).

Check the Tk your Python links against (macOS especially). The GUI is tkinter, and the frozen app inherits whatever Tcl/Tk the building Python had - a bad Tk here cannot be fixed later by repackaging. Before building:

python3 -c "
import tkinter
from tkinter import ttk
r = tkinter.Tk(); r.withdraw()
s = ttk.Style()
print('Tk', tkinter.TkVersion, '| themes:', s.theme_names(), '| using:', s.theme_use())
r.destroy()"

On macOS expect Tk 8.6 and the aqua theme. macOS's bundled /usr/bin/python3 links an old Tk 8.5 whose widgets render dated and mis-sized; build with a python.org Python (or any Python whose tkinter reports 8.6/aqua) instead.

macOS (arm64 or Intel)

Run on the architecture you are shipping - an Apple Silicon Mac produces an arm64 app, an Intel Mac an x86_64 app.

rm -rf build dist m8raw2dng2.spec
python3 -m PyInstaller --windowed --onedir --name m8raw2dng2 \
  --collect-all tkinter --icon assets/m8raw2dng2.icns m8raw2dng2_gui.py

The app is written to dist/m8raw2dng2.app. Confirm that a real bundle was produced (not a bare executable) and that its architecture is the one you meant to ship:

ls -d dist/m8raw2dng2.app
file dist/m8raw2dng2.app/Contents/MacOS/m8raw2dng2

The first command must succeed - if dist/m8raw2dng2.app does not exist but dist/m8raw2dng2/ does, the build was driven by a stale spec (see Gotchas). Launch the app once (open dist/m8raw2dng2.app) and confirm the GUI renders correctly before packaging.

Windows (x64)

On Command Prompt, install the dependencies, clear any prior build, and build:

py -m pip install -r requirements.txt
py -m pip install --upgrade pyinstaller
if exist build rmdir /S /Q build
if exist dist rmdir /S /Q dist
if exist m8raw2dng2.spec del m8raw2dng2.spec
python -m PyInstaller --windowed --onedir --name m8raw2dng2 ^
  --collect-all tkinter --icon assets\m8raw2dng2.ico m8raw2dng2_gui.py

The app folder is written to dist\m8raw2dng2 (the .exe plus its _internal folder). Both must ship together. On a shared VM/host folder, see the gotcha below before building.

Packaging

Drop the matching per-platform README.txt into the build's m8raw2dng2/ folder and zip so the archive expands to a single top-level m8raw2dng2/ directory:

  • macOS: m8raw2dng2/m8raw2dng2.app + README.txt
  • Windows: m8raw2dng2/m8raw2dng2.exe + _internal/ + README.txt

Gotchas

A stale .spec silently retargets the build. This is the trap most worth knowing, because it does not error - it produces a wrong build that looks like a successful one. Every command-line build writes m8raw2dng2.spec beside the sources; the file is gitignored because it is a build artifact, not source. A spec generated on Windows carries icon=['assets\m8raw2dng2.ico'] and, more importantly, no BUNDLE() section - BUNDLE is what --windowed adds on macOS to wrap the executable into m8raw2dng2.app. Reuse that spec on the Mac (python3 -m PyInstaller m8raw2dng2.spec) and PyInstaller reports success while emitting only dist/m8raw2dng2/m8raw2dng2, a bare Unix executable with no .app around it, which macOS does not treat as a proper GUI app. On a shared macOS/Windows folder both hosts write to the same spec, so this is easy to hit. Always rm -rf build dist m8raw2dng2.spec first (the build commands above do), never carry a spec between platforms, and verify the .app exists afterwards.

The build environment's optional packages are frozen in. requirements.txt lists numpy as required and tifffile / pillow as optional, and the converter imports the latter two behind try/except guards. PyInstaller bundles only what is importable at build time, and a frozen app cannot be pip-installed into afterwards - so anything missing from the build environment is missing from the shipped app permanently, with no error at build time. Install the full requirements.txt before building. Without tifffile the app loses re-processing an existing DNG (reported cleanly, and the GUI greys the option); without pillow it loses the --legacy-preview path, which is not guarded at runtime and so fails during conversion rather than up front. A successful build tells you nothing about either - exercise the options in the built app, do not just launch it.

Shared dist/ on a VM/host setup (Windows). When one working folder is shared between a macOS host and a Windows guest (e.g. Parallels), every build writes to the same dist/. A dist/ left by a macOS build holds .dylib files the Windows guest cannot delete, so its clean step hits Access is denied / WinError 5. Fix: clear dist/ from the host (rm -rf build dist) before building on the guest, so the guest builds into a fresh folder.

All builds target the same dist/. If you build for several platforms/architectures from one checkout, each build overwrites the last. Fully build and zip one target before starting the next, or point each at its own work folder.

UPX, if installed, is applied automatically. The spec PyInstaller generates sets upx=True, which takes effect only when a UPX binary happens to be on PATH - so builds differ depending on the machine. UPX-compressed executables draw more antivirus false positives on Windows and save little here. If UPX is present on the build machine, add --noupx to the build command.

The apps are unsigned. First launch is blocked by Gatekeeper (macOS) and SmartScreen (Windows); the per-platform README.txt and Installation cover the one-time unlock.

Clone this wiki locally