Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

BUG: Support env argument in CCompiler.spawn #20640

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
BUG: Support env argument in CCompiler.spawn
  • Loading branch information
isuruf committed Dec 22, 2021
commit 3842786bd5b7515c5f86fe4471ffa3fdb7f7c568
8 changes: 5 additions & 3 deletions 8 numpy/distutils/ccompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class where more documentation can be found.


# 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.

Expand All @@ -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
-------
Expand All @@ -131,16 +132,17 @@ 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):
display = ' '.join(list(display))
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
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.