import requests
import io
import tarfile


def sources_from_arxiv(eprint):
    """
    Download sources on arXiv for a given preprint.

    :param eprint: The arXiv id (e.g. ``1401.2910`` or ``1401.2910v1``).
    :returns: A ``TarFile`` object of the sources of the arXiv preprint.
    """
    r = requests.get("http://arxiv.org/e-print/%s" % (eprint,))
    file_object = io.BytesIO(r.content)
    return tarfile.open(fileobj=file_object)