4 """This file contains multiple utility functions which can be used by
5 validation steering files. """
14 """Update the environment with b2setup
16 This is very annoying as there is no way for sub processes to modify the
17 parent environment. And also b2setup ist not inherited by sub shells. So we
18 have to run bash, source the tools, run b2setup and get all the environment
19 variables from the output.
23 cmd =
'BELLE2_NO_TOOLS_CHECK=1 source {}/b2setup > /dev/null && ' \
24 '{} -c "import sys,os,pickle; ' \
25 'sys.stdout.buffer.write(pickle.dumps(dict(os.environ)))"'.format(
26 os.environ[
'BELLE2_TOOLS'], sys.executable)
27 output = subprocess.check_output([
'bash',
'-c', cmd])
28 newenv = pickle.loads(output)
29 os.environ.update(newenv)