@@ -100,11 +100,15 @@ def get_setup_result(setup_py, *, env: Optional[dict]):
100100 :return: Dictionary of data describing the package.
101101 :raise: RuntimeError if the setup script encountered an error
102102 """
103+ env_copy = os .environ .copy ()
104+ if env is not None :
105+ env_copy .update (env )
106+
103107 conn_recv , conn_send = multiprocessing .Pipe (duplex = False )
104108 with conn_send :
105109 p = multiprocessing .Process (
106110 target = _get_setup_result_target ,
107- args = (os .path .abspath (str (setup_py )), env , conn_send )
111+ args = (os .path .abspath (str (setup_py )), env_copy , conn_send ),
108112 )
109113 p .start ()
110114 p .join ()
@@ -118,7 +122,7 @@ def get_setup_result(setup_py, *, env: Optional[dict]):
118122 .format (setup_py , result_or_exception_string ))
119123
120124
121- def _get_setup_result_target (setup_py : str , env : Optional [ dict ] , conn_send ):
125+ def _get_setup_result_target (setup_py : str , env : dict , conn_send ):
122126 """
123127 Run setup.py in a modified environment.
124128
@@ -136,11 +140,8 @@ def _get_setup_result_target(setup_py: str, env: Optional[dict], conn_send):
136140 # need to be in setup.py's parent dir to detect any setup.cfg
137141 os .chdir (os .path .dirname (setup_py ))
138142
139- # don't worry - the environments of functions called with
140- # subprocess.Process don't leak into each other
141143 os .environ .clear ()
142- if env is not None :
143- os .environ .update (env )
144+ os .environ .update (env )
144145
145146 result = distutils .core .run_setup (
146147 str (setup_py ), ('--dry-run' ,), stop_after = 'config' )
0 commit comments