Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Pywin32 updates #5615

Merged
merged 4 commits into from
Jun 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
759 changes: 241 additions & 518 deletions mingw-w64-python-pywin32/001-compile-and-setup-fixes.patch

Large diffs are not rendered by default.

56 changes: 56 additions & 0 deletions mingw-w64-python-pywin32/002-dependency-fixes.patch
Original file line number Diff line number Diff line change
@@ -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,
86 changes: 86 additions & 0 deletions mingw-w64-python-pywin32/003-seh.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
--- 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
@@ -707,7 +707,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
@@ -795,6 +795,7 @@ static PyObject *PyFormatMessageA(PyObject *self, PyObject *args)
{
baccessviolation = TRUE;
}
+ __except_end
PyW32_END_ALLOW_THREADS
}

@@ -819,7 +818,7 @@ cleanup:
}

// @pymethod <o PyUnicode>|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
}

@@ -5555,7 +5553,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
--- 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 <olectl.h>

#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;
89 changes: 89 additions & 0 deletions mingw-w64-python-pywin32/004-disable-modules.patch
Original file line number Diff line number Diff line change
@@ -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",
82 changes: 41 additions & 41 deletions mingw-w64-python-pywin32/PKGBUILD
Original file line number Diff line number Diff line change
@@ -1,65 +1,65 @@
# Maintainer: Ray Donnelly <mingw.android@gmail.com>
# Maintainer: Joan Karadimov <joan.karadimov@gmail.com>
# Contributor: Renato Silva <br.renatosilva@gmail.com>

_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')
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
pkgver=219
pkgver=228
pkgrel=1
makedepends=(${MINGW_PACKAGE_PREFIX}-python2 ${MINGW_PACKAGE_PREFIX}-python3 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')
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
minmax.h
001-compile-and-setup-fixes.patch
002-dependency-fixes.patch
003-seh.patch
004-disable-modules.patch)
sha256sums=('524a40b85bd0d0bd52a5bcce7ccb236ae46a336975df5452b336d813f4b64a6d'
'74033ac90498a63b579b4dd8c5948b2ea1a9de63aa57f3d4e4e44bb0f549520b'
'03f8c0372059bb5b1933d77309101c67fa08504b42a6fce1186ed9a29e0c271f'
'17eb1454e8955771af57209a49439f7cf26a885767a8e707f6c77e3c3ccd479f'
'a6dc5c309148b85cd0b2e90f673d998528747e9fceab43d246bbe17ee7a4c8ad'
'fcc23eaaff99160147db4dd48cf951b6db62adb8287807e7a281c032902c4f98'
'109a3ece2cfa359b6e68aebbcc74db4b7e80eda0be3d9c6bed88a7d099c70d37'
'e8c32de54fe2a375b0331fae36efaa4400518386d03ee429da13e1846b4c2e08')

prepare() {
cd "${srcdir}/${_realname}-${pkgver}"
cd "${srcdir}/${_realname}-b${pkgver}"
patch -p1 < "${startdir}"/001-compile-and-setup-fixes.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}-${pkgver}"/* "${srcdir}/build-${_python}-${CARCH}-${_realname}-${pkgver}"
cd "${srcdir}/build-${_python}-${CARCH}-${_realname}-${pkgver}"
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-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/python setup.py build
}

_package() {
cd "${srcdir}/build-${_python}-${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/${_python} 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)
_python=python2 _package
}

package_python3-pywin32() {
depends=(${MINGW_PACKAGE_PREFIX}-python3-setuptools)
_python=python3 _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;
2 changes: 2 additions & 0 deletions mingw-w64-python-pywin32/minmax.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#define min(a, b) (((a)<(b))?(a):(b))
#define max(a, b) (((a)>(b))?(a):(b))
Loading