summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRalf Gommers <ralf.gommers@gmail.com>2021-12-22 20:07:42 +0100
committerGitHub <noreply@github.com>2021-12-22 20:07:42 +0100
commit4c15ba7f0143778e37b7841b8ccd17b21c796b71 (patch)
tree128e8bca1ba74673311efebce6060baf0fe54540
parent0d2673c3914580f5af7ca0451f261f30e070a0d2 (diff)
parent3842786bd5b7515c5f86fe4471ffa3fdb7f7c568 (diff)
downloadnumpy-4c15ba7f0143778e37b7841b8ccd17b21c796b71.tar.gz
Merge pull request #20640 from isuruf/spawn
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