def update_manifest():
    """Update the MANIFEST.in file from git, if necessary."""
    # It would be more efficient to create MANIFEST directly, rather
    # than creating a MANIFEST.in where every line just includes one file.
    # Unfortunately, setuptools/distribute do not support this (distutils
    # does).
    gitdir = os.path.join('.', '.git')
    try:
        st = os.stat(gitdir)
    except __HOLE__:
        return
    cmd = subprocess.Popen(['git', 'ls-tree', '-r', 'master', '--name-only'],
                           stdout=subprocess.PIPE)
    stdout, _ = cmd.communicate()
    files = stdout.splitlines()
    files.append('lib/testmill/_version.py')
    lines = ['include {0}\n'.format(fname)for fname in files]
    new = ''.join(sorted(lines))
    try:
        with open('MANIFEST.in', 'r') as fin:
            current = fin.read()
    except IOError:
        current = None
    if new == current:
        return
    tmpname = 'MANIFEST.in.{0}-tmp'.format(os.getpid())
    with open(tmpname, 'w') as fout:
        fout.write(new)
    os.rename(tmpname, 'MANIFEST.in')
    print('Updated MANIFEST.in')
    # Remove the SOURCES.txt that setuptools maintains. It appears not to
    # accurately regenerate it when MANIFEST.in changes.
    sourcestxt = os.path.join('lib', 'testmill.egg-info', 'SOURCES.txt')
    if not os.access(sourcestxt, os.R_OK):
        return
    os.unlink(sourcestxt)
    print('Removed {0}'.format(sourcestxt))
dataset/ETHPy150Open ravello/testmill/setup.py/update_manifest