build: bundle borg.chunkers.kernel_env into the binary

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 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TwV6jAxVttxcnJ5AVhfPxm
This commit is contained in:
Thomas Waldmann
2026-08-06 14:19:54 +02:00
co-authored by Claude Opus 5
parent 2163abfe19
commit f71c3def0d
+8 -4
View File
@@ -14,12 +14,16 @@ if is_win32:
else:
hiddenimports = ['borg.platform.posix', 'borghash', 'rich._unicode_data.unicode17-0-0']
# The chunkers cimport their shared base classes (ChunkerBase, and ChunkerPHTE
# for the *-aes chunkers), so they import those modules at C level when
# initializing - PyInstaller can not see this by static analysis of the Python
# sources.
# 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