<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def make_tar_stream(build_context, buffer):
 """ Write a tar stream of the build context to the provided buffer Args: build_context (Mapping[str, pyccc.FileReferenceBase]):
 dict mapping filenames to file references buffer (io.BytesIO):
 writable binary mode buffer """

    tf = tarfile.TarFile(fileobj=buffer, mode='w')
    for context_path, fileobj in build_context.items():
        if getattr(fileobj, 'localpath', None) is not None:
            tf.add(fileobj.localpath, arcname=context_path)
        else:
            tar_add_bytes(tf, context_path, fileobj.read('rb'))
    tf.close()