From 22643072146458fa9db7e66439f15de42c40293d Mon Sep 17 00:00:00 2001 From: Rasmus Wriedt Larsen Date: Wed, 21 Sep 2022 10:01:57 +0200 Subject: [PATCH] python-setup: change `env` passing --- python-setup/auto_install_packages.py | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/python-setup/auto_install_packages.py b/python-setup/auto_install_packages.py index 3efa955c17..b134bf673a 100755 --- a/python-setup/auto_install_packages.py +++ b/python-setup/auto_install_packages.py @@ -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