From e40bf7e544f381e941798070a776b8382218c0e5 Mon Sep 17 00:00:00 2001 From: Michael Allwright Date: Tue, 9 Jul 2024 14:37:34 +0000 Subject: [PATCH 1/2] Unset `PYTHONSAFEPATH` in env.bat and env.sh. In Python 3.11 and above `PYTHONSAFEPATH` prevents the containing directory of a script from being imported into `sys.path`. This results in `emcc.py` (and other programs) failing with "ModuleNotFoundError: No module named 'tools'". By unsetting `PYTHONSAFEPATH` in env.bat and env.sh, the expected behavior of importing the containing directory of a script to `sys.path` is restored. --- bazel/emscripten_toolchain/env.bat | 2 ++ bazel/emscripten_toolchain/env.sh | 2 ++ 2 files changed, 4 insertions(+) diff --git a/bazel/emscripten_toolchain/env.bat b/bazel/emscripten_toolchain/env.bat index 644519ebf0..2930452d86 100644 --- a/bazel/emscripten_toolchain/env.bat +++ b/bazel/emscripten_toolchain/env.bat @@ -3,3 +3,5 @@ set ROOT_DIR=%CD% set EMSCRIPTEN=%ROOT_DIR%\%EM_BIN_PATH%\emscripten set EM_CONFIG=%ROOT_DIR%\%EM_CONFIG_PATH% + +set PYTHONSAFEPATH= \ No newline at end of file diff --git a/bazel/emscripten_toolchain/env.sh b/bazel/emscripten_toolchain/env.sh index b2a6bd60b0..c0de78af5f 100755 --- a/bazel/emscripten_toolchain/env.sh +++ b/bazel/emscripten_toolchain/env.sh @@ -3,3 +3,5 @@ export ROOT_DIR=${EXT_BUILD_ROOT:-$(pwd -P)} export EMSCRIPTEN=$ROOT_DIR/$EM_BIN_PATH/emscripten export EM_CONFIG=$ROOT_DIR/$EM_CONFIG_PATH + +unset PYTHONSAFEPATH \ No newline at end of file From 8a9ba848c1b916ac648ba5584f50bd0b14c05f52 Mon Sep 17 00:00:00 2001 From: Michael Allwright Date: Wed, 10 Jul 2024 07:38:20 +0000 Subject: [PATCH 2/2] Add comments and newlines at the end of env.sh and env.bat --- bazel/emscripten_toolchain/env.bat | 4 +++- bazel/emscripten_toolchain/env.sh | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/bazel/emscripten_toolchain/env.bat b/bazel/emscripten_toolchain/env.bat index 2930452d86..7c3f3e29cc 100644 --- a/bazel/emscripten_toolchain/env.bat +++ b/bazel/emscripten_toolchain/env.bat @@ -4,4 +4,6 @@ set ROOT_DIR=%CD% set EMSCRIPTEN=%ROOT_DIR%\%EM_BIN_PATH%\emscripten set EM_CONFIG=%ROOT_DIR%\%EM_CONFIG_PATH% -set PYTHONSAFEPATH= \ No newline at end of file +:: Ensure PYTHONSAFEPATH is not set so that modules in the same +:: directory as emcc.py and emar.py etc. can be found via sys.path +set PYTHONSAFEPATH= diff --git a/bazel/emscripten_toolchain/env.sh b/bazel/emscripten_toolchain/env.sh index c0de78af5f..44bf6f6b60 100755 --- a/bazel/emscripten_toolchain/env.sh +++ b/bazel/emscripten_toolchain/env.sh @@ -4,4 +4,6 @@ export ROOT_DIR=${EXT_BUILD_ROOT:-$(pwd -P)} export EMSCRIPTEN=$ROOT_DIR/$EM_BIN_PATH/emscripten export EM_CONFIG=$ROOT_DIR/$EM_CONFIG_PATH -unset PYTHONSAFEPATH \ No newline at end of file +# Ensure PYTHONSAFEPATH is not set so that modules in the same +# directory as emcc.py and emar.py etc. can be found via sys.path +unset PYTHONSAFEPATH