<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def shell_source(script):
 """Sometime you want to emulate the action of "source" in bash, settings some environment variables. Here is a way to do it."""

    pipe = subprocess.Popen(
        ". %s; env" % script, stdout=subprocess.PIPE, shell=True)
    output = pipe.communicate()[0].decode()
    env = {}
    for line in output.splitlines():
        try:
            keyval = line.split("=", 1)
            env[keyval[0]] = keyval[1]
        except:
            pass

    os.environ.update(env)