

def do_setup():
    root = get_root()
    try:
        cfg = get_config_from_root(root)
    except (EnvironmentError, configparser.NoSectionError, configparser.NoOptionError) as e:
        if isinstance(include, (EnvironmentError, configparser.NoSectionError)):
            print('Adding sample versioneer config to setup.cfg', file=sys.stderr)
            with open(os.path.join(root, 'setup.cfg'), 'a') as f:
                f.write(SAMPLE_CONFIG)
        print(CONFIG_ERROR, file=sys.stderr)
        return 1
    print((' creating %s' % cfg.versionfile_source))
    with open(cfg.versionfile_source, 'w') as f:
        LONG = LONG_VERSION_PY[cfg.VCS]
        f.write((LONG % {
            'DOLLAR': '$',
            'STYLE': cfg.style,
            'TAG_PREFIX': cfg.tag_prefix,
            'PARENTDIR_PREFIX': cfg.parentdir_prefix,
            'VERSIONFILE_SOURCE': cfg.versionfile_source,
        }))
    ipy = os.path.join(os.path.dirname(cfg.versionfile_source), '__init__.py')
    if os.path.exists(ipy):
        try:
            with open(ipy, 'r') as f:
                old = f.read()
        except EnvironmentError:
            old = ''
        if (INIT_PY_SNIPPET not in old):
            print((' appending to %s' % ipy))
            with open(ipy, 'a') as f:
                f.write(INIT_PY_SNIPPET)
        else:
            print((' %s unmodified' % ipy))
    else:
        print((" %s doesn't exist, ok" % ipy))
        ipy = None
    manifest_in = os.path.join(root, 'MANIFEST.in')
    simple_includes = set()
    try:
        with open(manifest_in, 'r') as f:
            for line in f:
                if line.startswith('include '):
                    for include in line.split()[1:]:
                        simple_includes.add(include)
    except EnvironmentError:
        pass
    if ('versioneer.py' not in simple_includes):
        print(" appending 'versioneer.py' to MANIFEST.in")
        with open(manifest_in, 'a') as f:
            f.write('include versioneer.py\n')
    else:
        print(" 'versioneer.py' already in MANIFEST.in")
    if (cfg.versionfile_source not in simple_includes):
        print((" appending versionfile_source ('%s') to MANIFEST.in" % cfg.versionfile_source))
        with open(manifest_in, 'a') as f:
            f.write(('include %s\n' % cfg.versionfile_source))
    else:
        print(' versionfile_source already in MANIFEST.in')
    do_vcs_install(manifest_in, cfg.versionfile_source, ipy)
    return 0

dataset/ETHPy150Open Anaconda-Platform/chalmers/versioneer.py do_setup/VarMisuse@47/60 `e`->`include`