Skip to content

Commit cc11739

Browse files
committed
Rename Python vendor dir to python_modules
1 parent e034d03 commit cc11739

File tree

5 files changed

+17
-17
lines changed

5 files changed

+17
-17
lines changed

src/pyodide/internal/python.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ function setupPythonSearchPath(pyodide: Pyodide): void {
6565
import sys
6666
from pathlib import Path
6767
68-
VENDOR_PATH = "/session/metadata/vendor"
68+
VENDOR_PATH = "/session/metadata/python_modules"
6969
7070
# adjustSysPath adds the session path, but it is immortalised by the memory snapshot. This
7171
# code runs irrespective of the memory snapshot.

src/workerd/api/pyodide/pyodide-test.c++

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,8 +359,8 @@ KJ_TEST("Filters out so") {
359359
}
360360

361361
KJ_TEST("Filters out vendor stuff") {
362-
auto workerModules =
363-
strArray("vendor/a.py", "vendor/package/b.py", "vendor/c.so", "vendor/x.txt");
362+
auto workerModules = strArray("python_modules/a.py", "python_modules/package/b.py",
363+
"python_modules/c.so", "python_modules/x.txt");
364364
auto imports = strArray("a", "package", "x");
365365
auto result = filterPythonScriptImports(kj::mv(workerModules), kj::mv(imports), "");
366366
KJ_REQUIRE(result.size() == 1);

src/workerd/api/pyodide/pyodide.c++

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ kj::Array<kj::String> PythonModuleInfo::getPythonFileContents() {
9898

9999
kj::HashSet<kj::String> PythonModuleInfo::getWorkerModuleSet() {
100100
auto result = kj::HashSet<kj::String>();
101-
const auto vendor = "vendor/"_kj;
101+
const auto vendor = "python_modules/"_kj;
102102
const auto dotPy = ".py"_kj;
103103
const auto dotSo = ".so"_kj;
104104
for (auto& item: names) {
@@ -418,26 +418,26 @@ kj::Own<PyodideMetadataReader::State> PyodideMetadataReader::State::clone() {
418418
}
419419

420420
void PyodideMetadataReader::State::verifyNoMainModuleInVendor() {
421-
// Verify that we don't have module named after the main module in the `vendor` subdir.
421+
// Verify that we don't have module named after the main module in the `python_modules` subdir.
422422
// mainModule includes the .py extension, so we need to extract the base name
423423
kj::ArrayPtr<const char> mainModuleBase = mainModule;
424424
if (mainModule.endsWith(".py")) {
425425
mainModuleBase = mainModuleBase.slice(0, mainModuleBase.size() - 3);
426426
}
427427

428428
for (auto& name: moduleInfo.names) {
429-
if (name.startsWith(kj::str("vendor/", mainModule))) {
429+
if (name.startsWith(kj::str("python_modules/", mainModule))) {
430430
JSG_FAIL_REQUIRE(
431-
Error, kj::str("Python module vendor/", mainModule, " clashes with main module"));
431+
Error, kj::str("Python module python_modules/", mainModule, " clashes with main module"));
432432
}
433-
if (name == kj::str("vendor/", mainModuleBase, "/__init__.py")) {
433+
if (name == kj::str("python_modules/", mainModuleBase, "/__init__.py")) {
434434
JSG_FAIL_REQUIRE(Error,
435-
kj::str(
436-
"Python module vendor/", mainModuleBase, "/__init__.py clashes with main module"));
435+
kj::str("Python module python_modules/", mainModuleBase,
436+
"/__init__.py clashes with main module"));
437437
}
438-
if (name == kj::str("vendor/", mainModuleBase, ".so")) {
439-
JSG_FAIL_REQUIRE(
440-
Error, kj::str("Python module vendor/", mainModuleBase, ".so clashes with main module"));
438+
if (name == kj::str("python_modules/", mainModuleBase, ".so")) {
439+
JSG_FAIL_REQUIRE(Error,
440+
kj::str("Python module python_modules/", mainModuleBase, ".so clashes with main module"));
441441
}
442442
}
443443
}

src/workerd/server/tests/python/vendor_dir/vendor_dir.wd-test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ const unitTests :Workerd.Config = (
77
modules = [
88
(name = "worker.py", pythonModule = embed "worker.py"),
99
(name = "duplicate.py", pythonModule = embed "vendor/a.py"),
10-
(name = "vendor/a.py", pythonModule = embed "vendor/a.py"),
10+
(name = "python_modules/a.py", pythonModule = embed "vendor/a.py"),
1111
# This module below is only here to verify that we don't crash because of
1212
# duplicate module names.
13-
(name = "vendor/duplicate.py", pythonModule = embed "vendor/a.py"),
13+
(name = "python_modules/duplicate.py", pythonModule = embed "vendor/a.py"),
1414
# This module below exercises a bug which caused our internal introspection.py
1515
# module to import it instead of the SDK module. See EW-9317 for more info.
1616
(name = "workers.py", pythonModule = embed "vendor/a.py"),

src/workerd/server/tests/python/vendor_dir/worker.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ def test():
1010

1111
def test_path_ordering():
1212
"""Verify that the Python path is set in the correct order.
13-
'/session/metadata/vendor' should be positioned after the system paths
13+
'/session/metadata/python_modules' should be positioned after the system paths
1414
but before any site-packages paths.
1515
"""
16-
vendor_path = "/session/metadata/vendor"
16+
vendor_path = "/session/metadata/python_modules"
1717
vendor_index = sys.path.index(vendor_path)
1818

1919
# Check that vendor_path is in sys.path

0 commit comments

Comments
 (0)