blob: b5e8cb1bcaea8fdef6be6d01a3696da9a34db093 [file] [log] [blame]
From 5cf0ca1ebaec17df425a2b2829f6520e355f81cc 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 014/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 04eb6b2..b483dd3 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.32.0