Skip to content

Commit

Permalink
python-setup: change env passing
Browse files Browse the repository at this point in the history
  • Loading branch information
RasmusWL committed Sep 21, 2022
1 parent 1309aaf commit 2264307
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions python-setup/auto_install_packages.py
Expand Up @@ -9,30 +9,20 @@
import extractor_version


def _check_call(command, extra_env=None):
def _check_call(command, extra_env={}):
print('+ {}'.format(' '.join(command)), flush=True)

# only pass `env` argument if we need to pass in an updated environment
kwargs = {}
if extra_env:
new_env = os.environ.copy()
new_env.update(extra_env)
kwargs = {"env": new_env}
env = os.environ.copy()
env.update(extra_env)
subprocess.check_call(command, stdin=subprocess.DEVNULL, env=env)

subprocess.check_call(command, stdin=subprocess.DEVNULL, **kwargs)


def _check_output(command, extra_env=None):
def _check_output(command, extra_env={}):
print('+ {}'.format(' '.join(command)), flush=True)

# only pass `env` argument if we need to pass in an updated environment
kwargs = {}
if extra_env:
new_env = os.environ.copy()
new_env.update(extra_env)
kwargs = {"env": new_env}

out = subprocess.check_output(command, stdin=subprocess.DEVNULL, **kwargs)
env = os.environ.copy()
env.update(extra_env)
out = subprocess.check_output(command, stdin=subprocess.DEVNULL, env=env)
print(out, flush=True)
sys.stderr.flush()
return out
Expand Down

0 comments on commit 2264307

Please sign in to comment.