summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsuru Fernando <isuruf@gmail.com>2021-12-22 15:13:46 +0530
committerIsuru Fernando <isuruf@gmail.com>2021-12-22 15:15:48 +0530
commit3842786bd5b7515c5f86fe4471ffa3fdb7f7c568 (patch)
tree48bb96a362b25e0a2d64f70e107ca55effe42e17
parent7acb0fd4123673dc38aa5634b47f93770e61cfab (diff)
downloadnumpy-3842786bd5b7515c5f86fe4471ffa3fdb7f7c568.tar.gz
BUG: Support env argument in CCompiler.spawn
-rw-r--r--numpy/distutils/ccompiler.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/numpy/distutils/ccompiler.py b/numpy/distutils/ccompiler.py
index 713b8c72f..ef1744db2 100644
--- a/numpy/distutils/ccompiler.py
+++ b/numpy/distutils/ccompiler.py
@@ -109,7 +109,7 @@ replace_method(CCompiler, 'find_executables', CCompiler_find_executables)
# Using customized CCompiler.spawn.
-def CCompiler_spawn(self, cmd, display=None):
+def CCompiler_spawn(self, cmd, display=None, env=None):
"""
Execute a command in a sub-process.
@@ -120,6 +120,7 @@ def CCompiler_spawn(self, cmd, display=None):
display : str or sequence of str, optional
The text to add to the log file kept by `numpy.distutils`.
If not given, `display` is equal to `cmd`.
+ env: a dictionary for environment variables, optional
Returns
-------
@@ -131,6 +132,7 @@ def CCompiler_spawn(self, cmd, display=None):
If the command failed, i.e. the exit status was not 0.
"""
+ env = env if env is not None else dict(os.environ)
if display is None:
display = cmd
if is_sequence(display):
@@ -138,9 +140,9 @@ def CCompiler_spawn(self, cmd, display=None):
log.info(display)
try:
if self.verbose:
- subprocess.check_output(cmd)
+ subprocess.check_output(cmd, env=env)
else:
- subprocess.check_output(cmd, stderr=subprocess.STDOUT)
+ subprocess.check_output(cmd, stderr=subprocess.STDOUT, env=env)
except subprocess.CalledProcessError as exc:
o = exc.output
s = exc.returncode