From 63b12b21aae2268da35cd557e526b241a65198c2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?=
 <alexey.pawlow@gmail.com>
Date: Thu, 17 Jun 2021 18:51:30 +0530
Subject: [PATCH 020/N] MINGW setup _ctypes module with system libffi
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Алексей <alexey.pawlow@gmail.com>
Co-authored-by: Christoph Reiter <reiter.christoph@gmail.com>
---
 setup.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/setup.py b/setup.py
index a6145c4..e36ef5d 100644
--- a/setup.py
+++ b/setup.py
@@ -2149,9 +2149,12 @@ class PyBuildExt(build_ext):
         self.add(ext)
         if TEST_EXTENSIONS:
             # function my_sqrt() needs libm for sqrt()
+            ffi_test_libs = ['m']
+            if MS_WINDOWS:
+                ffi_test_libs += ['oleaut32']
             self.add(Extension('_ctypes_test',
                                sources=['_ctypes/_ctypes_test.c'],
-                               libraries=['m']))
+                               libraries=ffi_test_libs))
 
         ffi_inc = sysconfig.get_config_var("LIBFFI_INCLUDEDIR")
         ffi_lib = None
@@ -2196,6 +2199,8 @@ class PyBuildExt(build_ext):
 
             ext.include_dirs.append(ffi_inc)
             ext.libraries.append(ffi_lib)
+            if MS_WINDOWS:
+                ext.libraries.extend(['ole32', 'oleaut32', 'uuid'])
             self.use_system_libffi = True
 
         if sysconfig.get_config_var('HAVE_LIBDL'):
-- 
2.32.0

