Skip to content
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
Prev Previous commit
Next Next commit
Fix NODEFLAGS
  • Loading branch information
hoodmane committed Dec 2, 2024
commit 1e434938b78feff62d0b1837164fad5a01f473e5
2 changes: 1 addition & 1 deletion Tools/wasm/emscripten/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def configure_emscripten_python(context, working_dir):
# We compute our own path, not following symlinks and pass it in so that
# node_entry.mjs can set sys.executable correctly.
# Intentionally allow word splitting on NODEFLAGS.
exec {host_runner} {node_entry} $NODEFLAGS "$($REALPATH "$0")" "$@"
exec node $NODEFLAGS /home/rchatham/cpython/cross-build/wasm32-emscripten/node_entry.mjs "$($REALPATH "$0")" "$@"
Comment thread
hoodmane marked this conversation as resolved.
Outdated
"""
)
)
Expand Down
9 changes: 5 additions & 4 deletions Tools/wasm/emscripten/node_entry.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,21 @@ function mountDirectories(Module) {
}
}

const pythonShIndex = process.argv.findIndex(x => x.endsWith("python.sh"));

const settings = {
preRun(Module) {
Module.FS.mkdirTree("/home/");
mountDirectories(Module);
Module.FS.chdir(process.cwd());
Object.assign(Module.ENV, process.env);
Comment thread
hoodmane marked this conversation as resolved.
},
// The first three arguments are: "node", path to this file, path to
// python.sh. After that come the arguments the user passed to python.sh.
arguments: process.argv.slice(3),
// Ensure that sys.executable, sys._base_executable, etc point to python.sh
// not to this file. To properly handle symlinks, python.sh needs to compute
// its own path.
thisProgram: process.argv[2],
thisProgram: process.argv[pythonShIndex],
// After python.sh come the arguments that the user passed to python.sh.
arguments: process.argv.slice(pythonShIndex + 1),
};

await EmscriptenModule(settings);