Skip to content

Commit e0c39d9

Browse files
authored
Run python with -E to ignore incoming PYTHONPATH/etc environment variables (#16736)
1 parent 48298d9 commit e0c39d9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+270
-131
lines changed

em++

+5-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
# To make modifications to this file, edit `tools/run_python_compiler.sh` and
1212
# then run `tools/create_entry_points.py`
1313

14+
# $PYTHON -E will not ignore _PYTHON_SYSCONFIGDATA_NAME an internal
15+
# of cpython used in cross compilation via setup.py.
16+
unset _PYTHON_SYSCONFIGDATA_NAME
17+
1418
if [ -z "$PYTHON" ]; then
1519
PYTHON=$EMSDK_PYTHON
1620
fi
@@ -29,7 +33,7 @@ if [ -z "$PYTHON" ]; then
2933
fi
3034

3135
if [ -z "$_EMCC_CCACHE" ]; then
32-
exec "$PYTHON" "$0.py" "$@"
36+
exec "$PYTHON" -E "$0.py" "$@"
3337
else
3438
unset _EMCC_CCACHE
3539
exec ccache "$0" "$@"

em++.bat

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77

88
:: All env. vars specified in this file are to be local only to this script.
99
@setlocal
10-
10+
:: -E will not ignore _PYTHON_SYSCONFIGDATA_NAME an internal
11+
:: of cpython used in cross compilation via setup.py.
12+
@set _PYTHON_SYSCONFIGDATA_NAME=
1113
@set EM_PY=%EMSDK_PYTHON%
1214
@if "%EM_PY%"=="" (
1315
set EM_PY=python
@@ -16,7 +18,7 @@
1618
:: If _EMCC_CCACHE is not set, do a regular invocation of the python compiler driver.
1719
:: Otherwise remove the ccache env. var, and then reinvoke this script with ccache enabled.
1820
@if "%_EMCC_CCACHE%"=="" (
19-
set CMD="%EM_PY%" "%~dp0\%~n0.py"
21+
set CMD="%EM_PY%" -E "%~dp0\%~n0.py"
2022
) else (
2123
set _EMCC_CCACHE=
2224
set CMD=ccache "%~dp0\%~n0.bat"

em-config

+5-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
# To make modifications to this file, edit `tools/run_python.sh` and then run
1212
# `tools/create_entry_points.py`
1313

14+
# $PYTHON -E will not ignore _PYTHON_SYSCONFIGDATA_NAME an internal
15+
# of cpython used in cross compilation via setup.py.
16+
unset _PYTHON_SYSCONFIGDATA_NAME
17+
1418
if [ -z "$PYTHON" ]; then
1519
PYTHON=$EMSDK_PYTHON
1620
fi
@@ -28,4 +32,4 @@ if [ -z "$PYTHON" ]; then
2832
exit 1
2933
fi
3034

31-
exec "$PYTHON" "$0.py" "$@"
35+
exec "$PYTHON" -E "$0.py" "$@"

em-config.bat

+7-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77

88
:: All env. vars specified in this file are to be local only to this script.
99
@setlocal
10-
10+
:: -E will not ignore _PYTHON_SYSCONFIGDATA_NAME an internal
11+
:: of cpython used in cross compilation via setup.py.
12+
@set _PYTHON_SYSCONFIGDATA_NAME=
1113
@set EM_PY=%EMSDK_PYTHON%
1214
@if "%EM_PY%"=="" (
1315
set EM_PY=python
@@ -45,16 +47,16 @@
4547
)
4648

4749
:NORMAL_EXIT
48-
@"%EM_PY%" "%~dp0\%~n0.py" %*
50+
@"%EM_PY%" -E "%~dp0\%~n0.py" %*
4951
@exit %ERRORLEVEL%
5052

5153
:MUTE_STDIN
52-
@"%EM_PY%" "%~dp0\%~n0.py" %* < NUL
54+
@"%EM_PY%" -E "%~dp0\%~n0.py" %* < NUL
5355
@exit /b %ERRORLEVEL%
5456

5557
:MUTE_STDIN_EXIT
56-
@"%EM_PY%" "%~dp0\%~n0.py" %* < NUL
58+
@"%EM_PY%" -E "%~dp0\%~n0.py" %* < NUL
5759
@exit %ERRORLEVEL%
5860

5961
:NORMAL
60-
@"%EM_PY%" "%~dp0\%~n0.py" %*
62+
@"%EM_PY%" -E "%~dp0\%~n0.py" %*

emar

+5-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
# To make modifications to this file, edit `tools/run_python.sh` and then run
1212
# `tools/create_entry_points.py`
1313

14+
# $PYTHON -E will not ignore _PYTHON_SYSCONFIGDATA_NAME an internal
15+
# of cpython used in cross compilation via setup.py.
16+
unset _PYTHON_SYSCONFIGDATA_NAME
17+
1418
if [ -z "$PYTHON" ]; then
1519
PYTHON=$EMSDK_PYTHON
1620
fi
@@ -28,4 +32,4 @@ if [ -z "$PYTHON" ]; then
2832
exit 1
2933
fi
3034

31-
exec "$PYTHON" "$0.py" "$@"
35+
exec "$PYTHON" -E "$0.py" "$@"

emar.bat

+7-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77

88
:: All env. vars specified in this file are to be local only to this script.
99
@setlocal
10-
10+
:: -E will not ignore _PYTHON_SYSCONFIGDATA_NAME an internal
11+
:: of cpython used in cross compilation via setup.py.
12+
@set _PYTHON_SYSCONFIGDATA_NAME=
1113
@set EM_PY=%EMSDK_PYTHON%
1214
@if "%EM_PY%"=="" (
1315
set EM_PY=python
@@ -45,16 +47,16 @@
4547
)
4648

4749
:NORMAL_EXIT
48-
@"%EM_PY%" "%~dp0\%~n0.py" %*
50+
@"%EM_PY%" -E "%~dp0\%~n0.py" %*
4951
@exit %ERRORLEVEL%
5052

5153
:MUTE_STDIN
52-
@"%EM_PY%" "%~dp0\%~n0.py" %* < NUL
54+
@"%EM_PY%" -E "%~dp0\%~n0.py" %* < NUL
5355
@exit /b %ERRORLEVEL%
5456

5557
:MUTE_STDIN_EXIT
56-
@"%EM_PY%" "%~dp0\%~n0.py" %* < NUL
58+
@"%EM_PY%" -E "%~dp0\%~n0.py" %* < NUL
5759
@exit %ERRORLEVEL%
5860

5961
:NORMAL
60-
@"%EM_PY%" "%~dp0\%~n0.py" %*
62+
@"%EM_PY%" -E "%~dp0\%~n0.py" %*

embuilder

+5-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
# To make modifications to this file, edit `tools/run_python.sh` and then run
1212
# `tools/create_entry_points.py`
1313

14+
# $PYTHON -E will not ignore _PYTHON_SYSCONFIGDATA_NAME an internal
15+
# of cpython used in cross compilation via setup.py.
16+
unset _PYTHON_SYSCONFIGDATA_NAME
17+
1418
if [ -z "$PYTHON" ]; then
1519
PYTHON=$EMSDK_PYTHON
1620
fi
@@ -28,4 +32,4 @@ if [ -z "$PYTHON" ]; then
2832
exit 1
2933
fi
3034

31-
exec "$PYTHON" "$0.py" "$@"
35+
exec "$PYTHON" -E "$0.py" "$@"

embuilder.bat

+7-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77

88
:: All env. vars specified in this file are to be local only to this script.
99
@setlocal
10-
10+
:: -E will not ignore _PYTHON_SYSCONFIGDATA_NAME an internal
11+
:: of cpython used in cross compilation via setup.py.
12+
@set _PYTHON_SYSCONFIGDATA_NAME=
1113
@set EM_PY=%EMSDK_PYTHON%
1214
@if "%EM_PY%"=="" (
1315
set EM_PY=python
@@ -45,16 +47,16 @@
4547
)
4648

4749
:NORMAL_EXIT
48-
@"%EM_PY%" "%~dp0\%~n0.py" %*
50+
@"%EM_PY%" -E "%~dp0\%~n0.py" %*
4951
@exit %ERRORLEVEL%
5052

5153
:MUTE_STDIN
52-
@"%EM_PY%" "%~dp0\%~n0.py" %* < NUL
54+
@"%EM_PY%" -E "%~dp0\%~n0.py" %* < NUL
5355
@exit /b %ERRORLEVEL%
5456

5557
:MUTE_STDIN_EXIT
56-
@"%EM_PY%" "%~dp0\%~n0.py" %* < NUL
58+
@"%EM_PY%" -E "%~dp0\%~n0.py" %* < NUL
5759
@exit %ERRORLEVEL%
5860

5961
:NORMAL
60-
@"%EM_PY%" "%~dp0\%~n0.py" %*
62+
@"%EM_PY%" -E "%~dp0\%~n0.py" %*

emcc

+5-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
# To make modifications to this file, edit `tools/run_python_compiler.sh` and
1212
# then run `tools/create_entry_points.py`
1313

14+
# $PYTHON -E will not ignore _PYTHON_SYSCONFIGDATA_NAME an internal
15+
# of cpython used in cross compilation via setup.py.
16+
unset _PYTHON_SYSCONFIGDATA_NAME
17+
1418
if [ -z "$PYTHON" ]; then
1519
PYTHON=$EMSDK_PYTHON
1620
fi
@@ -29,7 +33,7 @@ if [ -z "$PYTHON" ]; then
2933
fi
3034

3135
if [ -z "$_EMCC_CCACHE" ]; then
32-
exec "$PYTHON" "$0.py" "$@"
36+
exec "$PYTHON" -E "$0.py" "$@"
3337
else
3438
unset _EMCC_CCACHE
3539
exec ccache "$0" "$@"

emcc.bat

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77

88
:: All env. vars specified in this file are to be local only to this script.
99
@setlocal
10-
10+
:: -E will not ignore _PYTHON_SYSCONFIGDATA_NAME an internal
11+
:: of cpython used in cross compilation via setup.py.
12+
@set _PYTHON_SYSCONFIGDATA_NAME=
1113
@set EM_PY=%EMSDK_PYTHON%
1214
@if "%EM_PY%"=="" (
1315
set EM_PY=python
@@ -16,7 +18,7 @@
1618
:: If _EMCC_CCACHE is not set, do a regular invocation of the python compiler driver.
1719
:: Otherwise remove the ccache env. var, and then reinvoke this script with ccache enabled.
1820
@if "%_EMCC_CCACHE%"=="" (
19-
set CMD="%EM_PY%" "%~dp0\%~n0.py"
21+
set CMD="%EM_PY%" -E "%~dp0\%~n0.py"
2022
) else (
2123
set _EMCC_CCACHE=
2224
set CMD=ccache "%~dp0\%~n0.bat"

emcc.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1104,7 +1104,7 @@ def run(args):
11041104
args = [x for x in args if x != '--cflags']
11051105
with misc_temp_files.get_file(suffix='.o') as temp_target:
11061106
input_file = 'hello_world.c'
1107-
cmd = [shared.PYTHON, sys.argv[0], utils.path_from_root('tests', input_file), '-v', '-c', '-o', temp_target] + args
1107+
cmd = [shared.PYTHON, "-E", sys.argv[0], utils.path_from_root('tests', input_file), '-v', '-c', '-o', temp_target] + args
11081108
proc = run_process(cmd, stderr=PIPE, check=False)
11091109
if proc.returncode != 0:
11101110
print(proc.stderr)

emcmake

+5-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
# To make modifications to this file, edit `tools/run_python.sh` and then run
1212
# `tools/create_entry_points.py`
1313

14+
# $PYTHON -E will not ignore _PYTHON_SYSCONFIGDATA_NAME an internal
15+
# of cpython used in cross compilation via setup.py.
16+
unset _PYTHON_SYSCONFIGDATA_NAME
17+
1418
if [ -z "$PYTHON" ]; then
1519
PYTHON=$EMSDK_PYTHON
1620
fi
@@ -28,4 +32,4 @@ if [ -z "$PYTHON" ]; then
2832
exit 1
2933
fi
3034

31-
exec "$PYTHON" "$0.py" "$@"
35+
exec "$PYTHON" -E "$0.py" "$@"

emcmake.bat

+7-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77

88
:: All env. vars specified in this file are to be local only to this script.
99
@setlocal
10-
10+
:: -E will not ignore _PYTHON_SYSCONFIGDATA_NAME an internal
11+
:: of cpython used in cross compilation via setup.py.
12+
@set _PYTHON_SYSCONFIGDATA_NAME=
1113
@set EM_PY=%EMSDK_PYTHON%
1214
@if "%EM_PY%"=="" (
1315
set EM_PY=python
@@ -45,16 +47,16 @@
4547
)
4648

4749
:NORMAL_EXIT
48-
@"%EM_PY%" "%~dp0\%~n0.py" %*
50+
@"%EM_PY%" -E "%~dp0\%~n0.py" %*
4951
@exit %ERRORLEVEL%
5052

5153
:MUTE_STDIN
52-
@"%EM_PY%" "%~dp0\%~n0.py" %* < NUL
54+
@"%EM_PY%" -E "%~dp0\%~n0.py" %* < NUL
5355
@exit /b %ERRORLEVEL%
5456

5557
:MUTE_STDIN_EXIT
56-
@"%EM_PY%" "%~dp0\%~n0.py" %* < NUL
58+
@"%EM_PY%" -E "%~dp0\%~n0.py" %* < NUL
5759
@exit %ERRORLEVEL%
5860

5961
:NORMAL
60-
@"%EM_PY%" "%~dp0\%~n0.py" %*
62+
@"%EM_PY%" -E "%~dp0\%~n0.py" %*

emconfigure

+5-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
# To make modifications to this file, edit `tools/run_python.sh` and then run
1212
# `tools/create_entry_points.py`
1313

14+
# $PYTHON -E will not ignore _PYTHON_SYSCONFIGDATA_NAME an internal
15+
# of cpython used in cross compilation via setup.py.
16+
unset _PYTHON_SYSCONFIGDATA_NAME
17+
1418
if [ -z "$PYTHON" ]; then
1519
PYTHON=$EMSDK_PYTHON
1620
fi
@@ -28,4 +32,4 @@ if [ -z "$PYTHON" ]; then
2832
exit 1
2933
fi
3034

31-
exec "$PYTHON" "$0.py" "$@"
35+
exec "$PYTHON" -E "$0.py" "$@"

emconfigure.bat

+7-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77

88
:: All env. vars specified in this file are to be local only to this script.
99
@setlocal
10-
10+
:: -E will not ignore _PYTHON_SYSCONFIGDATA_NAME an internal
11+
:: of cpython used in cross compilation via setup.py.
12+
@set _PYTHON_SYSCONFIGDATA_NAME=
1113
@set EM_PY=%EMSDK_PYTHON%
1214
@if "%EM_PY%"=="" (
1315
set EM_PY=python
@@ -45,16 +47,16 @@
4547
)
4648

4749
:NORMAL_EXIT
48-
@"%EM_PY%" "%~dp0\%~n0.py" %*
50+
@"%EM_PY%" -E "%~dp0\%~n0.py" %*
4951
@exit %ERRORLEVEL%
5052

5153
:MUTE_STDIN
52-
@"%EM_PY%" "%~dp0\%~n0.py" %* < NUL
54+
@"%EM_PY%" -E "%~dp0\%~n0.py" %* < NUL
5355
@exit /b %ERRORLEVEL%
5456

5557
:MUTE_STDIN_EXIT
56-
@"%EM_PY%" "%~dp0\%~n0.py" %* < NUL
58+
@"%EM_PY%" -E "%~dp0\%~n0.py" %* < NUL
5759
@exit %ERRORLEVEL%
5860

5961
:NORMAL
60-
@"%EM_PY%" "%~dp0\%~n0.py" %*
62+
@"%EM_PY%" -E "%~dp0\%~n0.py" %*

emdump

+5-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
# To make modifications to this file, edit `tools/run_python.sh` and then run
1212
# `tools/create_entry_points.py`
1313

14+
# $PYTHON -E will not ignore _PYTHON_SYSCONFIGDATA_NAME an internal
15+
# of cpython used in cross compilation via setup.py.
16+
unset _PYTHON_SYSCONFIGDATA_NAME
17+
1418
if [ -z "$PYTHON" ]; then
1519
PYTHON=$EMSDK_PYTHON
1620
fi
@@ -28,4 +32,4 @@ if [ -z "$PYTHON" ]; then
2832
exit 1
2933
fi
3034

31-
exec "$PYTHON" "$(dirname $0)/tools/emdump.py" "$@"
35+
exec "$PYTHON" -E "$(dirname $0)/tools/emdump.py" "$@"

emdump.bat

+7-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77

88
:: All env. vars specified in this file are to be local only to this script.
99
@setlocal
10-
10+
:: -E will not ignore _PYTHON_SYSCONFIGDATA_NAME an internal
11+
:: of cpython used in cross compilation via setup.py.
12+
@set _PYTHON_SYSCONFIGDATA_NAME=
1113
@set EM_PY=%EMSDK_PYTHON%
1214
@if "%EM_PY%"=="" (
1315
set EM_PY=python
@@ -45,16 +47,16 @@
4547
)
4648

4749
:NORMAL_EXIT
48-
@"%EM_PY%" "%~dp0\tools\emdump.py" %*
50+
@"%EM_PY%" -E "%~dp0\tools\emdump.py" %*
4951
@exit %ERRORLEVEL%
5052

5153
:MUTE_STDIN
52-
@"%EM_PY%" "%~dp0\tools\emdump.py" %* < NUL
54+
@"%EM_PY%" -E "%~dp0\tools\emdump.py" %* < NUL
5355
@exit /b %ERRORLEVEL%
5456

5557
:MUTE_STDIN_EXIT
56-
@"%EM_PY%" "%~dp0\tools\emdump.py" %* < NUL
58+
@"%EM_PY%" -E "%~dp0\tools\emdump.py" %* < NUL
5759
@exit %ERRORLEVEL%
5860

5961
:NORMAL
60-
@"%EM_PY%" "%~dp0\tools\emdump.py" %*
62+
@"%EM_PY%" -E "%~dp0\tools\emdump.py" %*

emdwp

+5-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
# To make modifications to this file, edit `tools/run_python.sh` and then run
1212
# `tools/create_entry_points.py`
1313

14+
# $PYTHON -E will not ignore _PYTHON_SYSCONFIGDATA_NAME an internal
15+
# of cpython used in cross compilation via setup.py.
16+
unset _PYTHON_SYSCONFIGDATA_NAME
17+
1418
if [ -z "$PYTHON" ]; then
1519
PYTHON=$EMSDK_PYTHON
1620
fi
@@ -28,4 +32,4 @@ if [ -z "$PYTHON" ]; then
2832
exit 1
2933
fi
3034

31-
exec "$PYTHON" "$(dirname $0)/tools/emdwp.py" "$@"
35+
exec "$PYTHON" -E "$(dirname $0)/tools/emdwp.py" "$@"

0 commit comments

Comments
 (0)