@@ -67,17 +67,28 @@ def run_python_until_end(*args, **env_vars):
6767 elif not env_vars and not env_required :
6868 # ignore Python environment variables
6969 cmd_line .append ('-E' )
70- # Need to preserve the original environment, for in-place testing of
71- # shared library builds.
72- env = os .environ .copy ()
73- # set TERM='' unless the TERM environment variable is passed explicitly
74- # see issues #11390 and #18300
75- if 'TERM' not in env_vars :
76- env ['TERM' ] = ''
70+
7771 # But a special flag that can be set to override -- in this case, the
7872 # caller is responsible to pass the full environment.
7973 if env_vars .pop ('__cleanenv' , None ):
8074 env = {}
75+ if sys .platform == 'win32' :
76+ # Windows requires at least the SYSTEMROOT environment variable to
77+ # start Python.
78+ env ['SYSTEMROOT' ] = os .environ ['SYSTEMROOT' ]
79+
80+ # Other interesting environment variables, not copied currently:
81+ # COMSPEC, HOME, PATH, TEMP, TMPDIR, TMP.
82+ else :
83+ # Need to preserve the original environment, for in-place testing of
84+ # shared library builds.
85+ env = os .environ .copy ()
86+
87+ # set TERM='' unless the TERM environment variable is passed explicitly
88+ # see issues #11390 and #18300
89+ if 'TERM' not in env_vars :
90+ env ['TERM' ] = ''
91+
8192 env .update (env_vars )
8293 cmd_line .extend (args )
8394 proc = subprocess .Popen (cmd_line , stdin = subprocess .PIPE ,
0 commit comments