python-setup: change env passing
This commit is contained in:
parent
1309aafb7d
commit
2264307214
1 changed files with 8 additions and 18 deletions
|
|
@ -9,30 +9,20 @@ from typing import Optional
|
||||||
import extractor_version
|
import extractor_version
|
||||||
|
|
||||||
|
|
||||||
def _check_call(command, extra_env=None):
|
def _check_call(command, extra_env={}):
|
||||||
print('+ {}'.format(' '.join(command)), flush=True)
|
print('+ {}'.format(' '.join(command)), flush=True)
|
||||||
|
|
||||||
# only pass `env` argument if we need to pass in an updated environment
|
env = os.environ.copy()
|
||||||
kwargs = {}
|
env.update(extra_env)
|
||||||
if extra_env:
|
subprocess.check_call(command, stdin=subprocess.DEVNULL, env=env)
|
||||||
new_env = os.environ.copy()
|
|
||||||
new_env.update(extra_env)
|
|
||||||
kwargs = {"env": new_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)
|
print('+ {}'.format(' '.join(command)), flush=True)
|
||||||
|
|
||||||
# only pass `env` argument if we need to pass in an updated environment
|
env = os.environ.copy()
|
||||||
kwargs = {}
|
env.update(extra_env)
|
||||||
if extra_env:
|
out = subprocess.check_output(command, stdin=subprocess.DEVNULL, env=env)
|
||||||
new_env = os.environ.copy()
|
|
||||||
new_env.update(extra_env)
|
|
||||||
kwargs = {"env": new_env}
|
|
||||||
|
|
||||||
out = subprocess.check_output(command, stdin=subprocess.DEVNULL, **kwargs)
|
|
||||||
print(out, flush=True)
|
print(out, flush=True)
|
||||||
sys.stderr.flush()
|
sys.stderr.flush()
|
||||||
return out
|
return out
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue