def main(opts): environ = {} # Get the initial environment if not opts.ignore_environment: environ.update(os.environ) # Update environment from stdin if opts.stdin: input_env_str = sys.stdin.read() environ.update(parse_env_str(input_env_str)) # Finally, update with explicit vars environ.update(opts.envs) if len(opts.cmd) == 0: # Print environment and exit if there's no command print(format_env_dict(environ)) else: # Run the subcommand with the modified environment for ret in execute_process(opts.cmd, env=environ, emulate_tty=True): if ret: if isinstance(ret, int): return ret else: print(ret, end='') # Flush stdout # NOTE: This is done to ensure that automated use of this tool doesn't miss # the output sys.stdout.flush() return 0
def print_build_env(context, package_name): workspace_packages = find_packages(context.source_space_abs, exclude_subspaces=True, warnings=[]) # Load the environment used by this package for building for pth, pkg in workspace_packages.items(): if pkg.name == package_name: environ = get_env_loader(pkg, context)(os.environ) print(format_env_dict(environ)) return 0 print('[build] Error: Package `{}` not in workspace.'.format(package_name), file=sys.stderr) return 1
def print_build_env(context, package_name): workspace_packages = find_packages(context.source_space_abs, exclude_subspaces=True, warnings=[]) # Load the environment used by this package for building for pth, pkg in workspace_packages.items(): if pkg.name == package_name: environ = dict(os.environ) loadenv(None, None, environ, pkg, context) print(format_env_dict(environ)) return 0 print('[build] Error: Package `{}` not in workspace.'.format(package_name), file=sys.stderr) return 1