aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2017-12-10 01:10:40 +0530
committerNirbheek Chauhan <nirbheek@centricular.com>2017-12-10 01:29:33 +0530
commit6f42f83867a52c1f9c61a2780dfd808a21984e41 (patch)
tree30a81bca6859227c882f35894f1a26c26959db42
parent7586a4ac091a262008c96c0eed004e9b5aeab56a (diff)
downloadmeson-6f42f83867a52c1f9c61a2780dfd808a21984e41.zip
meson-6f42f83867a52c1f9c61a2780dfd808a21984e41.tar.gz
meson-6f42f83867a52c1f9c61a2780dfd808a21984e41.tar.bz2
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.
-rw-r--r--mesonbuild/dependencies/misc.py31
1 files changed, 27 insertions, 4 deletions
diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py
index 41666a3..71962a3 100644
--- a/mesonbuild/dependencies/misc.py
+++ b/mesonbuild/dependencies/misc.py
@@ -638,12 +638,35 @@ class Python3Dependency(ExternalDependency):
else:
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):
'''
Find python3 libraries on Windows and also verify that the arch matches
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)
if arch == 'x86':
arch = '32'
@@ -656,9 +679,9 @@ class Python3Dependency(ExternalDependency):
self.is_found = False
return
# Pyarch ends in '32' or '64'
- if arch != pyarch[-2:]:
- mlog.log('Need', mlog.bold(self.name),
- 'for {}-bit, but found {}-bit'.format(arch, pyarch[-2:]))
+ if arch != pyarch:
+ mlog.log('Need', mlog.bold(self.name), 'for {}-bit, but '
+ 'found {}-bit'.format(arch, pyarch))
self.is_found = False
return
inc = sysconfig.get_path('include')