Skip to content

Load Python generator wheels alongside browser bundles - #12507

Draft
Timothee Guerin (timotheeguerin) wants to merge 2 commits into
microsoft:mainfrom
timotheeguerin:fix/python-browser-wheel-url
Draft

Timothee Guerin (timotheeguerin) wants to merge 2 commits into
microsoft:mainfrom
timotheeguerin:fix/python-browser-wheel-url

Conversation

@timotheeguerin

@timotheeguerin Timothee Guerin (timotheeguerin) commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Python browser generation constructs a global wheel URL from the emitter version, independently of where its JavaScript was loaded. This breaks stable npm releases and makes local and PR-preview bundles depend on separately published assets.

Import the wheel as a browser bundle asset and resolve it relative to the emitted JavaScript. The same layout now works for stable deployments, PR previews, and local development, including when Python is bundled inside the Azure emitter:

libs/<emitter>/index.js
libs/<emitter>/assets/<hash>/pygen-0.1.0-py3-none-any.whl

The bundler, Vite plugin, and bundle uploader carry the wheel alongside JavaScript without decoding its binary contents. Native Python execution and Pyodide's runtime/dependency loading are unchanged. Browser builds need this bundler's wheel-asset support or equivalent file-asset handling.

Verified real Azure client generation at root and nested preview URLs in Chromium/Firefox, plus native generation. The normal code build, 64 existing Python tests, and focused bundler unit tests pass; no playground smoke tests were added.

This is needed by Azure/typespec-azure#5989, which will consume the upstream Python and bundler changes instead of carrying a dependency patch.

@pkg-pr-new

pkg-pr-new Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/bundler@12507
npm i https://pkg.pr.new/@typespec/http-client-python@12507

commit: 983b5f1

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • ✅ @typespec/bundler
  • ✅ @typespec/http-client-python
Show changes

@typespec/bundler - feature ✏️

Include imported Python wheels as binary assets alongside browser bundles, including assets imported by bundled dependencies. The Vite plugin and bundle uploader serve and publish these assets with the JavaScript.,> ,> js,> import wheel from "./generator.whl";,> ,> export const wheelUrl = new URL(wheel, import.meta.url).href;,>

@typespec/bundle-uploader - feature ✏️

Include imported Python wheels as binary assets alongside browser bundles, including assets imported by bundled dependencies. The Vite plugin and bundle uploader serve and publish these assets with the JavaScript.,> ,> js,> import wheel from "./generator.whl";,> ,> export const wheelUrl = new URL(wheel, import.meta.url).href;,>

@typespec/http-client-python - fix ✏️

Load the browser generator wheel relative to the emitter's JavaScript bundle, so local, PR-preview, and published playgrounds can ship the matching wheel alongside it without version-specific download hosts.

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Python emitter diff

Baseline gh:837b5a769414f853fd22eeed0a123c953425b1d8 vs this PR.

No changes to generated output.

Rendered diff: inline on the run summary, or the emitter-diff-html artifact.

Informational check (eng/emitter-diff); does not block the PR.

@azure-sdk-automation

azure-sdk-automation Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

@timotheeguerin Timothee Guerin (timotheeguerin) changed the title Fix Python browser generation for stable npm releases Load Python generator wheels alongside browser bundles Nov 6, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:client:python Issue for the Python client emitter: @typespec/http-client-python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant