

def build_wininst(root, python_exe=None, copy_to=None, architecture=None, verbose=False, installer='bdist_wininst'):
    'Build wininst installer from Python package located in *root*\n    and eventually copy it to *copy_to* folder.\n    Return wininst installer full path.'
    if (python_exe is None):
        python_exe = sys.executable
    assert osp.isfile(python_exe)
    cmd = [python_exe, 'setup.py', 'build']
    if (architecture is not None):
        archstr = ('win32' if (architecture == 32) else 'win-amd64')
        cmd += [('--plat-name=%s' % archstr)]
    cmd += [installer]
    if verbose:
        subprocess.call(cmd, cwd=root)
    else:
        p = subprocess.Popen(cmd, cwd=root, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        p.communicate()
        p.stdout.close()
        p.stderr.close()
    distdir = osp.join(root, 'dist')
    if (not osp.isdir(distdir)):
        raise RuntimeError('Build failed: see package README file for further details regarding installation requirements.\n\nFor more concrete debugging infos, please try to build the package from the command line:\n1. Open a WinPython command prompt\n2. Change working directory to the appropriate folder\n3. Type `python setup.py build install`')
    pattern = WININST_PATTERN.replace('(win32|win\\-amd64)', archstr)
    for distname in os.listdir(distdir):
        match = re.match(pattern, distname)
        if (match is not None):
            break
        match = re.match(SOURCE_PATTERN, distname)
        if (match is not None):
            break
        match = re.match(WHEELBIN_PATTERN, distname)
        if (match is not None):
            break
    else:
        raise RuntimeError(('Build failed: not a pure Python package? %s' % distdir))
    src_fname = osp.join(distdir, distname)
    if (copy_to is None):
        return src_fname
    else:
        dst_fname = osp.join(copy_to, distname)
        shutil.move(cmd, dst_fname)
        if verbose:
            print(('Move: %s --> %s' % (src_fname, dst_fname)))
            shutil.rmtree(root, onerror=onerror)
        return dst_fname

dataset/ETHPy150Open winpython/winpython/winpython/utils.py build_wininst/VarMisuse@361/648 `src_fname`->`cmd`