From 2d91ba3ef5afca8d7b4f1966586e9f3709297f8e Mon Sep 17 00:00:00 2001 From: Joan Karadimov Date: Tue, 16 Jul 2019 17:15:16 +0300 Subject: [PATCH 1/4] python-pywin32: Fix multiple compilation issues - ignore Windows SDKs installed by Visual Studio - avoid compilation errors via compiler flags - extract min/max patches to a separate file - fix more min/max calls - move module dependency fixes to a separate patch file - add more missing module dependencies - generate static import libraries for pywintypes and pythoncom - remove the python version suffixes from dependencies - update to version 225 --- .../001-compile-and-setup-fixes.patch | 699 +++++------------- mingw-w64-python-pywin32/002-min-max.patch | 193 +++++ .../003-dependency-fixes.patch | 158 ++++ mingw-w64-python-pywin32/PKGBUILD | 26 +- 4 files changed, 554 insertions(+), 522 deletions(-) create mode 100644 mingw-w64-python-pywin32/002-min-max.patch create mode 100644 mingw-w64-python-pywin32/003-dependency-fixes.patch diff --git a/mingw-w64-python-pywin32/001-compile-and-setup-fixes.patch b/mingw-w64-python-pywin32/001-compile-and-setup-fixes.patch index c0411322d74e0..9d29449682628 100644 --- a/mingw-w64-python-pywin32/001-compile-and-setup-fixes.patch +++ b/mingw-w64-python-pywin32/001-compile-and-setup-fixes.patch @@ -1,44 +1,40 @@ diff -aur 000/setup.py 001/setup.py --- 000/setup.py 2015-04-09 21:00:48.725278100 -0300 +++ 001/setup.py 2015-04-09 21:02:02.350399800 -0300 -@@ -224,7 +224,7 @@ - # languishing and will probably never be fixed for Python 2.6... - if sys.version_info > (2,6): - from distutils.spawn import spawn -- from distutils.msvc9compiler import MSVCCompiler -+ from distutils.msvccompiler import MSVCCompiler - MSVCCompiler._orig_spawn = MSVCCompiler.spawn - MSVCCompiler._orig_link = MSVCCompiler.link - -@@ -293,7 +293,7 @@ - MSVCCompiler.link = monkeypatched_link - - --sdk_dir = find_platform_sdk_dir() -+sdk_dir = find_platform_sdk_dir() or '' +@@ -245,16 +245,7 @@ + MSVCCompiler.link = monkeypatched_link + + +-sdk_info = find_platform_sdk_dir() +-if not sdk_info: +- print() +- print("It looks like you are trying to build pywin32 in an environment without") +- print("the necessary tools installed. It's much easier to grab binaries!") +- print() +- print("Please read the docstring at the top of this file, or read README.md") +- print("for more information.") +- print() +- raise RuntimeError("Can't find the Windows SDK") ++sdk_info = { 'include': '', 'lib': '' } class WinExt (Extension): # Base class for all win32 extensions, with some predefined -@@ -304,7 +304,7 @@ - include_dirs=[], - define_macros=None, - undef_macros=None, -- library_dirs=[], -+ library_dirs=['build/lib.mingw-2.7/pywin32_system32'], - libraries="", - runtime_library_dirs=None, - extra_objects=None, -@@ -340,6 +340,9 @@ +@@ -291,11 +282,13 @@ + + extra_link_args = extra_link_args or [] + if export_symbol_file: +- extra_link_args.append("/DEF:" + export_symbol_file) ++ extra_link_args.append(export_symbol_file) + # Some of our swigged files behave differently in distutils vs # MSVC based builds. Always define DISTUTILS_BUILD so they can tell. define_macros = define_macros or [] ++ define_macros.append(("NTDDI_VERSION", 0x06000000)) + define_macros.append(("_WIN32_WINNT", 0x0600)) -+ define_macros.append(("UNICODE", None)) -+ define_macros.append(("_UNICODE", None)) define_macros.append(("DISTUTILS_BUILD", None)) define_macros.append(("_CRT_SECURE_NO_WARNINGS", None)) self.pch_header = pch_header -@@ -691,7 +694,7 @@ +@@ -638,7 +632,7 @@ def finalize_options(self): build_ext.finalize_options(self) @@ -64,9 +60,9 @@ diff -aur 000/setup.py 001/setup.py + if self.mingw32: + self.compiler.shared_lib_extension = '.dll' + - if sdk_dir: - self._fixup_sdk_dirs() - + self._fixup_sdk_dirs() + + # Here we hack a "pywin32" directory (one of 'win32', 'win32com', @@ -1226,7 +1233,7 @@ # XXX This has to be changed for mingw32 # Get the .lib files we need. This is limited to pywintypes, @@ -76,7 +72,7 @@ diff -aur 000/setup.py 001/setup.py if ext.name in ("pywintypes", "pythoncom"): # The import libraries are created as PyWinTypes23.lib, but # are expected to be pywintypes.lib. -@@ -1595,7 +1602,7 @@ +@@ -1551,7 +1549,7 @@ win32/src/win32crypt/PyCRYPTPROV.cpp win32/src/win32crypt/PyCTL_CONTEXT.cpp """), @@ -85,46 +81,20 @@ diff -aur 000/setup.py 001/setup.py win32/src/win32file.i win32/src/win32file_comm.cpp """), -@@ -1652,7 +1659,7 @@ - sources = info[4].split() - extra_compile_args = [] - ext = WinExt_win32(name, -- libraries=lib_names, -+ libraries=(lib_names + ' pywintypes27'), - extra_compile_args = extra_compile_args, - windows_h_version = windows_h_ver, - sources = sources, -@@ -1665,7 +1672,7 @@ - sources = """ - win32\\src\\win32evtlog_messages.mc win32\\src\\win32evtlog.i - """.split(), -- libraries="advapi32 oleaut32", -+ libraries="advapi32 oleaut32 pywintypes27", - delay_load_libraries="wevtapi", - windows_h_version=0x0600 - ), -@@ -1701,7 +1708,7 @@ - # winxptheme - WinExt_win32("_winxptheme", - sources = ["win32/src/_winxptheme.i"], -- libraries="gdi32 user32 comdlg32 comctl32 shell32 Uxtheme", -+ libraries="gdi32 user32 comdlg32 comctl32 shell32 Uxtheme pywintypes27", - windows_h_version=0x0500, - ), - ] +@@ -1813,7 +1813,7 @@ + WinExt_win32com('axscript', + sources=(""" + %(axscript)s/AXScript.cpp +- %(axscript)s/GUIDS.CPP %(axscript)s/PyGActiveScript.cpp ++ %(axscript)s/GUIDS.cpp %(axscript)s/PyGActiveScript.cpp + %(axscript)s/PyGActiveScriptError.cpp %(axscript)s/PyGActiveScriptParse.cpp + %(axscript)s/PyGActiveScriptSite.cpp %(axscript)s/PyGObjectSafety.cpp + %(axscript)s/PyIActiveScript.cpp %(axscript)s/PyIActiveScriptError.cpp diff -aur 000/win32/src/odbc.cpp 001/win32/src/odbc.cpp --- 000/win32/src/odbc.cpp 2015-04-09 21:00:49.053401800 -0300 +++ 001/win32/src/odbc.cpp 2015-04-09 21:02:02.366025800 -0300 -@@ -13,6 +13,7 @@ - #include - #include - #include -+#include - - #include "PyWinTypes.h" - #include "PyWinObjects.h" -@@ -105,8 +106,8 @@ - } +@@ -93,8 +93,8 @@ + static cursorObject *cursor(PyObject *o) { return (cursorObject *)o; } static void cursorDealloc(PyObject *self); -PyMethodDef cursorMethods[]; @@ -132,99 +102,36 @@ diff -aur 000/win32/src/odbc.cpp 001/win32/src/odbc.cpp +extern PyMethodDef cursorMethods[8]; +extern PyMemberDef cursorMembers[3]; - static PyTypeObject Cursor_Type = - { -@@ -152,8 +153,8 @@ - + static PyTypeObject Cursor_Type = { + PYWIN_OBJECT_HEAD "odbccur", /*tp_name */ +@@ -137,8 +137,8 @@ + }; static void connectionDealloc(PyObject *self); -PyMethodDef connectionMethods[]; -PyMemberDef connectionMembers[]; +extern PyMethodDef connectionMethods[6]; +extern PyMemberDef connectionMembers[2]; - static PyTypeObject Connection_Type = - { - PYWIN_OBJECT_HEAD -@@ -458,7 +459,7 @@ - } - - /* @object connection|An object representing an ODBC connection */ --static struct PyMethodDef connectionMethods[] = { -+struct PyMethodDef connectionMethods[] = { - { "setautocommit", odbcSetAutoCommit, 1 }, /* @pymeth setautocommit|Sets the autocommit mode. */ - { "commit", odbcCommit, 1 } , /* @pymeth commit|Commits a transaction. */ - { "rollback", odbcRollback, 1 } , /* @pymeth rollback|Rollsback a transaction. */ -@@ -467,7 +468,7 @@ - {0, 0} - }; - --static PyMemberDef connectionMembers[] = { -+PyMemberDef connectionMembers[] = { - {"error", T_OBJECT, offsetof(connectionObject, connectionError), READONLY}, - {NULL} - }; -@@ -1192,21 +1193,21 @@ - case SQL_DATE: - case SQL_TIMESTAMP: - case SQL_BIT: -- return(max(collen, (int)_tcslen(colname))); -+ return(std::max(collen, (int)_tcslen(colname))); - case SQL_SMALLINT: - case SQL_INTEGER: - case SQL_TINYINT: -- return(max(collen+1, (int)_tcslen(colname))); -+ return(std::max(collen+1, (int)_tcslen(colname))); - case SQL_DECIMAL: - case SQL_NUMERIC: -- return(max(collen+2, (int)_tcslen(colname))); -+ return(std::max(collen+2, (int)_tcslen(colname))); - case SQL_REAL: - case SQL_FLOAT: - case SQL_DOUBLE: -- return(max(20, (int)_tcslen(colname))); -+ return(std::max(20, (int)_tcslen(colname))); - case SQL_BINARY: - case SQL_VARBINARY: -- return(max(2*collen, (int)_tcslen(colname))); -+ return(std::max(2*collen, (int)_tcslen(colname))); - case SQL_LONGVARBINARY: - case SQL_LONGVARCHAR: - default: -@@ -1797,7 +1798,7 @@ - } - - /* @object cursor|An object representing an ODBC cursor. */ --static PyMethodDef cursorMethods[] = { -+PyMethodDef cursorMethods[] = { - { "close", odbcCurClose, 1} , /* @pymeth close|Closes the cursor */ - { "execute", odbcCurExec, 1} , /* @pymeth execute|Execute some SQL */ - { "fetchone", odbcCurFetchOne, 1} , /* @pymeth fetchone|Fetch one row of data */ -@@ -1808,7 +1809,7 @@ - {0, 0} - }; - --static PyMemberDef cursorMembers[] = { -+PyMemberDef cursorMembers[] = { - {"description", T_OBJECT, offsetof(cursorObject, description), READONLY}, - {"error", T_OBJECT, offsetof(cursorObject, cursorError), READONLY}, - {NULL} + static PyTypeObject Connection_Type = { + PYWIN_OBJECT_HEAD "odbcconn", /*tp_name */ + sizeof(connectionObject), /*tp_basicsize */ diff -aur 000/win32/src/PerfMon/perfmondata.cpp 001/win32/src/PerfMon/perfmondata.cpp --- 000/win32/src/PerfMon/perfmondata.cpp 2015-04-09 21:00:48.772153700 -0300 +++ 001/win32/src/PerfMon/perfmondata.cpp 2015-04-09 21:02:02.366025800 -0300 -@@ -89,9 +89,9 @@ +@@ -93,9 +93,9 @@ // these are used to insure that the data collection functions // accessed by Perflib will have the correct calling format. // --PM_OPEN_PROC OpenPerformanceData; --PM_COLLECT_PROC CollectPerformanceData; --PM_CLOSE_PROC ClosePerformanceData; -+extern "C" PM_OPEN_PROC OpenPerformanceData; -+extern "C" PM_COLLECT_PROC CollectPerformanceData; -+extern "C" PM_CLOSE_PROC ClosePerformanceData; +-PM_OPEN_PROC OpenPerformanceData; +-PM_COLLECT_PROC CollectPerformanceData; +-PM_CLOSE_PROC ClosePerformanceData; ++extern "C" PM_OPEN_PROC OpenPerformanceData; ++extern "C" PM_COLLECT_PROC CollectPerformanceData; ++extern "C" PM_CLOSE_PROC ClosePerformanceData; TCHAR szFullModulePath[MAX_PATH]; - TCHAR szModuleName[MAX_PATH]; // will point into the buffer above. -@@ -445,7 +445,7 @@ + TCHAR szModuleName[MAX_PATH]; // will point into the buffer above. +@@ -414,7 +414,7 @@ --*/ { HKEY hAppKey; @@ -232,179 +139,114 @@ diff -aur 000/win32/src/PerfMon/perfmondata.cpp 001/win32/src/PerfMon/perfmondat + TCHAR LogLevelKeyName[] = _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Perflib"); TCHAR LogLevelValueName[] = _T("EventLogLevel"); - LONG lStatus; -diff -aur 000/win32/src/PySECURITY_DESCRIPTOR.cpp 001/win32/src/PySECURITY_DESCRIPTOR.cpp ---- 000/win32/src/PySECURITY_DESCRIPTOR.cpp 2015-04-09 21:00:48.819029400 -0300 -+++ 001/win32/src/PySECURITY_DESCRIPTOR.cpp 2015-04-09 21:01:55.881645000 -0300 -@@ -5,6 +5,7 @@ - #include "PyWinObjects.h" - #include "PySecurityObjects.h" - #include "structmember.h" -+#include - - #ifndef NO_PYWINTYPES_SECURITY - BOOL (WINAPI *setsecuritydescriptorcontrol)(PSECURITY_DESCRIPTOR, SECURITY_DESCRIPTOR_CONTROL, SECURITY_DESCRIPTOR_CONTROL)=NULL; -@@ -786,7 +787,7 @@ - { - ob_type = &PySECURITY_DESCRIPTORType; - _Py_NewReference(this); -- cb = max(cb, SECURITY_DESCRIPTOR_MIN_LENGTH); -+ cb = std::max((long long unsigned int)cb, SECURITY_DESCRIPTOR_MIN_LENGTH); - PSECURITY_DESCRIPTOR psd = malloc(cb); - this->m_psd=NULL; - if (::InitializeSecurityDescriptor(psd, SECURITY_DESCRIPTOR_REVISION)) + LONG lStatus; diff -aur 000/win32/src/PySecurityObjects.h 001/win32/src/PySecurityObjects.h --- 000/win32/src/PySecurityObjects.h 2015-04-09 21:00:48.850278300 -0300 +++ 001/win32/src/PySecurityObjects.h 2015-04-09 21:01:55.881645000 -0300 -@@ -121,7 +121,7 @@ - static PyObject *GetSubAuthorityCount(PyObject *self, PyObject *args); - static PyObject *GetSubAuthority(PyObject *self, PyObject *args); - static PyObject *GetSidIdentifierAuthority(PyObject *self, PyObject *args); -- static struct PyMethodDef PySID::methods[]; -+ static struct PyMethodDef methods[]; - - protected: - PSID m_psid; -@@ -159,7 +159,7 @@ - /* Python support */ - int compare(PyObject *ob); - static void deallocFunc(PyObject *ob); -- static struct PyMethodDef PyACL::methods[]; -+ static struct PyMethodDef methods[]; - - static PyObject *Initialize(PyObject *self, PyObject *args); - static PyObject *IsValid(PyObject *self, PyObject *args); +@@ -118,7 +118,7 @@ + static PyObject *GetSubAuthorityCount(PyObject *self, PyObject *args); + static PyObject *GetSubAuthority(PyObject *self, PyObject *args); + static PyObject *GetSidIdentifierAuthority(PyObject *self, PyObject *args); +- static struct PyMethodDef PySID::methods[]; ++ static struct PyMethodDef methods[]; + + protected: + PSID m_psid; +@@ -155,7 +155,7 @@ + /* Python support */ + int compare(PyObject *ob); + static void deallocFunc(PyObject *ob); +- static struct PyMethodDef PyACL::methods[]; ++ static struct PyMethodDef methods[]; + + static PyObject *Initialize(PyObject *self, PyObject *args); + static PyObject *IsValid(PyObject *self, PyObject *args); diff -aur 000/win32/src/PyWinObjects.h 001/win32/src/PyWinObjects.h --- 000/win32/src/PyWinObjects.h 2015-04-09 21:00:48.881528000 -0300 +++ 001/win32/src/PyWinObjects.h 2015-04-09 21:01:55.881645000 -0300 -@@ -52,7 +52,7 @@ - PyObject *str(); - PyObject *repr(); - int compare(PyObject *ob); -- PyObject *PyTime::richcompare(PyObject *other, int op); -+ PyObject *richcompare(PyObject *other, int op); - - int print(FILE *fp, int flags); - Py_hash_t hash(void); -diff -aur 000/win32/src/PyWinTypes.h 001/win32/src/PyWinTypes.h ---- 000/win32/src/PyWinTypes.h 2015-04-09 21:00:48.944027900 -0300 -+++ 001/win32/src/PyWinTypes.h 2015-04-09 21:02:02.381651500 -0300 -@@ -796,7 +796,7 @@ - - // A helper for simple exception handling. - // try/__try --#ifdef MAINWIN -+#if defined(__MINGW32__) || defined(MAINWIN) - #define PYWINTYPES_TRY try - #else - #define PYWINTYPES_TRY __try +@@ -50,7 +50,7 @@ + PyObject *str(); + PyObject *repr(); + int compare(PyObject *ob); +- PyObject *PyTime::richcompare(PyObject *other, int op); ++ PyObject *richcompare(PyObject *other, int op); + + int print(FILE *fp, int flags); + Py_hash_t hash(void); diff -aur 000/win32/src/PyWinTypesmodule.cpp 001/win32/src/PyWinTypesmodule.cpp --- 000/win32/src/PyWinTypesmodule.cpp 2015-04-09 21:00:48.990903200 -0300 +++ 001/win32/src/PyWinTypesmodule.cpp 2015-04-09 21:01:55.897264900 -0300 -@@ -1139,7 +1139,7 @@ - } - +@@ -1119,7 +1119,7 @@ // Function to format a python traceback into a character string. --#define GPEM_ERROR(what) {errorMsg = "";goto done;} -+#define GPEM_ERROR(what) {errorMsg = "";goto done;} - char *GetPythonTraceback(PyObject *exc_type, PyObject *exc_value, PyObject *exc_tb) - { - // Sleep (30000); // Time enough to attach the debugger (barely) -diff -aur 000/win32/src/win32crypt/PyCRYPTPROV.cpp 001/win32/src/win32crypt/PyCRYPTPROV.cpp ---- 000/win32/src/win32crypt/PyCRYPTPROV.cpp 2015-04-09 21:00:49.100277500 -0300 -+++ 001/win32/src/win32crypt/PyCRYPTPROV.cpp 2015-04-09 21:02:02.381651500 -0300 -@@ -1,4 +1,5 @@ - // @doc -+#include - #include "win32crypt.h" - - // @object PyCRYPTPROV|Handle to a cryptographic provider, created using -@@ -351,7 +352,7 @@ - //initialize buffer with char string if passed if - ZeroMemory(pbBuffer, dwLen+1); - if (seeddata != NULL) -- memcpy(pbBuffer, seeddata, min(dwLen,seedlen)); -+ memcpy(pbBuffer, seeddata, std::min(dwLen,seedlen)); - if (CryptGenRandom(hcryptprov, dwLen, pbBuffer)) - ret=PyString_FromStringAndSize((char *)pbBuffer, dwLen); - else -diff -aur 000/win32/src/win32crypt/win32cryptmodule.cpp 001/win32/src/win32crypt/win32cryptmodule.cpp + #define GPEM_ERROR(what) \ + { \ +- errorMsg = ""; \ ++ errorMsg = ""; \ + goto done; \ + } + PYWINTYPES_EXPORT char *GetPythonTraceback(PyObject *exc_type, PyObject *exc_value, PyObject *exc_tb) --- 000/win32/src/win32crypt/win32cryptmodule.cpp 2015-04-09 21:00:49.194027800 -0300 +++ 001/win32/src/win32crypt/win32cryptmodule.cpp 2015-04-09 21:02:02.397275800 -0300 -@@ -596,44 +596,37 @@ - pvPara=(void *)&cssrp; - } - else{ -- switch((ULONG_PTR)StoreProvider){ -- case CERT_STORE_PROV_PHYSICAL: -- case CERT_STORE_PROV_FILENAME: -- case CERT_STORE_PROV_SYSTEM: -- case CERT_STORE_PROV_SYSTEM_REGISTRY: -- case CERT_STORE_PROV_LDAP:{ -- if (!PyWinObject_AsWCHAR(obpvPara, (WCHAR **)&pvPara)) -- return NULL; -- free_wchar=TRUE; -- break; -- } -- case CERT_STORE_PROV_REG:{ -- if (!PyWinObject_AsHKEY(obpvPara, (HKEY *)&pvPara)) -- return NULL; -- break; -- } -- case CERT_STORE_PROV_FILE:{ -- if (!PyWinObject_AsHANDLE(obpvPara, (HANDLE *)&pvPara)) -- return NULL; -- break; -- } -- case CERT_STORE_PROV_SERIALIZED: -- case CERT_STORE_PROV_PKCS7:{ -- if (!PyWinObject_AsReadBuffer(obpvPara, (void **)&crypt_data_blob.pbData, &crypt_data_blob.cbData)) -- return NULL; -- pvPara=(void *)&crypt_data_blob; -- break; -- } -- case CERT_STORE_PROV_MEMORY:{ -- // pvPara is not used, warn if something passed in -- if (obpvPara != Py_None) -- PyErr_Warn(PyExc_RuntimeWarning, "Para ignored for CERT_STORE_PROV_MEMORY"); -- break; -- } -- default:{ -- PyErr_SetString(PyExc_NotImplementedError,"Specified store provider type not supported"); -+ if (StoreProvider == CERT_STORE_PROV_PHYSICAL || -+ StoreProvider == CERT_STORE_PROV_FILENAME || -+ StoreProvider == CERT_STORE_PROV_SYSTEM || -+ StoreProvider == CERT_STORE_PROV_SYSTEM_REGISTRY || -+ StoreProvider == CERT_STORE_PROV_LDAP){ -+ if (!PyWinObject_AsWCHAR(obpvPara, (WCHAR **)&pvPara)) - return NULL; -- } -+ free_wchar=TRUE; -+ } -+ else if (StoreProvider == CERT_STORE_PROV_REG){ -+ if (!PyWinObject_AsHKEY(obpvPara, (HKEY *)&pvPara)) -+ return NULL; -+ } -+ else if (StoreProvider == CERT_STORE_PROV_FILE){ -+ if (!PyWinObject_AsHANDLE(obpvPara, (HANDLE *)&pvPara)) -+ return NULL; -+ } -+ else if (StoreProvider == CERT_STORE_PROV_SERIALIZED || -+ StoreProvider == CERT_STORE_PROV_PKCS7){ -+ if (!PyWinObject_AsReadBuffer(obpvPara, (void **)&crypt_data_blob.pbData, &crypt_data_blob.cbData)) -+ return NULL; -+ pvPara=(void *)&crypt_data_blob; -+ } -+ else if (StoreProvider == CERT_STORE_PROV_MEMORY){ -+ // pvPara is not used, warn if something passed in -+ if (obpvPara != Py_None) -+ PyErr_Warn(PyExc_RuntimeWarning, "Para ignored for CERT_STORE_PROV_MEMORY"); -+ } -+ else{ -+ PyErr_SetString(PyExc_NotImplementedError,"Specified store provider type not supported"); -+ return NULL; - } - } +@@ -581,44 +581,37 @@ + pvPara = (void *)&cssrp; + } + else { +- switch ((ULONG_PTR)StoreProvider) { +- case CERT_STORE_PROV_PHYSICAL: +- case CERT_STORE_PROV_FILENAME: +- case CERT_STORE_PROV_SYSTEM: +- case CERT_STORE_PROV_SYSTEM_REGISTRY: +- case CERT_STORE_PROV_LDAP: { ++ if (StoreProvider == CERT_STORE_PROV_PHYSICAL || ++ StoreProvider == CERT_STORE_PROV_FILENAME || ++ StoreProvider == CERT_STORE_PROV_SYSTEM || ++ StoreProvider == CERT_STORE_PROV_SYSTEM_REGISTRY || ++ StoreProvider == CERT_STORE_PROV_LDAP) { + if (!PyWinObject_AsWCHAR(obpvPara, (WCHAR **)&pvPara)) + return NULL; + free_wchar = TRUE; +- break; +- } +- case CERT_STORE_PROV_REG: { ++ } ++ else if (StoreProvider == CERT_STORE_PROV_REG) { + if (!PyWinObject_AsHKEY(obpvPara, (HKEY *)&pvPara)) + return NULL; +- break; +- } +- case CERT_STORE_PROV_FILE: { ++ } ++ else if (StoreProvider == CERT_STORE_PROV_FILE) { + if (!PyWinObject_AsHANDLE(obpvPara, (HANDLE *)&pvPara)) + return NULL; +- break; +- } +- case CERT_STORE_PROV_SERIALIZED: +- case CERT_STORE_PROV_PKCS7: { ++ } ++ else if (StoreProvider == CERT_STORE_PROV_SERIALIZED || ++ StoreProvider == CERT_STORE_PROV_PKCS7) { + if (!PyWinObject_AsReadBuffer(obpvPara, (void **)&crypt_data_blob.pbData, &crypt_data_blob.cbData)) + return NULL; + pvPara = (void *)&crypt_data_blob; +- break; +- } +- case CERT_STORE_PROV_MEMORY: { ++ } ++ else if (StoreProvider == CERT_STORE_PROV_MEMORY) { + // pvPara is not used, warn if something passed in + if (obpvPara != Py_None) + PyErr_Warn(PyExc_RuntimeWarning, "Para ignored for CERT_STORE_PROV_MEMORY"); +- break; +- } +- default: { ++ } ++ else { + PyErr_SetString(PyExc_NotImplementedError, "Specified store provider type not supported"); + return NULL; +- } + } + } diff -aur 000/win32/src/win32evtlog.i 001/win32/src/win32evtlog.i --- 000/win32/src/win32evtlog.i 2015-04-09 21:00:49.256528100 -0300 @@ -424,70 +266,49 @@ diff -aur 000/win32/src/win32evtlog.i 001/win32/src/win32evtlog.i PyObject *PyWinObject_FromEVT_VARIANT(PEVT_VARIANT val) { if (val->Type & EVT_VARIANT_TYPE_ARRAY){ -diff -aur 000/win32/src/win32file.i 001/win32/src/win32file.i ---- 000/win32/src/win32file.i 2015-04-09 21:00:49.459654600 -0300 -+++ 001/win32/src/win32file.i 2015-04-09 21:02:02.412900800 -0300 -@@ -1404,11 +1404,11 @@ - // the filename is exactly 1 byte! Not clear the best way to - // check this, but this works for now - is it at least the size of - // the *head* of the struct. -- if (nbytes < sizeof DWORD*3+2) -+ if (nbytes < sizeof(DWORD)*3+2) - return ret; - DWORD nbytes_read = 0; - while (1) { -- PyObject *fname = PyWinObject_FromOLECHAR(p->FileName, p->FileNameLength/sizeof WCHAR); -+ PyObject *fname = PyWinObject_FromOLECHAR(p->FileName, p->FileNameLength/sizeof(WCHAR)); - if (!fname) { - Py_DECREF(ret); - return NULL; diff -aur 000/win32/src/win32file_comm.cpp 001/win32/src/win32file_comm.cpp --- 000/win32/src/win32file_comm.cpp 2015-04-09 21:00:49.490903600 -0300 +++ 001/win32/src/win32file_comm.cpp 2015-04-09 21:02:02.412900800 -0300 -@@ -175,7 +175,7 @@ +@@ -163,7 +163,7 @@ + PyDCB::~PyDCB(void) {} #define GET_BITFIELD_ENTRY(bitfield_name) \ - else if (strcmp(name, #bitfield_name)==0) { \ -- return PyInt_FromLong(pydcb->m_DCB.##bitfield_name); \ -+ return PyInt_FromLong(pydcb->m_DCB.bitfield_name); \ - } \ +- else if (strcmp(name, #bitfield_name) == 0) { return PyInt_FromLong(pydcb->m_DCB.##bitfield_name); } ++ else if (strcmp(name, #bitfield_name) == 0) { return PyInt_FromLong(pydcb->m_DCB.bitfield_name); } PyObject *PyDCB::getattro(PyObject *self, PyObject *obname) -@@ -210,7 +210,7 @@ - PyErr_Format(PyExc_TypeError, szNeedIntAttr, #bitfield_name); \ - return -1; \ - } \ -- pydcb->m_DCB.##bitfield_name = PyInt_AsLong(v); \ -+ pydcb->m_DCB.bitfield_name = PyInt_AsLong(v); \ - return 0; \ - } \ + { +@@ -198,7 +198,7 @@ + PyErr_Format(PyExc_TypeError, szNeedIntAttr, #bitfield_name); \ + return -1; \ + } \ +- pydcb->m_DCB.##bitfield_name = PyInt_AsLong(v); \ ++ pydcb->m_DCB.bitfield_name = PyInt_AsLong(v); \ + return 0; \ + } + +@@ -362,7 +362,7 @@ -@@ -369,7 +369,7 @@ #undef GET_BITFIELD_ENTRY #define GET_BITFIELD_ENTRY(bitfield_name) \ - else if (strcmp(name, #bitfield_name)==0) { \ -- return PyInt_FromLong(pyCOMSTAT->m_COMSTAT.##bitfield_name); \ -+ return PyInt_FromLong(pyCOMSTAT->m_COMSTAT.bitfield_name); \ - } \ +- else if (strcmp(name, #bitfield_name) == 0) { return PyInt_FromLong(pyCOMSTAT->m_COMSTAT.##bitfield_name); } ++ else if (strcmp(name, #bitfield_name) == 0) { return PyInt_FromLong(pyCOMSTAT->m_COMSTAT.bitfield_name); } PyObject *PyCOMSTAT::getattro(PyObject *self, PyObject *obname) -@@ -398,7 +398,7 @@ - PyErr_Format(PyExc_TypeError, szNeedIntAttr, #bitfield_name); \ - return -1; \ - } \ -- pyCOMSTAT->m_COMSTAT.##bitfield_name = PyInt_AsLong(v); \ -+ pyCOMSTAT->m_COMSTAT.bitfield_name = PyInt_AsLong(v); \ - return 0; \ - } \ + { +@@ -391,7 +391,7 @@ + PyErr_Format(PyExc_TypeError, szNeedIntAttr, #bitfield_name); \ + return -1; \ + } \ +- pyCOMSTAT->m_COMSTAT.##bitfield_name = PyInt_AsLong(v); \ ++ pyCOMSTAT->m_COMSTAT.bitfield_name = PyInt_AsLong(v); \ + return 0; \ + } diff -aur 000/win32/src/win32inet.i 001/win32/src/win32inet.i --- 000/win32/src/win32inet.i 2015-04-09 21:00:49.569028200 -0300 +++ 001/win32/src/win32inet.i 2015-04-09 21:02:02.428526500 -0300 -@@ -4,9 +4,26 @@ - %{ - // #define UNICODE - // #define _UNICODE -+#include +@@ -7,6 +7,22 @@ #include "Windows.h" #include "WinInet.h" #undef BOOLAPI // wininet.h defines this! @@ -510,148 +331,18 @@ diff -aur 000/win32/src/win32inet.i 001/win32/src/win32inet.i %} %include "typemaps.i" -@@ -1835,7 +1852,7 @@ - } - } - if (bsuccess && GroupName) -- _tcsncpy(GroupInfo->szGroupName, GroupName, min(namelen, GROUPNAME_MAX_LENGTH)); -+ _tcsncpy(GroupInfo->szGroupName, GroupName, std::min(namelen, GROUPNAME_MAX_LENGTH)); - Py_DECREF(dummy_tuple); - PyWinObject_FreeTCHAR(GroupName); - if (OwnerStorage) -diff -aur 000/win32/src/win32net/win32net.h 001/win32/src/win32net/win32net.h ---- 000/win32/src/win32net/win32net.h 2015-04-09 21:00:49.600278800 -0300 -+++ 001/win32/src/win32net/win32net.h 2015-04-09 21:02:02.428526500 -0300 -@@ -62,15 +62,15 @@ - - #if WINVER >= 0x0500 - typedef NET_API_STATUS (NET_API_FUNCTION *NetValidateNamefunc)(LPCWSTR, LPCWSTR, LPCWSTR, LPCWSTR, NETSETUP_NAME_TYPE); --extern NetValidateNamefunc pfnNetValidateName; -+extern "C" NetValidateNamefunc pfnNetValidateName; - - typedef NET_API_STATUS (NET_API_FUNCTION *NetGetJoinInformationfunc)(LPCWSTR, LPWSTR *, PNETSETUP_JOIN_STATUS); --extern NetGetJoinInformationfunc pfnNetGetJoinInformation; -+extern "C" NetGetJoinInformationfunc pfnNetGetJoinInformation; - - typedef NET_API_STATUS (NET_API_FUNCTION *NetValidatePasswordPolicyfunc)(LPCWSTR, LPVOID, NET_VALIDATE_PASSWORD_TYPE, LPVOID, LPVOID *); --extern NetValidatePasswordPolicyfunc pfnNetValidatePasswordPolicy; -+extern "C" NetValidatePasswordPolicyfunc pfnNetValidatePasswordPolicy; - - typedef NET_API_STATUS (NET_API_FUNCTION *NetValidatePasswordPolicyFreefunc)(LPVOID *); --extern NetValidatePasswordPolicyFreefunc pfnNetValidatePasswordPolicyFree; -+extern "C" NetValidatePasswordPolicyFreefunc pfnNetValidatePasswordPolicyFree; - - #endif // WINVER diff -aur 000/win32/src/win32pdhmodule.cpp 001/win32/src/win32pdhmodule.cpp --- 000/win32/src/win32pdhmodule.cpp 2015-04-09 21:00:49.662779100 -0300 +++ 001/win32/src/win32pdhmodule.cpp 2015-04-09 21:02:02.444150800 -0300 -@@ -11,6 +11,7 @@ - - ******************************************************************/ - -+#include - #include "PyWinTypes.h" - #include "pdh.h" - #include "pdhmsg.h" -@@ -1016,7 +1017,7 @@ - #define SET_BOOL(r, i) { \ - if (i(cchInitialPath+1, 1024); - myCfg.cfg.szReturnPathBuffer = (TCHAR *)malloc(myCfg.cfg.cchReturnPathLength * sizeof(TCHAR)); - if (myCfg.cfg.szReturnPathBuffer == NULL){ - PyErr_NoMemory(); -diff -aur 000/win32/src/win32popen.cpp 001/win32/src/win32popen.cpp ---- 000/win32/src/win32popen.cpp 2015-04-09 21:00:49.709655500 -0300 -+++ 001/win32/src/win32popen.cpp 2015-04-09 21:02:02.444150800 -0300 -@@ -166,19 +166,27 @@ - { - PROCESS_INFORMATION piProcInfo; - STARTUPINFO siStartInfo; -- char *s1,*s2, *s3=" /c "; -+ LPTSTR s1, s2, s3 = TEXT(" /c "); - DWORD i; - size_t x; - -- if (i = GetEnvironmentVariable("COMSPEC",NULL,0)) -+ if (i = GetEnvironmentVariable(TEXT("COMSPEC"),NULL,0)) - { -- s1 = (char *)_alloca(i); -- if (!(x = GetEnvironmentVariable("COMSPEC", s1, i))) -+ s1 = (LPTSTR)_alloca(i); -+ if (!(x = GetEnvironmentVariable(TEXT("COMSPEC"), s1, i))) - return FALSE; -- x = i + strlen(s3) + strlen(cmdstring) + 1; -- s2 = (char *)_alloca(x); -+#ifdef UNICODE -+ size_t cmdlen = strlen(cmdstring); -+ WCHAR _cmdstring[cmdlen + 1]; -+ if (!MultiByteToWideChar(CP_OEMCP, 0, cmdstring, -1, _cmdstring, cmdlen + 1)) -+ return FALSE; -+#else -+ char *_cmdstring = cmdstring; -+#endif -+ x = (i + _tcslen(s3) + _tcslen(_cmdstring) + 1) * sizeof(TCHAR); -+ s2 = (LPTSTR)_alloca(x); - ZeroMemory(s2, x); -- sprintf(s2, "%s%s%s", s1, s3, cmdstring); -+ _stprintf(s2, TEXT("%s%s%s"), s1, s3, _cmdstring); +@@ -1004,7 +1004,7 @@ + { \ + if (i < seqLen) { \ + PyObject *subItem = PyTuple_GET_ITEM(flags_tuple, i); \ +- myCfg.cfg.##r = PyObject_IsTrue(subItem); \ ++ myCfg.cfg.r = PyObject_IsTrue(subItem); \ + } \ } - // Could be an else here to try cmd.exe / command.com in the path - // Now we'll just error out.. -diff -aur 000/win32/src/win32rasmodule.cpp 001/win32/src/win32rasmodule.cpp ---- 000/win32/src/win32rasmodule.cpp 2015-04-09 21:00:49.756528400 -0300 -+++ 001/win32/src/win32rasmodule.cpp 2015-04-09 21:02:02.459777500 -0300 -@@ -463,7 +463,7 @@ - if (obCallback==Py_None) { - pNotification = NULL; - } else if (PyCallable_Check(obCallback)) { -- pNotification = PyRasDialFunc1; -+ pNotification = (LPVOID)PyRasDialFunc1; - notType = 1; - } else if (PyInt_Check(obCallback)) { - if (!PyWinLong_AsVoidPtr(obCallback, &pNotification)) -diff -aur 000/win32/src/win32security.i 001/win32/src/win32security.i ---- 000/win32/src/win32security.i 2015-04-09 21:00:49.912778600 -0300 -+++ 001/win32/src/win32security.i 2015-04-09 21:02:02.459777500 -0300 -@@ -3563,9 +3563,9 @@ - return FALSE; - } - static const BOOL none_ok = TRUE; // NULL seems OK anywhere -- if (!PyWinObject_AsWCHAR(obUser, &pAuthData->User, none_ok, &pAuthData->UserLength) || \ -- !PyWinObject_AsWCHAR(obDomain, &pAuthData->Domain, none_ok, &pAuthData->DomainLength) || \ -- !PyWinObject_AsWCHAR(obPW, &pAuthData->Password, none_ok, &pAuthData->PasswordLength)) { -+ if (!PyWinObject_AsWCHAR(obUser, (WCHAR**)&pAuthData->User, none_ok, &pAuthData->UserLength) || \ -+ !PyWinObject_AsWCHAR(obDomain, (WCHAR**)&pAuthData->Domain, none_ok, &pAuthData->DomainLength) || \ -+ !PyWinObject_AsWCHAR(obPW, (WCHAR**)&pAuthData->Password, none_ok, &pAuthData->PasswordLength)) { - PyErr_Clear(); - PyErr_SetString(PyExc_TypeError, err_msg); - return FALSE; -@@ -3579,11 +3579,11 @@ - if (!pAuthData) - return; - if (pAuthData->User) -- PyWinObject_FreeWCHAR(pAuthData->User); -+ PyWinObject_FreeWCHAR((WCHAR*)pAuthData->User); - if (pAuthData->Domain) -- PyWinObject_FreeWCHAR(pAuthData->Domain); -+ PyWinObject_FreeWCHAR((WCHAR*)pAuthData->Domain); - if (pAuthData->Password) -- PyWinObject_FreeWCHAR(pAuthData->Password); -+ PyWinObject_FreeWCHAR((WCHAR*)pAuthData->Password); - } - %} diff -aur 000/win32/src/win32service.i 001/win32/src/win32service.i --- 000/win32/src/win32service.i 2015-04-09 21:00:49.990904900 -0300 +++ 001/win32/src/win32service.i 2015-04-09 21:02:02.475400700 -0300 @@ -669,23 +360,3 @@ diff -aur 000/win32/src/win32service.i 001/win32/src/win32service.i %} %{ -diff -aur 000/win32/src/win32trace.cpp 001/win32/src/win32trace.cpp ---- 000/win32/src/win32trace.cpp 2015-04-09 21:00:50.022154900 -0300 -+++ 001/win32/src/win32trace.cpp 2015-04-09 21:02:02.475400700 -0300 -@@ -30,6 +30,7 @@ - - */ - -+#include - #include "PyWinTypes.h" - #include "PyWinObjects.h" - -@@ -341,7 +342,7 @@ - Py_BEGIN_ALLOW_THREADS - const char *data_this = data; - while (len) { -- unsigned len_this = min(len, BUFFER_SIZE/2); -+ unsigned len_this = std::min(len, BUFFER_SIZE/2); - BOOL ok = GetMyMutex(); - if (ok) { - // must use types with identical size on win32 and win64 diff --git a/mingw-w64-python-pywin32/002-min-max.patch b/mingw-w64-python-pywin32/002-min-max.patch new file mode 100644 index 0000000000000..0b02b306e1153 --- /dev/null +++ b/mingw-w64-python-pywin32/002-min-max.patch @@ -0,0 +1,193 @@ +diff -aur 000/win32/src/win32crypt/PyCRYPTPROV.cpp 001/win32/src/win32crypt/PyCRYPTPROV.cpp +--- 000/win32/src/win32crypt/PyCRYPTPROV.cpp 2015-04-09 21:00:49.100277500 -0300 ++++ 001/win32/src/win32crypt/PyCRYPTPROV.cpp 2015-04-09 21:02:02.381651500 -0300 +@@ -351,7 +352,7 @@ + // initialize buffer with char string if passed if + ZeroMemory(pbBuffer, dwLen + 1); + if (seeddata != NULL) +- memcpy(pbBuffer, seeddata, min(dwLen, seedlen)); ++ memcpy(pbBuffer, seeddata, __min(dwLen, seedlen)); + if (CryptGenRandom(hcryptprov, dwLen, pbBuffer)) + ret = PyString_FromStringAndSize((char *)pbBuffer, dwLen); + else +diff -aur 000/win32/src/PySECURITY_DESCRIPTOR.cpp 001/win32/src/PySECURITY_DESCRIPTOR.cpp +--- 000/win32/src/PySECURITY_DESCRIPTOR.cpp 2015-04-09 21:00:48.819029400 -0300 ++++ 001/win32/src/PySECURITY_DESCRIPTOR.cpp 2015-04-09 21:01:55.881645000 -0300 +@@ -786,7 +787,7 @@ + { + ob_type = &PySECURITY_DESCRIPTORType; + _Py_NewReference(this); +- cb = max(cb, SECURITY_DESCRIPTOR_MIN_LENGTH); ++ cb = __max(cb, SECURITY_DESCRIPTOR_MIN_LENGTH); + PSECURITY_DESCRIPTOR psd = malloc(cb); + this->m_psd=NULL; + if (::InitializeSecurityDescriptor(psd, SECURITY_DESCRIPTOR_REVISION)) +diff -aur 000/win32/src/win32gui.i 001/win32/src/win32gui.i +--- 000/win32/src/win32gui.i 2019-07-26 15:14:57.295569500 +0300 ++++ 001/win32/src/win32gui.i 2019-07-26 15:15:11.562304200 +0300 +@@ -3802,7 +3802,7 @@ + nicons_got = 1; + #endif + // Asking for 1 always says it got 2!? +- nicons = min(nicons, nicons_got); ++ nicons = __min(nicons, nicons_got); + objects_large = PyList_New(nicons); + if (!objects_large) goto done; + objects_small = PyList_New(nicons); +@@ -6370,7 +6370,7 @@ + // lpstrFile buffer receives full path and possibly multiple file names, allocate extra space + if (!PyWinObject_AsWCHAR(obFile, &initfile, TRUE, &initfilechars)) + goto done; +- pofn->nMaxFile=max(pofn->nMaxFile, initfilechars+1); ++ pofn->nMaxFile=__max(pofn->nMaxFile, initfilechars+1); + bufsize=pofn->nMaxFile*sizeof(WCHAR); + pofn->lpstrFile=(LPWSTR)malloc(bufsize); + if (pofn->lpstrFile==NULL){ +diff -aur 000/win32/src/win32inet.i 001/win32/src/win32inet.i +--- 000/win32/src/win32inet.i 2015-04-09 21:00:49.569028200 -0300 ++++ 001/win32/src/win32inet.i 2015-04-09 21:02:02.428526500 -0300 +@@ -1851,7 +1851,7 @@ + } + } + if (bsuccess && GroupName) +- _tcsncpy(GroupInfo->szGroupName, GroupName, min(namelen, GROUPNAME_MAX_LENGTH)); ++ _tcsncpy(GroupInfo->szGroupName, GroupName, __min(namelen, GROUPNAME_MAX_LENGTH)); + Py_DECREF(dummy_tuple); + PyWinObject_FreeTCHAR(GroupName); + if (OwnerStorage) +diff -aur 000/win32/src/win32pdhmodule.cpp 001/win32/src/win32pdhmodule.cpp +--- 000/win32/src/win32pdhmodule.cpp 2015-04-09 21:00:49.662779100 -0300 ++++ 001/win32/src/win32pdhmodule.cpp 2015-04-09 21:02:02.444150800 -0300 +@@ -1082,7 +1083,7 @@ + // Initialize the return buffer if starting path is passed in. (bInitializePath will also be set) + if (!PyWinObject_AsTCHAR(obInitialPath, &InitialPath, TRUE, &cchInitialPath)) + return NULL; // Last exit without cleanup +- myCfg.cfg.cchReturnPathLength = max(cchInitialPath + 1, 1024); ++ myCfg.cfg.cchReturnPathLength = __max(cchInitialPath + 1, 1024); + myCfg.cfg.szReturnPathBuffer = (TCHAR *)malloc(myCfg.cfg.cchReturnPathLength * sizeof(TCHAR)); + if (myCfg.cfg.szReturnPathBuffer == NULL) { + PyErr_NoMemory(); +diff -aur 000/win32/src/win32trace.cpp 001/win32/src/win32trace.cpp +--- 000/win32/src/win32trace.cpp 2015-04-09 21:00:50.022154900 -0300 ++++ 001/win32/src/win32trace.cpp 2015-04-09 21:02:02.475400700 -0300 +@@ -315,7 +315,7 @@ + BOOL rc = TRUE; + Py_BEGIN_ALLOW_THREADS const char *data_this = data; + while (len) { +- unsigned len_this = min(len, BUFFER_SIZE / 2); ++ unsigned len_this = __min(len, BUFFER_SIZE / 2); + BOOL ok = GetMyMutex(); + if (ok) { + // must use types with identical size on win32 and win64 +--- 000/com/win32com/src/PyGatewayBase.cpp 2019-07-26 01:25:33.000000000 +0300 ++++ 001/com/win32com/src/PyGatewayBase.cpp 2019-07-27 11:50:36.216356200 +0300 +@@ -382,7 +382,7 @@ + // make sure its not a special DISPID we don't understand. + if (params->rgdispidNamedArgs[i] < 0) + return DISP_E_PARAMNOTFOUND; +- numArgs = max(numArgs, (UINT)params->rgdispidNamedArgs[i] + 1); ++ numArgs = __max(numArgs, (UINT)params->rgdispidNamedArgs[i] + 1); + } + + PyObject *argList = PyTuple_New(numArgs); +@@ -597,7 +597,7 @@ + ob = NULL; + firstByRef = 1; + } +- UINT max_args = min(cUserResult - firstByRef, pDispParams->cArgs); ++ UINT max_args = __min(cUserResult - firstByRef, pDispParams->cArgs); + UINT *offsets = (UINT *)_malloca(sizeof(UINT) * max_args); + // Get the offsets into our params of all BYREF args, in order. + fill_byref_offsets(pDispParams, offsets, max_args); +--- 000/com/win32comext/axcontrol/src/PyIOleCommandTarget.cpp 2019-07-26 01:25:33.000000000 +0300 ++++ 001/com/win32comext/axcontrol/src/PyIOleCommandTarget.cpp 2019-07-27 12:24:16.667134100 +0300 +@@ -205,7 +205,7 @@ + ok = PyWinObject_AsAutoFreeBstr(obText, &tempString); + if (ok) { + UINT strLen = SysStringLen(tempString); +- UINT nwrite = min(strLen, pCmdText->cwBuf); ++ UINT nwrite = __min(strLen, pCmdText->cwBuf); + wcsncpy(pCmdText->rgwz, (WCHAR *)(BSTR)tempString, nwrite); + pCmdText->cwActual = nwrite; + } +diff -aur 000/win32/src/odbc.cpp 001/win32/src/odbc.cpp +--- 000/win32/src/odbc.cpp 2015-04-09 21:00:49.053401800 -0300 ++++ 001/win32/src/odbc.cpp 2015-04-09 21:02:02.366025800 -0300 +@@ -958,21 +958,21 @@ + case SQL_DATE: + case SQL_TIMESTAMP: + case SQL_BIT: +- return (max(collen, (int)_tcslen(colname))); ++ return (__max(collen, (int)_tcslen(colname))); + case SQL_SMALLINT: + case SQL_INTEGER: + case SQL_TINYINT: +- return (max(collen + 1, (int)_tcslen(colname))); ++ return (__max(collen + 1, (int)_tcslen(colname))); + case SQL_DECIMAL: + case SQL_NUMERIC: +- return (max(collen + 2, (int)_tcslen(colname))); ++ return (__max(collen + 2, (int)_tcslen(colname))); + case SQL_REAL: + case SQL_FLOAT: + case SQL_DOUBLE: +- return (max(20, (int)_tcslen(colname))); ++ return (__max(20, (int)_tcslen(colname))); + case SQL_BINARY: + case SQL_VARBINARY: +- return (max(2 * collen, (int)_tcslen(colname))); ++ return (__max(2 * collen, (int)_tcslen(colname))); + case SQL_LONGVARBINARY: + case SQL_LONGVARCHAR: + default: +--- 000/com/win32comext/internet/src/PyIInternetProtocol.cpp 2019-07-26 01:25:33.000000000 +0300 ++++ 001/com/win32comext/internet/src/PyIInternetProtocol.cpp 2019-07-27 15:30:10.810253700 +0300 +@@ -178,7 +178,7 @@ + } + else { + char *buf = PyString_AsString(result); +- *pcbRead = min(cb, (ULONG)PyString_Size(result)); ++ *pcbRead = __min(cb, (ULONG)PyString_Size(result)); + memcpy(pv, buf, *pcbRead); + } + return hr; +--- 000/com/win32comext/internet/src/PyIInternetProtocolInfo.cpp 2019-07-26 01:25:33.000000000 +0300 ++++ 001/com/win32comext/internet/src/PyIInternetProtocolInfo.cpp 2019-07-27 15:31:50.481163500 +0300 +@@ -233,7 +233,7 @@ + if (!bPythonIsHappy) + return PyCom_HandlePythonFailureToCOM(/*pexcepinfo*/); + ++(*pcchResult); // Null terminator +- *pcchResult = min(*pcchResult, cchResult); ++ *pcchResult = __min(*pcchResult, cchResult); + memcpy(pwzResult, bstrTemp, *pcchResult * sizeof(WCHAR)); + SysFreeString(bstrTemp); + Py_DECREF(result); +@@ -269,7 +269,7 @@ + if (!bPythonIsHappy) + hr = PyCom_HandlePythonFailureToCOM(/*pexcepinfo*/); + ++(*pcchResult); // Null terminator +- *pcchResult = min(*pcchResult, cchResult); ++ *pcchResult = __min(*pcchResult, cchResult); + memcpy(pwzResult, bstrTemp, *pcchResult * sizeof(WCHAR)); + SysFreeString(bstrTemp); + Py_DECREF(result); +@@ -332,7 +332,7 @@ + } + } + else { +- *pcbBuf = min(cbBuffer, (ULONG)PyString_Size(result)); ++ *pcbBuf = __min(cbBuffer, (ULONG)PyString_Size(result)); + memcpy(pBuffer, PyString_AsString(result), *pcbBuf); + } + Py_DECREF(result); +--- 000/com/win32comext/internet/src/PyIInternetSecurityManager.cpp 2019-07-26 01:25:33.000000000 +0300 ++++ 001/com/win32comext/internet/src/PyIInternetSecurityManager.cpp 2019-07-27 15:33:21.876845300 +0300 +@@ -336,7 +336,7 @@ + Py_DECREF(result); + return MAKE_PYCOM_GATEWAY_FAILURE_CODE("GetSecurityId"); + } +- *pcbSecurityId = min(buf_len, *pcbSecurityId); ++ *pcbSecurityId = __min(buf_len, *pcbSecurityId); + memcpy(pbSecurityId, buf, *pcbSecurityId); + Py_DECREF(result); + return hr; diff --git a/mingw-w64-python-pywin32/003-dependency-fixes.patch b/mingw-w64-python-pywin32/003-dependency-fixes.patch new file mode 100644 index 0000000000000..dd326d8906752 --- /dev/null +++ b/mingw-w64-python-pywin32/003-dependency-fixes.patch @@ -0,0 +1,158 @@ +diff -aur 000/setup.py 001/setup.py +--- 000/setup.py 2015-04-09 21:00:48.725278100 -0300 ++++ 001/setup.py 2015-04-09 21:02:02.350399800 -0300 +@@ -1500,6 +1504,10 @@ + "win32/src/PySecurityObjects.h", + ], + extra_compile_args = ['-DBUILD_PYWINTYPES'], ++ extra_link_args = ['-Wl,--out-implib,build/temp.mingw-%d.%d/libpywintypes.dll.a' % ( ++ sys.version_info.major, ++ sys.version_info.minor, ++ )], + libraries = "advapi32 user32 ole32 oleaut32", + pch_header = "PyWinTypes.h", + ) +@@ -1608,7 +1606,7 @@ + sources = info[4].split() + extra_compile_args = [] + ext = WinExt_win32(name, +- libraries=lib_names, ++ libraries=(lib_names + ' pywintypes'), + extra_compile_args = extra_compile_args, + windows_h_version = windows_h_ver, + sources = sources, +@@ -1621,7 +1619,7 @@ + sources = """ + win32\\src\\win32evtlog_messages.mc win32\\src\\win32evtlog.i + """.split(), +- libraries="advapi32 oleaut32", ++ libraries="advapi32 oleaut32 pywintypes", + delay_load_libraries="wevtapi", + windows_h_version=0x0600 + ), +@@ -1629,7 +1627,7 @@ + sources = """ + win32/src/win32apimodule.cpp win32/src/win32api_display.cpp + """.split(), +- libraries="user32 advapi32 shell32 version", ++ libraries="user32 advapi32 shell32 version pywintypes", + delay_load_libraries="powrprof", + windows_h_version=0x0500, + ), +@@ -1637,7 +1637,7 @@ + win32/src/win32gui.i + """.split(), + windows_h_version=0x0500, +- libraries="gdi32 user32 comdlg32 comctl32 shell32", ++ libraries="gdi32 user32 comdlg32 comctl32 shell32 pywintypes", + define_macros = [("WIN32GUI", None)], + ), + # winxpgui is built from win32gui.i, but sets up different #defines before +@@ -1649,7 +1647,7 @@ + win32/src/winxpgui.rc win32/src/win32dynamicdialog.cpp + win32/src/win32gui.i + """.split(), +- libraries="gdi32 user32 comdlg32 comctl32 shell32", ++ libraries="gdi32 user32 comdlg32 comctl32 shell32 pywintypes", + windows_h_version=0x0500, + define_macros = [("WIN32GUI",None), ("WINXPGUI",None)], + extra_swig_commands=["-DWINXPGUI"], +@@ -1657,7 +1655,7 @@ + # winxptheme + WinExt_win32("_winxptheme", + sources = ["win32/src/_winxptheme.i"], +- libraries="gdi32 user32 comdlg32 comctl32 shell32 Uxtheme", ++ libraries="gdi32 user32 comdlg32 comctl32 shell32 Uxtheme pywintypes", + windows_h_version=0x0500, + ), + ] +@@ -1665,7 +1663,7 @@ + WinExt_win32('servicemanager', + sources = ["win32/src/PythonServiceMessages.mc", "win32/src/PythonService.cpp"], + extra_compile_args = ['-DPYSERVICE_BUILD_DLL'], +- libraries = "user32 ole32 advapi32 shell32", ++ libraries = "user32 ole32 advapi32 shell32 pywintypes", + windows_h_version = 0x500, + unicode_mode=True,), + ] +@@ -1764,9 +1762,13 @@ + %(win32com)s/include\\PyIEnumContextProps.h %(win32com)s/include\\PyIClientSecurity.h + %(win32com)s/include\\PyIServerSecurity.h + """ % dirs).split(), +- libraries = "oleaut32 ole32 user32 urlmon", +- export_symbol_file = 'com/win32com/src/PythonCOM.def', ++ libraries = "oleaut32 ole32 user32 urlmon uuid pywintypes", ++ # export_symbol_file = 'com/win32com/src/PythonCOM.def', + extra_compile_args = ['-DBUILD_PYTHONCOM'], ++ extra_link_args = ['-Wl,--out-implib,build/temp.mingw-%d.%d/libpythoncom.dll.a' % ( ++ sys.version_info.major, ++ sys.version_info.minor, ++ )], + pch_header = "stdafx.h", + windows_h_version = 0x500, + base_address = dll_base_address, +@@ -1788,7 +1786,7 @@ + %(adsi)s/PyADSIUtil.cpp %(adsi)s/PyDSOPObjects.cpp + %(adsi)s/PyIADs.cpp + """ % dirs).split()), +- WinExt_win32com('axcontrol', pch_header="axcontrol_pch.h", ++ WinExt_win32com('axcontrol', pch_header="axcontrol_pch.h", libraries = "uuid pywintypes pythoncom", + sources=(""" + %(axcontrol)s/AXControl.cpp + %(axcontrol)s/PyIOleControl.cpp %(axcontrol)s/PyIOleControlSite.cpp +@@ -1800,7 +1800,7 @@ + %(axcontrol)s/PyIOleObject.cpp %(axcontrol)s/PyIViewObject2.cpp + %(axcontrol)s/PyIOleCommandTarget.cpp + """ % dirs).split()), +- WinExt_win32com('axscript', ++ WinExt_win32com('axscript', libraries = "uuid pywintypes pythoncom", + sources=(""" + %(axscript)s/AXScript.cpp + %(axscript)s/GUIDS.cpp %(axscript)s/PyGActiveScript.cpp +@@ -1873,7 +1871,7 @@ + %(axdebug)s/stdafx.cpp + """ % dirs).split(), + ), +- WinExt_win32com('internet', pch_header="internet_pch.h", ++ WinExt_win32com('internet', pch_header="internet_pch.h", libraries = "uuid pywintypes pythoncom", + sources=(""" + %(internet)s/internet.cpp %(internet)s/PyIDocHostUIHandler.cpp + %(internet)s/PyIHTMLOMWindowServices.cpp %(internet)s/PyIInternetBindInfo.cpp +@@ -1930,7 +1928,7 @@ + %(mapi)s/mapi_stub_library/MapiStubLibrary.cpp + %(mapi)s/mapi_stub_library/StubUtils.cpp + """ % dirs).split()), +- WinExt_win32com('shell', libraries='shell32', pch_header="shell_pch.h", ++ WinExt_win32com('shell', libraries='shell32 uuid pywintypes pythoncom', pch_header="shell_pch.h", + windows_h_version = 0x600, + sources=(""" + %(shell)s/PyIActiveDesktop.cpp +@@ -2033,7 +2031,7 @@ + ), + + +- WinExt_win32com('taskscheduler', libraries='mstask', ++ WinExt_win32com('taskscheduler', libraries='mstask uuid pywintypes pythoncom', + sources=(""" + %(taskscheduler)s/taskscheduler.cpp + %(taskscheduler)s/PyIProvideTaskPage.cpp +@@ -2078,8 +2076,8 @@ + %(directsound)s/PyIDirectSoundCaptureBuffer.h %(directsound)s/PyIDirectSoundNotify.h + """ % dirs).split(), + optional_headers = ['dsound.h'], +- libraries='user32 dsound dxguid'), +- WinExt_win32com('authorization', libraries='aclui advapi32', ++ libraries='user32 dsound dxguid uuid pywintypes pythoncom'), ++ WinExt_win32com('authorization', libraries='aclui advapi32 pywintypes pythoncom', + sources=(""" + %(authorization)s/authorization.cpp + %(authorization)s/PyGSecurityInformation.cpp +@@ -2273,7 +2273,7 @@ + sources=[os.path.join("win32", "src", s) for s in + "PythonService.cpp PythonService.rc".split()], + unicode_mode = True, +- libraries = "user32 advapi32 ole32 shell32"), ++ libraries = "user32 advapi32 ole32 shell32 pywintypes"), + WinExt_pythonwin_subsys_win("Pythonwin", + sources = [ + "Pythonwin/pythonwin.cpp", diff --git a/mingw-w64-python-pywin32/PKGBUILD b/mingw-w64-python-pywin32/PKGBUILD index ae50c9bdad0e1..c5465c5b22dbc 100644 --- a/mingw-w64-python-pywin32/PKGBUILD +++ b/mingw-w64-python-pywin32/PKGBUILD @@ -1,4 +1,5 @@ # Maintainer: Ray Donnelly +# Maintainer: Joan Karadimov # Contributor: Renato Silva _realname='pywin32' @@ -7,26 +8,35 @@ pkgdesc='Python for Windows Extensions (mingw-w64)' license=('PSF') arch=('any') mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64') -pkgver=219 +pkgver=225 pkgrel=1 -makedepends=(${MINGW_PACKAGE_PREFIX}-python2 ${MINGW_PACKAGE_PREFIX}-python3 rsync) +makedepends=(${MINGW_PACKAGE_PREFIX}-python2 ${MINGW_PACKAGE_PREFIX}-python2-setuptools + ${MINGW_PACKAGE_PREFIX}-python3 ${MINGW_PACKAGE_PREFIX}-python3-setuptools + rsync) pkgbase=mingw-w64-python-${_realname} pkgname=(${MINGW_PACKAGE_PREFIX}-python2-${_realname} ${MINGW_PACKAGE_PREFIX}-python3-${_realname}) -source=("https://prdownloads.sourceforge.net/${_realname}/${_realname}-${pkgver}.zip" - 001-compile-and-setup-fixes.patch) -sha256sums=('30c3dbcd45d0c126ad9102d4bbcdeb6b9846869d0b1721faa4f8c9b563ccdb49' - '6968c607e1768fd2a78aa5aa8bf7238606638aec81e8844f840eabcf2a6da092') +source=("https://github.com/mhammond/${_realname}/archive/b${pkgver}.zip" + 001-compile-and-setup-fixes.patch + 002-min-max.patch + 003-dependency-fixes.patch) +sha256sums=('4fe036b83caf8cfb1fcbf6cf98b82a11ab1e41d2b652121d0a4395b5e9deeb46' + '071b119512ee06ea9008b96f83f6a38fdbcd55266758e169da64340861f29c3b' + '0dc953883a2917f1eddb93f1615db9749b5f758664ec539a4bf2a96f11087524' + '0013d3bb9b10511f28e5e71fa59b0431445a5cfc5ae7950e33251af14a087f5f') prepare() { - cd "${srcdir}/${_realname}-${pkgver}" + cd "${srcdir}/${_realname}-b${pkgver}" patch -p1 < "${startdir}"/001-compile-and-setup-fixes.patch + patch -p1 < "${startdir}"/002-min-max.patch + patch -p1 < "${startdir}"/003-dependency-fixes.patch } build() { for _python in python2 python3; do msg2 "Synchronizing ${_python} build directory" - rsync --recursive --times "${srcdir}/${_realname}-${pkgver}"/* "${srcdir}/build-${_python}-${CARCH}-${_realname}-${pkgver}" + rsync --recursive --times "${srcdir}/${_realname}-b${pkgver}"/* "${srcdir}/build-${_python}-${CARCH}-${_realname}-${pkgver}" cd "${srcdir}/build-${_python}-${CARCH}-${_realname}-${pkgver}" + CFLAGS="-Wno-narrowing -fno-operator-names -fpermissive" \ LIB="${MINGW_PREFIX}/lib:${MINGW_PREFIX}/${CARCH}-w64-mingw32/lib" \ INCLUDE="${MINGW_PREFIX}/include:${MINGW_PREFIX}/${CARCH}-w64-mingw32/include" \ ${MINGW_PREFIX}/bin/${_python} setup.py build --compiler=mingw32 From 266b4488a6630aef4947012a4483dc77ddd647b2 Mon Sep 17 00:00:00 2001 From: Joan Karadimov Date: Sun, 10 Nov 2019 22:51:30 +0200 Subject: [PATCH 2/4] python-pywin32: Handle SEH try-except blocks --- mingw-w64-python-pywin32/004-seh.patch | 45 ++++++++++++++++++++ mingw-w64-python-pywin32/PKGBUILD | 11 +++-- mingw-w64-python-pywin32/seh.h | 59 ++++++++++++++++++++++++++ 3 files changed, 112 insertions(+), 3 deletions(-) create mode 100644 mingw-w64-python-pywin32/004-seh.patch create mode 100644 mingw-w64-python-pywin32/seh.h diff --git a/mingw-w64-python-pywin32/004-seh.patch b/mingw-w64-python-pywin32/004-seh.patch new file mode 100644 index 0000000000000..043293aa5d81f --- /dev/null +++ b/mingw-w64-python-pywin32/004-seh.patch @@ -0,0 +1,45 @@ +--- 000/win32/src/win32apimodule.cpp 2019-07-18 09:05:08.224088200 +0300 ++++ 001/win32/src/win32apimodule.cpp 2018-09-28 09:32:03.000000000 +0300 +@@ -706,7 +706,7 @@ static PyObject *PyFindCloseChangeNotification(PyObject *self, PyObject *args) + } + + // @pymethod string|win32api|FormatMessage|Returns an error message from the system error file. +-static PyObject *PyFormatMessageA(PyObject *self, PyObject *args) ++__attribute__((optimize("O0"), noinline)) static PyObject *PyFormatMessageA(PyObject *self, PyObject *args) + { + int errCode = 0; + // @pyparm int|errCode|0|The error code to return the message for, If this value is 0, then GetLastError() is +@@ -788,6 +798,7 @@ static PyObject *PyFormatMessageA(PyObject *self, PyObject *args) + { + baccessviolation = TRUE; + } ++ __except_end + PyW32_END_ALLOW_THREADS + } + +@@ -820,7 +831,7 @@ cleanup: + } + + // @pymethod |win32api|FormatMessageW|Returns an error message from the system error file. +-static PyObject *PyFormatMessageW(PyObject *self, PyObject *args) ++__attribute__((optimize("O0"), noinline)) static PyObject *PyFormatMessageW(PyObject *self, PyObject *args) + { + int errCode = 0; + // Accept just the error code +@@ -902,6 +913,7 @@ static PyObject *PyFormatMessageW(PyObject *self, PyObject *args) + { + baccessviolation = TRUE; + } ++ __except_end + PyW32_END_ALLOW_THREADS + } + +@@ -5554,7 +5554,7 @@ static PyObject *PyApply(PyObject *self, PyObject *args) + Py_XDECREF(exc_type); + Py_XDECREF(exc_value); + ret = NULL; +- } ++ } __except_end + return ret; + // @comm Calls the specified function in a manner similar to + // the built-in function apply(), but allows Win32 exceptions diff --git a/mingw-w64-python-pywin32/PKGBUILD b/mingw-w64-python-pywin32/PKGBUILD index c5465c5b22dbc..00f8c3bb097ed 100644 --- a/mingw-w64-python-pywin32/PKGBUILD +++ b/mingw-w64-python-pywin32/PKGBUILD @@ -16,19 +16,24 @@ makedepends=(${MINGW_PACKAGE_PREFIX}-python2 ${MINGW_PACKAGE_PREFIX}-python2-set pkgbase=mingw-w64-python-${_realname} pkgname=(${MINGW_PACKAGE_PREFIX}-python2-${_realname} ${MINGW_PACKAGE_PREFIX}-python3-${_realname}) source=("https://github.com/mhammond/${_realname}/archive/b${pkgver}.zip" + seh.h 001-compile-and-setup-fixes.patch 002-min-max.patch - 003-dependency-fixes.patch) + 003-dependency-fixes.patch + 004-seh.patch) sha256sums=('4fe036b83caf8cfb1fcbf6cf98b82a11ab1e41d2b652121d0a4395b5e9deeb46' + '03f8c0372059bb5b1933d77309101c67fa08504b42a6fce1186ed9a29e0c271f' '071b119512ee06ea9008b96f83f6a38fdbcd55266758e169da64340861f29c3b' '0dc953883a2917f1eddb93f1615db9749b5f758664ec539a4bf2a96f11087524' - '0013d3bb9b10511f28e5e71fa59b0431445a5cfc5ae7950e33251af14a087f5f') + '0013d3bb9b10511f28e5e71fa59b0431445a5cfc5ae7950e33251af14a087f5f' + '726ab045a127c98bd431f6840a7f63042668e61fa5d22834af4e5f8a2ea4cf70') prepare() { cd "${srcdir}/${_realname}-b${pkgver}" patch -p1 < "${startdir}"/001-compile-and-setup-fixes.patch patch -p1 < "${startdir}"/002-min-max.patch patch -p1 < "${startdir}"/003-dependency-fixes.patch + patch -p1 < "${startdir}"/004-seh.patch } build() { @@ -36,7 +41,7 @@ build() { msg2 "Synchronizing ${_python} build directory" rsync --recursive --times "${srcdir}/${_realname}-b${pkgver}"/* "${srcdir}/build-${_python}-${CARCH}-${_realname}-${pkgver}" cd "${srcdir}/build-${_python}-${CARCH}-${_realname}-${pkgver}" - CFLAGS="-Wno-narrowing -fno-operator-names -fpermissive" \ + CFLAGS="-Wno-narrowing -fno-operator-names -fpermissive -include ../seh.h -DCRYPT_DECRYPT_MESSAGE_PARA_HAS_EXTRA_FIELDS" \ LIB="${MINGW_PREFIX}/lib:${MINGW_PREFIX}/${CARCH}-w64-mingw32/lib" \ INCLUDE="${MINGW_PREFIX}/include:${MINGW_PREFIX}/${CARCH}-w64-mingw32/include" \ ${MINGW_PREFIX}/bin/${_python} setup.py build --compiler=mingw32 diff --git a/mingw-w64-python-pywin32/seh.h b/mingw-w64-python-pywin32/seh.h new file mode 100644 index 0000000000000..b2570face9b52 --- /dev/null +++ b/mingw-w64-python-pywin32/seh.h @@ -0,0 +1,59 @@ +#include + +#define __try \ +{ \ + __label__ l_start, l_end, l_handler, l_setup_handler, l_seh_end; \ + goto l_setup_handler; \ + l_start: + +// TODO: implement for x86 32 bit + +#if defined(__x86_64) + +#define __except(filter) \ + goto l_seh_end; \ + l_handler: \ + { \ + EXCEPTION_POINTERS *ep; \ + __asm__ __volatile__( \ + "movq %%rcx, %0\n\t" \ + "push %%rbp\n\t" \ + "push %%rdi" : "=r"(ep) :: "%rcx"); \ + auto er = ep->ExceptionRecord; \ + auto _exception_code = [er] { return er->ExceptionCode; }; \ + auto _exception_info = [er] { return er->ExceptionInformation; }; \ + long result = (filter); \ + __asm__ __volatile__( \ + "mov %[result], %%eax\n\t" \ + "pop %%rdi\n\t" \ + "pop %%rbp\n\t" \ + "ret" :: [result] "r"(result) : "%eax"); \ + } \ + l_setup_handler: \ + __asm__ __volatile__ goto( \ + ".seh_handler __C_specific_handler, @except\n\t" \ + ".seh_handlerdata\n\t" \ + ".long 1\n\t" \ + ".rva %l[l_start], %l[l_end], %l[l_handler], %l[l_end]\n\t" \ + ".text" :::: l_start, l_end, l_handler); \ + goto l_start; \ + l_end: + +#else + +#define __except(filter) \ + goto l_seh_end; \ + l_handler: \ + l_setup_handler: \ + goto l_start; \ + l_end: + +#endif + +#define __except_end l_seh_end: ; \ +} + +#define __leave goto l_seh_end + +#define _try __try +#define _except __except From d3bf624dad60f157df2b79eb7996801b3741fbb0 Mon Sep 17 00:00:00 2001 From: Joan Karadimov Date: Sat, 20 Jun 2020 14:25:30 +0300 Subject: [PATCH 3/4] python-pywin32: Fix more compilation errors - update to 228 - drop Python 2 support - fix some MAPI compilation problems - simplfy the patch file for dependencies - drop the patch file for min/max - disable some modules --- .../001-compile-and-setup-fixes.patch | 66 +++++- .../002-dependency-fixes.patch | 56 +++++ mingw-w64-python-pywin32/002-min-max.patch | 193 ------------------ .../003-dependency-fixes.patch | 158 -------------- .../{004-seh.patch => 003-seh.patch} | 49 ++++- .../004-disable-modules.patch | 89 ++++++++ mingw-w64-python-pywin32/PKGBUILD | 61 +++--- mingw-w64-python-pywin32/minmax.h | 2 + mingw-w64-python-pywin32/setup.cfg | 2 + 9 files changed, 285 insertions(+), 391 deletions(-) create mode 100644 mingw-w64-python-pywin32/002-dependency-fixes.patch delete mode 100644 mingw-w64-python-pywin32/002-min-max.patch delete mode 100644 mingw-w64-python-pywin32/003-dependency-fixes.patch rename mingw-w64-python-pywin32/{004-seh.patch => 003-seh.patch} (51%) create mode 100644 mingw-w64-python-pywin32/004-disable-modules.patch create mode 100644 mingw-w64-python-pywin32/minmax.h create mode 100644 mingw-w64-python-pywin32/setup.cfg diff --git a/mingw-w64-python-pywin32/001-compile-and-setup-fixes.patch b/mingw-w64-python-pywin32/001-compile-and-setup-fixes.patch index 9d29449682628..af17650f64a18 100644 --- a/mingw-w64-python-pywin32/001-compile-and-setup-fixes.patch +++ b/mingw-w64-python-pywin32/001-compile-and-setup-fixes.patch @@ -1,7 +1,7 @@ diff -aur 000/setup.py 001/setup.py --- 000/setup.py 2015-04-09 21:00:48.725278100 -0300 +++ 001/setup.py 2015-04-09 21:02:02.350399800 -0300 -@@ -245,16 +245,7 @@ +@@ -264,16 +264,7 @@ MSVCCompiler.link = monkeypatched_link @@ -19,7 +19,7 @@ diff -aur 000/setup.py 001/setup.py class WinExt (Extension): # Base class for all win32 extensions, with some predefined -@@ -291,11 +282,13 @@ +@@ -305,11 +296,20 @@ extra_link_args = extra_link_args or [] if export_symbol_file: @@ -31,6 +31,13 @@ diff -aur 000/setup.py 001/setup.py define_macros = define_macros or [] + define_macros.append(("NTDDI_VERSION", 0x06000000)) + define_macros.append(("_WIN32_WINNT", 0x0600)) ++ define_macros.append(("USE_COM_CONTEXT_DEF", None)) ++ define_macros.append(("NO_PYCOM_IDISPATCHEX", None)) ++ define_macros.append(("__in", "")) ++ define_macros.append(("__in_opt", "")) ++ define_macros.append(("__out", "")) ++ define_macros.append(("__deref_out_ecount_full(x)", "")) ++ define_macros.append(("_Check_return_", "")) define_macros.append(("DISTUTILS_BUILD", None)) define_macros.append(("_CRT_SECURE_NO_WARNINGS", None)) self.pch_header = pch_header @@ -164,7 +171,7 @@ diff -aur 000/win32/src/PySecurityObjects.h 001/win32/src/PySecurityObjects.h diff -aur 000/win32/src/PyWinObjects.h 001/win32/src/PyWinObjects.h --- 000/win32/src/PyWinObjects.h 2015-04-09 21:00:48.881528000 -0300 +++ 001/win32/src/PyWinObjects.h 2015-04-09 21:01:55.881645000 -0300 -@@ -50,7 +50,7 @@ +@@ -49,7 +49,7 @@ PyObject *str(); PyObject *repr(); int compare(PyObject *ob); @@ -251,7 +258,7 @@ diff -aur 000/win32/src/PyWinTypesmodule.cpp 001/win32/src/PyWinTypesmodule.cpp diff -aur 000/win32/src/win32evtlog.i 001/win32/src/win32evtlog.i --- 000/win32/src/win32evtlog.i 2015-04-09 21:00:49.256528100 -0300 +++ 001/win32/src/win32evtlog.i 2015-04-09 21:02:02.397275800 -0300 -@@ -997,6 +997,14 @@ +@@ -1206,6 +1206,14 @@ } PyCFunction pfnPyEvtUpdateBookmark = (PyCFunction) PyEvtUpdateBookmark; @@ -263,9 +270,9 @@ diff -aur 000/win32/src/win32evtlog.i 001/win32/src/win32evtlog.i +#define EVT_VARIANT_TYPE_MASK 0x7F +#endif + - PyObject *PyWinObject_FromEVT_VARIANT(PEVT_VARIANT val) + PyObject *PyList_FromEVT_VARIANTArray(PEVT_VARIANT val) { - if (val->Type & EVT_VARIANT_TYPE_ARRAY){ + if ((val->Type & EVT_VARIANT_TYPE_ARRAY) == 0) { diff -aur 000/win32/src/win32file_comm.cpp 001/win32/src/win32file_comm.cpp --- 000/win32/src/win32file_comm.cpp 2015-04-09 21:00:49.490903600 -0300 +++ 001/win32/src/win32file_comm.cpp 2015-04-09 21:02:02.412900800 -0300 @@ -334,7 +341,7 @@ diff -aur 000/win32/src/win32inet.i 001/win32/src/win32inet.i diff -aur 000/win32/src/win32pdhmodule.cpp 001/win32/src/win32pdhmodule.cpp --- 000/win32/src/win32pdhmodule.cpp 2015-04-09 21:00:49.662779100 -0300 +++ 001/win32/src/win32pdhmodule.cpp 2015-04-09 21:02:02.444150800 -0300 -@@ -1004,7 +1004,7 @@ +@@ -1005,7 +1005,7 @@ { \ if (i < seqLen) { \ PyObject *subItem = PyTuple_GET_ITEM(flags_tuple, i); \ @@ -360,3 +367,48 @@ diff -aur 000/win32/src/win32service.i 001/win32/src/win32service.i %} %{ +--- 000/com/win32comext/mapi/src/mapi_headers/mapidefs.h 2020-06-13 08:39:03.000000000 +0300 ++++ 001/com/win32comext/mapi/src/mapi_headers/mapidefs.h 2020-06-19 16:10:51.180079900 +0300 +@@ -2728,5 +2728,4 @@ + #endif + + #endif /* MAPIDEFS_H */ +- + +--- 000/com/win32comext/mapi/src/mapi_headers/MAPICode.h 2020-06-13 08:39:03.000000000 +0300 ++++ 001/com/win32comext/mapi/src/mapi_headers/MAPICode.h 2020-06-19 16:11:57.872096400 +0300 +@@ -216,5 +216,4 @@ + #endif + + #endif /* MAPICODE_H */ +- + +--- 000/com/win32comext/mapi/src/mapi_headers/MSPST.h 2020-06-13 08:39:03.000000000 +0300 ++++ 001/com/win32comext/mapi/src/mapi_headers/MSPST.h 2020-06-19 16:12:52.572096500 +0300 +@@ -97,5 +97,4 @@ + 0xd9, 0x6e, 0x00, 0x00 } + + #endif /* _MSPST_H_ */ +- + +--- 000/com/win32comext/mapi/src/mapi_headers/MAPIForm.h 2020-06-13 08:39:03.000000000 +0300 ++++ 001/com/win32comext/mapi/src/mapi_headers/MAPIForm.h 2020-06-20 13:20:38.548390500 +0300 +@@ -631,5 +631,4 @@ + + #endif /* MAPIFORM_H */ + +- + +--- 000/com/win32comext/mapi/src/PyIMAPIAdviseSink.cpp 2020-06-13 08:39:03.000000000 +0300 ++++ 001/com/win32comext/mapi/src/PyIMAPIAdviseSink.cpp 2020-06-20 13:17:46.660390600 +0300 +@@ -6,6 +6,10 @@ + #include "PyMAPIUtil.h" + #include "PyIMAPIAdviseSink.h" + ++#ifdef __MINGW32__ ++#define __FUNCSIG__ __PRETTY_FUNCTION__ ++#endif ++ + // @doc - This file contains autoduck documentation + // --------------------------------------------------- + // diff --git a/mingw-w64-python-pywin32/002-dependency-fixes.patch b/mingw-w64-python-pywin32/002-dependency-fixes.patch new file mode 100644 index 0000000000000..e9a9eac66e48e --- /dev/null +++ b/mingw-w64-python-pywin32/002-dependency-fixes.patch @@ -0,0 +1,56 @@ +diff -aur 000/setup.py 001/setup.py +--- 000/setup.py 2015-04-09 21:00:48.725278100 -0300 ++++ 001/setup.py 2015-04-09 21:02:02.350399800 -0300 +@@ -100,7 +100,7 @@ + + # some modules need a static CRT to avoid problems caused by them having a + # manifest. +-static_crt_modules = ["winxpgui"] ++static_crt_modules = [] + + + from distutils.dep_util import newer_group +@@ -476,6 +476,7 @@ + + class WinExt_win32(WinExt): + def __init__ (self, name, **kw): ++ kw["libraries"] = kw.get("libraries", "") + " oleaut32 ole32 pywintypes" + WinExt.__init__(self, name, **kw) + def get_pywin32_dir(self): + return "win32" +@@ -499,7 +500,7 @@ + # itself - thus, output is "win32comext" + class WinExt_win32com(WinExt): + def __init__ (self, name, **kw): +- kw["libraries"] = kw.get("libraries", "") + " oleaut32 ole32" ++ kw["libraries"] = kw.get("libraries", "") + " oleaut32 ole32 uuid pywintypes pythoncom" + + # COM extensions require later windows headers. + if not kw.get("windows_h_version"): +@@ -1500,6 +1504,10 @@ + "win32/src/PySecurityObjects.h", + ], + extra_compile_args = ['-DBUILD_PYWINTYPES'], ++ extra_link_args = ['-Wl,--out-implib,build/temp.mingw-%d.%d/libpywintypes.dll.a' % ( ++ sys.version_info.major, ++ sys.version_info.minor, ++ )], + libraries = "advapi32 user32 ole32 oleaut32", + pch_header = "PyWinTypes.h", + ) +@@ -1764,9 +1762,13 @@ + %(win32com)s/include\\PyIEnumContextProps.h %(win32com)s/include\\PyIClientSecurity.h + %(win32com)s/include\\PyIServerSecurity.h + """ % dirs).split(), +- libraries = "oleaut32 ole32 user32 urlmon", +- export_symbol_file = 'com/win32com/src/PythonCOM.def', ++ libraries = "oleaut32 ole32 user32 urlmon uuid pywintypes", ++ # export_symbol_file = 'com/win32com/src/PythonCOM.def', + extra_compile_args = ['-DBUILD_PYTHONCOM'], ++ extra_link_args = ['-Wl,--out-implib,build/temp.mingw-%d.%d/libpythoncom.dll.a' % ( ++ sys.version_info.major, ++ sys.version_info.minor, ++ )], + pch_header = "stdafx.h", + windows_h_version = 0x500, + base_address = dll_base_address, diff --git a/mingw-w64-python-pywin32/002-min-max.patch b/mingw-w64-python-pywin32/002-min-max.patch deleted file mode 100644 index 0b02b306e1153..0000000000000 --- a/mingw-w64-python-pywin32/002-min-max.patch +++ /dev/null @@ -1,193 +0,0 @@ -diff -aur 000/win32/src/win32crypt/PyCRYPTPROV.cpp 001/win32/src/win32crypt/PyCRYPTPROV.cpp ---- 000/win32/src/win32crypt/PyCRYPTPROV.cpp 2015-04-09 21:00:49.100277500 -0300 -+++ 001/win32/src/win32crypt/PyCRYPTPROV.cpp 2015-04-09 21:02:02.381651500 -0300 -@@ -351,7 +352,7 @@ - // initialize buffer with char string if passed if - ZeroMemory(pbBuffer, dwLen + 1); - if (seeddata != NULL) -- memcpy(pbBuffer, seeddata, min(dwLen, seedlen)); -+ memcpy(pbBuffer, seeddata, __min(dwLen, seedlen)); - if (CryptGenRandom(hcryptprov, dwLen, pbBuffer)) - ret = PyString_FromStringAndSize((char *)pbBuffer, dwLen); - else -diff -aur 000/win32/src/PySECURITY_DESCRIPTOR.cpp 001/win32/src/PySECURITY_DESCRIPTOR.cpp ---- 000/win32/src/PySECURITY_DESCRIPTOR.cpp 2015-04-09 21:00:48.819029400 -0300 -+++ 001/win32/src/PySECURITY_DESCRIPTOR.cpp 2015-04-09 21:01:55.881645000 -0300 -@@ -786,7 +787,7 @@ - { - ob_type = &PySECURITY_DESCRIPTORType; - _Py_NewReference(this); -- cb = max(cb, SECURITY_DESCRIPTOR_MIN_LENGTH); -+ cb = __max(cb, SECURITY_DESCRIPTOR_MIN_LENGTH); - PSECURITY_DESCRIPTOR psd = malloc(cb); - this->m_psd=NULL; - if (::InitializeSecurityDescriptor(psd, SECURITY_DESCRIPTOR_REVISION)) -diff -aur 000/win32/src/win32gui.i 001/win32/src/win32gui.i ---- 000/win32/src/win32gui.i 2019-07-26 15:14:57.295569500 +0300 -+++ 001/win32/src/win32gui.i 2019-07-26 15:15:11.562304200 +0300 -@@ -3802,7 +3802,7 @@ - nicons_got = 1; - #endif - // Asking for 1 always says it got 2!? -- nicons = min(nicons, nicons_got); -+ nicons = __min(nicons, nicons_got); - objects_large = PyList_New(nicons); - if (!objects_large) goto done; - objects_small = PyList_New(nicons); -@@ -6370,7 +6370,7 @@ - // lpstrFile buffer receives full path and possibly multiple file names, allocate extra space - if (!PyWinObject_AsWCHAR(obFile, &initfile, TRUE, &initfilechars)) - goto done; -- pofn->nMaxFile=max(pofn->nMaxFile, initfilechars+1); -+ pofn->nMaxFile=__max(pofn->nMaxFile, initfilechars+1); - bufsize=pofn->nMaxFile*sizeof(WCHAR); - pofn->lpstrFile=(LPWSTR)malloc(bufsize); - if (pofn->lpstrFile==NULL){ -diff -aur 000/win32/src/win32inet.i 001/win32/src/win32inet.i ---- 000/win32/src/win32inet.i 2015-04-09 21:00:49.569028200 -0300 -+++ 001/win32/src/win32inet.i 2015-04-09 21:02:02.428526500 -0300 -@@ -1851,7 +1851,7 @@ - } - } - if (bsuccess && GroupName) -- _tcsncpy(GroupInfo->szGroupName, GroupName, min(namelen, GROUPNAME_MAX_LENGTH)); -+ _tcsncpy(GroupInfo->szGroupName, GroupName, __min(namelen, GROUPNAME_MAX_LENGTH)); - Py_DECREF(dummy_tuple); - PyWinObject_FreeTCHAR(GroupName); - if (OwnerStorage) -diff -aur 000/win32/src/win32pdhmodule.cpp 001/win32/src/win32pdhmodule.cpp ---- 000/win32/src/win32pdhmodule.cpp 2015-04-09 21:00:49.662779100 -0300 -+++ 001/win32/src/win32pdhmodule.cpp 2015-04-09 21:02:02.444150800 -0300 -@@ -1082,7 +1083,7 @@ - // Initialize the return buffer if starting path is passed in. (bInitializePath will also be set) - if (!PyWinObject_AsTCHAR(obInitialPath, &InitialPath, TRUE, &cchInitialPath)) - return NULL; // Last exit without cleanup -- myCfg.cfg.cchReturnPathLength = max(cchInitialPath + 1, 1024); -+ myCfg.cfg.cchReturnPathLength = __max(cchInitialPath + 1, 1024); - myCfg.cfg.szReturnPathBuffer = (TCHAR *)malloc(myCfg.cfg.cchReturnPathLength * sizeof(TCHAR)); - if (myCfg.cfg.szReturnPathBuffer == NULL) { - PyErr_NoMemory(); -diff -aur 000/win32/src/win32trace.cpp 001/win32/src/win32trace.cpp ---- 000/win32/src/win32trace.cpp 2015-04-09 21:00:50.022154900 -0300 -+++ 001/win32/src/win32trace.cpp 2015-04-09 21:02:02.475400700 -0300 -@@ -315,7 +315,7 @@ - BOOL rc = TRUE; - Py_BEGIN_ALLOW_THREADS const char *data_this = data; - while (len) { -- unsigned len_this = min(len, BUFFER_SIZE / 2); -+ unsigned len_this = __min(len, BUFFER_SIZE / 2); - BOOL ok = GetMyMutex(); - if (ok) { - // must use types with identical size on win32 and win64 ---- 000/com/win32com/src/PyGatewayBase.cpp 2019-07-26 01:25:33.000000000 +0300 -+++ 001/com/win32com/src/PyGatewayBase.cpp 2019-07-27 11:50:36.216356200 +0300 -@@ -382,7 +382,7 @@ - // make sure its not a special DISPID we don't understand. - if (params->rgdispidNamedArgs[i] < 0) - return DISP_E_PARAMNOTFOUND; -- numArgs = max(numArgs, (UINT)params->rgdispidNamedArgs[i] + 1); -+ numArgs = __max(numArgs, (UINT)params->rgdispidNamedArgs[i] + 1); - } - - PyObject *argList = PyTuple_New(numArgs); -@@ -597,7 +597,7 @@ - ob = NULL; - firstByRef = 1; - } -- UINT max_args = min(cUserResult - firstByRef, pDispParams->cArgs); -+ UINT max_args = __min(cUserResult - firstByRef, pDispParams->cArgs); - UINT *offsets = (UINT *)_malloca(sizeof(UINT) * max_args); - // Get the offsets into our params of all BYREF args, in order. - fill_byref_offsets(pDispParams, offsets, max_args); ---- 000/com/win32comext/axcontrol/src/PyIOleCommandTarget.cpp 2019-07-26 01:25:33.000000000 +0300 -+++ 001/com/win32comext/axcontrol/src/PyIOleCommandTarget.cpp 2019-07-27 12:24:16.667134100 +0300 -@@ -205,7 +205,7 @@ - ok = PyWinObject_AsAutoFreeBstr(obText, &tempString); - if (ok) { - UINT strLen = SysStringLen(tempString); -- UINT nwrite = min(strLen, pCmdText->cwBuf); -+ UINT nwrite = __min(strLen, pCmdText->cwBuf); - wcsncpy(pCmdText->rgwz, (WCHAR *)(BSTR)tempString, nwrite); - pCmdText->cwActual = nwrite; - } -diff -aur 000/win32/src/odbc.cpp 001/win32/src/odbc.cpp ---- 000/win32/src/odbc.cpp 2015-04-09 21:00:49.053401800 -0300 -+++ 001/win32/src/odbc.cpp 2015-04-09 21:02:02.366025800 -0300 -@@ -958,21 +958,21 @@ - case SQL_DATE: - case SQL_TIMESTAMP: - case SQL_BIT: -- return (max(collen, (int)_tcslen(colname))); -+ return (__max(collen, (int)_tcslen(colname))); - case SQL_SMALLINT: - case SQL_INTEGER: - case SQL_TINYINT: -- return (max(collen + 1, (int)_tcslen(colname))); -+ return (__max(collen + 1, (int)_tcslen(colname))); - case SQL_DECIMAL: - case SQL_NUMERIC: -- return (max(collen + 2, (int)_tcslen(colname))); -+ return (__max(collen + 2, (int)_tcslen(colname))); - case SQL_REAL: - case SQL_FLOAT: - case SQL_DOUBLE: -- return (max(20, (int)_tcslen(colname))); -+ return (__max(20, (int)_tcslen(colname))); - case SQL_BINARY: - case SQL_VARBINARY: -- return (max(2 * collen, (int)_tcslen(colname))); -+ return (__max(2 * collen, (int)_tcslen(colname))); - case SQL_LONGVARBINARY: - case SQL_LONGVARCHAR: - default: ---- 000/com/win32comext/internet/src/PyIInternetProtocol.cpp 2019-07-26 01:25:33.000000000 +0300 -+++ 001/com/win32comext/internet/src/PyIInternetProtocol.cpp 2019-07-27 15:30:10.810253700 +0300 -@@ -178,7 +178,7 @@ - } - else { - char *buf = PyString_AsString(result); -- *pcbRead = min(cb, (ULONG)PyString_Size(result)); -+ *pcbRead = __min(cb, (ULONG)PyString_Size(result)); - memcpy(pv, buf, *pcbRead); - } - return hr; ---- 000/com/win32comext/internet/src/PyIInternetProtocolInfo.cpp 2019-07-26 01:25:33.000000000 +0300 -+++ 001/com/win32comext/internet/src/PyIInternetProtocolInfo.cpp 2019-07-27 15:31:50.481163500 +0300 -@@ -233,7 +233,7 @@ - if (!bPythonIsHappy) - return PyCom_HandlePythonFailureToCOM(/*pexcepinfo*/); - ++(*pcchResult); // Null terminator -- *pcchResult = min(*pcchResult, cchResult); -+ *pcchResult = __min(*pcchResult, cchResult); - memcpy(pwzResult, bstrTemp, *pcchResult * sizeof(WCHAR)); - SysFreeString(bstrTemp); - Py_DECREF(result); -@@ -269,7 +269,7 @@ - if (!bPythonIsHappy) - hr = PyCom_HandlePythonFailureToCOM(/*pexcepinfo*/); - ++(*pcchResult); // Null terminator -- *pcchResult = min(*pcchResult, cchResult); -+ *pcchResult = __min(*pcchResult, cchResult); - memcpy(pwzResult, bstrTemp, *pcchResult * sizeof(WCHAR)); - SysFreeString(bstrTemp); - Py_DECREF(result); -@@ -332,7 +332,7 @@ - } - } - else { -- *pcbBuf = min(cbBuffer, (ULONG)PyString_Size(result)); -+ *pcbBuf = __min(cbBuffer, (ULONG)PyString_Size(result)); - memcpy(pBuffer, PyString_AsString(result), *pcbBuf); - } - Py_DECREF(result); ---- 000/com/win32comext/internet/src/PyIInternetSecurityManager.cpp 2019-07-26 01:25:33.000000000 +0300 -+++ 001/com/win32comext/internet/src/PyIInternetSecurityManager.cpp 2019-07-27 15:33:21.876845300 +0300 -@@ -336,7 +336,7 @@ - Py_DECREF(result); - return MAKE_PYCOM_GATEWAY_FAILURE_CODE("GetSecurityId"); - } -- *pcbSecurityId = min(buf_len, *pcbSecurityId); -+ *pcbSecurityId = __min(buf_len, *pcbSecurityId); - memcpy(pbSecurityId, buf, *pcbSecurityId); - Py_DECREF(result); - return hr; diff --git a/mingw-w64-python-pywin32/003-dependency-fixes.patch b/mingw-w64-python-pywin32/003-dependency-fixes.patch deleted file mode 100644 index dd326d8906752..0000000000000 --- a/mingw-w64-python-pywin32/003-dependency-fixes.patch +++ /dev/null @@ -1,158 +0,0 @@ -diff -aur 000/setup.py 001/setup.py ---- 000/setup.py 2015-04-09 21:00:48.725278100 -0300 -+++ 001/setup.py 2015-04-09 21:02:02.350399800 -0300 -@@ -1500,6 +1504,10 @@ - "win32/src/PySecurityObjects.h", - ], - extra_compile_args = ['-DBUILD_PYWINTYPES'], -+ extra_link_args = ['-Wl,--out-implib,build/temp.mingw-%d.%d/libpywintypes.dll.a' % ( -+ sys.version_info.major, -+ sys.version_info.minor, -+ )], - libraries = "advapi32 user32 ole32 oleaut32", - pch_header = "PyWinTypes.h", - ) -@@ -1608,7 +1606,7 @@ - sources = info[4].split() - extra_compile_args = [] - ext = WinExt_win32(name, -- libraries=lib_names, -+ libraries=(lib_names + ' pywintypes'), - extra_compile_args = extra_compile_args, - windows_h_version = windows_h_ver, - sources = sources, -@@ -1621,7 +1619,7 @@ - sources = """ - win32\\src\\win32evtlog_messages.mc win32\\src\\win32evtlog.i - """.split(), -- libraries="advapi32 oleaut32", -+ libraries="advapi32 oleaut32 pywintypes", - delay_load_libraries="wevtapi", - windows_h_version=0x0600 - ), -@@ -1629,7 +1627,7 @@ - sources = """ - win32/src/win32apimodule.cpp win32/src/win32api_display.cpp - """.split(), -- libraries="user32 advapi32 shell32 version", -+ libraries="user32 advapi32 shell32 version pywintypes", - delay_load_libraries="powrprof", - windows_h_version=0x0500, - ), -@@ -1637,7 +1637,7 @@ - win32/src/win32gui.i - """.split(), - windows_h_version=0x0500, -- libraries="gdi32 user32 comdlg32 comctl32 shell32", -+ libraries="gdi32 user32 comdlg32 comctl32 shell32 pywintypes", - define_macros = [("WIN32GUI", None)], - ), - # winxpgui is built from win32gui.i, but sets up different #defines before -@@ -1649,7 +1647,7 @@ - win32/src/winxpgui.rc win32/src/win32dynamicdialog.cpp - win32/src/win32gui.i - """.split(), -- libraries="gdi32 user32 comdlg32 comctl32 shell32", -+ libraries="gdi32 user32 comdlg32 comctl32 shell32 pywintypes", - windows_h_version=0x0500, - define_macros = [("WIN32GUI",None), ("WINXPGUI",None)], - extra_swig_commands=["-DWINXPGUI"], -@@ -1657,7 +1655,7 @@ - # winxptheme - WinExt_win32("_winxptheme", - sources = ["win32/src/_winxptheme.i"], -- libraries="gdi32 user32 comdlg32 comctl32 shell32 Uxtheme", -+ libraries="gdi32 user32 comdlg32 comctl32 shell32 Uxtheme pywintypes", - windows_h_version=0x0500, - ), - ] -@@ -1665,7 +1663,7 @@ - WinExt_win32('servicemanager', - sources = ["win32/src/PythonServiceMessages.mc", "win32/src/PythonService.cpp"], - extra_compile_args = ['-DPYSERVICE_BUILD_DLL'], -- libraries = "user32 ole32 advapi32 shell32", -+ libraries = "user32 ole32 advapi32 shell32 pywintypes", - windows_h_version = 0x500, - unicode_mode=True,), - ] -@@ -1764,9 +1762,13 @@ - %(win32com)s/include\\PyIEnumContextProps.h %(win32com)s/include\\PyIClientSecurity.h - %(win32com)s/include\\PyIServerSecurity.h - """ % dirs).split(), -- libraries = "oleaut32 ole32 user32 urlmon", -- export_symbol_file = 'com/win32com/src/PythonCOM.def', -+ libraries = "oleaut32 ole32 user32 urlmon uuid pywintypes", -+ # export_symbol_file = 'com/win32com/src/PythonCOM.def', - extra_compile_args = ['-DBUILD_PYTHONCOM'], -+ extra_link_args = ['-Wl,--out-implib,build/temp.mingw-%d.%d/libpythoncom.dll.a' % ( -+ sys.version_info.major, -+ sys.version_info.minor, -+ )], - pch_header = "stdafx.h", - windows_h_version = 0x500, - base_address = dll_base_address, -@@ -1788,7 +1786,7 @@ - %(adsi)s/PyADSIUtil.cpp %(adsi)s/PyDSOPObjects.cpp - %(adsi)s/PyIADs.cpp - """ % dirs).split()), -- WinExt_win32com('axcontrol', pch_header="axcontrol_pch.h", -+ WinExt_win32com('axcontrol', pch_header="axcontrol_pch.h", libraries = "uuid pywintypes pythoncom", - sources=(""" - %(axcontrol)s/AXControl.cpp - %(axcontrol)s/PyIOleControl.cpp %(axcontrol)s/PyIOleControlSite.cpp -@@ -1800,7 +1800,7 @@ - %(axcontrol)s/PyIOleObject.cpp %(axcontrol)s/PyIViewObject2.cpp - %(axcontrol)s/PyIOleCommandTarget.cpp - """ % dirs).split()), -- WinExt_win32com('axscript', -+ WinExt_win32com('axscript', libraries = "uuid pywintypes pythoncom", - sources=(""" - %(axscript)s/AXScript.cpp - %(axscript)s/GUIDS.cpp %(axscript)s/PyGActiveScript.cpp -@@ -1873,7 +1871,7 @@ - %(axdebug)s/stdafx.cpp - """ % dirs).split(), - ), -- WinExt_win32com('internet', pch_header="internet_pch.h", -+ WinExt_win32com('internet', pch_header="internet_pch.h", libraries = "uuid pywintypes pythoncom", - sources=(""" - %(internet)s/internet.cpp %(internet)s/PyIDocHostUIHandler.cpp - %(internet)s/PyIHTMLOMWindowServices.cpp %(internet)s/PyIInternetBindInfo.cpp -@@ -1930,7 +1928,7 @@ - %(mapi)s/mapi_stub_library/MapiStubLibrary.cpp - %(mapi)s/mapi_stub_library/StubUtils.cpp - """ % dirs).split()), -- WinExt_win32com('shell', libraries='shell32', pch_header="shell_pch.h", -+ WinExt_win32com('shell', libraries='shell32 uuid pywintypes pythoncom', pch_header="shell_pch.h", - windows_h_version = 0x600, - sources=(""" - %(shell)s/PyIActiveDesktop.cpp -@@ -2033,7 +2031,7 @@ - ), - - -- WinExt_win32com('taskscheduler', libraries='mstask', -+ WinExt_win32com('taskscheduler', libraries='mstask uuid pywintypes pythoncom', - sources=(""" - %(taskscheduler)s/taskscheduler.cpp - %(taskscheduler)s/PyIProvideTaskPage.cpp -@@ -2078,8 +2076,8 @@ - %(directsound)s/PyIDirectSoundCaptureBuffer.h %(directsound)s/PyIDirectSoundNotify.h - """ % dirs).split(), - optional_headers = ['dsound.h'], -- libraries='user32 dsound dxguid'), -- WinExt_win32com('authorization', libraries='aclui advapi32', -+ libraries='user32 dsound dxguid uuid pywintypes pythoncom'), -+ WinExt_win32com('authorization', libraries='aclui advapi32 pywintypes pythoncom', - sources=(""" - %(authorization)s/authorization.cpp - %(authorization)s/PyGSecurityInformation.cpp -@@ -2273,7 +2273,7 @@ - sources=[os.path.join("win32", "src", s) for s in - "PythonService.cpp PythonService.rc".split()], - unicode_mode = True, -- libraries = "user32 advapi32 ole32 shell32"), -+ libraries = "user32 advapi32 ole32 shell32 pywintypes"), - WinExt_pythonwin_subsys_win("Pythonwin", - sources = [ - "Pythonwin/pythonwin.cpp", diff --git a/mingw-w64-python-pywin32/004-seh.patch b/mingw-w64-python-pywin32/003-seh.patch similarity index 51% rename from mingw-w64-python-pywin32/004-seh.patch rename to mingw-w64-python-pywin32/003-seh.patch index 043293aa5d81f..eb0cdfdf703f9 100644 --- a/mingw-w64-python-pywin32/004-seh.patch +++ b/mingw-w64-python-pywin32/003-seh.patch @@ -1,6 +1,6 @@ --- 000/win32/src/win32apimodule.cpp 2019-07-18 09:05:08.224088200 +0300 +++ 001/win32/src/win32apimodule.cpp 2018-09-28 09:32:03.000000000 +0300 -@@ -706,7 +706,7 @@ static PyObject *PyFindCloseChangeNotification(PyObject *self, PyObject *args) +@@ -707,7 +707,7 @@ static PyObject *PyFindCloseChangeNotification(PyObject *self, PyObject *args) } // @pymethod string|win32api|FormatMessage|Returns an error message from the system error file. @@ -9,7 +9,7 @@ { int errCode = 0; // @pyparm int|errCode|0|The error code to return the message for, If this value is 0, then GetLastError() is -@@ -788,6 +798,7 @@ static PyObject *PyFormatMessageA(PyObject *self, PyObject *args) +@@ -795,6 +795,7 @@ static PyObject *PyFormatMessageA(PyObject *self, PyObject *args) { baccessviolation = TRUE; } @@ -17,7 +17,7 @@ PyW32_END_ALLOW_THREADS } -@@ -820,7 +831,7 @@ cleanup: +@@ -819,7 +818,7 @@ cleanup: } // @pymethod |win32api|FormatMessageW|Returns an error message from the system error file. @@ -34,7 +34,7 @@ PyW32_END_ALLOW_THREADS } -@@ -5554,7 +5554,7 @@ static PyObject *PyApply(PyObject *self, PyObject *args) +@@ -5555,7 +5553,7 @@ static PyObject *PyApply(PyObject *self, PyObject *args) Py_XDECREF(exc_type); Py_XDECREF(exc_value); ret = NULL; @@ -43,3 +43,44 @@ return ret; // @comm Calls the specified function in a manner similar to // the built-in function apply(), but allows Win32 exceptions +--- 000/com/win32com/src/include/PythonCOM.h 2020-06-13 08:39:03.000000000 +0300 ++++ 001/com/win32com/src/include/PythonCOM.h 2020-06-20 13:10:05.609363700 +0300 +@@ -111,8 +111,6 @@ + #ifdef __MINGW32__ + // Special Mingw32 considerations. + #define NO_PYCOM_ENUMSTATPROPSTG +-#define __try try +-#define __except catch + #include + + #endif // __MINGW32__ +--- 000/com/win32comext/mapi/src/mapi.i 2020-06-13 08:39:03.000000000 +0300 ++++ 001/com/win32comext/mapi/src/mapi.i 2020-06-20 13:10:05.609363700 +0300 +@@ -129,6 +129,7 @@ + PyWin_SetAPIError("MAPIUninitialize", ERROR_INVALID_HANDLE); + rc = NULL; + } ++ __except_end + return rc; + } + +--- 000/com/win32comext/shell/src/shell.cpp 2020-06-13 08:39:03.000000000 +0300 ++++ 001/com/win32comext/shell/src/shell.cpp 2020-06-20 14:15:11.188333200 +0300 +@@ -258,16 +258,13 @@ + pidl = _ILNext(pidl); + } + } +-#if defined(__MINGW32__) || defined(MAINWIN) +- catch (...) +-#else + __except (EXCEPTION_EXECUTE_HANDLER) +-#endif + { + Py_DECREF(ret); + PyErr_SetString(PyExc_ValueError, "This string is an invalid PIDL (win32 exception unpacking)"); + ret = NULL; + } ++ __except_end + if (bFreeSystemPIDL) + CoTaskMemFree((void *)pidl_free); + return ret; diff --git a/mingw-w64-python-pywin32/004-disable-modules.patch b/mingw-w64-python-pywin32/004-disable-modules.patch new file mode 100644 index 0000000000000..927524174e2ba --- /dev/null +++ b/mingw-w64-python-pywin32/004-disable-modules.patch @@ -0,0 +1,89 @@ +--- 000/setup.py 2020-06-20 14:41:31.583265800 +0300 ++++ 001/setup.py 2020-06-20 17:41:06.998916300 +0300 +@@ -1006,12 +1009,12 @@ + # need at this stage. + if sys.version_info > (2, 7) and sys.version_info < (3, 3): + # only stuff built with msvc9 needs this loader. +- self._build_pycom_loader() +- self._build_scintilla() ++ #self._build_pycom_loader() ++ pass ++ #self._build_scintilla() + # Copy cpp lib files needed to create Python COM extensions +- clib_files = (['win32', 'pywintypes%s.lib'], +- ['win32com', 'pythoncom%s.lib'], +- ['win32com', 'axscript%s.lib']) ++ clib_files = (['win32', 'pywintypes%s.def'], ++ ['win32com', 'pythoncom%s.def']) + for clib_file in clib_files: + target_dir = os.path.join(self.build_lib, clib_file[0], "libs") + if not os.path.exists(target_dir): +@@ -1041,20 +1041,6 @@ + mfc_version = "vc140" + mfc_libraries = ["mfc140u.dll", "mfcm140u.dll"] + +- mfc_contents = self.lookupMfcInVisualStudio(mfc_version, mfc_libraries) +- if not mfc_contents: +- print("Can't find MFC contents in VisualStudio. Looking into WinSxS now..") +- mfc_contents = self.lookupMfcInWinSxS(mfc_version, mfc_libraries) +- +- if not mfc_contents: +- raise RuntimeError("No MFC files found!") +- +- for mfc_content in mfc_contents: +- shutil.copyfile(mfc_content, +- os.path.join(target_dir, os.path.split(mfc_content)[1]), +- ) +- +- + def build_exefile(self, ext): + sources = ext.sources + if sources is None or type(sources) not in (list, tuple): +@@ -1917,6 +1920,6 @@ + """ % dirs).split(), + depends=["%(internet)s/internet_pch.h" % dirs]), +- WinExt_win32com('mapi', libraries="advapi32", pch_header="PythonCOM.h", ++ WinExt_win32com('mapi', libraries="advapi32 SKIP", pch_header="PythonCOM.h", + include_dirs=["%(mapi)s/mapi_headers" % dirs], + sources=(""" + %(mapi)s/mapi.i %(mapi)s/mapi.cpp +@@ -2041,6 +2045,6 @@ + """ % dirs).split()), + +- WinExt_win32com('propsys', libraries='propsys', delay_load_libraries='shell32', ++ WinExt_win32com('propsys', libraries='propsys SKIP', delay_load_libraries='shell32', + unicode_mode=True, + sources=(""" + %(propsys)s/propsys.cpp +@@ -2122,6 +2127,7 @@ + + pythonwin_extensions = [ + WinExt_pythonwin("win32ui", ++ libraries="SKIP", + sources = [ + "Pythonwin/dbgthread.cpp", + "Pythonwin/dibapi.cpp", +@@ -2225,6 +2231,7 @@ + ], + optional_headers=['afxres.h']), + WinExt_pythonwin("win32uiole", ++ libraries="SKIP", + sources = [ + "Pythonwin/stdafxole.cpp", + "Pythonwin/win32oleDlgInsert.cpp", +@@ -2242,6 +2249,7 @@ + windows_h_version = 0x500, + optional_headers=['afxres.h']), + WinExt_pythonwin("dde", ++ libraries="SKIP", + sources = [ + "Pythonwin/stddde.cpp", + "Pythonwin/ddetopic.cpp", +@@ -2292,6 +2300,7 @@ + unicode_mode = True, + libraries = "user32 advapi32 ole32 shell32 pywintypes"), + WinExt_pythonwin_subsys_win("Pythonwin", ++ libraries="SKIP", + sources = [ + "Pythonwin/pythonwin.cpp", + "Pythonwin/pythonwin.rc", diff --git a/mingw-w64-python-pywin32/PKGBUILD b/mingw-w64-python-pywin32/PKGBUILD index 00f8c3bb097ed..955548d60daba 100644 --- a/mingw-w64-python-pywin32/PKGBUILD +++ b/mingw-w64-python-pywin32/PKGBUILD @@ -8,51 +8,54 @@ pkgdesc='Python for Windows Extensions (mingw-w64)' license=('PSF') arch=('any') mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64') -pkgver=225 +pkgver=228 pkgrel=1 -makedepends=(${MINGW_PACKAGE_PREFIX}-python2 ${MINGW_PACKAGE_PREFIX}-python2-setuptools - ${MINGW_PACKAGE_PREFIX}-python3 ${MINGW_PACKAGE_PREFIX}-python3-setuptools - rsync) +makedepends=(${MINGW_PACKAGE_PREFIX}-python3 ${MINGW_PACKAGE_PREFIX}-python3-setuptools rsync) pkgbase=mingw-w64-python-${_realname} -pkgname=(${MINGW_PACKAGE_PREFIX}-python2-${_realname} ${MINGW_PACKAGE_PREFIX}-python3-${_realname}) +pkgname=(${MINGW_PACKAGE_PREFIX}-python3-${_realname}) source=("https://github.com/mhammond/${_realname}/archive/b${pkgver}.zip" + setup.cfg seh.h + minmax.h 001-compile-and-setup-fixes.patch - 002-min-max.patch - 003-dependency-fixes.patch - 004-seh.patch) -sha256sums=('4fe036b83caf8cfb1fcbf6cf98b82a11ab1e41d2b652121d0a4395b5e9deeb46' + 002-dependency-fixes.patch + 003-seh.patch + 004-disable-modules.patch) +sha256sums=('524a40b85bd0d0bd52a5bcce7ccb236ae46a336975df5452b336d813f4b64a6d' + '74033ac90498a63b579b4dd8c5948b2ea1a9de63aa57f3d4e4e44bb0f549520b' '03f8c0372059bb5b1933d77309101c67fa08504b42a6fce1186ed9a29e0c271f' - '071b119512ee06ea9008b96f83f6a38fdbcd55266758e169da64340861f29c3b' - '0dc953883a2917f1eddb93f1615db9749b5f758664ec539a4bf2a96f11087524' - '0013d3bb9b10511f28e5e71fa59b0431445a5cfc5ae7950e33251af14a087f5f' - '726ab045a127c98bd431f6840a7f63042668e61fa5d22834af4e5f8a2ea4cf70') + '17eb1454e8955771af57209a49439f7cf26a885767a8e707f6c77e3c3ccd479f' + 'a6dc5c309148b85cd0b2e90f673d998528747e9fceab43d246bbe17ee7a4c8ad' + 'fcc23eaaff99160147db4dd48cf951b6db62adb8287807e7a281c032902c4f98' + '109a3ece2cfa359b6e68aebbcc74db4b7e80eda0be3d9c6bed88a7d099c70d37' + 'e8c32de54fe2a375b0331fae36efaa4400518386d03ee429da13e1846b4c2e08') prepare() { cd "${srcdir}/${_realname}-b${pkgver}" patch -p1 < "${startdir}"/001-compile-and-setup-fixes.patch - patch -p1 < "${startdir}"/002-min-max.patch - patch -p1 < "${startdir}"/003-dependency-fixes.patch - patch -p1 < "${startdir}"/004-seh.patch + patch -p1 < "${startdir}"/002-dependency-fixes.patch + patch -p1 < "${startdir}"/003-seh.patch + patch -p1 < "${startdir}"/004-disable-modules.patch + cp "${startdir}"/setup.cfg setup.cfg } build() { - for _python in python2 python3; do - msg2 "Synchronizing ${_python} build directory" - rsync --recursive --times "${srcdir}/${_realname}-b${pkgver}"/* "${srcdir}/build-${_python}-${CARCH}-${_realname}-${pkgver}" - cd "${srcdir}/build-${_python}-${CARCH}-${_realname}-${pkgver}" - CFLAGS="-Wno-narrowing -fno-operator-names -fpermissive -include ../seh.h -DCRYPT_DECRYPT_MESSAGE_PARA_HAS_EXTRA_FIELDS" \ - LIB="${MINGW_PREFIX}/lib:${MINGW_PREFIX}/${CARCH}-w64-mingw32/lib" \ - INCLUDE="${MINGW_PREFIX}/include:${MINGW_PREFIX}/${CARCH}-w64-mingw32/include" \ - ${MINGW_PREFIX}/bin/${_python} setup.py build --compiler=mingw32 - done + msg2 "Synchronizing build directory" + rsync --recursive --times "${srcdir}/${_realname}-b${pkgver}"/* "${srcdir}/build-python3-${CARCH}-${_realname}-${pkgver}" + cd "${srcdir}/build-python3-${CARCH}-${_realname}-${pkgver}" + + CFLAGS="-Wno-narrowing -fno-operator-names -fpermissive -include ../seh.h -include ../minmax.h -DCRYPT_DECRYPT_MESSAGE_PARA_HAS_EXTRA_FIELDS" \ + LIB="${MINGW_PREFIX}/lib:${MINGW_PREFIX}/${CARCH}-w64-mingw32/lib" \ + INCLUDE="${MINGW_PREFIX}/include:${MINGW_PREFIX}/${CARCH}-w64-mingw32/include" \ + ${MINGW_PREFIX}/bin/python3 setup.py build } _package() { - cd "${srcdir}/build-${_python}-${CARCH}-${_realname}-${pkgver}" + cd "${srcdir}/build-python3-${CARCH}-${_realname}-${pkgver}" + LIB="${MINGW_PREFIX}/lib:${MINGW_PREFIX}/${CARCH}-w64-mingw32/lib" \ DISTUTILS_DEBUG=1 \ MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \ - ${MINGW_PREFIX}/bin/${_python} setup.py install \ + ${MINGW_PREFIX}/bin/python3 setup.py install \ --prefix=${MINGW_PREFIX} \ --root="${pkgdir}" \ --optimize=1 @@ -60,12 +63,12 @@ _package() { package_python2-pywin32() { depends=(${MINGW_PACKAGE_PREFIX}-python2-setuptools) - _python=python2 _package + _package } package_python3-pywin32() { depends=(${MINGW_PACKAGE_PREFIX}-python3-setuptools) - _python=python3 _package + _package } # template start; name=mingw-w64-splitpkg-wrappers; version=1.0; diff --git a/mingw-w64-python-pywin32/minmax.h b/mingw-w64-python-pywin32/minmax.h new file mode 100644 index 0000000000000..df1bf85ef1f1b --- /dev/null +++ b/mingw-w64-python-pywin32/minmax.h @@ -0,0 +1,2 @@ +#define min(a, b) (((a)<(b))?(a):(b)) +#define max(a, b) (((a)>(b))?(a):(b)) diff --git a/mingw-w64-python-pywin32/setup.cfg b/mingw-w64-python-pywin32/setup.cfg new file mode 100644 index 0000000000000..68ed37fbd5f3a --- /dev/null +++ b/mingw-w64-python-pywin32/setup.cfg @@ -0,0 +1,2 @@ +[build] +compiler=mingw32 From 5ddac0fd796e9ac1017c4cb84b24652569b89788 Mon Sep 17 00:00:00 2001 From: Christoph Reiter Date: Sun, 27 Jun 2021 17:15:01 +0200 Subject: [PATCH 4/4] pywin32: drop py2 package --- mingw-w64-python-pywin32/PKGBUILD | 42 +++++++++---------------------- 1 file changed, 12 insertions(+), 30 deletions(-) diff --git a/mingw-w64-python-pywin32/PKGBUILD b/mingw-w64-python-pywin32/PKGBUILD index 955548d60daba..65a9f4018aa8e 100644 --- a/mingw-w64-python-pywin32/PKGBUILD +++ b/mingw-w64-python-pywin32/PKGBUILD @@ -3,6 +3,8 @@ # Contributor: Renato Silva _realname='pywin32' +pkgbase=mingw-w64-python-${_realname} +pkgname=${MINGW_PACKAGE_PREFIX}-python-${_realname} url='https://sourceforge.net/projects/pywin32' pkgdesc='Python for Windows Extensions (mingw-w64)' license=('PSF') @@ -10,9 +12,10 @@ arch=('any') mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64') pkgver=228 pkgrel=1 -makedepends=(${MINGW_PACKAGE_PREFIX}-python3 ${MINGW_PACKAGE_PREFIX}-python3-setuptools rsync) -pkgbase=mingw-w64-python-${_realname} -pkgname=(${MINGW_PACKAGE_PREFIX}-python3-${_realname}) +makedepends=( + ${MINGW_PACKAGE_PREFIX}-python + ${MINGW_PACKAGE_PREFIX}-python-setuptools + rsync) source=("https://github.com/mhammond/${_realname}/archive/b${pkgver}.zip" setup.cfg seh.h @@ -41,43 +44,22 @@ prepare() { build() { msg2 "Synchronizing build directory" - rsync --recursive --times "${srcdir}/${_realname}-b${pkgver}"/* "${srcdir}/build-python3-${CARCH}-${_realname}-${pkgver}" - cd "${srcdir}/build-python3-${CARCH}-${_realname}-${pkgver}" + rsync --recursive --times "${srcdir}/${_realname}-b${pkgver}"/* "${srcdir}/build-python-${CARCH}-${_realname}-${pkgver}" + cd "${srcdir}/build-python-${CARCH}-${_realname}-${pkgver}" CFLAGS="-Wno-narrowing -fno-operator-names -fpermissive -include ../seh.h -include ../minmax.h -DCRYPT_DECRYPT_MESSAGE_PARA_HAS_EXTRA_FIELDS" \ LIB="${MINGW_PREFIX}/lib:${MINGW_PREFIX}/${CARCH}-w64-mingw32/lib" \ INCLUDE="${MINGW_PREFIX}/include:${MINGW_PREFIX}/${CARCH}-w64-mingw32/include" \ - ${MINGW_PREFIX}/bin/python3 setup.py build + ${MINGW_PREFIX}/bin/python setup.py build } -_package() { - cd "${srcdir}/build-python3-${CARCH}-${_realname}-${pkgver}" +package() { + cd "${srcdir}/build-python-${CARCH}-${_realname}-${pkgver}" LIB="${MINGW_PREFIX}/lib:${MINGW_PREFIX}/${CARCH}-w64-mingw32/lib" \ DISTUTILS_DEBUG=1 \ MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \ - ${MINGW_PREFIX}/bin/python3 setup.py install \ + ${MINGW_PREFIX}/bin/python setup.py install \ --prefix=${MINGW_PREFIX} \ --root="${pkgdir}" \ --optimize=1 } - -package_python2-pywin32() { - depends=(${MINGW_PACKAGE_PREFIX}-python2-setuptools) - _package -} - -package_python3-pywin32() { - depends=(${MINGW_PACKAGE_PREFIX}-python3-setuptools) - _package -} - -# template start; name=mingw-w64-splitpkg-wrappers; version=1.0; -# vim: set ft=bash : - -# generate wrappers -for _name in "${pkgname[@]}"; do - _short="package_${_name#${MINGW_PACKAGE_PREFIX}-}" - _func="$(declare -f "${_short}")" - eval "${_func/#${_short}/package_${_name}}" -done -# template end;