aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/utils/universal.py
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2022-12-15 16:32:14 -0500
committerEli Schwartz <eschwartz@archlinux.org>2022-12-15 16:44:35 -0500
commit2ef94a71f8072567e39f22bfed7bcae0ca2038c2 (patch)
treeb0c58513f81b5126cd497aa982b3d87f0d0db0db /mesonbuild/utils/universal.py
parent57f91bb593b9eebf772a16a5519de58996d27c3a (diff)
downloadmeson-2ef94a71f8072567e39f22bfed7bcae0ca2038c2.zip
meson-2ef94a71f8072567e39f22bfed7bcae0ca2038c2.tar.gz
meson-2ef94a71f8072567e39f22bfed7bcae0ca2038c2.tar.bz2
delay importing ctypes unless it is actually used
ctypes uses FFI, and surprisingly often people's Python installations will be broken because ctypes is broken (e.g. the system libffi has been updated and Python needs to be recompiled). That is not our fault, but it does manifest as Meson failing to run. It turns out we aren't even using it though. At least, pretty often. We have two uses of ctypes, and both of them are for Windows. One of them is already conditionally imported in the function that uses it, but the other is imported at startup. Move this down into the invoking function. On non-Windows systems, it is now impossible for Meson to fail to run when ctypes is broken, because we don't use it. Anecdotally, this issue tends to come up on Linux systems primarily. Fixes #11111 Closes #11112
Diffstat (limited to 'mesonbuild/utils/universal.py')
-rw-r--r--mesonbuild/utils/universal.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/mesonbuild/utils/universal.py b/mesonbuild/utils/universal.py
index 220a7f4..a78ca7f 100644
--- a/mesonbuild/utils/universal.py
+++ b/mesonbuild/utils/universal.py
@@ -17,7 +17,6 @@
from __future__ import annotations
from pathlib import Path
import argparse
-import ctypes
import enum
import sys
import stat
@@ -699,6 +698,7 @@ def windows_detect_native_arch() -> str:
if sys.platform != 'win32':
return ''
try:
+ import ctypes
process_arch = ctypes.c_ushort()
native_arch = ctypes.c_ushort()
kernel32 = ctypes.windll.kernel32