def install_branch(branch):
    # if it's already in the virtualenv, remove it
    ver = '.'.join(map(str, (sys.version_info.major, sys.version_info.minor)))
    sitepack = os.path.join(virtual_dir, 'lib', 'python'+ver, 'site-packages')
    if os.path.exists(sitepack):
        dir_list = os.listdir(sitepack)
    else:
        dir_list = []
    for f in dir_list:
        if 'statsmodels' in f:
            shutil.rmtree(os.path.join(sitepack, f))

    # checkout the branch
    os.chdir(gitdname)
    retcode = subprocess.call('git checkout ' + branch, shell=True,
                              stdout=sys.stdout, stderr=sys.stderr)
    if retcode != 0:
        msg = """Could not checkout out branch %s""" % branch
        raise Exception(msg)

    p = subprocess.Popen('git rev-parse HEAD ', shell=True,
                              stdout=subprocess.PIPE, stderr=sys.stderr)
    version = p.communicate()[0][:7]

    # build and install
    retcode = subprocess.call(" ".join([virtual_python, 'setup.py', 'build']),
                              shell=True, stdout=sys.stdout, stderr=sys.stderr)
    if retcode != 0:
        msg = """Could not build branch %s""" % branch
        raise Exception(msg)
    retcode = subprocess.call(" ".join([virtual_python, os.path.join(gitdname,
                                        'setup.py'), 'install']), shell=True,
                              stdout=sys.stdout, stderr=sys.stderr)
    if retcode != 0:
        os.chdir(dname)
        msg = """Could not install branch %s""" % branch
        raise Exception(msg)
    os.chdir(dname)
    return version
Test IO for evoked data (fif + gz) with integer and str args
dataset/ETHPy150Open statsmodels/statsmodels/tools/update_web.py/install_branch--crossover with--dataset/ETHPy150Open mne-tools/mne-python/mne/tests/test_evoked.py/test_io_evoked