Skip to content

Commit

Permalink
Merge pull request #3199 from cloudflare/dominik/disable-embedded-tar…
Browse files Browse the repository at this point in the history
…-reader

Remove embedded packages tar when retrieval is enabled.
  • Loading branch information
dom96 authored Dec 3, 2024
2 parents e6768de + 5b8942c commit ea6878d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/pyodide/internal/setupPackages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ class SitePackagesDir {
* TODO(later): This needs to be removed when external package loading is enabled.
*/
export function buildSitePackages(requirements: Set<string>): SitePackagesDir {
if (EmbeddedPackagesTarReader.read === undefined) {
// Package retrieval is enabled, so the embedded tar reader isn't initialised.
return new SitePackagesDir();
}

const [bigTarInfo, bigTarSoFiles] = parseTarInfo(EmbeddedPackagesTarReader);

let requirementsInBigBundle = new Set([...STDLIB_PACKAGES]);
Expand Down
12 changes: 8 additions & 4 deletions src/workerd/server/workerd-api.c++
Original file line number Diff line number Diff line change
Expand Up @@ -572,10 +572,14 @@ void WorkerdApi::compileModules(jsg::Lock& lockParam,
makePyodideMetadataReader(conf, impl->pythonConfig), jsg::ModuleRegistry::Type::INTERNAL);

// Inject packages tar file
// TODO(later): This shouldn't exist once featureFlags.getPythonExternalPackages() is true.
modules->addBuiltinModule("pyodide-internal:packages_tar_reader",
jsg::alloc<ReadOnlyBuffer>(PYODIDE_PACKAGES_TAR.get()),
workerd::jsg::ModuleRegistry::Type::INTERNAL);
if (featureFlags.getPythonExternalPackages()) {
modules->addBuiltinModule("pyodide-internal:packages_tar_reader", "export default { }"_kj,
workerd::jsg::ModuleRegistry::Type::INTERNAL, {});
} else {
modules->addBuiltinModule("pyodide-internal:packages_tar_reader",
jsg::alloc<ReadOnlyBuffer>(PYODIDE_PACKAGES_TAR.get()),
workerd::jsg::ModuleRegistry::Type::INTERNAL);
}

// Inject artifact bundler.
modules->addBuiltinModule("pyodide-internal:artifacts",
Expand Down

0 comments on commit ea6878d

Please sign in to comment.