Skip to content

Stop passing literal quotes as package_folder_prefix - #290

Merged
tannewt merged 1 commit into
adafruit:mainfrom
tyeth-ai-assisted:fix-package-folder-prefix
Sep 14, 2026
Merged

tannewt merged 1 commit into
adafruit:mainfrom
tyeth-ai-assisted:fix-package-folder-prefix

Conversation

@tyeth-ai-assisted

@tyeth-ai-assisted tyeth-ai-assisted commented Sep 10, 2026

Copy link
Copy Markdown

build.sh and release.yml build the --package_folder_prefix list with a gawk that wraps it in literal double quotes. build_bundles splits that argument on ", " and matches each entry with str.startswith(), so the first and last entries arrive as \"foo and bar\" and match no folder.

Reproduced with build-tools 1.20.1 by calling get_package_info() directly:

prefix entry result
sensirion_i2c_sen5x is_package=True, 33 files
\"sensirion_i2c_sen5x is_package=False, module_name=conftest, 1 file

Latent here today. With this change the bundle is byte-identical to main — 1788 files in the py bundle, same list, same 6839808 bytes. Of the 47 entries in the prefix list, only 11 belong to libraries that still reach _detect_legacy_package_structure; the other 36 declare tool.setuptools.packages in pyproject.toml, which takes precedence and never consults the prefix. So it only bites when the first or last entry in ls -U order is one of those 11 — currently neither is. Adding, removing or reordering a library can change that.

It is not latent everywhere. In a fork of this bundle carrying two third-party libraries with no [tool.setuptools] metadata, both entries are the quoted ones, and the released bundle was 4 KB containing a single conftest module.

Changes:

  • Drop the quotes. build.sh already passes "$P".
  • release.yml expanded the value unquoted, which is what the literal quotes were accidentally doing. Compute it in the step that consumes it and pass "$prefix", rather than routing a directory name through $GITHUB_OUTPUT and an expression that splices it into the script as text.
  • Refuse an empty list. "".startswith("") is True, so an empty prefix makes every folder a package.

CI on this PR is green and, as above, produces exactly the same bundle as main.

🤖 Generated with Claude Code

@tyeth

tyeth commented Sep 10, 2026

Copy link
Copy Markdown
Member

Sorry for the slop description/PR.

The gawk wraps the list in literal double quotes. build_bundles splits the
argument on ", " and matches with str.startswith(), so the first and last
entries of the list arrive with a stray quote attached and match no folder.

Latent here today: with this change the bundle is byte-identical to main,
1788 files. Only 11 of the 47 entries belong to libraries that still reach
_detect_legacy_package_structure; the rest declare tool.setuptools.packages
in pyproject.toml and never consult the prefix. It bites when the first or
last entry in ls -U order is one of those 11, which reordering can change.

Drop the quotes. build.sh already passes "$P". In release.yml the value was
expanded unquoted, so compute it in the step that consumes it and pass it as
"$prefix" rather than routing it through $GITHUB_OUTPUT and an expression,
which splices a directory name into the script as text.

Refuse an empty list: "".startswith("") is True, so an empty prefix makes
every folder a package.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@tyeth-ai-assisted

Copy link
Copy Markdown
Author

Correcting my own description: I first wrote that two libraries are currently mis-bundled here. That is wrong, and I have edited the body. Measured after opening it — this PR's bundle is byte-identical to main's, so the defect is latent in this repo. Only 11 of the 47 prefix entries belong to libraries that still use legacy autodetection, and neither of the two damaged entries is one of them right now.

Still worth taking as hardening rather than a fix, and the release.yml half removes a directory name being spliced into a later step as script text.

🤖 Generated with Claude Code

@tannewt tannewt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the official bundle have the same issue? I suspect they use the same github actions.

@tyeth

tyeth commented Sep 11, 2026

Copy link
Copy Markdown
Member

Does the official bundle have the same issue? I suspect they use the same github actions.

Great question, probably, but I think we mostly avoid the older project style these days.
Mentally filed to have a look at some point (hopefully next week)

@tannewt tannewt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, fine here!

@tannewt
tannewt merged commit 4d76b40 into adafruit:main Sep 14, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants