Repository navigation
Conversation
assembleBuildResult() prefixed every non-entrypoint module with "./". Python Workers only install vendored packages whose module names start with "python_modules/", so `cf deploy` of a Python Worker importing the Workers SDK failed with 10021 "No module named 'workers'". Use the manifest path as-is, matching Wrangler. Fixes cloudflare#392 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
commit: |
|
✅ Approved — This is a small, targeted fix that brings non-entrypoint module names in line with the main module and with Wrangler. It comes with a regression test, updated assertions and a patch changeset, and no issues were found. The decision is advisory: this comment never approves, blocks or requests changes on the pull request. ✅ All checks passed📋 Code Quality: ✅ LGTM
Tests cover the change. The existing assertions in 📝 Documentation: ✅ LGTMThe patch changeset The body explains the user-visible symptom ( Reviewed commit: |
Python Workers use module names as file paths without normalising them, so a `./python_modules/...` package is not on the import path. The previous text described a prefix-based install step that does not exist, and named only `cf deploy` although `cf workers versions create` and `cf previews deploy` share the fix.
Reviews of the Build Output upload names flagged a regression for service-worker format Workers. That format is deprecated and cf does not support it, so record this to stop future reviews designing for it.
The comments described a prefix-based install step that does not exist. The runtime normalises `./` in JavaScript module names but uses Python module names as file paths, so a `./python_modules/...` package is not on `sys.path`.
Fixes #392
What
assembleBuildResult()(packages/cli/src/lib/deploy-input.ts) prefixed every non-entrypoint Build Output module with./when turning the manifest into upload modules. This change uses the manifest path as-is, which is what Wrangler uploads.Why
Python Workers use module names as file paths without normalising them, and import vendored packages from
python_modules/. JavaScript module names are normalised, which is why the prefix went unnoticed. With the prefix,pywrangler sync's vendoredworkersSDK was uploaded as./python_modules/workers/__init__.py, socf deployof any Python Worker that imports the SDK failed validation:I captured both tools' uploads against a fake API: the multipart parts are identical in content and content type, and the part names are the only difference (
python_modules/...from Wrangler,./python_modules/...from cf). Full write-up in #392.The prefix was also inconsistent within cf itself: the main module was already uploaded unprefixed (
index.js), while siblings were./lib.cjs,./app.pyand so on.Testing
deploy-input.test.tsandcommands/deploy/index.test.tsthat expected./-prefixed names.keeps Python vendored module paths exactly as in the manifesttodeploy-input.test.ts.deploy-input,deploy/index,previews-deployandworkers-checktests pass.workers checkruns Workers thatimport "./message.js"/require("./helper.cjs"), so relative imports still resolve with unprefixed module names.cf dev > happy path > reports missing project commands and restores signal listeners, which fails the same way onmain(8e51747) in that environment.check:lint,check:formatandcheck:typepass.workersSDK): failed with 10021 before; now deploys and returns200 Hello from a Python Worker.worker-build, Wasm + JS shim): still deploys and returns200 Hello from a Rust Worker.Includes a patch changeset.
🤖 Generated with Claude Code