Skip to content

extension: fix importlib_resources detection for U-Boot v2024.x-v2025.04#9692

Merged
igorpecovnik merged 1 commit intoarmbian:mainfrom
iav:fix/uboot-binman-importlib-v2024x
Apr 18, 2026
Merged

extension: fix importlib_resources detection for U-Boot v2024.x-v2025.04#9692
igorpecovnik merged 1 commit intoarmbian:mainfrom
iav:fix/uboot-binman-importlib-v2024x

Conversation

@iav
Copy link
Copy Markdown
Contributor

@iav iav commented Apr 17, 2026

Problem

After merging #9407, three CI jobs failed with:

binman: name 'importlib_resources' is not defined
make: *** [Makefile:1135: .binman_stamp] Error 1

Affected boards: tinkerboard-2, h96-tvbox-3566, coolpi-genbook — all using U-Boot v2025.04.

Root Cause

U-Boot v2024.x–v2025.04 has this pattern in tools/binman/control.py:

try:
    import importlib.resources
except ImportError:  # pragma: no cover
    # for Python 3.6
    import importlib_resources
import pkg_resources

The previous check 'importlib_resources' in content matched the string inside the except clause and incorrectly concluded the alias already existed — skipping the import. After removing import pkg_resources, calls to importlib_resources.files(...) were left without a valid import.

Fix

Replace the string check with a regex anchored to the start of line:

# before:
has_importlib_alias = 'importlib_resources' in content

# after:
has_importlib_alias = bool(re.search(
    r'^import importlib\.resources\s+as\s+importlib_resources\b',
    content, flags=re.MULTILINE
))

U-Boot v2024.x–v2025.04 now falls through to the "no top-level import" branch and receives a proper try/except alias block.

Testing

Board U-Boot Result
tinkerboard-2 (edge) v2025.04 ✅ fixed
h96-tvbox-3566 (current) v2025.04 ✅ fixed
coolpi-genbook (edge) v2025.04 ✅ fixed
odroidc4 (current) v2022.07 ✅ regression ok
tritium-h5 (current) v2024.01 ✅ regression ok
odroidn2 (current) v2026.04 ✅ no-op ok

Summary by CodeRabbit

  • Chores
    • Improved the accuracy of import detection in the build system, refining how package dependencies are handled during the extension build process to prevent unnecessary duplication.

U-Boot v2024.x through v2025.04 has "import importlib_resources" inside
a try/except fallback block. The previous check ('importlib_resources' in
content) treated that string as a proper alias and skipped adding the import,
leaving importlib_resources undefined at runtime.

Fix: use a regex anchored to the start of line to detect only a real
top-level alias import.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@iav iav requested a review from igorpecovnik as a code owner April 17, 2026 20:43
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 17, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4459dcf8-3cc3-4ecf-9e40-c6ebf60b7856

📥 Commits

Reviewing files that changed from the base of the PR and between 5c50706 and 8e1a99f.

📒 Files selected for processing (1)
  • extensions/uboot-binman-fix-pkg-resources.sh

📝 Walkthrough

Walkthrough

The script's detection of importlib.resources alias imports was changed from a simple substring check to a regex pattern that matches only top-level import statements. This prevents false positives when the identifier appears in other contexts, such as within exception clauses, ensuring the script accurately determines whether the alias import is present.

Changes

Cohort / File(s) Summary
Import Detection Refinement
extensions/uboot-binman-fix-pkg-resources.sh
Changed alias detection from substring matching ('importlib_resources' in content) to regex pattern matching (^import importlib\.resources as importlib_resources\b), improving precision for identifying top-level import statements.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A regex pattern, precise and keen,
Spots imports where they should be seen,
No more false alarms in the except zone—
Just clean, real imports, crystal shown!
✨ The binman hops with glee, so bright!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and clearly describes the main change: fixing importlib_resources detection for specific U-Boot versions, which matches the core purpose of replacing a substring check with a more accurate regex-based detection.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added size/small PR with less then 50 lines 05 Milestone: Second quarter release Needs review Seeking for review Framework Framework components labels Apr 17, 2026
@igorpecovnik igorpecovnik merged commit b15593b into armbian:main Apr 18, 2026
11 checks passed
@iav iav deleted the fix/uboot-binman-importlib-v2024x branch April 20, 2026 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

05 Milestone: Second quarter release Framework Framework components Needs review Seeking for review size/small PR with less then 50 lines

Development

Successfully merging this pull request may close these issues.

2 participants