From a1dcbd33c38d71a294d1d480114a06a7f5381f81 Mon Sep 17 00:00:00 2001 From: Naveen M K Date: Tue, 14 Feb 2023 20:40:42 +0530 Subject: [PATCH] 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 ac5ee3600f2b96..7c1d6086776ccc 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 f6bb07fd8b06ef..0dc06cc9d4d3ae 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 +#endif #include "winreparse.h" #if defined(MS_WIN32) && !defined(MS_WIN64) diff --git a/PC/msvcrtmodule.c b/PC/msvcrtmodule.c index 1f78d99c790ff9..0f2da8055f0553 100644 --- a/PC/msvcrtmodule.c +++ b/PC/msvcrtmodule.c @@ -22,7 +22,9 @@ #include #include #include +#ifdef _DEBUG #include +#endif #include #ifdef _MSC_VER diff --git a/Python/dynamic_annotations.c b/Python/dynamic_annotations.c index 7febaa09df1950..70d5b3dc72069c 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 #endif diff --git a/configure.ac b/configure.ac index 297a52905a3b48..5f5fd54b5cb1c4 100644 --- a/configure.ac +++ b/configure.ac @@ -7310,6 +7310,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 39535f37831906..7bcc9d0cd4d621 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']))