Files
MINGW-packages/mingw-w64-python/0018-Enable-some-windows-specific-modules.patch
2023-12-07 08:12:51 +01:00

111 lines
3.6 KiB
Diff

From cd75eb028a40b44d43909fb45f4c9e417ee850d3 Mon Sep 17 00:00:00 2001
From: Naveen M K <naveen521kk@gmail.com>
Date: Tue, 14 Feb 2023 20:40:42 +0530
Subject: [PATCH 018/N] Enable some windows specific modules
---
Modules/Setup.bootstrap.in | 2 ++
Modules/_winapi.c | 2 ++
PC/msvcrtmodule.c | 2 ++
Python/dynamic_annotations.c | 2 +-
configure.ac | 10 ++++++++++
setup.py | 13 +++++++++++++
6 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/Modules/Setup.bootstrap.in b/Modules/Setup.bootstrap.in
index ac5ee36..7c1d608 100644
--- a/Modules/Setup.bootstrap.in
+++ b/Modules/Setup.bootstrap.in
@@ -36,3 +36,5 @@ _symtable symtablemodule.c
# build-in modules for windows platform:
@USE_WIN32_MODULE@winreg ../PC/winreg.c
+@MODULE_MSVCRT_TRUE@msvcrt -DPy_BUILD_CORE ../PC/msvcrtmodule.c
+@MODULE__WINAPI_TRUE@_winapi _winapi.c
diff --git a/Modules/_winapi.c b/Modules/_winapi.c
index 7fb1f2f..9c4c1ff 100644
--- a/Modules/_winapi.c
+++ b/Modules/_winapi.c
@@ -41,7 +41,9 @@
#define WINDOWS_LEAN_AND_MEAN
#include "windows.h"
+#if defined(Py_DEBUG)
#include <crtdbg.h>
+#endif
#include "winreparse.h"
#if defined(MS_WIN32) && !defined(MS_WIN64)
diff --git a/PC/msvcrtmodule.c b/PC/msvcrtmodule.c
index 1f78d99..0f2da80 100644
--- a/PC/msvcrtmodule.c
+++ b/PC/msvcrtmodule.c
@@ -22,7 +22,9 @@
#include <io.h>
#include <conio.h>
#include <sys/locking.h>
+#ifdef _DEBUG
#include <crtdbg.h>
+#endif
#include <windows.h>
#ifdef _MSC_VER
diff --git a/Python/dynamic_annotations.c b/Python/dynamic_annotations.c
index 7febaa0..70d5b3d 100644
--- a/Python/dynamic_annotations.c
+++ b/Python/dynamic_annotations.c
@@ -27,7 +27,7 @@
* Author: Kostya Serebryany
*/
-#ifdef _MSC_VER
+#ifdef MS_WINDOWS
# include <windows.h>
#endif
diff --git a/configure.ac b/configure.ac
index 59f2ae0..0b88879 100644
--- a/configure.ac
+++ b/configure.ac
@@ -7336,6 +7336,16 @@ PY_STDLIB_MOD([_ssl], [], [test "$ac_cv_working_openssl_ssl" = yes],
PY_STDLIB_MOD([_hashlib], [], [test "$ac_cv_working_openssl_hashlib" = yes],
[$OPENSSL_INCLUDES], [$OPENSSL_LDFLAGS $OPENSSL_LDFLAGS_RPATH $LIBCRYPTO_LIBS])
+dnl windows specific modules
+PY_STDLIB_MOD([msvcrt], [test "$MACHDEP" = "win32"])
+PY_STDLIB_MOD([_winapi], [test "$MACHDEP" = "win32"])
+PY_STDLIB_MOD([_msi], [test "$MACHDEP" = "win32"], [], [],
+ [-lmsi -lcabinet -lrpcrt4])
+PY_STDLIB_MOD([winsound], [test "$MACHDEP" = "win32"], [], [],
+ [-lwinmm])
+PY_STDLIB_MOD([_overlapped], [test "$MACHDEP" = "win32"], [], [],
+ [-lws2_32])
+
dnl test modules
PY_STDLIB_MOD([_testcapi], [test "$TEST_MODULES" = yes])
PY_STDLIB_MOD([_testclinic], [test "$TEST_MODULES" = yes])
diff --git a/setup.py b/setup.py
index 39535f3..7bcc9d0 100644
--- a/setup.py
+++ b/setup.py
@@ -1286,6 +1286,19 @@ def detect_platform_specific_exts(self):
# macOS-only, needs SystemConfiguration and CoreFoundation framework
self.addext(Extension('_scproxy', ['_scproxy.c']))
+ # Windows-only modules
+ if MS_WINDOWS:
+ srcdir = sysconfig.get_config_var('srcdir')
+ pc_srcdir = os.path.abspath(os.path.join(srcdir, 'PC'))
+
+ self.addext(Extension('_msi',
+ [os.path.join(pc_srcdir, '_msi.c')]))
+
+ self.addext(Extension('winsound',
+ [os.path.join(pc_srcdir, 'winsound.c')]))
+
+ self.addext(Extension('_overlapped', ['overlapped.c']))
+
def detect_compress_exts(self):
# Andrew Kuchling's zlib module.
self.addext(Extension('zlib', ['zlibmodule.c']))