Skip to content

Commit 6cbee1d

Browse files
lazkargommers
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 (cherry picked from commit 6eee9e7)
1 parent e6e1bf9 commit 6cbee1d

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

mesonbuild/dependencies/python.py

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

251251
def get_windows_python_arch(self) -> T.Optional[str]:
252-
if self.platform == 'mingw':
253-
pycc = self.variables.get('CC')
254-
if pycc.startswith('x86_64'):
252+
if self.platform.startswith('mingw'):
253+
if 'x86_64' in self.platform:
255254
return 'x86_64'
256-
elif pycc.startswith(('i686', 'i386')):
255+
elif 'i686' in self.platform:
257256
return 'x86'
257+
elif 'aarch64' in self.platform:
258+
return 'aarch64'
258259
else:
259-
mlog.log(f'MinGW Python built with unknown CC {pycc!r}, please file a bug')
260+
mlog.log(f'MinGW Python built with unknown platform {self.platform!r}, please file a bug')
260261
return None
261262
elif self.platform == 'win32':
262263
return 'x86'
@@ -311,7 +312,7 @@ def get_windows_link_args(self) -> T.Optional[T.List[str]]:
311312
'''))
312313
# base_prefix to allow for virtualenvs.
313314
lib = Path(self.variables.get('base_prefix')) / libpath
314-
elif self.platform == 'mingw':
315+
elif self.platform.startswith('mingw'):
315316
if self.static:
316317
libname = self.variables.get('LIBRARY')
317318
else:

0 commit comments

Comments
 (0)