Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't embed Python packages in workerd. #1580

Merged
merged 2 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ http_archive(
http_archive(
name = "pyodide_packages",
build_file = "//:build/BUILD.pyodide_packages",
sha256 = "048d42372928aaef4dc565f507ec39fe9a4954e62bdb9163aaee1e106cffb6d8",
sha256 = "1b29a9a0db8429b02e1ccacc16ac8a001fc8631caa41370ab1602f9d28c7f7fd",
type = "zip",
urls = ["https://github.com/dom96/pyodide_packages/releases/download/v0.11/pyodide_packages.tar.zip"],
urls = ["https://github.com/dom96/pyodide_packages/releases/download/empty/pyodide_packages.tar.zip"],
)

# ========================================================================================
Expand Down
13 changes: 12 additions & 1 deletion src/pyodide/python-entrypoint-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function initializePackageIndex(pyodide) {
};
}

// These packages are currently embedded inside workerd and so don't need to
// These packages are currently embedded inside EW and so don't need to
// be separately installed.
const EMBEDDED_PYTHON_PACKAGES = [
"aiohttp",
Expand Down Expand Up @@ -133,6 +133,7 @@ function transformMetadata(metadata) {
async function setupPackages(pyodide) {
// The metadata is a JSON-serialised WorkerBundle (defined in pipeline.capnp).
const metadata = transformMetadata(origMetadata);
const isWorkerd = metadata.modules !== undefined;

initializePackageIndex(pyodide);

Expand All @@ -153,16 +154,26 @@ async function setupPackages(pyodide) {
if (!EMBEDDED_PYTHON_PACKAGES.includes(name)) {
pythonRequirements.push(name);
}
// Packages are not embedded in workerd.
dom96 marked this conversation as resolved.
Show resolved Hide resolved
// TODO: Improve package loading in workerd.
if (isWorkerd) {
micropipRequirements.push(name);
}
}
}

if (isWorkerd) {
pythonRequirements.push("micropip");
}
hoodmane marked this conversation as resolved.
Show resolved Hide resolved

if (pythonRequirements.length > 0) {
await pyodide.loadPackage(pythonRequirements);
}

if (micropipRequirements.length > 0) {
// Micropip and ssl packages are pre-loaded via the packages tarball. This means
// we should be able to load micropip directly now.

const micropip = pyodide.pyimport("micropip");
await micropip.install(micropipRequirements);
}
Expand Down
Loading