From b64d1dbc4d1ef5a0c144e492c010624b0bf1ea6a Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Tue, 2 Jun 2026 18:56:28 +0200 Subject: [PATCH] scripts/build-nuitka.sh: generate single-file binary using nuitka, fixes #3227 Very experimental and little tested. --- scripts/build-nuitka.sh | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 scripts/build-nuitka.sh diff --git a/scripts/build-nuitka.sh b/scripts/build-nuitka.sh new file mode 100755 index 000000000..34df041d8 --- /dev/null +++ b/scripts/build-nuitka.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# Generate a single-file binary of borgbackup using Nuitka. + +set -euo pipefail + +OUTPUT_DIR="build" +OUTPUT_FILENAME="borg-nuitka.exe" # .exe does NOT mean windows here +SRC_DIR="src/borg" + +echo "============================================" +echo "Found Nuitka $(python -m nuitka --version | head -n 1)." +echo "Building single-file binary of borgbackup..." +echo "============================================" + +# Run Nuitka compilation +# We use --assume-yes-for-downloads to avoid interactive prompts in automated runs. +# We set PYTHONPATH=src to ensure the local version of borg is used. +# We include cffi and _cffi_backend to avoid runtime ModuleNotFoundError in argon2-cffi. +PYTHONPATH=src python -m nuitka \ + --standalone \ + --onefile \ + --assume-yes-for-downloads \ + --include-package=borg \ + --include-package=borghash \ + --include-package=borgstore \ + --include-package=cffi \ + --include-module=_cffi_backend \ + --output-dir="$OUTPUT_DIR" \ + --output-filename="$OUTPUT_FILENAME" \ + "$SRC_DIR" + +echo "=============================================" +echo "Build completed successfully!" +echo "Single-file binary generated at:" +echo " $OUTPUT_DIR/$OUTPUT_FILENAME" +echo "============================================="