@@ -109,7 +109,7 @@ class where more documentation can be found.
109
109
110
110
111
111
# Using customized CCompiler.spawn.
112
- def CCompiler_spawn (self , cmd , display = None ):
112
+ def CCompiler_spawn (self , cmd , display = None , env = None ):
113
113
"""
114
114
Execute a command in a sub-process.
115
115
@@ -120,6 +120,7 @@ def CCompiler_spawn(self, cmd, display=None):
120
120
display : str or sequence of str, optional
121
121
The text to add to the log file kept by `numpy.distutils`.
122
122
If not given, `display` is equal to `cmd`.
123
+ env: a dictionary for environment variables, optional
123
124
124
125
Returns
125
126
-------
@@ -131,16 +132,17 @@ def CCompiler_spawn(self, cmd, display=None):
131
132
If the command failed, i.e. the exit status was not 0.
132
133
133
134
"""
135
+ env = env if env is not None else dict (os .environ )
134
136
if display is None :
135
137
display = cmd
136
138
if is_sequence (display ):
137
139
display = ' ' .join (list (display ))
138
140
log .info (display )
139
141
try :
140
142
if self .verbose :
141
- subprocess .check_output (cmd )
143
+ subprocess .check_output (cmd , env = env )
142
144
else :
143
- subprocess .check_output (cmd , stderr = subprocess .STDOUT )
145
+ subprocess .check_output (cmd , stderr = subprocess .STDOUT , env = env )
144
146
except subprocess .CalledProcessError as exc :
145
147
o = exc .output
146
148
s = exc .returncode
0 commit comments