From 5b2e584e0d3e46e9f928e22370262e0c28f0da24 Mon Sep 17 00:00:00 2001 From: Greg Roodt Date: Sun, 19 Jun 2022 23:02:32 +1000 Subject: [PATCH 1/3] PYTHONSAFEPATH --- .../build/lib/bazel/rules/python/python_stub_template.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/python/python_stub_template.txt b/src/main/java/com/google/devtools/build/lib/bazel/rules/python/python_stub_template.txt index c389af01c2df1f..2ec9fe1db6f2e3 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/python/python_stub_template.txt +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/python/python_stub_template.txt @@ -314,6 +314,10 @@ def Main(): if runfiles_envkey: new_env[runfiles_envkey] = runfiles_envvalue + # Don’t prepend a potentially unsafe path to sys.path + # See: https://docs.python.org/3.11/using/cmdline.html#envvar-PYTHONSAFEPATH + new_env['PYTHONSAFEPATH'] = 'non_empty' + # Now look for my main python source file. # The magic string percent-main-percent is replaced with the filename of the # main file of the Python binary in BazelPythonSemantics.java. From 3b6bb992ab93d22bd818df5f3924d2b77bb132cc Mon Sep 17 00:00:00 2001 From: Greg Roodt Date: Sun, 19 Jun 2022 23:32:13 +1000 Subject: [PATCH 2/3] Update python_stub_template.txt --- .../build/lib/bazel/rules/python/python_stub_template.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/python/python_stub_template.txt b/src/main/java/com/google/devtools/build/lib/bazel/rules/python/python_stub_template.txt index 2ec9fe1db6f2e3..29bb987da87602 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/python/python_stub_template.txt +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/python/python_stub_template.txt @@ -314,7 +314,7 @@ def Main(): if runfiles_envkey: new_env[runfiles_envkey] = runfiles_envvalue - # Don’t prepend a potentially unsafe path to sys.path + # Don't prepend a potentially unsafe path to sys.path # See: https://docs.python.org/3.11/using/cmdline.html#envvar-PYTHONSAFEPATH new_env['PYTHONSAFEPATH'] = 'non_empty' From b3f37d3cb804c80ef252b9e747de431b0d2f02f6 Mon Sep 17 00:00:00 2001 From: Greg Roodt Date: Wed, 6 Jul 2022 08:22:53 +1000 Subject: [PATCH 3/3] Update src/main/java/com/google/devtools/build/lib/bazel/rules/python/python_stub_template.txt --- .../build/lib/bazel/rules/python/python_stub_template.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/python/python_stub_template.txt b/src/main/java/com/google/devtools/build/lib/bazel/rules/python/python_stub_template.txt index 29bb987da87602..aa6f7dc4e3227b 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/python/python_stub_template.txt +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/python/python_stub_template.txt @@ -316,7 +316,7 @@ def Main(): # Don't prepend a potentially unsafe path to sys.path # See: https://docs.python.org/3.11/using/cmdline.html#envvar-PYTHONSAFEPATH - new_env['PYTHONSAFEPATH'] = 'non_empty' + new_env['PYTHONSAFEPATH'] = '1' # Now look for my main python source file. # The magic string percent-main-percent is replaced with the filename of the