mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-07 04:20:07 +01:00
Verify that the cl.exe used for the wx and py builds is the one that the target Python wants to be built with, and also set the environment vars from that version of the compiler's vcvarsall.bat the same way that distutils does it. Ensure that CPU is set for the wx build.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@73187 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
43
build.py
43
build.py
@@ -173,6 +173,7 @@ def setPythonVersion(args):
|
||||
global PYSHORTVER
|
||||
global PYTHON
|
||||
global PYTHON_ARCH
|
||||
|
||||
for idx, arg in enumerate(args):
|
||||
if re.match(r'^[0-9]\.[0-9]$', arg):
|
||||
PYVER = arg
|
||||
@@ -191,8 +192,11 @@ def setPythonVersion(args):
|
||||
TOOLS = os.environ.get('TOOLS')
|
||||
if 'cygdrive' in TOOLS:
|
||||
TOOLS = runcmd('c:/cygwin/bin/cygpath -w '+TOOLS, True, False)
|
||||
use64flag = '--x64' in args
|
||||
if use64flag:
|
||||
args.remove('--x64')
|
||||
CPU = os.environ.get('CPU')
|
||||
if CPU in ['AMD64', 'X64']:
|
||||
if use64flag or CPU in ['AMD64', 'X64', 'amd64', 'x64']:
|
||||
TOOLS = posixjoin(TOOLS, 'amd64')
|
||||
PYTHON = posixjoin(TOOLS,
|
||||
'python%s' % PYSHORTVER,
|
||||
@@ -204,6 +208,8 @@ def setPythonVersion(args):
|
||||
PYVER = sys.version[:3]
|
||||
PYSHORTVER = PYVER[0] + PYVER[2]
|
||||
msg('Using %s' % PYTHON)
|
||||
|
||||
|
||||
else:
|
||||
findPython = runcmd("which %s" % PYTHON, True, False)
|
||||
msg('Found %s at %s' % (PYTHON, findPython))
|
||||
@@ -214,6 +220,11 @@ def setPythonVersion(args):
|
||||
% PYTHON, True, False)
|
||||
msg('Python\'s architecture is %s' % PYTHON_ARCH)
|
||||
os.environ['PYTHON'] = PYTHON
|
||||
|
||||
if PYTHON_ARCH == '64bit':
|
||||
# This may be set already, but there are a couple code paths above
|
||||
# where it may not be...
|
||||
os.environ['CPU'] = 'X64'
|
||||
|
||||
|
||||
|
||||
@@ -520,6 +531,33 @@ def uploadPackage(fileName, matchString, keep=5):
|
||||
|
||||
|
||||
|
||||
def checkCompiler():
|
||||
if isWindows:
|
||||
# Make sure that the compiler that Python wants to use can be found.
|
||||
# It will terminate if the compiler is not found or other exceptions
|
||||
# are raised.
|
||||
cmd = "import distutils.msvc9compiler as msvc; " \
|
||||
"mc = msvc.MSVCCompiler(); " \
|
||||
"mc.initialize(); " \
|
||||
"print(mc.cc)"
|
||||
CC = runcmd('%s -c "%s"' % (PYTHON, cmd), getOutput=True, echoCmd=False)
|
||||
msg("MSVC: %s" % CC)
|
||||
|
||||
# Now get the environment variables which that compiler needs from
|
||||
# its vcvarsall.bat command and load them into this process's
|
||||
# environment.
|
||||
cmd = "import distutils.msvc9compiler as msvc; " \
|
||||
"arch = msvc.PLAT_TO_VCVARS[msvc.get_platform()]; " \
|
||||
"env = msvc.query_vcvarsall(msvc.VERSION, arch); " \
|
||||
"print(env)"
|
||||
env = eval(runcmd('%s -c "%s"' % (PYTHON, cmd), getOutput=True, echoCmd=False))
|
||||
os.environ['PATH'] = bytes(env['path'])
|
||||
os.environ['INCLUDE'] = bytes(env['include'])
|
||||
os.environ['LIB'] = bytes(env['lib'])
|
||||
os.environ['LIBPATH'] = bytes(env['libpath'])
|
||||
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Command functions
|
||||
#---------------------------------------------------------------------------
|
||||
@@ -812,6 +850,7 @@ def build(options, args):
|
||||
|
||||
def build_wx(options, args):
|
||||
cmdTimer = CommandTimer('build_wx')
|
||||
checkCompiler()
|
||||
|
||||
build_options = ['--wxpython', '--unicode']
|
||||
|
||||
@@ -960,6 +999,7 @@ def copyWxDlls(options):
|
||||
|
||||
def setup_py(options, args):
|
||||
cmdTimer = CommandTimer('setup_py')
|
||||
checkCompiler()
|
||||
|
||||
BUILD_DIR = getBuildDir(options)
|
||||
DESTDIR = options.installdir
|
||||
@@ -1054,6 +1094,7 @@ def setup_py(options, args):
|
||||
def waf_py(options, args):
|
||||
cmdTimer = CommandTimer('waf_py')
|
||||
waf = getWafCmd()
|
||||
checkCompiler()
|
||||
|
||||
BUILD_DIR = getBuildDir(options)
|
||||
DESTDIR = options.installdir
|
||||
|
||||
@@ -792,6 +792,8 @@ def runcmd(cmd, getOutput=False, echoCmd=True, fatal=True):
|
||||
# Failed!
|
||||
#raise subprocess.CalledProcessError(rval, cmd)
|
||||
print("Command '%s' failed with exit code %d." % (cmd, rval))
|
||||
if getOutput:
|
||||
print(output)
|
||||
if fatal:
|
||||
sys.exit(rval)
|
||||
|
||||
@@ -839,6 +841,8 @@ def getSipFiles(names):
|
||||
|
||||
def getVisCVersion():
|
||||
text = runcmd("cl.exe", getOutput=True, echoCmd=False)
|
||||
if 'Version 13' in text:
|
||||
return '71'
|
||||
if 'Version 15' in text:
|
||||
return '90'
|
||||
# TODO: Add more tests to get the other versions...
|
||||
|
||||
Reference in New Issue
Block a user