dependencies: Fix detection of Python arch on MSYS

sysconfig.get_platform() returns 'mingw' with MSYS2, so we need to
use some other method; in this case I chose to use the CC that
Python was compiled with, which is a relatively reliably indicator
unless people start using Python on Windows compiled with Clang or
something.
pull/2697/head
Nirbheek Chauhan 7 years ago
parent 7586a4ac09
commit 6f42f83867
  1. 31
      mesonbuild/dependencies/misc.py

@ -638,12 +638,35 @@ class Python3Dependency(ExternalDependency):
else: else:
mlog.log('Dependency', mlog.bold(self.name), 'found:', mlog.red('NO')) mlog.log('Dependency', mlog.bold(self.name), 'found:', mlog.red('NO'))
@staticmethod
def get_windows_python_arch():
pyplat = sysconfig.get_platform()
if pyplat == 'mingw':
pycc = sysconfig.get_config_var('CC')
if pycc.startswith('x86_64'):
return '64'
elif pycc.startswith(('i686', 'i386')):
return '32'
else:
mlog.log('MinGW Python built with unknown CC {!r}, please file'
'a bug'.format(pycc))
return None
elif pyplat == 'win32':
return '32'
elif pyplat in ('win64', 'win-amd64'):
return '64'
mlog.log('Unknown Windows Python platform {!r}'.format(pyplat))
return None
def _find_libpy3_windows(self, env): def _find_libpy3_windows(self, env):
''' '''
Find python3 libraries on Windows and also verify that the arch matches Find python3 libraries on Windows and also verify that the arch matches
what we are building for. what we are building for.
''' '''
pyarch = sysconfig.get_platform() pyarch = self.get_windows_python_arch()
if pyarch is None:
self.is_found = False
return
arch = detect_cpu_family(env.coredata.compilers) arch = detect_cpu_family(env.coredata.compilers)
if arch == 'x86': if arch == 'x86':
arch = '32' arch = '32'
@ -656,9 +679,9 @@ class Python3Dependency(ExternalDependency):
self.is_found = False self.is_found = False
return return
# Pyarch ends in '32' or '64' # Pyarch ends in '32' or '64'
if arch != pyarch[-2:]: if arch != pyarch:
mlog.log('Need', mlog.bold(self.name), mlog.log('Need', mlog.bold(self.name), 'for {}-bit, but '
'for {}-bit, but found {}-bit'.format(arch, pyarch[-2:])) 'found {}-bit'.format(arch, pyarch))
self.is_found = False self.is_found = False
return return
inc = sysconfig.get_path('include') inc = sysconfig.get_path('include')

Loading…
Cancel
Save