Example #1
0
def find_msvc_env(x64flag=False, ver0=None):
    vcvers = [140, 141, 150, 90, 100]
    if ver0 in vcvers:
        vcvers.insert(0, ver0)
    errs = []
    for vsver in vcvers:
        env = _get_msvc_env(vsver, x64flag)
        if env is not None:
            return env, vsver
    log.error("Could not find a Microsoft Compiler")
Example #2
0
def find_msvc_env(x64flag=False):
    # First, try to get the compiler which served to compile python
    msc_pos = sys.version.find('MSC v.')
    if msc_pos != -1:
        msc_ver = int(sys.version[msc_pos+6:msc_pos+10])
        # 1300 -> 70, 1310 -> 71, 1400 -> 80, 1500 -> 90
        vsver = (msc_ver / 10) - 60
        env = _get_msvc_env(vsver, x64flag)

        if env is not None:
            return env

    # Then, try any other version
    for vsver in (100, 90, 80, 71, 70): # All the versions I know
        env = _get_msvc_env(vsver, x64flag)

        if env is not None:
            return env
    log.error("Could not find a Microsoft Compiler")
Example #3
0
def find_msvc_env(x64flag=False):
    # First, try to get the compiler which served to compile python
    msc_pos = sys.version.find('MSC v.')
    if msc_pos != -1:
        msc_ver = int(sys.version[msc_pos + 6:msc_pos + 10])
        # 1300 -> 70, 1310 -> 71, 1400 -> 80, 1500 -> 90
        vsver = (msc_ver / 10) - 60
        env = _get_msvc_env(vsver, x64flag)

        if env is not None:
            return env

    # Then, try any other version
    for vsver in (100, 90, 80, 71, 70):  # All the versions I know
        env = _get_msvc_env(vsver, x64flag)

        if env is not None:
            return env
    log.error("Could not find a Microsoft Compiler")
Example #4
0
def _get_msvc_env(vsver, x64flag):
    vcdict = None
    toolsdir = None
    try:
        toolsdir = os.environ['VS%sCOMNTOOLS' % vsver]
    except KeyError:
        # use setuptools from python3 to find tools
        try:
            vcdict = _find_vcvarsall(vsver, x64flag)
        except ImportError as e:
            if 'setuptools' in str(e):
                log.error(
                    'is setuptools installed (perhaps try %s -mensurepip)?' %
                    sys.executable)
            log.error('looking for compiler %s raised exception "%s' %
                      (vsver, str(e)))
        except Exception as e:
            log.error('looking for compiler %s raised exception "%s' %
                      (vsver, str(e)))
            return None
    else:
        if x64flag:
            vsinstalldir = os.path.abspath(os.path.join(toolsdir, '..', '..'))
            vcinstalldir = os.path.join(vsinstalldir, 'VC')
            vcbindir = os.path.join(vcinstalldir, 'BIN')
            vcvars = os.path.join(vcbindir, 'amd64', 'vcvarsamd64.bat')
        else:
            vcvars = os.path.join(toolsdir, 'vsvars32.bat')
            if not os.path.exists(vcvars):
                # even msdn does not know which to run
                # see https://msdn.microsoft.com/en-us/library/1700bbwd(v=vs.90).aspx
                # which names both
                vcvars = os.path.join(toolsdir, 'vcvars32.bat')

        import subprocess
        try:
            popen = subprocess.Popen('"%s" & set' % (vcvars, ),
                                     stdout=subprocess.PIPE,
                                     stderr=subprocess.PIPE)

            stdout, stderr = popen.communicate()
            if popen.wait() != 0 or stdout[:5].lower() == 'error':
                log.msg(
                    'Running "%s" errored: \n\nstdout:\n%s\n\nstderr:\n%s' %
                    (vcvars, stdout.split()[0], stderr))
                return None
            else:
                log.msg('Running "%s" succeeded' % (vcvars, ))
        except Exception as e:
            log.msg('Running "%s" failed: "%s"' % (vcvars, str(e)))
            return None

        stdout = stdout.replace("\r\n", "\n")
        vcdict = {}
        for line in stdout.split("\n"):
            if '=' not in line:
                continue
            key, value = line.split('=', 1)
            vcdict[key] = value
    env = {}
    for key, value in vcdict.items():
        if key.upper() in ['PATH', 'INCLUDE', 'LIB']:
            env[key.upper()] = value
    if 'PATH' not in env:
        log.msg('Did not find "PATH" in stdout\n%s' % (stdout))
    if not _find_executable('mt.exe', env['PATH']):
        # For some reason the sdk bin path is missing?
        # put it together from some other env variables that happened to exist
        # on the buildbot where this occurred
        if 'WindowsSDKVersion' in vcdict and 'WindowsSdkDir' in vcdict:
            binpath = vcdict['WindowsSdkDir'] + '\\bin\\' + vcdict[
                'WindowsSDKVersion'] + 'x86'
            env['PATH'] += ';' + binpath
        if not _find_executable('mt.exe', env['PATH']):
            log.msg('Could not find mt.exe on path=%s' % env['PATH'])
            log.msg('Running vsver %s set this env' % vsver)
            for key, value in vcdict.items():
                log.msg('%s=%s' % (key, value))
    log.msg("Updated environment with vsver %d, using x64 %s" % (
        vsver,
        x64flag,
    ))
    return env
Example #5
0
File: arm.py Project: Darriall/pypy
from rpython.translator.platform.linux import Linux
from rpython.translator.platform.posix import _run_subprocess, GnuMakefile
from rpython.translator.platform import ExecutionResult, log
from os import getenv

SB2 = getenv('SB2')
if SB2 is None:
    log.error('SB2: Provide a path to the sb2 rootfs for the target in env variable SB2')
    assert 0

sb2_params = getenv('SB2OPT')
if sb2_params is None:
    log.info('Pass additional options to sb2 in SB2OPT')
    SB2ARGS = []
else:
    SB2ARGS = sb2_params.split(' ')

class ARM(Linux):
    name = "arm"
    shared_only = ('-fPIC',)

    available_librarydirs = [SB2 + '/lib/arm-linux-gnueabi/',
                             SB2 + '/lib/arm-linux-gnueabihf/',
                             SB2 + '/lib/aarch64-linux-gnu/',
                             SB2 + '/usr/lib/arm-linux-gnueabi/',
                             SB2 + '/usr/lib/arm-linux-gnueabihf/',
                             SB2 + '/usr/lib/aarch64-linux-gnu/']

    available_includedirs = [SB2 + '/usr/include/arm-linux-gnueabi/',
                             SB2 + '/usr/include/arm-linux-gnueabihf/',
                             SB2 + '/usr/include/aarch64-linux-gnu/']
Example #6
0
from rpython.translator.platform.linux import Linux
from rpython.translator.platform.posix import _run_subprocess, GnuMakefile
from rpython.translator.platform import ExecutionResult, log
from os import getenv

SB2 = getenv('SB2')
if SB2 is None:
    log.error('SB2: Provide a path to the sb2 rootfs for the target in env variable SB2')
    assert 0

sb2_params = getenv('SB2OPT')
if sb2_params is None:
    log.info('Pass additional options to sb2 in SB2OPT')
    SB2ARGS = []
else:
    SB2ARGS = sb2_params.split(' ')

class ARM(Linux):
    name = "arm"
    shared_only = ('-fPIC',)

    available_librarydirs = [SB2 + '/lib/arm-linux-gnueabi/',
                             SB2 + '/lib/arm-linux-gnueabihf/',
                             SB2 + '/usr/lib/arm-linux-gnueabi/',
                             SB2 + '/usr/lib/arm-linux-gnueabihf/']

    available_includedirs = [SB2 + '/usr/include/arm-linux-gnueabi/',
                             SB2 + '/usr/include/arm-linux-gnueabihf/']
    copied_cache = {}