Issue #26661: setup.py now detects system libffi with multiarch wrapper.
diff --git a/Misc/NEWS b/Misc/NEWS
index 15a7e0e..671a9b4 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -93,6 +93,8 @@
 Build
 -----
 
+- Issue #26661: setup.py now detects system libffi with multiarch wrapper.
+
 - Issue #15819: Remove redundant include search directory option for building
   outside the source tree.
 
diff --git a/setup.py b/setup.py
index b752a67..a1989aa 100644
--- a/setup.py
+++ b/setup.py
@@ -2025,14 +2025,16 @@
             ffi_inc = find_file('ffi.h', [], inc_dirs)
         if ffi_inc is not None:
             ffi_h = ffi_inc[0] + '/ffi.h'
-            with open(ffi_h) as fp:
-                while 1:
-                    line = fp.readline()
-                    if not line:
-                        ffi_inc = None
+            with open(ffi_h) as f:
+                for line in f:
+                    line = line.strip()
+                    if line.startswith(('#define LIBFFI_H',
+                                        '#define ffi_wrapper_h')):
                         break
-                    if line.startswith('#define LIBFFI_H'):
-                        break
+                else:
+                    ffi_inc = None
+                    print('Header file {} does not define LIBFFI_H or '
+                          'ffi_wrapper_h'.format(ffi_h))
         ffi_lib = None
         if ffi_inc is not None:
             for lib_name in ('ffi', 'ffi_pic'):