summarylogtreecommitdiffstats
path: root/0012-issue6672-v2-Add-Mingw-recognition-to-pyport.h-to-al.patch
blob: dcbaa45b0226ff22dbe9d97dd02a8b2a6fdd0a0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
From b04a5d9e049ad86d70f3977cb2604b2e6b7e0bca 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:23 +0530
Subject: [PATCH 012/N] issue6672 v2 Add Mingw recognition to pyport.h to al
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Алексей <alexey.pawlow@gmail.com>
---
 Include/pyport.h | 20 +++++++++++---------
 setup.py         |  3 +++
 2 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/Include/pyport.h b/Include/pyport.h
index 475c2a8..a05fa3a 100644
--- a/Include/pyport.h
+++ b/Include/pyport.h
@@ -664,12 +664,12 @@ extern char * _getpty(int *, int, mode_t, int);
 */
 
 /*
-  All windows ports, except cygwin, are handled in PC/pyconfig.h.
+  Only MSVC windows ports is handled in PC/pyconfig.h.
 
-  Cygwin is the only other autoconf platform requiring special
+  Cygwin and Mingw is the only other autoconf platform requiring special
   linkage handling and it uses __declspec().
 */
-#if defined(__CYGWIN__)
+#if defined(__CYGWIN__) || defined(__MINGW32__)
 #       define HAVE_DECLSPEC_DLL
 #endif
 
@@ -682,21 +682,23 @@ extern char * _getpty(int *, int, mode_t, int);
 #                       define PyAPI_FUNC(RTYPE) Py_EXPORTED_SYMBOL RTYPE
 #                       define PyAPI_DATA(RTYPE) extern Py_EXPORTED_SYMBOL RTYPE
         /* module init functions inside the core need no external linkage */
-        /* except for Cygwin to handle embedding */
-#                       if defined(__CYGWIN__)
+        /* except for Cygwin/Mingw to handle embedding */
+#                       if defined(__CYGWIN__) || defined(__MINGW32__)
 #                               define PyMODINIT_FUNC Py_EXPORTED_SYMBOL PyObject*
-#                       else /* __CYGWIN__ */
+#                       else /* __CYGWIN__ || __MINGW32__*/
 #                               define PyMODINIT_FUNC PyObject*
-#                       endif /* __CYGWIN__ */
+#                       endif /* __CYGWIN__ || __MINGW32__*/
 #               else /* Py_BUILD_CORE */
         /* Building an extension module, or an embedded situation */
         /* public Python functions and data are imported */
         /* Under Cygwin, auto-import functions to prevent compilation */
         /* failures similar to those described at the bottom of 4.1: */
         /* http://docs.python.org/extending/windows.html#a-cookbook-approach */
-#                       if !defined(__CYGWIN__)
+#                       if defined(__CYGWIN__) || defined(__MINGW32__)
+#                               define PyAPI_FUNC(RTYPE) RTYPE
+#                       else
 #                               define PyAPI_FUNC(RTYPE) Py_IMPORTED_SYMBOL RTYPE
-#                       endif /* !__CYGWIN__ */
+#                       endif /* __CYGWIN__ || __MINGW32__*/
 #                       define PyAPI_DATA(RTYPE) extern Py_IMPORTED_SYMBOL RTYPE
         /* module init functions outside the core must be exported */
 #                       if defined(__cplusplus)
diff --git a/setup.py b/setup.py
index 54d4b94..d7a4e3f 100644
--- a/setup.py
+++ b/setup.py
@@ -444,6 +444,9 @@ class PyBuildExt(build_ext):
     def build_extensions(self):
         self.set_srcdir()
 
+        if MS_WINDOWS:
+            self.compiler.define_macro("Py_BUILD_CORE_MODULE")
+
         # Detect which modules should be compiled
         self.detect_modules()
 
-- 
2.33.0