Skip to content

Rewrite pubspec with a comment-preserving YAML library in patch_pubspec_version.py#6656

Closed
jtullos-bt wants to merge 1 commit into
flet-dev:mainfrom
jtullos-bt:fix/pubspec-patch-preserve-comments
Closed

Rewrite pubspec with a comment-preserving YAML library in patch_pubspec_version.py#6656
jtullos-bt wants to merge 1 commit into
flet-dev:mainfrom
jtullos-bt:fix/pubspec-patch-preserve-comments

Conversation

@jtullos-bt

@jtullos-bt jtullos-bt commented Jul 7, 2026

Copy link
Copy Markdown

Description

Fixes #6655.

The CI step that publishes flet-build-template.zip rewrites the pubspec's flet dependency via .github/scripts/patch_pubspec_version.py, which round-trips the file through yaml.safe_load + yaml.dump and discards all comments, including the cookiecutter conditional markers that gate the app/app.zip assets to web builds. The published zip therefore declares the assets unconditionally, and desktop builds require a file the packaging step never produces.

This PR rewrites the pubspec in patch_pubspec_version.py with a comment-preserving YAML library (ruamel.yaml round-trip mode). Tested against the v0.86.0.dev1 template in both patch modes; the conditionals survive and the dependency rewrite is unchanged.

Test code

Repro repo demonstrating the failure on a stock GitHub macOS runner: https://github.com/jtullos-bt/flet-build-appzip-repro (failing run: https://github.com/jtullos-bt/flet-build-appzip-repro/actions/runs/28890234132)

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Additional details

The same patch step runs on stable release tags (with an exact version pin instead of a git ref), so an eventual 0.86.0 stable template zip is expected to carry the same defect unless the script is fixed first.

Summary by Sourcery

Preserve YAML comments when patching the pubspec dependency in the build template patching script so template conditionals continue to work.

Bug Fixes:

  • Fix loss of YAML comments and template conditionals when rewriting pubspec during the build template publish step.

Enhancements:

  • Switch the pubspec patching script to use ruamel.yaml round-trip mode to retain comments and original formatting while updating the flet dependency.

Build:

  • Update the script dependency metadata to require ruamel.yaml instead of PyYAML for the pubspec patching step.

yaml.safe_load/yaml.dump strips all YAML comments, and the build
template's cookiecutter conditionals live in comments (e.g. the
web-only gate around the app/app.zip assets). Every released
flet-build-template.zip therefore declares app.zip assets
unconditionally, and desktop flet build fails at asset bundling
because serious_python 4.x no longer produces app.zip on native
platforms. Switch to ruamel.yaml round-trip mode so comments,
ordering, and quoting survive the dependency rewrite.
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We've reviewed this pull request using the Sourcery rules engine

@FeodorFitsner

Copy link
Copy Markdown
Contributor

The fix is not relying anymore on jinja expressions in yaml comments (that was fragile): https://github.com/flet-dev/flet/pull/6654/changes#diff-ec4a6066761029ec8d50029894940e3c1fd754829c0caad08292127fdbd1a09f

But I don't mind using ruamel for preserving comments during CI patching.

Can you please:

  • re-target your PR to flet-0.86 branch.
  • add a record to changelog.

Thanks!

@jtullos-bt jtullos-bt closed this Jul 7, 2026
@jtullos-bt

jtullos-bt commented Jul 7, 2026

Copy link
Copy Markdown
Author

I had to close this, I'm not sure I can give you a good answer to the "Your Employer" section of the CLA. It might have been fine, but I would rather not sign a legal representation I havne't verified.

@FeodorFitsner

Copy link
Copy Markdown
Contributor

That's fine, thanks!

@jtullos-bt

Copy link
Copy Markdown
Author

The fix is not relying anymore on jinja expressions in yaml comments (that was fragile): https://github.com/flet-dev/flet/pull/6654/changes#diff-ec4a6066761029ec8d50029894940e3c1fd754829c0caad08292127fdbd1a09f

But I don't mind using ruamel for preserving comments during CI patching.

Can you please:

  • re-target your PR to flet-0.86 branch.
  • add a record to changelog.

Thanks!

sorry, see my comment below :(

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.

bug: desktop flet build fails with "No file or variants found for asset: app/app.zip"

3 participants