Skip to content

chore(worker-bundler): General tidy-up and move Python logic into a separate file - #2093

Merged
threepointone merged 3 commits into
cloudflare:mainfrom
abstractedfox:kira/worker-bundler/refactor
Aug 13, 2026
Merged

chore(worker-bundler): General tidy-up and move Python logic into a separate file#2093
threepointone merged 3 commits into
cloudflare:mainfrom
abstractedfox:kira/worker-bundler/refactor

Conversation

@abstractedfox

Copy link
Copy Markdown
Member

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

@changeset-bot

changeset-bot Bot commented Aug 12, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: d040b1d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@devin-ai-integration devin-ai-integration 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.

Devin Review found 1 potential issue.

View 1 additional finding in Devin Review.

Open in Devin Review

Comment on lines +95 to +97
// Collect dependencies to install. We will keep these as full dependency strings.
const depsToInstall: string[] = pyprojectToml.project?.dependencies ?? [];
depsToInstall.push("workers-runtime-sdk");

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.

🟡 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).

Suggested change
// 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");
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@pkg-pr-new

pkg-pr-new Bot commented Aug 12, 2026

Copy link
Copy Markdown

Open in StackBlitz

agents

npm i https://pkg.pr.new/agents@2093

@cloudflare/ai-chat

npm i https://pkg.pr.new/@cloudflare/ai-chat@2093

@cloudflare/codemode

npm i https://pkg.pr.new/@cloudflare/codemode@2093

hono-agents

npm i https://pkg.pr.new/hono-agents@2093

@cloudflare/shell

npm i https://pkg.pr.new/@cloudflare/shell@2093

@cloudflare/think

npm i https://pkg.pr.new/@cloudflare/think@2093

@cloudflare/voice

npm i https://pkg.pr.new/@cloudflare/voice@2093

@cloudflare/worker-bundler

npm i https://pkg.pr.new/@cloudflare/worker-bundler@2093

commit: d040b1d

@ryanking13 ryanking13 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I left a minor comment about code structure, otherwise looks good!

Comment thread packages/worker-bundler/src/installer-python.ts Outdated
@ryanking13

Copy link
Copy Markdown

Also please update the PR title to be more descriptive

@abstractedfox abstractedfox changed the title chore(worker-bundler): Refactor chore(worker-bundler): General tidy-up and move Python logic into a separate file Aug 12, 2026
@threepointone
threepointone merged commit c7abcf9 into cloudflare:main Aug 13, 2026
4 checks passed
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.

3 participants