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