Skip to content

fix(app-template): write extension example paths with TOML-safe forward slashes - #6775

Open
ndonkoHenri wants to merge 3 commits into
mainfrom
fix/extension-template-windows-paths
Open

fix(app-template): write extension example paths with TOML-safe forward slashes#6775
ndonkoHenri wants to merge 3 commits into
mainfrom
fix/extension-template-windows-paths

Conversation

@ndonkoHenri

@ndonkoHenri ndonkoHenri commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

flet create --template extension generates an example app whose pyproject.toml cannot be parsed on Windows, so the very first thing the user-extensions guide tells you to do — build or run the generated example — fails before it starts.

The two entries that point the example back at the extension package interpolated the host's os.sep into TOML basic strings:

[tool.flet.dev_packages]
flet-wvr = "..{{cookiecutter.sep}}.."           # -> "..\.."   on Windows

[tool.uv.sources]
flet-wvr = { path = "..{{cookiecutter.sep}}..{{cookiecutter.sep}}", editable = true }  # -> "..\..\"

create.py passes "sep": os.sep, so on Windows the first renders "..\.."\. is not a valid TOML escape — and the second renders "..\..\", where the trailing \" escapes the closing quote and leaves the string unterminated. That second one is the "unbalanced quotes" error reporters hit; tomllib reports it as Unescaped '\' in a string. POSIX was unaffected, since sep is / there.

Both paths are now written with plain forward slashes, which need no escaping in TOML and which pathlib (how [tool.flet.dev_packages] is resolved) and uv accept on Windows exactly as elsewhere. {{cookiecutter.sep}} no longer appears anywhere under sdk/python/templates/app/; the build template's use of it for Kotlin source directories is untouched, as that one really is a filesystem path.

This was fixed once, in August 2025, but only on the archived flet-app-templates 0.28.3 branch — it was never forward-ported when the templates moved into the monorepo.

Refs #5507. That issue reports two separate problems; this fixes the template half only. The packaging hang tracked there is unrelated to this change and stays open.

Test code

# Renders the extension template as Windows would (os.sep == "\") and parses
# every generated pyproject.toml. Fails on main, passes on this branch.
import pathlib, tempfile, tomllib
from cookiecutter.main import cookiecutter

out = tempfile.mkdtemp()
cookiecutter(
    template="sdk/python/templates/app",
    directory="extension",
    output_dir=out,
    no_input=True,
    extra_context={
        "template_name": "extension", "flet_version": "1.0.0", "sep": "\\",
        "platform": "windows", "out_dir": "flet_wvr", "project_name": "flet-wvr",
    },
)
for p in pathlib.Path(out, "flet_wvr").rglob("pyproject.toml"):
    tomllib.loads(p.read_text())   # main: tomllib.TOMLDecodeError: Unescaped '\' in a string
    print("OK", p)

Result on this branch, under both sep="\\" and sep="/":

OK flet_wvr/pyproject.toml
OK flet_wvr/examples/flet_wvr_example/pyproject.toml
   [tool.flet.dev_packages] = {'flet-wvr': '../..'}
   [tool.uv.sources]        = {'flet-wvr': {'path': '../../', 'editable': True}}

Summary by Sourcery

Ensure generated extension examples remain valid and buildable across platforms.

Bug Fixes:

  • Fix extension template projects generating Windows-invalid TOML paths by using forward-slash package references in generated example applications.

Enhancements:

  • Correct the macOS architecture help text to use the x86_64 architecture name.

…5507)

The `[tool.flet.dev_packages]` and `[tool.uv.sources]` entries of the
generated extension example interpolated `{{cookiecutter.sep}}` (`os.sep`)
inside TOML basic strings. On Windows that rendered `"..\.."` — an invalid
escape sequence — and `"..\..\"`, whose trailing `\"` escapes the closing
quote and leaves the string unterminated, which is the "unbalanced quotes"
error reported in #5507. Every Windows user had to hand-edit the file before
the example could be built or run.

Forward slashes need no escaping in TOML and are accepted by `pathlib` and
`uv` on Windows, so they render identically on every platform.

@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.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 17, 2026

Copy link
Copy Markdown

Deploying flet-website-v2 with  Cloudflare Pages  Cloudflare Pages

Latest commit: 7e6bb63
Status: ✅  Deploy successful!
Preview URL: https://f5cd261c.flet-website-v2.pages.dev
Branch Preview URL: https://fix-extension-template-windo.flet-website-v2.pages.dev

View logs

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.

1 participant