mirror of
https://github.com/borgbackup/borg.git
synced 2026-09-01 06:03:19 +02:00
The binary build broke with
File "src/borg/chunkers/buzhash64.pyx", line 26, in init borg.chunkers.buzhash64
from .kernel_env import kernel_error, requested_kernel
ModuleNotFoundError: No module named 'borg.chunkers.kernel_env'
kernel_env is imported only from .pyx files, and the chunkers are Cython
extensions, so PyInstaller's static analysis of the Python sources cannot
see the import at all and never collects the module. The spec already
lists borg.chunkers.base and .phte_chunker as hiddenimports for the same
reason (they are cimported at C level); this adds kernel_env and widens
the comment, since the rule is "anything a compiled chunker pulls in has
to be listed here", not just the cimported base classes.
Verified both ways with a local pyinstaller build: with the entry the
binary runs "borg benchmark cpu" through all chunkers, and rebuilding
with the entry removed reproduces the traceback above exactly.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TwV6jAxVttxcnJ5AVhfPxm
87 lines
3.1 KiB
Python
87 lines
3.1 KiB
Python
# -*- mode: python -*-
|
|
# This PyInstaller spec file is used to build Borg binaries on POSIX platforms and Windows.
|
|
|
|
import os, sys
|
|
|
|
is_win32 = sys.platform.startswith('win32')
|
|
|
|
# Note: SPEC contains the spec file argument given to pyinstaller
|
|
here = os.path.dirname(os.path.abspath(SPEC))
|
|
basepath = os.path.abspath(os.path.join(here, '..'))
|
|
|
|
if is_win32:
|
|
hiddenimports = ['borghash']
|
|
else:
|
|
hiddenimports = ['borg.platform.posix', 'borghash', 'rich._unicode_data.unicode17-0-0']
|
|
|
|
# Anything a compiled chunker module pulls in has to be listed here: the
|
|
# chunkers are Cython extensions, so PyInstaller's static analysis of the
|
|
# Python sources cannot see their imports at all. That covers both the base
|
|
# classes they cimport (ChunkerBase, and ChunkerPHTE for the *-aes chunkers),
|
|
# which are imported at C level during module init, and plain Python modules
|
|
# imported from a .pyx, such as kernel_env - it is imported ONLY from .pyx
|
|
# files, so nothing else would drag it in.
|
|
hiddenimports.append('borg.chunkers.base')
|
|
hiddenimports.append('borg.chunkers.phte_chunker')
|
|
hiddenimports.append('borg.chunkers.kernel_env')
|
|
|
|
block_cipher = None
|
|
|
|
a = Analysis([os.path.join(basepath, 'src', 'borg', '__main__.py'), ],
|
|
pathex=[basepath, ],
|
|
binaries=[],
|
|
datas=[
|
|
(os.path.join(basepath, 'src', 'borg', 'paperkey.html'), 'borg'),
|
|
(os.path.join(basepath, 'src', 'borg', 'cockpit', 'cockpit.tcss'), os.path.join('borg', 'cockpit')),
|
|
],
|
|
hiddenimports=hiddenimports,
|
|
hookspath=[],
|
|
runtime_hooks=[],
|
|
excludes=[
|
|
# '_ssl', 'ssl', # do not exclude these, needed for pyfuse3/trio
|
|
'pkg_resources', # avoid pkg_resources related warnings
|
|
],
|
|
win_no_prefer_redirects=False,
|
|
win_private_assemblies=False,
|
|
cipher=block_cipher)
|
|
|
|
if sys.platform == 'darwin':
|
|
# do not bundle the osxfuse libraries, so we do not get a version
|
|
# mismatch to the installed kernel driver of osxfuse.
|
|
a.binaries = [b for b in a.binaries if 'libosxfuse' not in b[0]]
|
|
|
|
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
|
|
|
|
exe = EXE(pyz,
|
|
a.scripts,
|
|
a.binaries,
|
|
a.zipfiles,
|
|
a.datas,
|
|
name='borg.exe',
|
|
debug=False,
|
|
strip=False,
|
|
upx=True,
|
|
console=True,
|
|
icon='NONE')
|
|
|
|
# Build a directory-based binary in addition to a packed
|
|
# single-file binary. This allows you to look at all included
|
|
# files easily (e.g., without having to strace or halt the built binary
|
|
# and introspect /tmp). It also avoids unpacking all libraries when
|
|
# running the app, which is better for application signing on various OSes.
|
|
slim_exe = EXE(pyz,
|
|
a.scripts,
|
|
exclude_binaries=True,
|
|
name='borg.exe',
|
|
debug=False,
|
|
strip=False,
|
|
upx=False,
|
|
console=True)
|
|
|
|
coll = COLLECT(slim_exe,
|
|
a.binaries,
|
|
a.zipfiles,
|
|
a.datas,
|
|
strip=False,
|
|
upx=False,
|
|
name='borg-dir')
|