Compare commits

...

3 Commits

Author SHA1 Message Date
Igor Velkov
e9ce7848f9
config: enable uboot-binman-fix-pkg-resources extension
Enable the binman pkg_resources fix for all builds.
The extension is a no-op for U-Boot >= v2025.10.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 02:15:25 +02:00
Igor Velkov
72954a7eb8
extension: fix binman pkg_resources removal in setuptools >= 82
setuptools 82.0.0 removed the deprecated pkg_resources module.
U-Boot's binman (tools/binman/control.py) uses `import pkg_resources`
for reading package resources in versions prior to v2025.10.

Add extension that patches binman at build time via pre_config_uboot_target
hook, migrating from pkg_resources to importlib.resources:

- Old U-Boot (<=v2023.x): adds try/except importlib_resources import block
- Intermediate U-Boot (v2024.01+): aliases existing importlib.resources import
- New U-Boot (>=v2025.10): no-op (pkg_resources already removed upstream)

Replaces:
- pkg_resources.resource_string() -> importlib_resources.files().joinpath().read_bytes()
- pkg_resources.resource_listdir() -> [r.name for r in ...files().joinpath().iterdir()]

Using an extension rather than patch files because BOOTPATCHDIR varies
across ~15 families, and control.py differs between U-Boot versions.
A single idempotent extension covers all versions.

Can be removed once all BOOTBRANCH versions in Armbian are >= v2025.10.

Tested:
- tritium-h5 (sunxi, U-Boot v2024.01): patch applied, build OK
- odroidc4 (meson-sm1, U-Boot v2022.07): patch applied, build OK
- odroidm2 (rk3588, U-Boot v2025.10): no-op as expected, build OK

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 02:15:19 +02:00
dependabot[bot]
85af201ce9
build(deps): bump setuptools from 80.10.2 to 82.0.0
Bumps [setuptools](https://github.com/pypa/setuptools) from 80.10.2 to 82.0.0.
- [Release notes](https://github.com/pypa/setuptools/releases)
- [Changelog](https://github.com/pypa/setuptools/blob/main/NEWS.rst)
- [Commits](https://github.com/pypa/setuptools/compare/v80.10.2...v82.0.0)

---
updated-dependencies:
- dependency-name: setuptools
  dependency-version: 82.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-02-16 18:46:45 +00:00
3 changed files with 92 additions and 1 deletions

View File

@ -0,0 +1,88 @@
#!/usr/bin/env bash
#
# SPDX-License-Identifier: GPL-2.0
#
# Copyright (c) 2013-2026 Igor Pecovnik, igor@armbian.com
#
# This file is a part of the Armbian Build Framework
# https://github.com/armbian/build/
#
# Fix binman's use of pkg_resources (removed in setuptools >= 82)
# by migrating to importlib.resources.
#
# Safe for all U-Boot versions: no-op if pkg_resources is not used.
# Can be removed once all BOOTBRANCH versions are >= v2025.10.
function pre_config_uboot_target__fix_binman_pkg_resources() {
local control_py="tools/binman/control.py"
# Skip if file doesn't exist or doesn't use pkg_resources
[[ -f "${control_py}" ]] || return 0
grep -q 'import pkg_resources' "${control_py}" || return 0
display_alert "Patching binman" "migrating pkg_resources to importlib.resources" "info"
python3 << 'PYTHON_SCRIPT'
import re
control_py = "tools/binman/control.py"
with open(control_py, "r") as f:
content = f.read()
# 1. Remove "import pkg_resources" line
content = re.sub(r'^import pkg_resources\b[^\n]*\n', '', content, flags=re.MULTILINE)
# 2. Ensure importlib_resources alias is available
has_importlib_alias = 'importlib_resources' in content
has_importlib_dotted = re.search(r'^import importlib\.resources\s*$', content, flags=re.MULTILINE)
if not has_importlib_alias and has_importlib_dotted:
# New U-Boot (v2024.01+): has "import importlib.resources" without alias
content = re.sub(
r'^import importlib\.resources\s*$',
'import importlib.resources as importlib_resources',
content, count=1, flags=re.MULTILINE
)
# Update existing dotted usage to use the alias
content = re.sub(r'\bimportlib\.resources\.', 'importlib_resources.', content)
elif not has_importlib_alias:
# Old U-Boot (<=v2023.x): no importlib.resources at all
import_block = (
'try:\n'
' import importlib.resources as importlib_resources\n'
' importlib_resources.files\n'
'except (ImportError, AttributeError):\n'
' import importlib_resources\n'
)
# Insert after the last top-level import line
lines = content.split('\n')
last_import_idx = 0
for i, line in enumerate(lines):
if re.match(r'^(?:import |from \S+ import )', line):
last_import_idx = i
lines.insert(last_import_idx + 1, import_block)
content = '\n'.join(lines)
# 3. Replace pkg_resources.resource_string(__name__, X)
# with importlib_resources.files(__package__).joinpath(X).read_bytes()
content = re.sub(
r'pkg_resources\.resource_string\s*\(\s*__name__\s*,\s*(.+?)\s*\)',
r'importlib_resources.files(__package__).joinpath(\1).read_bytes()',
content
)
# 4. Replace pkg_resources.resource_listdir(__name__, X)
# with [r.name for r in importlib_resources.files(__package__).joinpath(X).iterdir() if r.is_file()]
content = re.sub(
r'pkg_resources\.resource_listdir\s*\(\s*__name__\s*,\s*(.+?)\s*\)',
r'[r.name for r in importlib_resources.files(__package__).joinpath(\1).iterdir() if r.is_file()]',
content
)
with open(control_py, "w") as f:
f.write(content)
print("binman control.py patched successfully")
PYTHON_SCRIPT
}

View File

@ -65,6 +65,9 @@ function do_main_configuration() {
# Armbian config is central tool used in all builds. As its build externally, we have moved it to extension. Enable it here. # Armbian config is central tool used in all builds. As its build externally, we have moved it to extension. Enable it here.
enable_extension "armbian-config" enable_extension "armbian-config"
# Fix binman pkg_resources removal in setuptools >= 82. Can be removed when all U-Boot versions are >= v2025.10.
enable_extension "uboot-binman-fix-pkg-resources"
# Network stack to use, default to network-manager; configuration can override this. # Network stack to use, default to network-manager; configuration can override this.
# Will be made read-only further down. # Will be made read-only further down.
declare -g NETWORKING_STACK="${NETWORKING_STACK}" declare -g NETWORKING_STACK="${NETWORKING_STACK}"

View File

@ -6,7 +6,7 @@
# Dependabot will keep these versions up to date. # Dependabot will keep these versions up to date.
pip == 26.0.1 # pip is the package installer for Python pip == 26.0.1 # pip is the package installer for Python
setuptools == 80.10.2 # for building Python packages setuptools == 82.0.0 # for building Python packages
pyelftools == 0.32 # for building U-Boot pyelftools == 0.32 # for building U-Boot
unidiff == 0.7.5 # for parsing unified diff unidiff == 0.7.5 # for parsing unified diff
GitPython == 3.1.46 # for manipulating git repos GitPython == 3.1.46 # for manipulating git repos