chore(worker-bundler): General tidy-up and move Python logic into a separate file - #2093
Conversation
|
| // Collect dependencies to install. We will keep these as full dependency strings. | ||
| const depsToInstall: string[] = pyprojectToml.project?.dependencies ?? []; | ||
| depsToInstall.push("workers-runtime-sdk"); |
There was a problem hiding this comment.
🟡 Blank or malformed Python dependency entries now trigger a pointless failed download and a confusing warning
Empty or unparseable dependency entries from pyproject.toml are no longer skipped before being installed (depsToInstall at packages/worker-bundler/src/installer-python.ts:96), so the build tries to download a package with an empty name and reports a confusing failure.
Impact: Users with a stray or malformed dependency line get an unhelpful "Failed to install :" warning plus a wasted network request instead of that entry being quietly ignored.
Removed name guard when collecting dependencies
The previous implementation looped over pyproject.project.dependencies, parsed each entry, and did if (!name) continue; before adding it to the install set. The refactor passes the raw dependency list straight through. For an entry like "" or one starting with a non-identifier character, parsePythonDependencySpecifier (packages/worker-bundler/src/installer-python.ts:135-146) returns name: "". installPythonPackage then proceeds: getPyodideWheel("") misses, retrieveFromPyPI("", registry) fetches https://pypi.org/simple// which 404s and throws, producing result.warnings.push("Failed to install : ...") (packages/worker-bundler/src/installer-python.ts:229).
| // Collect dependencies to install. We will keep these as full dependency strings. | |
| const depsToInstall: string[] = pyprojectToml.project?.dependencies ?? []; | |
| depsToInstall.push("workers-runtime-sdk"); | |
| // Collect dependencies to install. We will keep these as full dependency strings. | |
| const depsToInstall: string[] = ( | |
| pyprojectToml.project?.dependencies ?? [] | |
| ).filter((dep) => parsePythonDependencySpecifier(dep).name !== ""); | |
| depsToInstall.push("workers-runtime-sdk"); |
Was this helpful? React with 👍 or 👎 to provide feedback.
agents
@cloudflare/ai-chat
@cloudflare/codemode
hono-agents
@cloudflare/shell
@cloudflare/think
@cloudflare/voice
@cloudflare/worker-bundler
commit: |
ryanking13
left a comment
There was a problem hiding this comment.
I left a minor comment about code structure, otherwise looks good!
|
Also please update the PR title to be more descriptive |
General refactor; cleans up a few vestiges of earlier work, removes outdated comments, and should make the code a little more descriptive. Also moves the Python logic into a separate file per an earlier review comment from @ryanking13 (abstractedfox#6 (comment))
I deliberately left the commits intact to make it easier to review, the first one is just the move into a new file and the second one has all the little changes I made afterward