U-Boot build fails with `ModuleNotFoundError: No module named 'distutils'`
When building U-Boot (due to adding new patches) v2022.04 and v2022.07 it's build fails with:
[🐳|🔨] CC arch/arm/lib/asm-offsets.s
[🐳|🔨] /armbian/cache/sources/u-boot-worktree/u-boot/v2022.07/scripts/dtc/pylibfdt/setup.py:27: SyntaxWarning: invalid escape sequence '\w'
[🐳|🔨] RE_KEY_VALUE = re.compile('(?P<key>\w+) *(?P<plus>[+])?= *(?P<value>.*)$')
[🐳|🔨] Traceback (most recent call last):
[🐳|🔨] File "/armbian/cache/sources/u-boot-worktree/u-boot/v2022.07/scripts/dtc/pylibfdt/setup.py", line 21, in <module>
[🐳|🔨] from distutils.core import setup, Extension
[🐳|🔨] ModuleNotFoundError: No module named 'distutils'
[🐳|🔨] make[2]: *** [scripts/dtc/pylibfdt/Makefile:30: rebuild] Error 1
[🐳|🔨] make[1]: *** [scripts/Makefile.build:398: scripts/dtc/pylibfdt] Error 2
[🐳|🔨] make[1]: *** Waiting for unfinished jobs....
[🐳|🔨] UPD include/generated/generic-asm-offsets.h
[🐳|🔨] UPD include/generated/asm-offsets.h
[🐳|🔨] LDS u-boot.lds
[🐳|🔨] make: *** [Makefile:2066: scripts_dtc] Error 2
[🐳|💥] Cleaning up [ please wait for cleanups to finish ]
Looks like the build system cannot find python3-setuptools or U-Boot make does not include or "require" python3-setuptools.
Originally posted by @djurny in https://github.com/armbian/build/issues/8260#issuecomment-2935445422
Jira ticket: AR-2697
This is worked around in https://github.com/armbian/build/pull/8260 by explicitly adding python3-setuptools to host_dependencies when U-Boot branches v2022.04 or v2022.07 are going to be built.
I foresee future pain related to this. distutils died, trying to ressurrect it here using (outdated/mismatched) distro packages will work up until it doesn't. this brings setuptools back using a conditional that's not always available during host prepare, so won't work for docker images, causing constant cache fails.
I would have suggested to upgrade u-boot instead.
Originally posted by @rpardini in https://github.com/armbian/build/issues/8260#issuecomment-2936989800
Maybe related: https://github.com/armbian/build/pull/8168