Requirement
(.venv) Revanths-MBP:Home revanth$ python set_env_vars.py # this will get an environment variable from the server and has to set that environment variable
set_env_vars.py
def main():
stage_vars = get_stage_vars(project_name, branch, aws_region)
import os
for key, value in stage_vars.items():
os.environ[key] = value
Problem
(.venv) Revanths-MBP:Home revanth$ echo $STAGE_VAR
(.venv) Revanths-MBP:Home revanth$
This will not print anything because the environment variables set in the above python process are not carried to its parent process
Another solution could be something like this set_env_vars.py
would return all the env variables as a string like below
export STAGE_VAR_1="stage_var_1"
export STAGE_VAR_2="stage_var_2"
...
...
...
export STAGE_VAR_N="stage_var_n"
Now is it possible to pipe(|) this output and use some shell commands to take the above output as input and execute each line above ?