Skip to content

Commit 6eee9e7

Browse files
lazkaeli-schwartz
authored andcommitted
python: fix mingw python detection code in case pkg-config isn't available
The code assumed that sysconfig.get_platform() returns "mingw" for mingw Python, but that's no longer the case for 2.5 years now, as it now only starts with "mingw" and contains further information like the arch and other ABI relevant things to avoid conflicts. This updates the detection code to the current status quo. mingw Python only documents right now that it starts with "mingw", and none of that arch stuff, but it's unlikely that this will change, and this looks less error prone than looking at CC. Fixes mesonbuild#12547
1 parent 4ddaef8 commit 6eee9e7

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

‎mesonbuild/dependencies/python.py‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -245,14 +245,15 @@ def find_libpy(self, environment: 'Environment') -> None:
245245
self.is_found = True
246246

247247
def get_windows_python_arch(self) -> T.Optional[str]:
248-
if self.platform == 'mingw':
249-
pycc = self.variables.get('CC')
250-
if pycc.startswith('x86_64'):
248+
if self.platform.startswith('mingw'):
249+
if 'x86_64' in self.platform:
251250
return 'x86_64'
252-
elif pycc.startswith(('i686', 'i386')):
251+
elif 'i686' in self.platform:
253252
return 'x86'
253+
elif 'aarch64' in self.platform:
254+
return 'aarch64'
254255
else:
255-
mlog.log(f'MinGW Python built with unknown CC {pycc!r}, please file a bug')
256+
mlog.log(f'MinGW Python built with unknown platform {self.platform!r}, please file a bug')
256257
return None
257258
elif self.platform == 'win32':
258259
return 'x86'
@@ -309,7 +310,7 @@ def get_windows_link_args(self, limited_api: bool) -> T.Optional[T.List[str]]:
309310
'''))
310311
# base_prefix to allow for virtualenvs.
311312
lib = Path(self.variables.get('base_prefix')) / libpath
312-
elif self.platform == 'mingw':
313+
elif self.platform.startswith('mingw'):
313314
if self.static:
314315
libname = self.variables.get('LIBRARY')
315316
else:

0 commit comments

Comments
 (0)