From 100ee163ffff6e40cad1740ccca656a596f11672 Mon Sep 17 00:00:00 2001 From: Christoph Reiter Date: Thu, 3 Jun 2021 14:19:00 +0200 Subject: [PATCH] Add a separate python3.9 package Based on #8278 --- ...0-make-_sysconfigdata.py-relocatable.patch | 41 ++ .../0002-restore-setup-config.patch | 62 ++ .../0100-MINGW-BASE-use-NT-thread-model.patch | 211 ++++++ ...gcc-internal-defines-to-python-platf.patch | 25 + ...igure-MACHDEP-and-platform-for-build.patch | 61 ++ ...0140-MINGW-preset-configure-defaults.patch | 63 ++ ...largefile-support-for-windows-builds.patch | 24 + ...0170-MINGW-add-srcdir-PC-to-CPPFLAGS.patch | 25 + .../0180-MINGW-init-system-calls.patch | 99 +++ ...INGW-build-in-windows-modules-winreg.patch | 56 ++ ...etermine-if-pwdmodule-should-be-used.patch | 42 ++ ...ler-customize-mingw-cygwin-compilers.patch | 36 + ...0260-MINGW-compiler-enable-new-dtags.patch | 19 + ...-Mingw-recognition-to-pyport.h-to-al.patch | 62 ++ ...300-MINGW-configure-for-shared-build.patch | 51 ++ .../0310-MINGW-dynamic-loading-support.patch | 81 +++ ...nore-main-program-for-frozen-scripts.patch | 32 + ...-MINGW-setup-_multiprocessing-module.patch | 16 + .../0360-MINGW-setup-select-module.patch | 40 ++ ...up-_ctypes-module-with-system-libffi.patch | 26 + ...ct-winsock2-and-setup-_socket-module.patch | 141 ++++ ...0390-MINGW-exclude-unix-only-modules.patch | 76 +++ ...NGW-setup-msvcrt-and-_winapi-modules.patch | 69 ++ ...0410-MINGW-build-extensions-with-GCC.patch | 57 ++ ...2CCompiler-as-default-compiler-for-m.patch | 52 ++ .../0430-MINGW-find-import-library.patch | 11 + .../0440-MINGW-setup-_ssl-module.patch | 12 + ...ation-of-posix-build-in-sysconfig.py.patch | 62 ++ ...W-support-stdcall-without-underscore.patch | 34 + ...ead-rename-to-avoid-failure-on-windo.patch | 12 + ...ular-dependency-from-time-module-dur.patch | 19 + ...tion-of-posix-build-in-distutils-sys.patch | 76 +++ .../0490-MINGW-customize-site.patch | 40 ++ .../0500-add-python-config-sh.patch | 143 ++++ .../0510-cross-darwin-feature.patch | 120 ++++ ...520-py3k-mingw-ntthreads-vs-pthreads.patch | 43 ++ .../0530-mingw-system-libffi.patch | 12 + ...sys-mingw-prefer-unix-sep-if-MSYSTEM.patch | 369 +++++++++++ .../0560-mingw-use-posix-getpath.patch | 474 ++++++++++++++ ...mingw-add-ModuleFileName-dir-to-PATH.patch | 40 ++ ...dd-BUILDIN_WIN32_MODULEs-time-msvcrt.patch | 9 + ...s-cygwin-semi-native-build-sysconfig.patch | 104 +++ .../0620-mingw-sysconfig-like-posix.patch | 64 ++ ...builtin_for_Popen_in_cygwinccompiler.patch | 61 ++ ...d-multiarch-paths-if-cross-compiling.patch | 15 + ...ngw-use-backslashes-in-compileall-py.patch | 12 + ...-msys-convert_path-fix-and-root-hack.patch | 93 +++ .../0690-allow-static-tcltk.patch | 69 ++ .../0720-mingw-pdcurses_ISPAD.patch | 17 + mingw-w64-python3.9/0740-grammar-fixes.patch | 25 + mingw-w64-python3.9/0750-builddir-fixes.patch | 49 ++ ...sys-monkeypatch-os-system-via-sh-exe.patch | 21 + ...place-slashes-used-in-io-redirection.patch | 54 ++ .../0800-mingw-install-layout-as-posix.patch | 29 + .../0810-remove_path_max.default.patch | 11 + .../0820-dont-link-with-gettext.patch | 40 ++ .../0830-ctypes-python-dll.patch | 14 + .../0840-gdbm-module-includes.patch | 12 + .../0850-use-gnu_printf-in-format.patch | 60 ++ ...w-fix-ssl-dont-use-enum_certificates.patch | 21 + .../0890-mingw-build-optimized-ext.patch | 16 + ...mpiler-dont-strip-modules-if-pydebug.patch | 12 + ...fix-using-dllhandle-and-winver-mingw.patch | 21 + ...0920-mingw-add-LIBPL-to-library-dirs.patch | 12 + ...msvccompiler-get_build_version-works.patch | 27 + ...0-MINGW-link-with-additional-library.patch | 19 + mingw-w64-python3.9/1010-install-msilib.patch | 11 + ...060-dont-include-system-ncurses-path.patch | 22 + .../1620-fix-signal-module-build.patch | 12 + .../1630-build-winconsoleio.patch | 12 + .../1650-expose-sem_unlink.patch | 12 + mingw-w64-python3.9/1700-cygpty-isatty.patch | 420 ++++++++++++ .../1701-disable-broken-gdbm-module.patch | 12 + ...win-resource-files-and-build-pythonw.patch | 114 ++++ .../1810-3.7-mpdec-mingw.patch | 12 + .../1850-disable-readline.patch | 15 + .../1860-fix-isselectable.patch | 12 + ...70-use-_wcsnicmp-instead-wcsncasecmp.patch | 12 + .../1890-_xxsubinterpretersmodule.patch | 11 + .../1891-sqlite3-module-defines.patch | 14 + .../2010-configure-have-inet-pton.patch | 18 + .../2030-fix-msvc9-import.patch | 21 + .../2051-set-venv-activate-path-unix.patch | 12 + .../2052-venv-creation-fixes.patch | 62 ++ .../2060-pass-gen-profile-ldflags.patch | 12 + ...tutils-add-windmc-to-cygwinccompiler.patch | 44 ++ ...indows-must-link-ext-with-python-lib.patch | 20 + .../3000-importlib-bootstrap-path-sep.patch | 13 + .../3001-pathlib-path-sep.patch | 11 + .../3011-fix-build-testinternalcapi.patch | 14 + .../3020-extend-MS_WINDOWS-flag.patch | 11 + mingw-w64-python3.9/4000-clang-arm64.patch | 46 ++ mingw-w64-python3.9/5000-warnings-fixes.patch | 105 +++ mingw-w64-python3.9/PKGBUILD | 615 ++++++++++++++++++ mingw-w64-python3.9/smoketests.py | 132 ++++ 95 files changed, 5648 insertions(+) create mode 100644 mingw-w64-python3.9/0000-make-_sysconfigdata.py-relocatable.patch create mode 100644 mingw-w64-python3.9/0002-restore-setup-config.patch create mode 100644 mingw-w64-python3.9/0100-MINGW-BASE-use-NT-thread-model.patch create mode 100644 mingw-w64-python3.9/0110-MINGW-translate-gcc-internal-defines-to-python-platf.patch create mode 100644 mingw-w64-python3.9/0130-MINGW-configure-MACHDEP-and-platform-for-build.patch create mode 100644 mingw-w64-python3.9/0140-MINGW-preset-configure-defaults.patch create mode 100644 mingw-w64-python3.9/0150-MINGW-configure-largefile-support-for-windows-builds.patch create mode 100644 mingw-w64-python3.9/0170-MINGW-add-srcdir-PC-to-CPPFLAGS.patch create mode 100644 mingw-w64-python3.9/0180-MINGW-init-system-calls.patch create mode 100644 mingw-w64-python3.9/0200-MINGW-build-in-windows-modules-winreg.patch create mode 100644 mingw-w64-python3.9/0210-MINGW-determine-if-pwdmodule-should-be-used.patch create mode 100644 mingw-w64-python3.9/0250-MINGW-compiler-customize-mingw-cygwin-compilers.patch create mode 100644 mingw-w64-python3.9/0260-MINGW-compiler-enable-new-dtags.patch create mode 100644 mingw-w64-python3.9/0290-issue6672-v2-Add-Mingw-recognition-to-pyport.h-to-al.patch create mode 100644 mingw-w64-python3.9/0300-MINGW-configure-for-shared-build.patch create mode 100644 mingw-w64-python3.9/0310-MINGW-dynamic-loading-support.patch create mode 100644 mingw-w64-python3.9/0330-MINGW-ignore-main-program-for-frozen-scripts.patch create mode 100644 mingw-w64-python3.9/0350-MINGW-setup-_multiprocessing-module.patch create mode 100644 mingw-w64-python3.9/0360-MINGW-setup-select-module.patch create mode 100644 mingw-w64-python3.9/0370-MINGW-setup-_ctypes-module-with-system-libffi.patch create mode 100644 mingw-w64-python3.9/0380-MINGW-defect-winsock2-and-setup-_socket-module.patch create mode 100644 mingw-w64-python3.9/0390-MINGW-exclude-unix-only-modules.patch create mode 100644 mingw-w64-python3.9/0400-MINGW-setup-msvcrt-and-_winapi-modules.patch create mode 100644 mingw-w64-python3.9/0410-MINGW-build-extensions-with-GCC.patch create mode 100644 mingw-w64-python3.9/0420-MINGW-use-Mingw32CCompiler-as-default-compiler-for-m.patch create mode 100644 mingw-w64-python3.9/0430-MINGW-find-import-library.patch create mode 100644 mingw-w64-python3.9/0440-MINGW-setup-_ssl-module.patch create mode 100644 mingw-w64-python3.9/0460-MINGW-generalization-of-posix-build-in-sysconfig.py.patch create mode 100644 mingw-w64-python3.9/0462-MINGW-support-stdcall-without-underscore.patch create mode 100644 mingw-w64-python3.9/0464-use-replace-instead-rename-to-avoid-failure-on-windo.patch create mode 100644 mingw-w64-python3.9/0470-MINGW-avoid-circular-dependency-from-time-module-dur.patch create mode 100644 mingw-w64-python3.9/0480-MINGW-generalization-of-posix-build-in-distutils-sys.patch create mode 100644 mingw-w64-python3.9/0490-MINGW-customize-site.patch create mode 100644 mingw-w64-python3.9/0500-add-python-config-sh.patch create mode 100644 mingw-w64-python3.9/0510-cross-darwin-feature.patch create mode 100644 mingw-w64-python3.9/0520-py3k-mingw-ntthreads-vs-pthreads.patch create mode 100644 mingw-w64-python3.9/0530-mingw-system-libffi.patch create mode 100644 mingw-w64-python3.9/0555-msys-mingw-prefer-unix-sep-if-MSYSTEM.patch create mode 100644 mingw-w64-python3.9/0560-mingw-use-posix-getpath.patch create mode 100644 mingw-w64-python3.9/0565-mingw-add-ModuleFileName-dir-to-PATH.patch create mode 100644 mingw-w64-python3.9/0570-mingw-add-BUILDIN_WIN32_MODULEs-time-msvcrt.patch create mode 100644 mingw-w64-python3.9/0610-msys-cygwin-semi-native-build-sysconfig.patch create mode 100644 mingw-w64-python3.9/0620-mingw-sysconfig-like-posix.patch create mode 100644 mingw-w64-python3.9/0630-mingw-_winapi_as_builtin_for_Popen_in_cygwinccompiler.patch create mode 100644 mingw-w64-python3.9/0650-cross-dont-add-multiarch-paths-if-cross-compiling.patch create mode 100644 mingw-w64-python3.9/0660-mingw-use-backslashes-in-compileall-py.patch create mode 100644 mingw-w64-python3.9/0670-msys-convert_path-fix-and-root-hack.patch create mode 100644 mingw-w64-python3.9/0690-allow-static-tcltk.patch create mode 100644 mingw-w64-python3.9/0720-mingw-pdcurses_ISPAD.patch create mode 100644 mingw-w64-python3.9/0740-grammar-fixes.patch create mode 100644 mingw-w64-python3.9/0750-builddir-fixes.patch create mode 100644 mingw-w64-python3.9/0760-msys-monkeypatch-os-system-via-sh-exe.patch create mode 100644 mingw-w64-python3.9/0770-msys-replace-slashes-used-in-io-redirection.patch create mode 100644 mingw-w64-python3.9/0800-mingw-install-layout-as-posix.patch create mode 100644 mingw-w64-python3.9/0810-remove_path_max.default.patch create mode 100644 mingw-w64-python3.9/0820-dont-link-with-gettext.patch create mode 100644 mingw-w64-python3.9/0830-ctypes-python-dll.patch create mode 100644 mingw-w64-python3.9/0840-gdbm-module-includes.patch create mode 100644 mingw-w64-python3.9/0850-use-gnu_printf-in-format.patch create mode 100644 mingw-w64-python3.9/0870-mingw-fix-ssl-dont-use-enum_certificates.patch create mode 100644 mingw-w64-python3.9/0890-mingw-build-optimized-ext.patch create mode 100644 mingw-w64-python3.9/0900-cygwinccompiler-dont-strip-modules-if-pydebug.patch create mode 100644 mingw-w64-python3.9/0910-fix-using-dllhandle-and-winver-mingw.patch create mode 100644 mingw-w64-python3.9/0920-mingw-add-LIBPL-to-library-dirs.patch create mode 100644 mingw-w64-python3.9/0970-Add-AMD64-to-sys-config-so-msvccompiler-get_build_version-works.patch create mode 100644 mingw-w64-python3.9/0990-MINGW-link-with-additional-library.patch create mode 100644 mingw-w64-python3.9/1010-install-msilib.patch create mode 100644 mingw-w64-python3.9/1060-dont-include-system-ncurses-path.patch create mode 100644 mingw-w64-python3.9/1620-fix-signal-module-build.patch create mode 100644 mingw-w64-python3.9/1630-build-winconsoleio.patch create mode 100644 mingw-w64-python3.9/1650-expose-sem_unlink.patch create mode 100644 mingw-w64-python3.9/1700-cygpty-isatty.patch create mode 100644 mingw-w64-python3.9/1701-disable-broken-gdbm-module.patch create mode 100644 mingw-w64-python3.9/1800-link-win-resource-files-and-build-pythonw.patch create mode 100644 mingw-w64-python3.9/1810-3.7-mpdec-mingw.patch create mode 100644 mingw-w64-python3.9/1850-disable-readline.patch create mode 100644 mingw-w64-python3.9/1860-fix-isselectable.patch create mode 100644 mingw-w64-python3.9/1870-use-_wcsnicmp-instead-wcsncasecmp.patch create mode 100644 mingw-w64-python3.9/1890-_xxsubinterpretersmodule.patch create mode 100644 mingw-w64-python3.9/1891-sqlite3-module-defines.patch create mode 100644 mingw-w64-python3.9/2010-configure-have-inet-pton.patch create mode 100644 mingw-w64-python3.9/2030-fix-msvc9-import.patch create mode 100644 mingw-w64-python3.9/2051-set-venv-activate-path-unix.patch create mode 100644 mingw-w64-python3.9/2052-venv-creation-fixes.patch create mode 100644 mingw-w64-python3.9/2060-pass-gen-profile-ldflags.patch create mode 100644 mingw-w64-python3.9/2070-distutils-add-windmc-to-cygwinccompiler.patch create mode 100644 mingw-w64-python3.9/2080-pkg-config-windows-must-link-ext-with-python-lib.patch create mode 100644 mingw-w64-python3.9/3000-importlib-bootstrap-path-sep.patch create mode 100644 mingw-w64-python3.9/3001-pathlib-path-sep.patch create mode 100644 mingw-w64-python3.9/3011-fix-build-testinternalcapi.patch create mode 100644 mingw-w64-python3.9/3020-extend-MS_WINDOWS-flag.patch create mode 100644 mingw-w64-python3.9/4000-clang-arm64.patch create mode 100644 mingw-w64-python3.9/5000-warnings-fixes.patch create mode 100644 mingw-w64-python3.9/PKGBUILD create mode 100644 mingw-w64-python3.9/smoketests.py diff --git a/mingw-w64-python3.9/0000-make-_sysconfigdata.py-relocatable.patch b/mingw-w64-python3.9/0000-make-_sysconfigdata.py-relocatable.patch new file mode 100644 index 0000000000..bb238fed55 --- /dev/null +++ b/mingw-w64-python3.9/0000-make-_sysconfigdata.py-relocatable.patch @@ -0,0 +1,41 @@ +diff -Naur Python-3.8.0-orig/Lib/sysconfig.py Python-3.8.0/Lib/sysconfig.py +--- Python-3.8.0-orig/Lib/sysconfig.py 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/Lib/sysconfig.py 2019-10-22 10:00:17.317067000 +0300 +@@ -2,6 +2,7 @@ + + import os + import sys ++import textwrap + from os.path import pardir, realpath + + __all__ = [ +@@ -405,11 +406,29 @@ + os.makedirs(pybuilddir, exist_ok=True) + destfile = os.path.join(pybuilddir, name + '.py') + ++ replacement = """ ++ keys_to_replace = [ ++ 'BINDIR', 'BINLIBDEST', 'CONFINCLUDEDIR', ++ 'CONFINCLUDEPY', 'DESTDIRS', 'DESTLIB', 'DESTSHARED', ++ 'INCLDIRSTOMAKE', 'INCLUDEDIR', 'INCLUDEPY', ++ 'LIBDEST', 'LIBDIR', 'LIBPC', 'LIBPL', 'MACHDESTLIB', ++ 'MANDIR', 'SCRIPTDIR', 'datarootdir', 'exec_prefix', ++ ] ++ ++ prefix = build_time_vars['BINDIR'][:-4] ++ ++ for key in keys_to_replace: ++ value = build_time_vars[key] ++ build_time_vars[key] = value.replace(prefix, sys.prefix) ++ """ ++ + with open(destfile, 'w', encoding='utf8') as f: ++ f.write('import sys\n') + f.write('# system configuration generated and used by' + ' the sysconfig module\n') + f.write('build_time_vars = ') + pprint.pprint(vars, stream=f) ++ f.write('\n%s' % textwrap.dedent(replacement)) + + # Create file used for sys.path fixup -- see Modules/getpath.c + with open('pybuilddir.txt', 'w', encoding='utf8') as f: diff --git a/mingw-w64-python3.9/0002-restore-setup-config.patch b/mingw-w64-python3.9/0002-restore-setup-config.patch new file mode 100644 index 0000000000..0cb775058b --- /dev/null +++ b/mingw-w64-python3.9/0002-restore-setup-config.patch @@ -0,0 +1,62 @@ +diff -Naur Python-3.8.0-orig/configure.ac Python-3.8.0/configure.ac +--- Python-3.8.0-orig/configure.ac 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/configure.ac 2019-10-22 10:00:26.817483700 +0300 +@@ -5624,7 +5624,7 @@ + + + # generate output files +-AC_CONFIG_FILES(Makefile.pre Misc/python.pc Misc/python-embed.pc Misc/python-config.sh) ++AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc Misc/python-embed.pc Misc/python-config.sh) + AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix]) + AC_OUTPUT + +@@ -5636,7 +5636,7 @@ + + echo "creating Makefile" >&AS_MESSAGE_FD + $SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \ +- -s Modules \ ++ -s Modules Modules/Setup.config \ + Modules/Setup.local $srcdir/Modules/Setup + mv config.c Modules + +diff -Naur Python-3.8.0-orig/Makefile.pre.in Python-3.8.0/Makefile.pre.in +--- Python-3.8.0-orig/Makefile.pre.in 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/Makefile.pre.in 2019-10-22 10:00:27.207484400 +0300 +@@ -683,10 +683,12 @@ + Makefile Modules/config.c: Makefile.pre \ + $(srcdir)/Modules/config.c.in \ + $(MAKESETUP) \ ++ Modules/Setup.config \ + $(srcdir)/Modules/Setup \ + Modules/Setup.local + $(SHELL) $(MAKESETUP) -c $(srcdir)/Modules/config.c.in \ + -s Modules \ ++ Modules/Setup.config \ + Modules/Setup.local \ + $(srcdir)/Modules/Setup + @mv config.c Modules +@@ -1574,6 +1576,7 @@ + $(INSTALL_DATA) Makefile $(DESTDIR)$(LIBPL)/Makefile + $(INSTALL_DATA) $(srcdir)/Modules/Setup $(DESTDIR)$(LIBPL)/Setup + $(INSTALL_DATA) Modules/Setup.local $(DESTDIR)$(LIBPL)/Setup.local ++ $(INSTALL_DATA) Modules/Setup.config $(DESTDIR)$(LIBPL)/Setup.config + $(INSTALL_DATA) Misc/python.pc $(DESTDIR)$(LIBPC)/python-$(VERSION).pc + $(INSTALL_DATA) Misc/python-embed.pc $(DESTDIR)$(LIBPC)/python-$(VERSION)-embed.pc + $(INSTALL_SCRIPT) $(srcdir)/Modules/makesetup $(DESTDIR)$(LIBPL)/makesetup +@@ -1789,6 +1792,7 @@ + if test "$$file" != "$(srcdir)/Lib/test/data/README"; then rm "$$file"; fi; \ + done + -rm -f core Makefile Makefile.pre config.status Modules/Setup.local \ ++ Modules/Setup.config \ + Modules/ld_so_aix Modules/python.exp Misc/python.pc \ + Misc/python-embed.pc Misc/python-config.sh + -rm -f python*-gdb.py +diff -Naur Python-3.8.0-orig/Modules/Setup.config.in Python-3.8.0/Modules/Setup.config.in +--- Python-3.8.0-orig/Modules/Setup.config.in 1970-01-01 03:00:00.000000000 +0300 ++++ Python-3.8.0/Modules/Setup.config.in 2019-10-22 10:00:27.613085100 +0300 +@@ -0,0 +1,5 @@ ++# This file is transmogrified into Setup.config by config.status. ++ ++# The purpose of this file is to conditionally enable certain modules ++# based on configure-time options. ++ diff --git a/mingw-w64-python3.9/0100-MINGW-BASE-use-NT-thread-model.patch b/mingw-w64-python3.9/0100-MINGW-BASE-use-NT-thread-model.patch new file mode 100644 index 0000000000..bdc68917fb --- /dev/null +++ b/mingw-w64-python3.9/0100-MINGW-BASE-use-NT-thread-model.patch @@ -0,0 +1,211 @@ +diff -Naur Python-3.8.0-orig/configure.ac Python-3.8.0/configure.ac +--- Python-3.8.0-orig/configure.ac 2019-10-22 10:00:29.329088100 +0300 ++++ Python-3.8.0/configure.ac 2019-10-22 10:00:31.778292400 +0300 +@@ -1960,6 +1960,46 @@ + BASECFLAGS="$BASECFLAGS $ac_arch_flags" + fi + ++dnl NOTE: ++dnl - GCC 4.4+ for mingw* require and use posix threads(pthreads-w32) ++dnl - Host may contain installed pthreads-w32. ++dnl - On windows platform only NT-thread model is supported. ++dnl To avoid miss detection scipt first will check for NT-thread model ++dnl and if is not found will try to detect build options for pthread ++dnl model. Autodetection could be overiden if variable with_nt_threads ++dnl is set in "Site Configuration" (see autoconf manual). ++dnl If NT-thread model is enabled script skips some checks that ++dnl impact build process. When a new functionality is added, developers ++dnl are responsible to update configure script to avoid thread models ++dnl to be mixed. ++ ++AC_MSG_CHECKING([for NT threads]) ++AC_ARG_WITH(nt-threads, ++ AS_HELP_STRING([--with-nt-threads], [build with windows threads]), ++[ ++ case $withval in ++ no) with_nt_threads=no;; ++ yes) with_nt_threads=yes;; ++ *) with_nt_threads=yes;; ++ esac], [ ++ with_nt_threads=no]) ++if test $with_nt_threads = yes ; then ++AC_LINK_IFELSE([ ++ AC_LANG_PROGRAM([[]],[[_beginthread(0, 0, 0);]]) ++ ], ++ [with_nt_threads=yes], ++ [with_nt_threads=no]) ++fi ++AC_MSG_RESULT([$with_nt_threads]) ++ ++if test $with_nt_threads = yes ; then ++ dnl temporary default flag to avoid additional pthread checks ++ dnl and initilize other ac..thread flags to no ++ ac_cv_pthread_is_default=no ++ ac_cv_kthread=no ++ ac_cv_pthread=no ++ dnl ac_cv_kpthread is set to no if default is yes (see below) ++else + # On some compilers, pthreads are available without further options + # (e.g. MacOS X). On some of these systems, the compiler will not + # complain if unaccepted options are passed (e.g. gcc on Mac OS X). +@@ -2078,6 +2118,8 @@ + AC_MSG_RESULT($ac_cv_pthread) + fi + ++fi ++ + # If we have set a CC compiler flag for thread support then + # check if it works for CXX, too. + ac_cv_cxx_thread=no +@@ -2098,6 +2140,10 @@ + then + CXX="$CXX -pthread" + ac_cv_cxx_thread=yes ++elif test $with_nt_threads = yes ++then ++ dnl set to always to skip extra pthread check below ++ ac_cv_cxx_thread=always + fi + + if test $ac_cv_cxx_thread = yes +@@ -2130,8 +2176,8 @@ + AC_HEADER_STDC + AC_CHECK_HEADERS(asm/types.h crypt.h conio.h direct.h dlfcn.h errno.h \ + fcntl.h grp.h \ +-ieeefp.h io.h langinfo.h libintl.h process.h pthread.h \ +-sched.h shadow.h signal.h stropts.h termios.h \ ++ieeefp.h io.h langinfo.h libintl.h process.h \ ++shadow.h signal.h stropts.h termios.h \ + utime.h \ + poll.h sys/devpoll.h sys/epoll.h sys/poll.h \ + sys/audioio.h sys/xattr.h sys/bsdtty.h sys/event.h sys/file.h sys/ioctl.h \ +@@ -2145,6 +2191,14 @@ + AC_HEADER_DIRENT + AC_HEADER_MAJOR + ++# If using nt threads, don't look for pthread.h or thread.h ++if test "x$with_nt_threads" = xno ; then ++AC_HEADER_STDC ++AC_CHECK_HEADERS(pthread.h sched.h thread.h) ++AC_HEADER_DIRENT ++AC_HEADER_MAJOR ++fi ++ + # bluetooth/bluetooth.h has been known to not compile with -std=c99. + # http://permalink.gmane.org/gmane.linux.bluez.kernel/22294 + SAVE_CFLAGS=$CFLAGS +@@ -2342,6 +2396,10 @@ + + AC_MSG_CHECKING(for pthread_t) + have_pthread_t=no ++if test $with_nt_threads = yes ; then ++ dnl skip check for pthread_t if NT-thread model is enabled ++ have_pthread_t=skip ++else + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[#include ]], [[pthread_t x; x = *(pthread_t*)0;]]) + ],[have_pthread_t=yes],[]) +@@ -2372,6 +2430,7 @@ + else + AC_MSG_RESULT(no) + fi ++fi + CC="$ac_save_cc" + + AC_SUBST(OTHER_LIBTOOL_OPT) +@@ -2814,10 +2873,15 @@ + [AC_MSG_RESULT(no)] + ) + ++if test $with_nt_threads = yes ; then ++ dnl do not search for sem_init if NT-thread model is enabled ++ : ++else + # 'Real Time' functions on Solaris + # posix4 on Solaris 2.6 + # pthread (first!) on Linux + AC_SEARCH_LIBS(sem_init, pthread rt posix4) ++fi + + # check if we need libintl for locale functions + AC_CHECK_LIB(intl, textdomain, +@@ -3087,6 +3151,11 @@ + CXX="$CXX -pthread" + fi + posix_threads=yes ++elif test $with_nt_threads = yes ++then ++ posix_threads=no ++ AC_DEFINE(NT_THREADS, 1, ++ [Define to 1 if you want to use native NT threads]) + else + if test ! -z "$withval" -a -d "$withval" + then LDFLAGS="$LDFLAGS -L$withval" +@@ -3538,6 +3607,15 @@ + fi + + # checks for library functions ++if test $with_nt_threads = yes ; then ++ dnl GCC(mingw) 4.4+ require and use posix threads(pthreads-w32) ++ dnl and host may contain installed pthreads-w32. ++ dnl Skip checks for some functions declared in pthreads-w32 if ++ dnl NT-thread model is enabled. ++ ac_cv_func_pthread_kill=skip ++ ac_cv_func_sem_open=skip ++ ac_cv_func_sched_setscheduler=skip ++fi + AC_CHECK_FUNCS(alarm accept4 setitimer getitimer bind_textdomain_codeset chown \ + clock confstr copy_file_range ctermid dup3 execv explicit_bzero explicit_memset \ + faccessat fchmod fchmodat fchown fchownat \ +@@ -4462,6 +4540,10 @@ + # the kernel module that provides POSIX semaphores + # isn't loaded by default, so an attempt to call + # sem_open results in a 'Signal 12' error. ++if test $with_nt_threads = yes ; then ++ dnl skip posix semaphores test if NT-thread model is enabled ++ ac_cv_posix_semaphores_enabled=no ++fi + AC_MSG_CHECKING(whether POSIX semaphores are enabled) + AC_CACHE_VAL(ac_cv_posix_semaphores_enabled, + AC_RUN_IFELSE([AC_LANG_SOURCE([[ +@@ -4495,6 +4577,14 @@ + + # Multiprocessing check for broken sem_getvalue + AC_MSG_CHECKING(for broken sem_getvalue) ++if test $with_nt_threads = yes ; then ++ dnl Skip test if NT-thread model is enabled. ++ dnl NOTE the test case below fail for pthreads-w32 as: ++ dnl - SEM_FAILED is not defined; ++ dnl - sem_open is a stub; ++ dnl - sem_getvalue work(!). ++ ac_cv_broken_sem_getvalue=skip ++fi + AC_CACHE_VAL(ac_cv_broken_sem_getvalue, + AC_RUN_IFELSE([AC_LANG_SOURCE([[ + #include +diff -Naur Python-3.8.0-orig/Modules/_multiprocessing/multiprocessing.h Python-3.8.0/Modules/_multiprocessing/multiprocessing.h +--- Python-3.8.0-orig/Modules/_multiprocessing/multiprocessing.h 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/Modules/_multiprocessing/multiprocessing.h 2019-10-22 10:00:32.168293100 +0300 +@@ -21,6 +21,9 @@ + # endif + # define SEM_HANDLE HANDLE + # define SEM_VALUE_MAX LONG_MAX ++# if defined(HAVE_SEM_OPEN) && defined(_POSIX_THREADS) ++# include ++# endif + #else + # include /* O_CREAT and O_EXCL */ + # if defined(HAVE_SEM_OPEN) && !defined(POSIX_SEMAPHORES_NOT_ENABLED) +diff -Naur Python-3.8.0-orig/pyconfig.h.in Python-3.8.0/pyconfig.h.in +--- Python-3.8.0-orig/pyconfig.h.in 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/pyconfig.h.in 2019-10-22 10:00:32.558293800 +0300 +@@ -1352,6 +1352,9 @@ + /* Define if mvwdelch in curses.h is an expression. */ + #undef MVWDELCH_IS_EXPRESSION + ++/* Define to 1 if you want to use native NT threads */ ++#undef NT_THREADS ++ + /* Define to the address where bug reports for this package should be sent. */ + #undef PACKAGE_BUGREPORT + diff --git a/mingw-w64-python3.9/0110-MINGW-translate-gcc-internal-defines-to-python-platf.patch b/mingw-w64-python3.9/0110-MINGW-translate-gcc-internal-defines-to-python-platf.patch new file mode 100644 index 0000000000..65ab5aa747 --- /dev/null +++ b/mingw-w64-python3.9/0110-MINGW-translate-gcc-internal-defines-to-python-platf.patch @@ -0,0 +1,25 @@ +diff -Naur Python-3.8.0-orig/Include/pyport.h Python-3.8.0/Include/pyport.h +--- Python-3.8.0-orig/Include/pyport.h 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/Include/pyport.h 2019-10-22 10:00:36.224300300 +0300 +@@ -26,6 +26,21 @@ + #endif + + ++#ifdef __MINGW32__ ++/* Translate GCC[mingw*] platform specific defines to those ++ * used in python code. ++ */ ++#if !defined(MS_WIN64) && defined(_WIN64) ++# define MS_WIN64 ++#endif ++#if !defined(MS_WIN32) && defined(_WIN32) ++# define MS_WIN32 ++#endif ++#if !defined(MS_WINDOWS) && defined(MS_WIN32) ++# define MS_WINDOWS ++#endif ++#endif /* __MINGW32__*/ ++ + /************************************************************************** + Symbols and macros to supply platform-independent interfaces to basic + C language & library operations whose spellings vary across platforms. diff --git a/mingw-w64-python3.9/0130-MINGW-configure-MACHDEP-and-platform-for-build.patch b/mingw-w64-python3.9/0130-MINGW-configure-MACHDEP-and-platform-for-build.patch new file mode 100644 index 0000000000..45acd7442d --- /dev/null +++ b/mingw-w64-python3.9/0130-MINGW-configure-MACHDEP-and-platform-for-build.patch @@ -0,0 +1,61 @@ +diff -Naur Python-3.8.0-orig/configure.ac Python-3.8.0/configure.ac +--- Python-3.8.0-orig/configure.ac 2019-10-22 10:00:34.321096900 +0300 ++++ Python-3.8.0/configure.ac 2019-10-22 10:00:39.843506600 +0300 +@@ -362,6 +362,17 @@ + # Set name for machine-dependent library files + AC_ARG_VAR([MACHDEP], [name for machine-dependent library files]) + AC_MSG_CHECKING(MACHDEP) ++case $host in ++ *-*-mingw*) ++ # On those hosts MACHDEP is 'win', as platform specific files ++ # go in plat-$(MACHDEP), but runtime platform is 'win32' ++ test -z "$MACHDEP" && MACHDEP=win ++ ++ dnl Configuration will be based only on "host triplet" as build ++ dnl must not depend from posix compatible environement. ++ ac_sys_system=ignore ++ ;; ++esac + if test -z "$MACHDEP" + then + # avoid using uname for cross builds +@@ -431,12 +442,23 @@ + *-*-vxworks*) + _host_cpu=$host_cpu + ;; ++ *-*-mingw*) ++ _host_cpu= ++ ;; + *) + # for now, limit cross builds to known configurations + MACHDEP="unknown" + AC_MSG_ERROR([cross build not supported for $host]) + esac + _PYTHON_HOST_PLATFORM="$MACHDEP${_host_cpu:+-$_host_cpu}" ++ ++ case "$host_os" in ++ mingw*) ++ # As sys.platform() return 'win32' to build python and extantions ++ # we will use 'mingw' (in setup.py and etc.) ++ _PYTHON_HOST_PLATFORM=mingw ++ ;; ++ esac + fi + + # Some systems cannot stand _XOPEN_SOURCE being defined at all; they +diff -Naur Python-3.8.0-orig/Python/getplatform.c Python-3.8.0/Python/getplatform.c +--- Python-3.8.0-orig/Python/getplatform.c 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/Python/getplatform.c 2019-10-22 10:00:40.249107300 +0300 +@@ -1,6 +1,12 @@ + + #include "Python.h" + ++#ifdef __MINGW32__ ++# undef PLATFORM ++/* see PC/pyconfig.h */ ++# define PLATFORM "win32" ++#endif ++ + #ifndef PLATFORM + #define PLATFORM "unknown" + #endif diff --git a/mingw-w64-python3.9/0140-MINGW-preset-configure-defaults.patch b/mingw-w64-python3.9/0140-MINGW-preset-configure-defaults.patch new file mode 100644 index 0000000000..cc9f8db4e2 --- /dev/null +++ b/mingw-w64-python3.9/0140-MINGW-preset-configure-defaults.patch @@ -0,0 +1,63 @@ +diff -Naur Python-3.8.0-orig/configure.ac Python-3.8.0/configure.ac +--- Python-3.8.0-orig/configure.ac 2019-10-22 10:00:41.996310400 +0300 ++++ Python-3.8.0/configure.ac 2019-10-22 10:00:43.025912200 +0300 +@@ -893,6 +893,28 @@ + fi + AC_SUBST(MULTIARCH_CPPFLAGS) + ++# initialize default configuration ++py_config= ++case $host in ++ *-*-mingw*) py_config=mingw ;; ++esac ++if test -n "$py_config" ; then ++ AC_MSG_NOTICE([loading configure defaults from .../Misc/config_$py_config"]) ++ . "$srcdir/Misc/config_$py_config" ++fi ++ ++# initialize defaults for cross-builds ++if test "$cross_compiling" = yes; then ++ py_config=$host_os ++ case $py_config in ++ mingw32*) py_config=mingw32 ;; ++ esac ++ if test -f "$srcdir/Misc/cross_$py_config" ; then ++ AC_MSG_NOTICE([loading cross defaults from .../Misc/cross_$py_config"]) ++ . "$srcdir/Misc/cross_$py_config" ++ fi ++fi ++ + AC_MSG_CHECKING([for -Wl,--no-as-needed]) + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS -Wl,--no-as-needed" +diff -Naur Python-3.8.0-orig/Misc/config_mingw Python-3.8.0/Misc/config_mingw +--- Python-3.8.0-orig/Misc/config_mingw 1970-01-01 03:00:00.000000000 +0300 ++++ Python-3.8.0/Misc/config_mingw 2019-10-22 10:00:43.415912900 +0300 +@@ -0,0 +1,12 @@ ++# configure defaults for mingw* hosts ++ ++# mingw functions to ignore ++ac_cv_func_ftruncate=ignore # implement it as _chsize ++ ++# mingw-w64 functions to ignore ++ac_cv_func_truncate=ignore ++ac_cv_func_alarm=ignore ++ ++# files to ignore ++ac_cv_file__dev_ptmx=ignore #NOTE: under MSYS environment device exist ++ac_cv_file__dev_ptc=no +diff -Naur Python-3.8.0-orig/Misc/cross_mingw32 Python-3.8.0/Misc/cross_mingw32 +--- Python-3.8.0-orig/Misc/cross_mingw32 1970-01-01 03:00:00.000000000 +0300 ++++ Python-3.8.0/Misc/cross_mingw32 2019-10-22 10:00:43.837113600 +0300 +@@ -0,0 +1,11 @@ ++# configure defaults for mingw32 host if cross-build ++ ++ac_cv_little_endian_double=yes ++ac_cv_big_endian_double=no ++ac_cv_mixed_endian_double=no ++ ++ac_cv_tanh_preserves_zero_sign=yes ++ ++ac_cv_wchar_t_signed=no ++ ++ac_cv_have_size_t_format=no diff --git a/mingw-w64-python3.9/0150-MINGW-configure-largefile-support-for-windows-builds.patch b/mingw-w64-python3.9/0150-MINGW-configure-largefile-support-for-windows-builds.patch new file mode 100644 index 0000000000..4874784a8f --- /dev/null +++ b/mingw-w64-python3.9/0150-MINGW-configure-largefile-support-for-windows-builds.patch @@ -0,0 +1,24 @@ +diff -Naur Python-3.8.0-orig/configure.ac Python-3.8.0/configure.ac +--- Python-3.8.0-orig/configure.ac 2019-10-22 10:00:45.568716700 +0300 ++++ Python-3.8.0/configure.ac 2019-10-22 10:00:47.456320000 +0300 +@@ -2407,8 +2407,20 @@ + ]) + + AC_MSG_CHECKING(whether to enable large file support) ++have_largefile_support=no + if test "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \ + "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then ++ have_largefile_support=yes ++else ++ case $host in ++ *-*-mingw*) ++ dnl Activate on windows platforms (32&64-bit) where off_t(4) < fpos_t(8) ++ have_largefile_support=yes ++ ;; ++ esac ++fi ++ ++if test $have_largefile_support = yes ; then + AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1, + [Defined to enable large file support when an off_t is bigger than a long + and long long is at least as big as an off_t. You may need diff --git a/mingw-w64-python3.9/0170-MINGW-add-srcdir-PC-to-CPPFLAGS.patch b/mingw-w64-python3.9/0170-MINGW-add-srcdir-PC-to-CPPFLAGS.patch new file mode 100644 index 0000000000..15d80d46c1 --- /dev/null +++ b/mingw-w64-python3.9/0170-MINGW-add-srcdir-PC-to-CPPFLAGS.patch @@ -0,0 +1,25 @@ +diff -Naur Python-3.8.0-orig/configure.ac Python-3.8.0/configure.ac +--- Python-3.8.0-orig/configure.ac 2019-10-22 10:00:49.172323000 +0300 ++++ Python-3.8.0/configure.ac 2019-10-22 10:00:50.295525000 +0300 +@@ -5619,8 +5619,21 @@ + THREADHEADERS="$THREADHEADERS \$(srcdir)/$h" + done + ++case $host in ++ *-*-mingw*) ++ dnl Required for windows builds as Objects/exceptions.c require ++ dnl "errmap.h" from $srcdir/PC. ++ dnl Note we cannot use BASECPPFLAGS as autogenerated pyconfig.h ++ dnl has to be before customized located in ../PC. ++ CPPFLAGS="-I\$(srcdir)/PC $CPPFLAGS" ++ ;; ++esac ++ + AC_SUBST(SRCDIRS) + SRCDIRS="Parser Parser/pegen Objects Python Modules Modules/_io Programs" ++case $host in ++ *-*-mingw*) SRCDIRS="$SRCDIRS PC";; ++esac + AC_MSG_CHECKING(for build directories) + for dir in $SRCDIRS; do + if test ! -d $dir; then diff --git a/mingw-w64-python3.9/0180-MINGW-init-system-calls.patch b/mingw-w64-python3.9/0180-MINGW-init-system-calls.patch new file mode 100644 index 0000000000..9612a43072 --- /dev/null +++ b/mingw-w64-python3.9/0180-MINGW-init-system-calls.patch @@ -0,0 +1,99 @@ +diff -Naur Python-3.8.0-orig/configure.ac Python-3.8.0/configure.ac +--- Python-3.8.0-orig/configure.ac 2019-10-22 10:00:52.028128100 +0300 ++++ Python-3.8.0/configure.ac 2019-10-22 10:00:53.198130100 +0300 +@@ -574,6 +574,14 @@ + AC_DEFINE(_INCLUDE__STDC_A1_SOURCE, 1, Define to include mbstate_t for mbrtowc) + fi + ++AC_MSG_CHECKING([for init system calls]) ++AC_SUBST(INITSYS) ++case $host in ++ *-*-mingw*) INITSYS=nt;; ++ *) INITSYS=posix;; ++esac ++AC_MSG_RESULT([$INITSYS]) ++ + # Record the configure-time value of MACOSX_DEPLOYMENT_TARGET, + # it may influence the way we can build extensions, so distutils + # needs to check it +--- Python-3.8.1/Modules/posixmodule.c.orig 2019-12-18 18:21:23.000000000 +0100 ++++ Python-3.8.1/Modules/posixmodule.c 2019-12-23 10:35:51.095967700 +0100 +@@ -309,6 +309,27 @@ + # define HAVE_CWAIT 1 + # define HAVE_FSYNC 1 + # define fsync _commit ++# elif defined(__MINGW32__) /* GCC for windows hosts */ ++/* getlogin is detected by configure on mingw-w64 */ ++# undef HAVE_GETLOGIN ++/*# define HAVE_GETCWD 1 - detected by configure*/ ++# define HAVE_GETPPID 1 ++# define HAVE_GETLOGIN 1 ++# define HAVE_SPAWNV 1 ++# define HAVE_WSPAWNV 1 ++# define HAVE_WEXECV 1 ++/*# define HAVE_EXECV 1 - detected by configure*/ ++# define HAVE_PIPE 1 ++# define HAVE_POPEN 1 ++# define HAVE_SYSTEM 1 ++# define HAVE_CWAIT 1 ++# define HAVE_FSYNC 1 ++# define fsync _commit ++# include ++# include ++# ifndef _MAX_ENV ++# define _MAX_ENV 32767 ++# endif + # else + /* Unix functions that the configure script doesn't check for */ + # ifndef __VXWORKS__ +@@ -409,7 +430,7 @@ + # endif + #endif + +-#ifdef _MSC_VER ++#ifdef MS_WINDOWS + # ifdef HAVE_DIRECT_H + # include + # endif +@@ -431,7 +452,7 @@ + # include // ShellExecute() + # include // UNLEN + # define HAVE_SYMLINK +-#endif /* _MSC_VER */ ++#endif /* MS_WINDOWS */ + + #ifndef MAXPATHLEN + # if defined(PATH_MAX) && PATH_MAX > 1024 +@@ -1520,9 +1520,9 @@ + ** man environ(7). + */ + #include +-#elif !defined(_MSC_VER) && (!defined(__WATCOMC__) || defined(__QNX__) || defined(__VXWORKS__)) ++#elif !defined(MS_WINDOWS) && (!defined(__WATCOMC__) || defined(__QNX__) || defined(__VXWORKS__)) + extern char **environ; +-#endif /* !_MSC_VER */ ++#endif /* !MS_WINDOWS */ + + static PyObject * + convertenviron(void) +diff -Naur Python-3.8.0-orig/Modules/Setup Python-3.8.0/Modules/Setup +--- Python-3.8.0-orig/Modules/Setup 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/Modules/Setup 2019-10-22 10:00:54.430532300 +0300 +@@ -101,7 +101,6 @@ + # This only contains the minimal set of modules required to run the + # setup.py script in the root of the Python source tree. + +-posix -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal posixmodule.c # posix (UNIX) system calls + errno errnomodule.c # posix (UNIX) errno values + pwd pwdmodule.c # this is needed to find out the user's home dir + # if $HOME is not set +diff -Naur Python-3.8.0-orig/Modules/Setup.config.in Python-3.8.0/Modules/Setup.config.in +--- Python-3.8.0-orig/Modules/Setup.config.in 2019-10-22 10:00:30.171489600 +0300 ++++ Python-3.8.0/Modules/Setup.config.in 2019-10-22 10:00:54.009331600 +0300 +@@ -3,3 +3,6 @@ + # The purpose of this file is to conditionally enable certain modules + # based on configure-time options. + ++# init system calls(posix/nt/...) for INITFUNC (used by makesetup) ++@INITSYS@ -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal posixmodule.c ++ diff --git a/mingw-w64-python3.9/0200-MINGW-build-in-windows-modules-winreg.patch b/mingw-w64-python3.9/0200-MINGW-build-in-windows-modules-winreg.patch new file mode 100644 index 0000000000..9ee4b813cf --- /dev/null +++ b/mingw-w64-python3.9/0200-MINGW-build-in-windows-modules-winreg.patch @@ -0,0 +1,56 @@ +diff -Naur Python-3.8.0-orig/configure.ac Python-3.8.0/configure.ac +--- Python-3.8.0-orig/configure.ac 2019-10-22 10:00:56.583336100 +0300 ++++ Python-3.8.0/configure.ac 2019-10-22 10:00:58.938940200 +0300 +@@ -3181,6 +3181,13 @@ + fi]) + AC_MSG_RESULT($with_dbmliborder) + ++# Determine if windows modules should be used. ++AC_SUBST(USE_WIN32_MODULE) ++USE_WIN32_MODULE='#' ++case $host in ++ *-*-mingw*) USE_WIN32_MODULE=;; ++esac ++ + # Templates for things AC_DEFINEd more than once. + # For a single AC_DEFINE, no template is needed. + AH_TEMPLATE(_REENTRANT, +diff -Naur Python-3.8.0-orig/Modules/Setup.config.in Python-3.8.0/Modules/Setup.config.in +--- Python-3.8.0-orig/Modules/Setup.config.in 2019-10-22 10:00:57.800138200 +0300 ++++ Python-3.8.0/Modules/Setup.config.in 2019-10-22 10:00:59.328940900 +0300 +@@ -6,3 +6,6 @@ + # init system calls(posix/nt/...) for INITFUNC (used by makesetup) + @INITSYS@ -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal posixmodule.c + ++# build-in modules for windows platform: ++@USE_WIN32_MODULE@winreg ../PC/winreg.c ++ +diff -Naur Python-3.8.0-orig/PC/winreg.c Python-3.8.0/PC/winreg.c +--- Python-3.8.0-orig/PC/winreg.c 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/PC/winreg.c 2019-10-22 10:00:59.734541600 +0300 +@@ -17,6 +17,25 @@ + #include "structmember.h" + #include "windows.h" + ++#ifndef SIZEOF_HKEY ++/* used only here */ ++#if defined(MS_WIN64) ++# define SIZEOF_HKEY 8 ++#elif defined(MS_WIN32) ++# define SIZEOF_HKEY 4 ++#else ++# error "SIZEOF_HKEY is not defined" ++#endif ++#endif ++ ++#ifndef REG_LEGAL_CHANGE_FILTER ++#define REG_LEGAL_CHANGE_FILTER (\ ++ REG_NOTIFY_CHANGE_NAME |\ ++ REG_NOTIFY_CHANGE_ATTRIBUTES |\ ++ REG_NOTIFY_CHANGE_LAST_SET |\ ++ REG_NOTIFY_CHANGE_SECURITY ) ++#endif ++ + static BOOL PyHKEY_AsHKEY(PyObject *ob, HKEY *pRes, BOOL bNoneOK); + static BOOL clinic_HKEY_converter(PyObject *ob, void *p); + static PyObject *PyHKEY_FromHKEY(HKEY h); diff --git a/mingw-w64-python3.9/0210-MINGW-determine-if-pwdmodule-should-be-used.patch b/mingw-w64-python3.9/0210-MINGW-determine-if-pwdmodule-should-be-used.patch new file mode 100644 index 0000000000..fc37f869fd --- /dev/null +++ b/mingw-w64-python3.9/0210-MINGW-determine-if-pwdmodule-should-be-used.patch @@ -0,0 +1,42 @@ +diff -Naur Python-3.8.0-orig/configure.ac Python-3.8.0/configure.ac +--- Python-3.8.0-orig/configure.ac 2019-10-22 10:01:01.887345400 +0300 ++++ Python-3.8.0/configure.ac 2019-10-22 10:01:03.821748800 +0300 +@@ -3188,6 +3188,13 @@ + *-*-mingw*) USE_WIN32_MODULE=;; + esac + ++# Determine if pwdmodule should be used. ++AC_SUBST(USE_PWD_MODULE) ++USE_PWD_MODULE= ++case $host in ++ *-*-mingw*) USE_PWD_MODULE='#';; ++esac ++ + # Templates for things AC_DEFINEd more than once. + # For a single AC_DEFINE, no template is needed. + AH_TEMPLATE(_REENTRANT, +diff -Naur Python-3.8.0-orig/Modules/Setup Python-3.8.0/Modules/Setup +--- Python-3.8.0-orig/Modules/Setup 2019-10-22 10:00:57.394537500 +0300 ++++ Python-3.8.0/Modules/Setup 2019-10-22 10:01:04.227349500 +0300 +@@ -102,8 +102,6 @@ + # setup.py script in the root of the Python source tree. + + errno errnomodule.c # posix (UNIX) errno values +-pwd pwdmodule.c # this is needed to find out the user's home dir +- # if $HOME is not set + _sre _sre.c # Fredrik Lundh's new regular expressions + _codecs _codecsmodule.c # access to the builtin codecs and codec registry + _weakref _weakref.c # weak references +diff -Naur Python-3.8.0-orig/Modules/Setup.config.in Python-3.8.0/Modules/Setup.config.in +--- Python-3.8.0-orig/Modules/Setup.config.in 2019-10-22 10:01:02.292946100 +0300 ++++ Python-3.8.0/Modules/Setup.config.in 2019-10-22 10:01:05.038550900 +0300 +@@ -6,6 +6,9 @@ + # init system calls(posix/nt/...) for INITFUNC (used by makesetup) + @INITSYS@ -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal posixmodule.c + ++# This is needed to find out the user's home dir if $HOME is not set ++@USE_PWD_MODULE@pwd pwdmodule.c ++ + # build-in modules for windows platform: + @USE_WIN32_MODULE@winreg ../PC/winreg.c + diff --git a/mingw-w64-python3.9/0250-MINGW-compiler-customize-mingw-cygwin-compilers.patch b/mingw-w64-python3.9/0250-MINGW-compiler-customize-mingw-cygwin-compilers.patch new file mode 100644 index 0000000000..eb8d0205b4 --- /dev/null +++ b/mingw-w64-python3.9/0250-MINGW-compiler-customize-mingw-cygwin-compilers.patch @@ -0,0 +1,36 @@ +diff -Naur Python-3.8.0-orig/Lib/distutils/sysconfig.py Python-3.8.0/Lib/distutils/sysconfig.py +--- Python-3.8.0-orig/Lib/distutils/sysconfig.py 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/Lib/distutils/sysconfig.py 2019-10-22 10:01:09.125758100 +0300 +@@ -170,7 +170,23 @@ + Mainly needed on Unix, so we can plug in the information that + varies across Unices and is stored in Python's Makefile. + """ +- if compiler.compiler_type == "unix": ++ global _config_vars ++ if compiler.compiler_type in ["cygwin", "mingw32"]: ++ # Note that cygwin use posix build and 'unix' compiler. ++ # If build is not based on posix then we must predefine ++ # some environment variables corresponding to posix ++ # build rules and defaults. ++ if not 'GCC' in sys.version: ++ _config_vars['CC'] = "gcc" ++ _config_vars['CXX'] = "g++" ++ _config_vars['OPT'] = "-fwrapv -O3 -Wall -Wstrict-prototypes" ++ _config_vars['CFLAGS'] = "" ++ _config_vars['CCSHARED'] = "" ++ _config_vars['LDSHARED'] = "gcc -shared -Wl,--enable-auto-image-base" ++ _config_vars['AR'] = "ar" ++ _config_vars['ARFLAGS'] = "rc" ++ ++ if compiler.compiler_type in ["unix", "cygwin", "mingw32"]: + if sys.platform == "darwin": + # Perform first-time customization of compiler-related + # config vars on OS X now that we know we need a compiler. +@@ -180,7 +196,6 @@ + # that Python itself was built on. Also the user OS + # version and build tools may not support the same set + # of CPU architectures for universal builds. +- global _config_vars + # Use get_config_var() to ensure _config_vars is initialized. + if not get_config_var('CUSTOMIZED_OSX_COMPILER'): + import _osx_support diff --git a/mingw-w64-python3.9/0260-MINGW-compiler-enable-new-dtags.patch b/mingw-w64-python3.9/0260-MINGW-compiler-enable-new-dtags.patch new file mode 100644 index 0000000000..88cb08f06e --- /dev/null +++ b/mingw-w64-python3.9/0260-MINGW-compiler-enable-new-dtags.patch @@ -0,0 +1,19 @@ +diff -Naur Python-3.8.0-orig/Lib/distutils/unixccompiler.py Python-3.8.0/Lib/distutils/unixccompiler.py +--- Python-3.8.0-orig/Lib/distutils/unixccompiler.py 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/Lib/distutils/unixccompiler.py 2019-10-22 10:01:11.964963100 +0300 +@@ -248,9 +248,13 @@ + # -Wl whenever gcc was used in the past it is probably + # safest to keep doing so. + if sysconfig.get_config_var("GNULD") == "yes": +- # GNU ld needs an extra option to get a RUNPATH ++ # GNU ELF ld needs an extra option to get a RUNPATH + # instead of just an RPATH. +- return "-Wl,--enable-new-dtags,-R" + dir ++ if sys.platform in ["win32", "cygwin"] or \ ++ "mingw" in compiler: ++ return [] ++ else: ++ return "-Wl,--enable-new-dtags,-R" + dir + else: + return "-Wl,-R" + dir + else: diff --git a/mingw-w64-python3.9/0290-issue6672-v2-Add-Mingw-recognition-to-pyport.h-to-al.patch b/mingw-w64-python3.9/0290-issue6672-v2-Add-Mingw-recognition-to-pyport.h-to-al.patch new file mode 100644 index 0000000000..c95a59a04c --- /dev/null +++ b/mingw-w64-python3.9/0290-issue6672-v2-Add-Mingw-recognition-to-pyport.h-to-al.patch @@ -0,0 +1,62 @@ +diff -Naur Python-3.8.0-orig/Include/pyport.h Python-3.8.0/Include/pyport.h +--- Python-3.8.0-orig/Include/pyport.h 2019-10-22 10:00:37.955903300 +0300 ++++ Python-3.8.0/Include/pyport.h 2019-10-22 10:01:14.850968200 +0300 +@@ -664,12 +664,12 @@ + */ + + /* +- All windows ports, except cygwin, are handled in PC/pyconfig.h. ++ Only MSVC windows ports is handled in PC/pyconfig.h. + +- Cygwin is the only other autoconf platform requiring special ++ Cygwin and Mingw is the only other autoconf platform requiring special + linkage handling and it uses __declspec(). + */ +-#if defined(__CYGWIN__) ++#if defined(__CYGWIN__) || defined(__MINGW32__) + # define HAVE_DECLSPEC_DLL + #endif + +@@ -682,21 +682,23 @@ + # define PyAPI_FUNC(RTYPE) Py_EXPORTED_SYMBOL RTYPE + # define PyAPI_DATA(RTYPE) extern Py_EXPORTED_SYMBOL RTYPE + /* module init functions inside the core need no external linkage */ +- /* except for Cygwin to handle embedding */ +-# if defined(__CYGWIN__) ++ /* except for Cygwin/Mingw to handle embedding */ ++# if defined(__CYGWIN__) || defined(__MINGW32__) + # define PyMODINIT_FUNC Py_EXPORTED_SYMBOL PyObject* +-# else /* __CYGWIN__ */ ++# else /* __CYGWIN__ || __MINGW32__*/ + # define PyMODINIT_FUNC PyObject* +-# endif /* __CYGWIN__ */ ++# endif /* __CYGWIN__ || __MINGW32__*/ + # else /* Py_BUILD_CORE */ + /* Building an extension module, or an embedded situation */ + /* public Python functions and data are imported */ + /* Under Cygwin, auto-import functions to prevent compilation */ + /* failures similar to those described at the bottom of 4.1: */ + /* http://docs.python.org/extending/windows.html#a-cookbook-approach */ +-# if !defined(__CYGWIN__) ++# if defined(__CYGWIN__) || defined(__MINGW32__) ++# define PyAPI_FUNC(RTYPE) RTYPE ++# else + # define PyAPI_FUNC(RTYPE) Py_IMPORTED_SYMBOL RTYPE +-# endif /* !__CYGWIN__ */ ++# endif /* __CYGWIN__ || __MINGW32__*/ + # define PyAPI_DATA(RTYPE) extern Py_IMPORTED_SYMBOL RTYPE + /* module init functions outside the core must be exported */ + # if defined(__cplusplus) +diff -Naur Python-3.8.0-orig/setup.py Python-3.8.0/setup.py +--- Python-3.8.0-orig/setup.py 2019-10-22 10:00:25.787881900 +0300 ++++ Python-3.8.0/setup.py 2019-10-22 10:01:15.256568900 +0300 +@@ -316,6 +316,9 @@ + raise ValueError("No source directory; cannot proceed.") + self.srcdir = os.path.abspath(self.srcdir) + ++ if MS_WINDOWS: ++ self.compiler.define_macro("Py_BUILD_CORE_MODULE") ++ + # Detect which modules should be compiled + self.detect_modules() + diff --git a/mingw-w64-python3.9/0300-MINGW-configure-for-shared-build.patch b/mingw-w64-python3.9/0300-MINGW-configure-for-shared-build.patch new file mode 100644 index 0000000000..1b81791f85 --- /dev/null +++ b/mingw-w64-python3.9/0300-MINGW-configure-for-shared-build.patch @@ -0,0 +1,51 @@ +diff -Naur Python-3.8.0-orig/configure.ac Python-3.8.0/configure.ac +--- Python-3.8.0-orig/configure.ac 2019-10-22 10:01:07.206954700 +0300 ++++ Python-3.8.0/configure.ac 2019-10-22 10:01:18.470174500 +0300 +@@ -1204,6 +1204,13 @@ + ;; + + esac ++ case $host in ++ *-*-mingw*) ++ LDLIBRARY='libpython$(LDVERSION).dll.a' ++ DLLLIBRARY='libpython$(LDVERSION).dll' ++ BLDLIBRARY='-L. -lpython$(LDVERSION)' ++ ;; ++ esac + else # shared is disabled + PY_ENABLE_SHARED=0 + case $ac_sys_system in +@@ -1212,6 +1219,10 @@ + LDLIBRARY='libpython$(LDVERSION).dll.a' + ;; + esac ++ case $host in ++ *-*-mingw*) ++ LDLIBRARY='libpython$(LDVERSION).a';; ++ esac + fi + + if test "$cross_compiling" = yes; then +@@ -2760,6 +2771,12 @@ + LDCXXSHARED="g++ -shared -Wl,--enable-auto-image-base";; + *) LDSHARED="ld";; + esac ++ case $host in ++ *-*-mingw*) ++ LDSHARED='$(CC) -shared -Wl,--enable-auto-image-base' ++ LDCXXSHARED='$(CXX) -shared -Wl,--enable-auto-image-base' ++ ;; ++ esac + fi + AC_MSG_RESULT($LDSHARED) + LDCXXSHARED=${LDCXXSHARED-$LDSHARED} +@@ -5478,7 +5495,8 @@ + dnl "errmap.h" from $srcdir/PC. + dnl Note we cannot use BASECPPFLAGS as autogenerated pyconfig.h + dnl has to be before customized located in ../PC. +- CPPFLAGS="-I\$(srcdir)/PC $CPPFLAGS" ++ dnl (-I. at end is workaround for setup.py logic) ++ CPPFLAGS="-I\$(srcdir)/PC $CPPFLAGS -I." + ;; + esac + diff --git a/mingw-w64-python3.9/0310-MINGW-dynamic-loading-support.patch b/mingw-w64-python3.9/0310-MINGW-dynamic-loading-support.patch new file mode 100644 index 0000000000..791c700515 --- /dev/null +++ b/mingw-w64-python3.9/0310-MINGW-dynamic-loading-support.patch @@ -0,0 +1,81 @@ +diff -Naur Python-3.8.0-orig/configure.ac Python-3.8.0/configure.ac +--- Python-3.8.0-orig/configure.ac 2019-10-22 10:01:20.201777600 +0300 ++++ Python-3.8.0/configure.ac 2019-10-22 10:01:21.340579600 +0300 +@@ -2635,6 +2635,9 @@ + CYGWIN*) SHLIB_SUFFIX=.dll;; + *) SHLIB_SUFFIX=.so;; + esac ++ case $host_os in ++ mingw*) SHLIB_SUFFIX=.dll;; ++ esac + fi + AC_MSG_RESULT($SHLIB_SUFFIX) + +@@ -3677,6 +3680,12 @@ + fi + ;; + esac ++ case $host in ++ *-*-mingw*) ++ DYNLOADFILE="dynload_win.o" ++ extra_machdep_objs="$extra_machdep_objs PC/dl_nt.o" ++ ;; ++ esac + fi + AC_MSG_RESULT($DYNLOADFILE) + if test "$DYNLOADFILE" != "dynload_stub.o" +@@ -4837,6 +4846,12 @@ + *) + EXT_SUFFIX=${SHLIB_SUFFIX};; + esac ++case $host_os in ++ mingw*) ++ dnl Synchronized with _PyImport_DynLoadFiletab (dynload_win.c) ++ dnl Do not use more then one dot on this platform ! ++ EXT_SUFFIX=-$SOABI$SHLIB_SUFFIX;; ++esac + + AC_MSG_CHECKING(LDVERSION) + LDVERSION='$(VERSION)$(ABIFLAGS)' +diff -Naur Python-3.8.0-orig/Makefile.pre.in Python-3.8.0/Makefile.pre.in +--- Python-3.8.0-orig/Makefile.pre.in 2019-10-22 10:00:29.734688900 +0300 ++++ Python-3.8.0/Makefile.pre.in 2019-10-22 10:01:21.746180300 +0300 +@@ -784,6 +784,12 @@ + -DSHLIB_EXT='"$(EXT_SUFFIX)"' \ + -o $@ $(srcdir)/Python/dynload_hpux.c + ++Python/dynload_win.o: $(srcdir)/Python/dynload_win.c Makefile ++ $(CC) -c $(PY_CORE_CFLAGS) \ ++ -DSHLIB_SUFFIX='"$(SHLIB_SUFFIX)"' \ ++ -DEXT_SUFFIX='"$(EXT_SUFFIX)"' \ ++ -o $@ $(srcdir)/Python/dynload_win.c ++ + Python/sysmodule.o: $(srcdir)/Python/sysmodule.c Makefile $(srcdir)/Include/pydtrace.h + $(CC) -c $(PY_CORE_CFLAGS) \ + -DABIFLAGS='"$(ABIFLAGS)"' \ +diff -Naur Python-3.8.0-orig/Python/dynload_win.c Python-3.8.0/Python/dynload_win.c +--- Python-3.8.0-orig/Python/dynload_win.c 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/Python/dynload_win.c 2019-10-22 10:01:22.151781000 +0300 +@@ -33,6 +33,12 @@ + #define PYD_UNTAGGED_SUFFIX PYD_DEBUG_SUFFIX ".pyd" + + const char *_PyImport_DynLoadFiletab[] = { ++#ifdef EXT_SUFFIX ++ EXT_SUFFIX, /* include SOABI flags where is encoded debug */ ++#endif ++#ifdef SHLIB_SUFFIX ++ "-abi" PYTHON_ABI_STRING SHLIB_SUFFIX, ++#endif + PYD_TAGGED_SUFFIX, + PYD_UNTAGGED_SUFFIX, + NULL +@@ -203,8 +209,7 @@ + ensure DLLs adjacent to the PYD are preferred. */ + Py_BEGIN_ALLOW_THREADS + hDLL = LoadLibraryExW(wpathname, NULL, +- LOAD_LIBRARY_SEARCH_DEFAULT_DIRS | +- LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR); ++ LOAD_WITH_ALTERED_SEARCH_PATH); + Py_END_ALLOW_THREADS + #if HAVE_SXS + _Py_DeactivateActCtx(cookie); diff --git a/mingw-w64-python3.9/0330-MINGW-ignore-main-program-for-frozen-scripts.patch b/mingw-w64-python3.9/0330-MINGW-ignore-main-program-for-frozen-scripts.patch new file mode 100644 index 0000000000..b58c402d34 --- /dev/null +++ b/mingw-w64-python3.9/0330-MINGW-ignore-main-program-for-frozen-scripts.patch @@ -0,0 +1,32 @@ +diff -Naur Python-3.8.0-orig/configure.ac Python-3.8.0/configure.ac +--- Python-3.8.0-orig/configure.ac 2019-10-22 10:01:23.898984100 +0300 ++++ Python-3.8.0/configure.ac 2019-10-22 10:01:25.833387400 +0300 +@@ -5515,6 +5515,16 @@ + ;; + esac + ++dnl Python interpreter main program for frozen scripts ++AC_SUBST(PYTHON_OBJS_FROZENMAIN) ++PYTHON_OBJS_FROZENMAIN="Python/frozenmain.o" ++case $host in ++ *-*-mingw*) ++ dnl 'PC/frozen_dllmain.c' - not yet ++ PYTHON_OBJS_FROZENMAIN= ++ ;; ++esac ++ + AC_SUBST(SRCDIRS) + SRCDIRS="Parser Objects Python Modules Modules/_io Programs" + case $host in +diff -Naur Python-3.8.0-orig/Makefile.pre.in Python-3.8.0/Makefile.pre.in +--- Python-3.8.0-orig/Makefile.pre.in 2019-10-22 10:01:24.304584800 +0300 ++++ Python-3.8.0/Makefile.pre.in 2019-10-22 10:01:26.238988200 +0300 +@@ -327,7 +327,7 @@ + Python/context.o \ + Python/dynamic_annotations.o \ + Python/errors.o \ +- Python/frozenmain.o \ ++ @PYTHON_OBJS_FROZENMAIN@ \ + Python/future.o \ + Python/getargs.o \ + Python/getcompiler.o \ diff --git a/mingw-w64-python3.9/0350-MINGW-setup-_multiprocessing-module.patch b/mingw-w64-python3.9/0350-MINGW-setup-_multiprocessing-module.patch new file mode 100644 index 0000000000..3df91065dc --- /dev/null +++ b/mingw-w64-python3.9/0350-MINGW-setup-_multiprocessing-module.patch @@ -0,0 +1,16 @@ +diff -Naur Python-3.8.0-orig/setup.py Python-3.8.0/setup.py +--- Python-3.8.0-orig/setup.py 2019-10-22 10:01:17.378172600 +0300 ++++ Python-3.8.0/setup.py 2019-10-22 10:01:29.904994600 +0300 +@@ -1667,7 +1667,12 @@ + libraries=libs, + include_dirs=["Modules/_multiprocessing"])) + ++ multiprocessing_libs = [] ++ if MS_WINDOWS: ++ multiprocessing_libs += ['ws2_32'] + self.add(Extension('_multiprocessing', multiprocessing_srcs, ++ define_macros={}, ++ libraries=multiprocessing_libs, + include_dirs=["Modules/_multiprocessing"])) + + def detect_uuid(self): diff --git a/mingw-w64-python3.9/0360-MINGW-setup-select-module.patch b/mingw-w64-python3.9/0360-MINGW-setup-select-module.patch new file mode 100644 index 0000000000..e8b9763925 --- /dev/null +++ b/mingw-w64-python3.9/0360-MINGW-setup-select-module.patch @@ -0,0 +1,40 @@ +diff -Naur Python-3.8.0-orig/Modules/selectmodule.c Python-3.8.0/Modules/selectmodule.c +--- Python-3.8.0-orig/Modules/selectmodule.c 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/Modules/selectmodule.c 2019-10-22 10:01:32.759799600 +0300 +@@ -134,9 +134,9 @@ + v = PyObject_AsFileDescriptor( o ); + if (v == -1) goto finally; + +-#if defined(_MSC_VER) ++#if defined(MS_WIN32) + max = 0; /* not used for Win32 */ +-#else /* !_MSC_VER */ ++#else /* !MS_WIN32 */ + if (!_PyIsSelectable_fd(v)) { + PyErr_SetString(PyExc_ValueError, + "filedescriptor out of range in select()"); +@@ -144,7 +144,7 @@ + } + if (v > max) + max = v; +-#endif /* _MSC_VER */ ++#endif /* MS_WIN32 */ + FD_SET(v, set); + + /* add object and its file descriptor to the list */ +diff -Naur Python-3.8.0-orig/setup.py Python-3.8.0/setup.py +--- Python-3.8.0-orig/setup.py 2019-10-22 10:01:31.636597600 +0300 ++++ Python-3.8.0/setup.py 2019-10-22 10:01:33.181000400 +0300 +@@ -817,7 +817,11 @@ + self.missing.append('spwd') + + # select(2); not on ancient System V +- self.add(Extension('select', ['selectmodule.c'])) ++ select_libs = [] ++ if MS_WINDOWS: ++ select_libs += ['ws2_32'] ++ self.add(Extension('select', ['selectmodule.c'], ++ libraries=select_libs)) + + # Fred Drake's interface to the Python parser + self.add(Extension('parser', ['parsermodule.c'])) diff --git a/mingw-w64-python3.9/0370-MINGW-setup-_ctypes-module-with-system-libffi.patch b/mingw-w64-python3.9/0370-MINGW-setup-_ctypes-module-with-system-libffi.patch new file mode 100644 index 0000000000..e7366f0176 --- /dev/null +++ b/mingw-w64-python3.9/0370-MINGW-setup-_ctypes-module-with-system-libffi.patch @@ -0,0 +1,26 @@ +diff -Naur Python-3.8.0-orig/setup.py Python-3.8.0/setup.py +--- Python-3.8.0-orig/setup.py 2019-10-22 10:01:35.318204100 +0300 ++++ Python-3.8.0/setup.py 2019-10-22 10:01:36.394606000 +0300 +@@ -2043,9 +2043,12 @@ + self.add(ext) + if TEST_EXTENSIONS: + # function my_sqrt() needs libm for sqrt() ++ ffi_test_libs = ['m'] ++ if MS_WINDOWS: ++ ffi_test_libs += ['oleaut32'] + self.add(Extension('_ctypes_test', + sources=['_ctypes/_ctypes_test.c'], +- libraries=['m'])) ++ libraries=ffi_test_libs)) + + ffi_inc_dirs = self.inc_dirs.copy() + if MACOS: +@@ -2073,6 +2076,8 @@ + if ffi_inc and ffi_lib: + ext.include_dirs.extend(ffi_inc) + ext.libraries.append(ffi_lib) ++ if MS_WINDOWS: ++ ext.libraries.extend(['ole32', 'oleaut32', 'uuid']) + self.use_system_libffi = True + + if sysconfig.get_config_var('HAVE_LIBDL'): diff --git a/mingw-w64-python3.9/0380-MINGW-defect-winsock2-and-setup-_socket-module.patch b/mingw-w64-python3.9/0380-MINGW-defect-winsock2-and-setup-_socket-module.patch new file mode 100644 index 0000000000..b36a1318b9 --- /dev/null +++ b/mingw-w64-python3.9/0380-MINGW-defect-winsock2-and-setup-_socket-module.patch @@ -0,0 +1,141 @@ +diff -Naur Python-3.8.0-orig/configure.ac Python-3.8.0/configure.ac +--- Python-3.8.0-orig/configure.ac 2019-10-22 10:01:27.970591200 +0300 ++++ Python-3.8.0/configure.ac 2019-10-22 10:01:39.327411100 +0300 +@@ -4291,21 +4291,36 @@ + ],[]) + AC_MSG_RESULT($was_it_defined) + ++AC_CHECK_HEADERS([ws2tcpip.h]) + AC_MSG_CHECKING(for addrinfo) + AC_CACHE_VAL(ac_cv_struct_addrinfo, +-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[struct addrinfo a]])], ++AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ++#ifdef HAVE_WS2TCPIP_H ++# include ++#else ++# include ++#endif]], ++ [[struct addrinfo a]])], + [ac_cv_struct_addrinfo=yes], + [ac_cv_struct_addrinfo=no])) + AC_MSG_RESULT($ac_cv_struct_addrinfo) + if test $ac_cv_struct_addrinfo = yes; then +- AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)]) ++ AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo]) + fi + + AC_MSG_CHECKING(for sockaddr_storage) + AC_CACHE_VAL(ac_cv_struct_sockaddr_storage, + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +-# include +-# include ]], [[struct sockaddr_storage s]])], ++#ifdef HAVE_WS2TCPIP_H ++#include ++#endif ++#ifdef HAVE_SYS_TYPES_H ++#include ++#endif ++#ifdef HAVE_SYS_SOCKET_H ++#include ++#endif]], ++ [[struct sockaddr_storage s]])], + [ac_cv_struct_sockaddr_storage=yes], + [ac_cv_struct_sockaddr_storage=no])) + AC_MSG_RESULT($ac_cv_struct_sockaddr_storage) +@@ -5411,7 +5426,10 @@ + + AC_CHECK_TYPE(socklen_t,, + AC_DEFINE(socklen_t,int, +- [Define to `int' if does not define.]),[ ++ [Define to `int' if or does not define.]),[ ++#ifdef HAVE_WS2TCPIP_H ++#include ++#endif + #ifdef HAVE_SYS_TYPES_H + #include + #endif +diff -Naur Python-3.8.0-orig/Misc/config_mingw Python-3.8.0/Misc/config_mingw +--- Python-3.8.0-orig/Misc/config_mingw 2019-10-22 10:00:45.989917400 +0300 ++++ Python-3.8.0/Misc/config_mingw 2019-10-22 10:01:39.733011900 +0300 +@@ -10,3 +10,6 @@ + # files to ignore + ac_cv_file__dev_ptmx=ignore #NOTE: under MSYS environment device exist + ac_cv_file__dev_ptc=no ++ ++# force detection of winsock2 functionality - require wxp or newer ++ac_cv_func_getpeername=yes +diff -Naur Python-3.8.0-orig/Modules/socketmodule.c Python-3.8.0/Modules/socketmodule.c +--- Python-3.8.0-orig/Modules/socketmodule.c 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/Modules/socketmodule.c 2019-10-22 10:01:40.123012500 +0300 +@@ -310,7 +310,7 @@ + # endif + + /* Macros based on the IPPROTO enum, see: https://bugs.python.org/issue29515 */ +-#ifdef MS_WINDOWS ++#ifdef _MSC_VER + #define IPPROTO_ICMP IPPROTO_ICMP + #define IPPROTO_IGMP IPPROTO_IGMP + #define IPPROTO_GGP IPPROTO_GGP +@@ -341,7 +341,7 @@ + #define IPPROTO_PGM IPPROTO_PGM // WinSock2 only + #define IPPROTO_L2TP IPPROTO_L2TP // WinSock2 only + #define IPPROTO_SCTP IPPROTO_SCTP // WinSock2 only +-#endif /* MS_WINDOWS */ ++#endif /* _MSC_VER */ + + /* Provides the IsWindows7SP1OrGreater() function */ + #include +@@ -434,6 +434,10 @@ + /* Do not include addrinfo.h for MSVC7 or greater. 'addrinfo' and + * EAI_* constants are defined in (the already included) ws2tcpip.h. + */ ++#elif defined(__MINGW32__) ++ /* Do not include addrinfo.h as minimum supported version is ++ * _WIN32_WINNT >= WindowsXP(0x0501) ++ */ + #else + # include "addrinfo.h" + #endif +diff -Naur Python-3.8.0-orig/pyconfig.h.in Python-3.8.0/pyconfig.h.in +--- Python-3.8.0-orig/pyconfig.h.in 2019-10-22 10:00:35.132298300 +0300 ++++ Python-3.8.0/pyconfig.h.in 2019-10-22 10:01:40.513013200 +0300 +@@ -54,7 +54,7 @@ + /* Define to 1 if you have the `acosh' function. */ + #undef HAVE_ACOSH + +-/* struct addrinfo (netdb.h) */ ++/* struct addrinfo */ + #undef HAVE_ADDRINFO + + /* Define to 1 if you have the `alarm' function. */ +@@ -1335,6 +1335,9 @@ + /* Define if libssl has X509_VERIFY_PARAM_set1_host and related function */ + #undef HAVE_X509_VERIFY_PARAM_SET1_HOST + ++/* Define to 1 if you have the header file. */ ++#undef HAVE_WS2TCPIP_H ++ + /* Define if the zlib library has inflateCopy */ + #undef HAVE_ZLIB_COPY + +@@ -1644,7 +1647,7 @@ + /* Define to `unsigned int' if does not define. */ + #undef size_t + +-/* Define to `int' if does not define. */ ++/* Define to `int' if or does not define. */ + #undef socklen_t + + /* Define to `int' if doesn't define. */ +diff -Naur Python-3.8.0-orig/setup.py Python-3.8.0/setup.py +--- Python-3.8.0-orig/setup.py 2019-10-22 10:01:38.141809100 +0300 ++++ Python-3.8.0/setup.py 2019-10-22 10:01:40.934214000 +0300 +@@ -1140,6 +1140,8 @@ + if MACOS: + # Issue #35569: Expose RFC 3542 socket options. + kwargs['extra_compile_args'] = ['-D__APPLE_USE_RFC_3542'] ++ if MS_WINDOWS: ++ kwargs['libraries'] = ['ws2_32', 'iphlpapi'] + + self.add(Extension('_socket', ['socketmodule.c'], **kwargs)) + elif self.compiler.find_library_file(self.lib_dirs, 'net'): diff --git a/mingw-w64-python3.9/0390-MINGW-exclude-unix-only-modules.patch b/mingw-w64-python3.9/0390-MINGW-exclude-unix-only-modules.patch new file mode 100644 index 0000000000..624f08cf24 --- /dev/null +++ b/mingw-w64-python3.9/0390-MINGW-exclude-unix-only-modules.patch @@ -0,0 +1,76 @@ +diff -Naur Python-3.8.0-orig/setup.py Python-3.8.0/setup.py +--- Python-3.8.0-orig/setup.py 2019-10-22 10:01:44.336020000 +0300 ++++ Python-3.8.0/setup.py 2019-10-22 10:01:45.428021900 +0300 +@@ -800,13 +800,21 @@ + if (self.config_h_vars.get('FLOCK_NEEDS_LIBBSD', False)): + # May be necessary on AIX for flock function + libs = ['bsd'] +- self.add(Extension('fcntl', ['fcntlmodule.c'], +- libraries=libs)) ++ if not MS_WINDOWS: ++ self.add(Extension('fcntl', ['fcntlmodule.c'], ++ libraries=libs)) ++ else: ++ self.missing.append('fcntl') + # pwd(3) +- self.add(Extension('pwd', ['pwdmodule.c'])) ++ if not MS_WINDOWS: ++ self.add(Extension('pwd', ['pwdmodule.c'])) ++ else: ++ self.missing.append('pwd') + # grp(3) +- if not VXWORKS: ++ if not VXWORKS and not MS_WINDOWS: + self.add(Extension('grp', ['grpmodule.c'])) ++ else: ++ self.missing.append('grp') + # spwd, shadow passwords + if (self.config_h_vars.get('HAVE_GETSPNAM', False) or + self.config_h_vars.get('HAVE_GETSPENT', False)): +@@ -831,7 +839,10 @@ + + # Lance Ellinghaus's syslog module + # syslog daemon interface +- self.add(Extension('syslog', ['syslogmodule.c'])) ++ if not MS_WINDOWS: ++ self.add(Extension('syslog', ['syslogmodule.c'])) ++ else: ++ self.missing.append('syslog') + + # Python interface to subinterpreter C-API. + self.add(Extension('_xxsubinterpreters', ['_xxsubinterpretersmodule.c'])) +@@ -857,7 +868,10 @@ + self.add(Extension('_csv', ['_csv.c'])) + + # POSIX subprocess module helper. +- self.add(Extension('_posixsubprocess', ['_posixsubprocess.c'])) ++ if not MS_WINDOWS: ++ self.add(Extension('_posixsubprocess', ['_posixsubprocess.c'])) ++ else: ++ self.missing.append('_posixsubprocess') + + def detect_test_extensions(self): + # Python C API test module +@@ -1039,13 +1053,16 @@ + # the encryption. + return + +- if self.compiler.find_library_file(self.lib_dirs, 'crypt'): +- libs = ['crypt'] +- else: +- libs = [] ++ if not MS_WINDOWS: ++ if self.compiler.find_library_file(self.lib_dirs, 'crypt'): ++ libs = ['crypt'] ++ else: ++ libs = [] + +- self.add(Extension('_crypt', ['_cryptmodule.c'], +- libraries=libs)) ++ self.add(Extension('_crypt', ['_cryptmodule.c'], ++ libraries=libs)) ++ else: ++ self.missing.append('_crypt') + + def detect_socket(self): + # socket(2) diff --git a/mingw-w64-python3.9/0400-MINGW-setup-msvcrt-and-_winapi-modules.patch b/mingw-w64-python3.9/0400-MINGW-setup-msvcrt-and-_winapi-modules.patch new file mode 100644 index 0000000000..e3bdf4fc3e --- /dev/null +++ b/mingw-w64-python3.9/0400-MINGW-setup-msvcrt-and-_winapi-modules.patch @@ -0,0 +1,69 @@ +diff -Naur Python-3.8.0-orig/Modules/_winapi.c Python-3.8.0/Modules/_winapi.c +--- Python-3.8.0-orig/Modules/_winapi.c 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/Modules/_winapi.c 2019-10-22 10:01:48.485627300 +0300 +@@ -39,7 +39,9 @@ + + #define WINDOWS_LEAN_AND_MEAN + #include "windows.h" ++#if defined(Py_DEBUG) + #include ++#endif + #include "winreparse.h" + + #if defined(MS_WIN32) && !defined(MS_WIN64) +diff -Naur Python-3.8.0-orig/PC/msvcrtmodule.c Python-3.8.0/PC/msvcrtmodule.c +--- Python-3.8.0-orig/PC/msvcrtmodule.c 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/PC/msvcrtmodule.c 2019-10-22 10:01:48.891228000 +0300 +@@ -21,7 +21,9 @@ + #include + #include + #include ++#ifdef _DEBUG + #include ++#endif + #include + + #ifdef _MSC_VER +diff -Naur Python-3.8.0-orig/Python/dynamic_annotations.c Python-3.8.0/Python/dynamic_annotations.c +--- Python-3.8.0-orig/Python/dynamic_annotations.c 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/Python/dynamic_annotations.c 2019-10-22 10:01:49.296828700 +0300 +@@ -27,7 +27,7 @@ + * Author: Kostya Serebryany + */ + +-#ifdef _MSC_VER ++#ifdef MS_WINDOWS + # include + #endif + +diff -Naur Python-3.8.0-orig/setup.py Python-3.8.0/setup.py +--- Python-3.8.0-orig/setup.py 2019-10-22 10:01:47.378025300 +0300 ++++ Python-3.8.0/setup.py 2019-10-22 10:01:49.702429400 +0300 +@@ -1540,6 +1540,27 @@ + '-framework', 'SystemConfiguration', + '-framework', 'CoreFoundation'])) + ++ # Modules with some Windows dependencies: ++ if MS_WINDOWS: ++ srcdir = sysconfig.get_config_var('srcdir') ++ pc_srcdir = os.path.abspath(os.path.join(srcdir, 'PC')) ++ ++ self.add(Extension('msvcrt', [os.path.join(pc_srcdir, p) ++ for p in ['msvcrtmodule.c']])) ++ ++ self.add(Extension('_winapi', ['_winapi.c'])) ++ ++ self.add(Extension('_msi', [os.path.join(pc_srcdir, p) ++ for p in ['_msi.c']], ++ libraries=['msi','cabinet','rpcrt4'])) # To link with lib(msi|cabinet|rpcrt4).a ++ ++ self.add(Extension('winsound', [os.path.join(pc_srcdir, p) ++ for p in ['winsound.c']], ++ libraries=['winmm'])) ++ ++ self.add(Extension('_overlapped', ['overlapped.c'], ++ libraries=['ws2_32'])) ++ + def detect_compress_exts(self): + # Andrew Kuchling's zlib module. Note that some versions of zlib + # 1.1.3 have security problems. See CERT Advisory CA-2002-07: diff --git a/mingw-w64-python3.9/0410-MINGW-build-extensions-with-GCC.patch b/mingw-w64-python3.9/0410-MINGW-build-extensions-with-GCC.patch new file mode 100644 index 0000000000..436f2c442d --- /dev/null +++ b/mingw-w64-python3.9/0410-MINGW-build-extensions-with-GCC.patch @@ -0,0 +1,57 @@ +diff -Naur Python-3.8.0-orig/Lib/distutils/command/build_ext.py Python-3.8.0/Lib/distutils/command/build_ext.py +--- Python-3.8.0-orig/Lib/distutils/command/build_ext.py 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/Lib/distutils/command/build_ext.py 2019-10-22 10:01:53.789636600 +0300 +@@ -186,7 +186,7 @@ + # for extensions under windows use different directories + # for Release and Debug builds. + # also Python's library directory must be appended to library_dirs +- if os.name == 'nt': ++ if os.name == 'nt' and not self.plat_name.startswith(('mingw')): + # the 'libs' directory is for binary installs - we assume that + # must be the *native* platform. But we don't really support + # cross-compiling via a binary install anyway, so we let it go. +@@ -703,6 +703,20 @@ + # pyconfig.h that MSVC groks. The other Windows compilers all seem + # to need it mentioned explicitly, though, so that's what we do. + # Append '_d' to the python import library on debug builds. ++ ++ # Use self.plat_name as it works even in case of ++ # cross-compilation (at least for mingw build). ++ if self.plat_name.startswith('mingw'): ++ from distutils import sysconfig ++ extra = [] ++ for lib in ( ++ sysconfig.get_config_var('BLDLIBRARY').split() ++ + sysconfig.get_config_var('SHLIBS').split() ++ ): ++ if lib.startswith('-l'): ++ extra.append(lib[2:]) ++ return ext.libraries + extra ++ + if sys.platform == "win32": + from distutils._msvccompiler import MSVCCompiler + if not isinstance(self.compiler, MSVCCompiler): +diff -Naur Python-3.8.0-orig/Lib/distutils/util.py Python-3.8.0/Lib/distutils/util.py +--- Python-3.8.0-orig/Lib/distutils/util.py 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/Lib/distutils/util.py 2019-10-22 10:01:54.210837300 +0300 +@@ -36,6 +36,8 @@ + + """ + if os.name == 'nt': ++ if 'GCC' in sys.version: ++ return 'mingw' + if 'amd64' in sys.version.lower(): + return 'win-amd64' + if '(arm)' in sys.version.lower(): +diff -Naur Python-3.8.0-orig/Lib/sysconfig.py Python-3.8.0/Lib/sysconfig.py +--- Python-3.8.0-orig/Lib/sysconfig.py 2019-10-22 10:00:21.731874800 +0300 ++++ Python-3.8.0/Lib/sysconfig.py 2019-10-22 10:01:54.600838000 +0300 +@@ -643,6 +643,8 @@ + + """ + if os.name == 'nt': ++ if 'GCC' in sys.version: ++ return 'mingw' + if 'amd64' in sys.version.lower(): + return 'win-amd64' + if '(arm)' in sys.version.lower(): diff --git a/mingw-w64-python3.9/0420-MINGW-use-Mingw32CCompiler-as-default-compiler-for-m.patch b/mingw-w64-python3.9/0420-MINGW-use-Mingw32CCompiler-as-default-compiler-for-m.patch new file mode 100644 index 0000000000..e0c0edb3b1 --- /dev/null +++ b/mingw-w64-python3.9/0420-MINGW-use-Mingw32CCompiler-as-default-compiler-for-m.patch @@ -0,0 +1,52 @@ +diff -Naur Python-3.8.0-orig/Lib/distutils/ccompiler.py Python-3.8.0/Lib/distutils/ccompiler.py +--- Python-3.8.0-orig/Lib/distutils/ccompiler.py 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/Lib/distutils/ccompiler.py 2019-10-22 10:01:58.266844500 +0300 +@@ -9,7 +9,7 @@ + from distutils.file_util import move_file + from distutils.dir_util import mkpath + from distutils.dep_util import newer_group +-from distutils.util import split_quoted, execute ++from distutils.util import split_quoted, execute, get_platform + from distutils import log + + class CCompiler: +@@ -948,6 +948,8 @@ + osname = os.name + if platform is None: + platform = sys.platform ++ if get_platform().startswith('mingw'): ++ return 'mingw32' + for pattern, compiler in _default_compilers: + if re.match(pattern, platform) is not None or \ + re.match(pattern, osname) is not None: +diff -Naur Python-3.8.0-orig/Lib/distutils/cygwinccompiler.py Python-3.8.0/Lib/distutils/cygwinccompiler.py +--- Python-3.8.0-orig/Lib/distutils/cygwinccompiler.py 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/Lib/distutils/cygwinccompiler.py 2019-10-22 10:01:58.656845200 +0300 +@@ -255,11 +255,16 @@ + output_dir = '' + obj_names = [] + for src_name in source_filenames: +- # use normcase to make sure '.rc' is really '.rc' and not '.RC' +- base, ext = os.path.splitext(os.path.normcase(src_name)) ++ base, ext = os.path.splitext(src_name) ++ # use 'normcase' only for resource suffixes ++ ext_normcase = os.path.normcase(ext) ++ if ext_normcase in ['.rc','.res']: ++ ext = ext_normcase + if ext not in (self.src_extensions + ['.rc','.res']): + raise UnknownFileError("unknown file type '%s' (from '%s')" % \ + (ext, src_name)) ++ base = os.path.splitdrive(base)[1] # Chop off the drive ++ base = base[os.path.isabs(base):] # If abs, chop off leading / + if strip_dir: + base = os.path.basename (base) + if ext in ('.res', '.rc'): +@@ -315,7 +320,7 @@ + + # Include the appropriate MSVC runtime library if Python was built + # with MSVC 7.0 or later. +- self.dll_libraries = get_msvcr() ++ self.dll_libraries = get_msvcr() or [] + + # Because these compilers aren't configured in Python's pyconfig.h file by + # default, we should at least warn the user if he is using an unmodified diff --git a/mingw-w64-python3.9/0430-MINGW-find-import-library.patch b/mingw-w64-python3.9/0430-MINGW-find-import-library.patch new file mode 100644 index 0000000000..f9cdb180b4 --- /dev/null +++ b/mingw-w64-python3.9/0430-MINGW-find-import-library.patch @@ -0,0 +1,11 @@ +diff -Naur Python-3.8.0-orig/Lib/distutils/cygwinccompiler.py Python-3.8.0/Lib/distutils/cygwinccompiler.py +--- Python-3.8.0-orig/Lib/distutils/cygwinccompiler.py 2019-10-22 10:02:00.856449000 +0300 ++++ Python-3.8.0/Lib/distutils/cygwinccompiler.py 2019-10-22 10:02:01.979651000 +0300 +@@ -93,6 +93,7 @@ + obj_extension = ".o" + static_lib_extension = ".a" + shared_lib_extension = ".dll" ++ dylib_lib_extension = ".dll.a" + static_lib_format = "lib%s%s" + shared_lib_format = "%s%s" + exe_extension = ".exe" diff --git a/mingw-w64-python3.9/0440-MINGW-setup-_ssl-module.patch b/mingw-w64-python3.9/0440-MINGW-setup-_ssl-module.patch new file mode 100644 index 0000000000..8d3fd06b10 --- /dev/null +++ b/mingw-w64-python3.9/0440-MINGW-setup-_ssl-module.patch @@ -0,0 +1,12 @@ +diff -Naur Python-3.8.0-orig/setup.py Python-3.8.0/setup.py +--- Python-3.8.0-orig/setup.py 2019-10-22 10:01:52.635234600 +0300 ++++ Python-3.8.0/setup.py 2019-10-22 10:02:04.772055900 +0300 +@@ -2257,6 +2257,8 @@ + openssl_includes = split_var('OPENSSL_INCLUDES', '-I') + openssl_libdirs = split_var('OPENSSL_LDFLAGS', '-L') + openssl_libs = split_var('OPENSSL_LIBS', '-l') ++ if MS_WINDOWS: ++ openssl_libs += tuple(['ws2_32']) + if not openssl_libs: + # libssl and libcrypto not found + self.missing.extend(['_ssl', '_hashlib']) diff --git a/mingw-w64-python3.9/0460-MINGW-generalization-of-posix-build-in-sysconfig.py.patch b/mingw-w64-python3.9/0460-MINGW-generalization-of-posix-build-in-sysconfig.py.patch new file mode 100644 index 0000000000..5b08582967 --- /dev/null +++ b/mingw-w64-python3.9/0460-MINGW-generalization-of-posix-build-in-sysconfig.py.patch @@ -0,0 +1,62 @@ +diff -Naur Python-3.8.0-orig/Lib/sysconfig.py Python-3.8.0/Lib/sysconfig.py +--- Python-3.8.0-orig/Lib/sysconfig.py 2019-10-22 10:01:57.159242500 +0300 ++++ Python-3.8.0/Lib/sysconfig.py 2019-10-22 10:02:07.580060800 +0300 +@@ -100,6 +100,9 @@ + _CONFIG_VARS = None + _USER_BASE = None + ++# GCC[mingw*] use posix build system ++_POSIX_BUILD = os.name == 'posix' or \ ++ (os.name == "nt" and 'GCC' in sys.version) + + def _safe_realpath(path): + try: +@@ -183,7 +186,7 @@ + + + def _get_default_scheme(): +- if os.name == 'posix': ++ if _POSIX_BUILD: + # the default scheme for posix is posix_prefix + return 'posix_prefix' + return os.name +@@ -199,7 +202,7 @@ + def joinuser(*args): + return os.path.expanduser(os.path.join(*args)) + +- if os.name == "nt": ++ if os.name == "nt" and not _POSIX_BUILD: + base = os.environ.get("APPDATA") or "~" + return joinuser(base, "Python") + +@@ -504,7 +507,7 @@ + def get_config_h_filename(): + """Return the path of pyconfig.h.""" + if _PYTHON_BUILD: +- if os.name == "nt": ++ if os.name == "nt" and not _POSIX_BUILD: + inc_dir = os.path.join(_sys_home or _PROJECT_BASE, "PC") + else: + inc_dir = _sys_home or _PROJECT_BASE +@@ -576,10 +579,10 @@ + # sys.abiflags may not be defined on all platforms. + _CONFIG_VARS['abiflags'] = '' + +- if os.name == 'nt': ++ if os.name == 'nt' and not _POSIX_BUILD: + _init_non_posix(_CONFIG_VARS) + _CONFIG_VARS['TZPATH'] = '' +- if os.name == 'posix': ++ if _POSIX_BUILD: + _init_posix(_CONFIG_VARS) + # For backward compatibility, see issue19555 + SO = _CONFIG_VARS.get('EXT_SUFFIX') +@@ -592,7 +595,7 @@ + + # Always convert srcdir to an absolute path + srcdir = _CONFIG_VARS.get('srcdir', _PROJECT_BASE) +- if os.name == 'posix': ++ if _POSIX_BUILD: + if _PYTHON_BUILD: + # If srcdir is a relative path (typically '.' or '..') + # then it should be interpreted relative to the directory diff --git a/mingw-w64-python3.9/0462-MINGW-support-stdcall-without-underscore.patch b/mingw-w64-python3.9/0462-MINGW-support-stdcall-without-underscore.patch new file mode 100644 index 0000000000..bcd83aaf58 --- /dev/null +++ b/mingw-w64-python3.9/0462-MINGW-support-stdcall-without-underscore.patch @@ -0,0 +1,34 @@ +diff -Naur Python-3.8.0-orig/Modules/_ctypes/_ctypes.c Python-3.8.0/Modules/_ctypes/_ctypes.c +--- Python-3.8.0-orig/Modules/_ctypes/_ctypes.c 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/Modules/_ctypes/_ctypes.c 2019-10-22 10:02:10.434865800 +0300 +@@ -3342,11 +3342,30 @@ + mangled_name = alloca(strlen(name) + 1 + 1 + 1 + 3); /* \0 _ @ %d */ + if (!mangled_name) + return NULL; ++ /* Issue: for stdcall decorated export functions MSVC compiler adds ++ * underscore, but GCC compiler create them without. This is ++ * visible by example for _ctypes_test.pyd module. ++ * As well functions from system libraries are without underscore. ++ * Solutions: ++ * - If a python module is build with gcc option --add-stdcall-alias ++ * the module will contain XXX as alias for function XXX@ as result ++ * first search in this method will succeed. ++ * - Distutil may use compiler to create def-file, to modify it as ++ * add underscore alias and with new def file to create module. ++ * - Or may be just to search for function without underscore. ++ */ + for (i = 0; i < 32; ++i) { + sprintf(mangled_name, "_%s@%d", name, i*4); + Py_BEGIN_ALLOW_THREADS + address = (PPROC)GetProcAddress(handle, mangled_name); + Py_END_ALLOW_THREADS ++ if (address) ++ return address; ++ /* search for function without underscore as weel */ ++ sprintf(mangled_name, "%s@%d", name, i*4); ++ Py_BEGIN_ALLOW_THREADS ++ address = (PPROC)GetProcAddress(handle, mangled_name); ++ Py_END_ALLOW_THREADS + if (address) + return address; + } diff --git a/mingw-w64-python3.9/0464-use-replace-instead-rename-to-avoid-failure-on-windo.patch b/mingw-w64-python3.9/0464-use-replace-instead-rename-to-avoid-failure-on-windo.patch new file mode 100644 index 0000000000..36e1e375ef --- /dev/null +++ b/mingw-w64-python3.9/0464-use-replace-instead-rename-to-avoid-failure-on-windo.patch @@ -0,0 +1,12 @@ +diff -Naur Python-3.8.0-orig/setup.py Python-3.8.0/setup.py +--- Python-3.8.0-orig/setup.py 2019-10-22 10:02:06.503658900 +0300 ++++ Python-3.8.0/setup.py 2019-10-22 10:02:13.258470800 +0300 +@@ -2434,7 +2434,7 @@ + else: + newfilename = filename + minoronly + log.info('renaming %s to %s', filename, newfilename) +- os.rename(filename, newfilename) ++ os.replace(filename, newfilename) + newoutfiles.append(newfilename) + if filename in updated_files: + newupdated_files.append(newfilename) diff --git a/mingw-w64-python3.9/0470-MINGW-avoid-circular-dependency-from-time-module-dur.patch b/mingw-w64-python3.9/0470-MINGW-avoid-circular-dependency-from-time-module-dur.patch new file mode 100644 index 0000000000..89a9968b7f --- /dev/null +++ b/mingw-w64-python3.9/0470-MINGW-avoid-circular-dependency-from-time-module-dur.patch @@ -0,0 +1,19 @@ +diff -Naur Python-3.8.0-orig/Lib/distutils/cygwinccompiler.py Python-3.8.0/Lib/distutils/cygwinccompiler.py +--- Python-3.8.0-orig/Lib/distutils/cygwinccompiler.py 2019-10-22 10:02:03.680054000 +0300 ++++ Python-3.8.0/Lib/distutils/cygwinccompiler.py 2019-10-22 10:02:16.066475700 +0300 +@@ -48,7 +48,6 @@ + import os + import sys + import copy +-from subprocess import Popen, PIPE, check_output + import re + + from distutils.ccompiler import gen_preprocess_options, gen_lib_options +@@ -385,6 +384,7 @@ + executable = cmd.split()[0] + if find_executable(executable) is None: + return None ++ from subprocess import Popen, PIPE + out = Popen(cmd, shell=True, stdout=PIPE).stdout + try: + out_string = out.read() diff --git a/mingw-w64-python3.9/0480-MINGW-generalization-of-posix-build-in-distutils-sys.patch b/mingw-w64-python3.9/0480-MINGW-generalization-of-posix-build-in-distutils-sys.patch new file mode 100644 index 0000000000..727c9feee9 --- /dev/null +++ b/mingw-w64-python3.9/0480-MINGW-generalization-of-posix-build-in-distutils-sys.patch @@ -0,0 +1,76 @@ +diff -Naur Python-3.8.0-orig/Lib/distutils/sysconfig.py Python-3.8.0/Lib/distutils/sysconfig.py +--- Python-3.8.0-orig/Lib/distutils/sysconfig.py 2019-10-22 10:01:10.872961200 +0300 ++++ Python-3.8.0/Lib/distutils/sysconfig.py 2019-10-22 10:02:18.890080700 +0300 +@@ -64,6 +64,17 @@ + python_build = _python_build() + + ++def _posix_build(): ++ # GCC[mingw*] use posix build system ++ # Check for cross builds explicitly ++ host_platform = os.environ.get("_PYTHON_HOST_PLATFORM") ++ if host_platform: ++ if host_platform.startswith('mingw'): ++ return True ++ return os.name == 'posix' or \ ++ (os.name == "nt" and 'GCC' in sys.version) ++posix_build = _posix_build() ++ + # Calculate the build qualifier flags if they are defined. Adding the flags + # to the include and lib directories only makes sense for an installation, not + # an in-source build. +@@ -97,7 +108,7 @@ + """ + if prefix is None: + prefix = plat_specific and BASE_EXEC_PREFIX or BASE_PREFIX +- if os.name == "posix": ++ if posix_build: + if python_build: + # Assume the executable is in the build directory. The + # pyconfig.h file should be in the same directory. Since +@@ -144,7 +155,7 @@ + else: + prefix = plat_specific and EXEC_PREFIX or PREFIX + +- if os.name == "posix": ++ if posix_build: + if plat_specific or standard_lib: + # Platform-specific modules (any module from a non-pure-Python + # module distribution) or standard Python library modules. +@@ -261,7 +272,7 @@ + def get_config_h_filename(): + """Return full pathname of installed pyconfig.h file.""" + if python_build: +- if os.name == "nt": ++ if os.name == "nt" and not posix_build: + inc_dir = os.path.join(_sys_home or project_base, "PC") + else: + inc_dir = _sys_home or project_base +@@ -467,6 +478,9 @@ + + + def _init_nt(): ++ if posix_build: ++ _init_posix() ++ return + """Initialize the module as appropriate for NT""" + g = {} + # set basic install directories +@@ -516,7 +530,7 @@ + + # Always convert srcdir to an absolute path + srcdir = _config_vars.get('srcdir', project_base) +- if os.name == 'posix': ++ if posix_build: + if python_build: + # If srcdir is a relative path (typically '.' or '..') + # then it should be interpreted relative to the directory +@@ -535,7 +549,7 @@ + # Normally it is relative to the build directory. However, during + # testing, for example, we might be running a non-installed python + # from a different directory. +- if python_build and os.name == "posix": ++ if python_build and posix_build: + base = project_base + if (not os.path.isabs(_config_vars['srcdir']) and + base != os.getcwd()): diff --git a/mingw-w64-python3.9/0490-MINGW-customize-site.patch b/mingw-w64-python3.9/0490-MINGW-customize-site.patch new file mode 100644 index 0000000000..897d411a8d --- /dev/null +++ b/mingw-w64-python3.9/0490-MINGW-customize-site.patch @@ -0,0 +1,40 @@ +diff -Naur Python-3.8.0-orig/Lib/site.py Python-3.8.0/Lib/site.py +--- Python-3.8.0-orig/Lib/site.py 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/Lib/site.py 2019-10-22 10:02:21.776085800 +0300 +@@ -251,7 +251,8 @@ + def joinuser(*args): + return os.path.expanduser(os.path.join(*args)) + +- if os.name == "nt": ++ from sysconfig import _POSIX_BUILD ++ if os.name == "nt" and not _POSIX_BUILD: + base = os.environ.get("APPDATA") or "~" + return joinuser(base, "Python") + +@@ -266,7 +267,8 @@ + def _get_path(userbase): + version = sys.version_info + +- if os.name == 'nt': ++ from sysconfig import _POSIX_BUILD ++ if sys.platform == 'win32' and not _POSIX_BUILD: + return f'{userbase}\\Python{version[0]}{version[1]}\\site-packages' + + if sys.platform == 'darwin' and sys._framework: +@@ -329,6 +331,7 @@ + if prefixes is None: + prefixes = PREFIXES + ++ from sysconfig import _POSIX_BUILD + for prefix in prefixes: + if not prefix or prefix in seen: + continue +@@ -338,7 +341,7 @@ + if sys.platlibdir != "lib": + libdirs.append("lib") + +- if os.sep == '/': ++ if _POSIX_BUILD: + for libdir in libdirs: + path = os.path.join(prefix, libdir, + "python%d.%d" % sys.version_info[:2], diff --git a/mingw-w64-python3.9/0500-add-python-config-sh.patch b/mingw-w64-python3.9/0500-add-python-config-sh.patch new file mode 100644 index 0000000000..be9fa77862 --- /dev/null +++ b/mingw-w64-python3.9/0500-add-python-config-sh.patch @@ -0,0 +1,143 @@ +diff -Naur Python-3.8.0-orig/Misc/python-config.sh.in Python-3.8.0/Misc/python-config.sh.in +--- Python-3.8.0-orig/Misc/python-config.sh.in 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/Misc/python-config.sh.in 2019-10-22 10:02:24.584090700 +0300 +@@ -1,32 +1,44 @@ + #!/bin/sh + +-# Keep this script in sync with python-config.in +- + exit_with_usage () + { + echo "Usage: $0 --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--help|--abiflags|--configdir|--embed" +- exit $1 ++ exit 1 + } + ++# Really, python-config.py (and thus .sh) should be called directly, but ++# sometimes software (e.g. GDB) calls python-config.sh as if it were the ++# Python executable, passing python-config.py as the first argument. ++# Work around that oddness by ignoring any .py passed as first arg. ++case "$1" in ++ *.py) ++ shift ++ ;; ++esac ++ + if [ "$1" = "" ] ; then +- exit_with_usage 1 ++ exit_with_usage + fi + + # Returns the actual prefix where this script was installed to. + installed_prefix () + { +- RESULT=$(dirname $(cd $(dirname "$1") && pwd -P)) +- if which readlink >/dev/null 2>&1 ; then +- if readlink -f "$RESULT" >/dev/null 2>&1; then +- RESULT=$(readlink -f "$RESULT") +- fi ++ local RESULT=$(dirname $(cd $(dirname "$1") && pwd -P)) ++ if [ $(which readlink) ] ; then ++ RESULT=$(readlink -f "$RESULT") ++ fi ++ # Since we don't know where the output from this script will end up ++ # we keep all paths in Windows-land since MSYS2 can handle that ++ # while native tools can't handle paths in MSYS2-land. ++ if [ "$OSTYPE" = "msys" ]; then ++ RESULT=$(cd "$RESULT" && pwd -W) + fi + echo $RESULT + } + + prefix_real=$(installed_prefix "$0") + +-# Use sed to fix paths from their built-to locations to their installed-to ++# Use sed to fix paths from their built-to locations to their installed to + # locations. Keep prefix & exec_prefix using their original values in case + # they are referenced in other configure variables, to prevent double + # substitution, issue #22140. +@@ -41,13 +53,17 @@ + LIBC="@LIBC@" + SYSLIBS="$LIBM $LIBC" + ABIFLAGS="@ABIFLAGS@" ++# Protect against lack of substitution. ++if [ "$ABIFLAGS" = "@""ABIFLAGS""@" ] ; then ++ ABIFLAGS= ++fi + LIBS="@LIBPYTHON@ @LIBS@ $SYSLIBS" + LIBS_EMBED="-lpython${VERSION}${ABIFLAGS} @LIBS@ $SYSLIBS" + BASECFLAGS="@BASECFLAGS@" +-LDLIBRARY="@LDLIBRARY@" + OPT="@OPT@" + PY_ENABLE_SHARED="@PY_ENABLE_SHARED@" + LDVERSION="@LDVERSION@" ++LDLIBRARY="@LDLIBRARY@" + LIBDEST=${prefix_real}/lib/python${VERSION} + LIBPL=$(echo "@LIBPL@" | sed "s#$prefix#$prefix_real#") + SO="@EXT_SUFFIX@" +@@ -61,7 +77,7 @@ + do + case $ARG in + --help) +- exit_with_usage 0 ++ exit_with_usage + ;; + --embed) + PY_EMBED=1 +@@ -69,7 +85,7 @@ + --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--abiflags|--configdir) + ;; + *) +- exit_with_usage 1 ++ exit_with_usage + ;; + esac + done +@@ -80,37 +96,37 @@ + + for ARG in "$@" + do +- case "$ARG" in ++ case $ARG in + --prefix) +- echo "$prefix_real" ++ echo -ne "$prefix_real" + ;; + --exec-prefix) +- echo "$exec_prefix_real" ++ echo -ne "$exec_prefix_real " + ;; + --includes) +- echo "$INCDIR $PLATINCDIR" ++ echo -ne "$INCDIR $PLATINCDIR" + ;; + --cflags) +- echo "$INCDIR $PLATINCDIR $BASECFLAGS $CFLAGS $OPT" ++ echo -ne "$INCDIR $PLATINCDIR $BASECFLAGS $CFLAGS $OPT" + ;; + --libs) +- echo "$LIBS" ++ echo -ne "$LIBS" + ;; + --ldflags) + LIBPLUSED= + if [ "$PY_ENABLE_SHARED" = "0" ] ; then + LIBPLUSED="-L$LIBPL" + fi +- echo "$LIBPLUSED -L$libdir $LIBS" ++ echo -ne "$LIBPLUSED -L$libdir $LIBS " + ;; + --extension-suffix) +- echo "$SO" ++ echo -ne "$SO " + ;; + --abiflags) +- echo "$ABIFLAGS" ++ echo -ne "$ABIFLAGS " + ;; + --configdir) +- echo "$LIBPL" ++ echo -ne "$LIBPL " + ;; + esac + done diff --git a/mingw-w64-python3.9/0510-cross-darwin-feature.patch b/mingw-w64-python3.9/0510-cross-darwin-feature.patch new file mode 100644 index 0000000000..7610492612 --- /dev/null +++ b/mingw-w64-python3.9/0510-cross-darwin-feature.patch @@ -0,0 +1,120 @@ +diff -Naur Python-3.8.0-orig/configure.ac Python-3.8.0/configure.ac +--- Python-3.8.0-orig/configure.ac 2019-10-22 10:01:42.698017100 +0300 ++++ Python-3.8.0/configure.ac 2019-10-22 10:02:27.392095600 +0300 +@@ -396,6 +396,7 @@ + then + # avoid using uname for cross builds + if test "$cross_compiling" = yes; then ++ ac_sys_release= + # ac_sys_system and ac_sys_release are used for setting + # a lot of different things including 'define_xopen_source' + # in the case statement below. +@@ -409,6 +410,27 @@ + *-*-cygwin*) + ac_sys_system=Cygwin + ;; ++ *-*-darwin*) ++ ac_sys_system=Darwin ++ ac_sys_release=$(echo $host | sed -n 's/.*-[^0-9]\+\([0-9]\+\)/\1/p') ++ if test -z "$ac_sys_release"; then ++ # A reasonable default. ++ ac_sys_release=11 ++ fi ++ # Use the last released version number for old versions. ++ if test "$ac_sys_release" = "9" ; then ++ ac_sys_release=9.8 ++ elif test "$ac_sys_release" = "10" ; then ++ ac_sys_release=10.8 ++ elif test "$ac_sys_release" = "11" ; then ++ ac_sys_release=11.4.0 ++ elif test "$ac_sys_release" = "12" ; then ++ ac_sys_release=12.0.0 ++ else ++ # ..and .0.0 for unknown versions. ++ ac_sys_release=${ac_sys_release}.0.0 ++ fi ++ ;; + *-*-vxworks*) + ac_sys_system=VxWorks + ;; +@@ -417,7 +439,6 @@ + MACHDEP="unknown" + AC_MSG_ERROR([cross build not supported for $host]) + esac +- ac_sys_release= + else + ac_sys_system=`uname -s` + if test "$ac_sys_system" = "AIX" \ +@@ -464,6 +485,9 @@ + *-*-mingw*) + _host_cpu= + ;; ++ *-*-darwin*) ++ _host_cpu= ++ ;; + *) + # for now, limit cross builds to known configurations + MACHDEP="unknown" +@@ -1657,6 +1681,26 @@ + AC_SUBST(CFLAGS_NODIST) + AC_SUBST(LDFLAGS_NODIST) + ++if test "x$cross_compiling" = xyes; then ++ function cross_arch ++ { ++ case $host in ++ x86_64*darwin*) ++ echo i386 ++ ;; ++ x86_64*) ++ echo x86_64 ++ ;; ++ *) ++ echo i386 ++ ;; ++ esac ++ } ++ ARCH_PROG=cross_arch ++else ++ ARCH_PROG=/usr/bin/arch ++fi ++ + # The -arch flags for universal builds on macOS + UNIVERSAL_ARCH_FLAGS= + AC_SUBST(UNIVERSAL_ARCH_FLAGS) +@@ -2033,7 +2077,7 @@ + ;; + esac + else +- if test `/usr/bin/arch` = "i386" ++ if test "$($ARCH_PROG)" = "i386" + then + # 10.4 was the first release to support Intel archs + cur_target="10.4" +@@ -2599,7 +2643,7 @@ + if test "${enable_universalsdk}"; then + : + else +- LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only `/usr/bin/arch`" ++ LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only $($ARCH_PROG)" + fi + LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' + LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';; +@@ -2624,7 +2668,7 @@ + ]])],[ac_osx_32bit=yes],[ac_osx_32bit=no],[ac_osx_32bit=yes]) + + if test "${ac_osx_32bit}" = "yes"; then +- case `/usr/bin/arch` in ++ case $($ARCH_PROG) in + i386) + MACOSX_DEFAULT_ARCH="i386" + ;; +@@ -2636,7 +2680,7 @@ + ;; + esac + else +- case `/usr/bin/arch` in ++ case $($ARCH_PROG) in + i386) + MACOSX_DEFAULT_ARCH="x86_64" + ;; diff --git a/mingw-w64-python3.9/0520-py3k-mingw-ntthreads-vs-pthreads.patch b/mingw-w64-python3.9/0520-py3k-mingw-ntthreads-vs-pthreads.patch new file mode 100644 index 0000000000..24c444f86e --- /dev/null +++ b/mingw-w64-python3.9/0520-py3k-mingw-ntthreads-vs-pthreads.patch @@ -0,0 +1,43 @@ +diff -Naur Python-3.8.0-orig/Include/internal/pycore_condvar.h Python-3.8.0/Include/internal/pycore_condvar.h +--- Python-3.8.0-orig/Include/internal/pycore_condvar.h 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/Include/internal/pycore_condvar.h 2019-10-22 10:02:30.231300600 +0300 +@@ -5,6 +5,12 @@ + # error "this header requires Py_BUILD_CORE define" + #endif + ++#ifdef __MINGW32__ ++# if !defined(HAVE_PTHREAD_H) || defined(NT_THREADS) ++# undef _POSIX_THREADS ++# endif ++#endif ++ + #ifndef _POSIX_THREADS + /* This means pthreads are not implemented in libc headers, hence the macro + not present in unistd.h. But they still can be implemented as an external +@@ -37,6 +43,10 @@ + /* include windows if it hasn't been done before */ + #define WIN32_LEAN_AND_MEAN + #include ++/* winpthreads are involved via windows header, so need undef _POSIX_THREADS after header include */ ++#if defined(_POSIX_THREADS) ++#undef _POSIX_THREADS ++#endif + + /* options */ + /* non-emulated condition variables are provided for those that want +diff -Naur Python-3.8.0-orig/Include/pythread.h Python-3.8.0/Include/pythread.h +--- Python-3.8.0-orig/Include/pythread.h 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/Include/pythread.h 2019-10-22 10:02:30.652501400 +0300 +@@ -9,6 +9,12 @@ + extern "C" { + #endif + ++#ifdef __MINGW32__ ++# if !defined(HAVE_PTHREAD_H) || defined(NT_THREADS) ++# undef _POSIX_THREADS ++# endif ++#endif ++ + /* Return status codes for Python lock acquisition. Chosen for maximum + * backwards compatibility, ie failure -> 0, success -> 1. */ + typedef enum PyLockStatus { diff --git a/mingw-w64-python3.9/0530-mingw-system-libffi.patch b/mingw-w64-python3.9/0530-mingw-system-libffi.patch new file mode 100644 index 0000000000..932fbf63d2 --- /dev/null +++ b/mingw-w64-python3.9/0530-mingw-system-libffi.patch @@ -0,0 +1,12 @@ +diff -Naur Python-3.8.0-orig/setup.py Python-3.8.0/setup.py +--- Python-3.8.0-orig/setup.py 2019-10-22 10:02:14.974473800 +0300 ++++ Python-3.8.0/setup.py 2019-10-22 10:02:33.866107000 +0300 +@@ -2237,6 +2237,8 @@ + ext.libraries.append(ffi_lib) + if MS_WINDOWS: + ext.libraries.extend(['ole32', 'oleaut32', 'uuid']) ++ ext.export_symbols.extend(['DllGetClassObject PRIVATE', ++ 'DllCanUnloadNow PRIVATE']) + self.use_system_libffi = True + + if sysconfig.get_config_var('HAVE_LIBDL'): diff --git a/mingw-w64-python3.9/0555-msys-mingw-prefer-unix-sep-if-MSYSTEM.patch b/mingw-w64-python3.9/0555-msys-mingw-prefer-unix-sep-if-MSYSTEM.patch new file mode 100644 index 0000000000..5a59d71f95 --- /dev/null +++ b/mingw-w64-python3.9/0555-msys-mingw-prefer-unix-sep-if-MSYSTEM.patch @@ -0,0 +1,369 @@ +diff -Naur Python-3.8.0-orig/Include/pylifecycle.h Python-3.8.0/Include/pylifecycle.h +--- Python-3.8.0-orig/Include/pylifecycle.h 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/Include/pylifecycle.h 2019-10-22 10:02:36.752112100 +0300 +@@ -21,6 +21,12 @@ + PyAPI_FUNC(PyThreadState *) Py_NewInterpreter(void); + PyAPI_FUNC(void) Py_EndInterpreter(PyThreadState *); + ++PyAPI_FUNC(wchar_t) Py_GetSepW(const wchar_t *); ++PyAPI_FUNC(char) Py_GetSepA(const char *); ++ ++PyAPI_FUNC(void) Py_NormalizeSepsW(wchar_t *); ++PyAPI_FUNC(void) Py_NormalizeSepsA(char *); ++ + + /* Py_PyAtExit is for the atexit module, Py_AtExit is for low-level + * exit functions. +diff -Naur Python-3.8.0-orig/Lib/ntpath.py Python-3.8.0/Lib/ntpath.py +--- Python-3.8.0-orig/Lib/ntpath.py 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/Lib/ntpath.py 2019-10-22 10:02:37.157712800 +0300 +@@ -11,9 +11,7 @@ + curdir = '.' + pardir = '..' + extsep = '.' +-sep = '\\' + pathsep = ';' +-altsep = '/' + defpath = '.;C:\\bin' + devnull = 'nul' + +@@ -23,6 +21,15 @@ + import genericpath + from genericpath import * + ++if sys.platform == "win32" and "MSYSTEM" in os.environ: ++ sep = '/' ++ altsep = '\\' ++else: ++ sep = '\\' ++ altsep = '/' ++bsep = str.encode(sep) ++baltsep = str.encode(altsep) ++ + __all__ = ["normcase","isabs","join","splitdrive","split","splitext", + "basename","dirname","commonprefix","getsize","getmtime", + "getatime","getctime", "islink","exists","lexists","isdir","isfile", +@@ -33,9 +40,27 @@ + + def _get_bothseps(path): + if isinstance(path, bytes): +- return b'\\/' ++ return bsep+baltsep ++ else: ++ return sep+altsep ++ ++def _get_sep(path): ++ if isinstance(path, bytes): ++ return bsep ++ else: ++ return sep ++ ++def _get_altsep(path): ++ if isinstance(path, bytes): ++ return baltsep ++ else: ++ return altsep ++ ++def _get_colon(path): ++ if isinstance(path, bytes): ++ return b':' + else: +- return '\\/' ++ return ':' + + # Normalize the case of a pathname and map slashes to backslashes. + # Other normalizations (such as optimizing '../' away) are not done +@@ -47,9 +72,9 @@ + Makes all characters lowercase and all slashes into backslashes.""" + s = os.fspath(s) + if isinstance(s, bytes): +- return s.replace(b'/', b'\\').lower() ++ return s.replace(baltsep, bsep).lower() + else: +- return s.replace('/', '\\').lower() ++ return s.replace(altsep, sep).lower() + + + # Return whether a path is absolute. +@@ -76,14 +101,9 @@ + # Join two (or more) paths. + def join(path, *paths): + path = os.fspath(path) +- if isinstance(path, bytes): +- sep = b'\\' +- seps = b'\\/' +- colon = b':' +- else: +- sep = '\\' +- seps = '\\/' +- colon = ':' ++ sep = _get_sep(path) ++ seps = _get_bothseps(path) ++ colon = _get_colon(path) + try: + if not paths: + path[:0] + sep #23780: Ensure compatible data type even if p is null. +@@ -142,14 +162,9 @@ + """ + p = os.fspath(p) + if len(p) >= 2: +- if isinstance(p, bytes): +- sep = b'\\' +- altsep = b'/' +- colon = b':' +- else: +- sep = '\\' +- altsep = '/' +- colon = ':' ++ sep = _get_sep(p) ++ altsep = _get_altsep(p) ++ colon = _get_colon(p) + normp = p.replace(altsep, sep) + if (normp[0:2] == sep*2) and (normp[2:3] != sep): + # is a UNC path: +@@ -203,9 +218,9 @@ + def splitext(p): + p = os.fspath(p) + if isinstance(p, bytes): +- return genericpath._splitext(p, b'\\', b'/', b'.') ++ return genericpath._splitext(p, bsep, baltsep, b'.') + else: +- return genericpath._splitext(p, '\\', '/', '.') ++ return genericpath._splitext(p, sep, altsep, '.') + splitext.__doc__ = genericpath._splitext.__doc__ + + +@@ -450,15 +465,13 @@ + def normpath(path): + """Normalize path, eliminating double slashes, etc.""" + path = os.fspath(path) ++ sep = _get_sep(path) ++ altsep = _get_altsep(path) + if isinstance(path, bytes): +- sep = b'\\' +- altsep = b'/' + curdir = b'.' + pardir = b'..' + special_prefixes = (b'\\\\.\\', b'\\\\?\\') + else: +- sep = '\\' +- altsep = '/' + curdir = '.' + pardir = '..' + special_prefixes = ('\\\\.\\', '\\\\?\\') +@@ -668,6 +681,7 @@ + # strip the prefix anyway. + if ex.winerror == initial_winerror: + path = spath ++ path = normpath(path) + return path + + +@@ -678,12 +692,11 @@ + def relpath(path, start=None): + """Return a relative version of a path""" + path = os.fspath(path) ++ sep = _get_sep(path) + if isinstance(path, bytes): +- sep = b'\\' + curdir = b'.' + pardir = b'..' + else: +- sep = '\\' + curdir = '.' + pardir = '..' + +@@ -738,13 +751,11 @@ + raise ValueError('commonpath() arg is an empty sequence') + + paths = tuple(map(os.fspath, paths)) ++ sep = _get_sep(paths[0]) ++ altsep = _get_altsep(paths[0]) + if isinstance(paths[0], bytes): +- sep = b'\\' +- altsep = b'/' + curdir = b'.' + else: +- sep = '\\' +- altsep = '/' + curdir = '.' + + try: +diff -Naur Python-3.8.0-orig/Modules/posixmodule.c Python-3.8.0/Modules/posixmodule.c +--- Python-3.8.0-orig/Modules/posixmodule.c 2019-10-22 10:00:56.988936800 +0300 ++++ Python-3.8.0/Modules/posixmodule.c 2019-10-22 10:02:37.547713500 +0300 +@@ -3739,6 +3739,7 @@ + return PyErr_SetFromWindowsErr(0); + } + ++ Py_NormalizeSepsW(wbuf2); + PyObject *resobj = PyUnicode_FromWideChar(wbuf2, len); + if (wbuf2 != wbuf) { + PyMem_RawFree(wbuf2); +@@ -4302,6 +4303,7 @@ + target_path = tmp; + } + ++ Py_NormalizeSepsW(target_path); + result = PyUnicode_FromWideChar(target_path, result_length); + if (result && path->narrow) { + Py_SETREF(result, PyUnicode_EncodeFSDefault(result)); +diff -Naur Python-3.8.0-orig/Python/initconfig.c Python-3.8.0/Python/initconfig.c +--- Python-3.8.0-orig/Python/initconfig.c 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/Python/initconfig.c 2019-10-22 10:02:37.968914200 +0300 +@@ -136,7 +136,7 @@ + "PYTHONDEVMODE: enable the development mode.\n" + "PYTHONPYCACHEPREFIX: root directory for bytecode cache (pyc) files.\n"; + +-#if defined(MS_WINDOWS) ++#if defined(_MSC_VER) + # define PYTHONHOMEHELP "\\python{major}{minor}" + #else + # define PYTHONHOMEHELP "/lib/pythonX.X" +@@ -1187,7 +1187,7 @@ + } + + /* Last fall back: hardcoded name */ +-#ifdef MS_WINDOWS ++#ifdef _MSC_VER + const wchar_t *default_program_name = L"python"; + #else + const wchar_t *default_program_name = L"python3"; +diff -Naur Python-3.8.0-orig/Python/pathconfig.c Python-3.8.0/Python/pathconfig.c +--- Python-3.8.0-orig/Python/pathconfig.c 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/Python/pathconfig.c 2019-10-22 10:02:38.358914900 +0300 +@@ -15,6 +15,114 @@ + extern "C" { + #endif + ++#ifdef __MINGW32__ ++#define wcstok wcstok_s ++#include ++#endif ++ ++char ++Py_GetSepA(const char *name) ++{ ++ char* msystem = (char*)2; /* So that non Windows use / as sep */ ++ static char sep = '\0'; ++#ifdef _WIN32 ++ /* https://msdn.microsoft.com/en-gb/library/windows/desktop/aa365247%28v=vs.85%29.aspx ++ * The "\\?\" prefix .. indicate that the path should be passed to the system with minimal ++ * modification, which means that you cannot use forward slashes to represent path separators ++ */ ++ if (name != NULL && memcmp(name, "\\\\?\\", sizeof("\\\\?\\") - sizeof(char)) == 0) ++ { ++ return '\\'; ++ } ++#endif ++ if (sep != '\0') ++ return sep; ++#if defined(__MINGW32__) ++ msystem = Py_GETENV("MSYSTEM"); ++#endif ++ if (msystem != NULL) ++ sep = '/'; ++ else ++ sep = '\\'; ++ return sep; ++} ++ ++static char ++Py_GetAltSepA(const char *name) ++{ ++ char sep = Py_GetSepA(name); ++ if (sep == '/') ++ return '\\'; ++ return '/'; ++} ++ ++void ++Py_NormalizeSepsA(char *name) ++{ ++ char sep = Py_GetSepA(name); ++ char altsep = Py_GetAltSepA(name); ++ char* seps; ++ if (strlen(name) > 1 && name[1] == ':') { ++ name[0] = toupper(name[0]); ++ } ++ seps = strchr(name, altsep); ++ while(seps) { ++ *seps = sep; ++ seps = strchr(seps, altsep); ++ } ++} ++ ++wchar_t ++Py_GetSepW(const wchar_t *name) ++{ ++ char* msystem = (char*)2; /* So that non Windows use / as sep */ ++ static wchar_t sep = L'\0'; ++#ifdef _WIN32 ++ /* https://msdn.microsoft.com/en-gb/library/windows/desktop/aa365247%28v=vs.85%29.aspx ++ * The "\\?\" prefix .. indicate that the path should be passed to the system with minimal ++ * modification, which means that you cannot use forward slashes to represent path separators ++ */ ++ if (name != NULL && memcmp(name, L"\\\\?\\", sizeof(L"\\\\?\\") - sizeof(wchar_t)) == 0) ++ { ++ return L'\\'; ++ } ++#endif ++ if (sep != L'\0') ++ return sep; ++#if defined(__MINGW32__) ++ msystem = Py_GETENV("MSYSTEM"); ++#endif ++ if (msystem != NULL) ++ sep = L'/'; ++ else ++ sep = L'\\'; ++ return sep; ++} ++ ++static wchar_t ++Py_GetAltSepW(const wchar_t *name) ++{ ++ char sep = Py_GetSepW(name); ++ if (sep == L'/') ++ return L'\\'; ++ return L'/'; ++} ++ ++void ++Py_NormalizeSepsW(wchar_t *name) ++{ ++ wchar_t sep = Py_GetSepW(name); ++ wchar_t altsep = Py_GetAltSepW(name); ++ wchar_t* seps; ++ if (wcslen(name) > 1 && name[1] == L':') { ++ name[0] = towupper(name[0]); ++ } ++ seps = wcschr(name, altsep); ++ while(seps) { ++ *seps = sep; ++ seps = wcschr(seps, altsep); ++ } ++} + + _PyPathConfig _Py_path_config = _PyPathConfig_INIT; + #ifdef MS_WINDOWS +@@ -541,6 +649,7 @@ + if (_Py_path_config.program_name == NULL) { + Py_FatalError("Py_SetProgramName() failed: out of memory"); + } ++ Py_NormalizeSepsW(_Py_path_config.program_name); + } + + void +diff -Naur Python-3.8.0-orig/Python/traceback.c Python-3.8.0/Python/traceback.c +--- Python-3.8.0-orig/Python/traceback.c 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/Python/traceback.c 2019-10-22 10:02:39.170116300 +0300 +@@ -314,7 +314,7 @@ + filepath = PyBytes_AS_STRING(filebytes); + + /* Search tail of filename in sys.path before giving up */ +- tail = strrchr(filepath, SEP); ++ tail = strrchr(filepath, Py_GetSepA(filepath)); + if (tail == NULL) + tail = filepath; + else diff --git a/mingw-w64-python3.9/0560-mingw-use-posix-getpath.patch b/mingw-w64-python3.9/0560-mingw-use-posix-getpath.patch new file mode 100644 index 0000000000..56492577c8 --- /dev/null +++ b/mingw-w64-python3.9/0560-mingw-use-posix-getpath.patch @@ -0,0 +1,474 @@ +diff -Naur Python-3.9.4-orig/Include/pylifecycle.h Python-3.9.4/Include/pylifecycle.h +--- Python-3.9.4-orig/Include/pylifecycle.h 2021-04-04 08:56:53 +0000 ++++ Python-3.9.4/Include/pylifecycle.h 2021-04-25 13:03:43 +0000 +@@ -49,7 +49,7 @@ + PyAPI_FUNC(wchar_t *) Py_GetExecPrefix(void); + PyAPI_FUNC(wchar_t *) Py_GetPath(void); + PyAPI_FUNC(void) Py_SetPath(const wchar_t *); +-#ifdef MS_WINDOWS ++#ifdef _MSC_VER + int _Py_CheckPython3(void); + #endif + +diff -Naur Python-3.9.4-orig/Modules/getpath.c Python-3.9.4/Modules/getpath.c +--- Python-3.9.4-orig/Modules/getpath.c 2021-04-04 08:56:53 +0000 ++++ Python-3.9.4/Modules/getpath.c 2021-04-25 13:39:07 +0000 +@@ -13,6 +13,11 @@ + # include + #endif + ++#ifdef MS_WINDOWS ++#include ++#include ++#endif ++ + /* Search in some common locations for the associated Python libraries. + * + * Two directories must be found, the platform independent directory +@@ -129,6 +134,7 @@ + wchar_t *prefix_macro; /* PREFIX macro */ + wchar_t *exec_prefix_macro; /* EXEC_PREFIX macro */ + wchar_t *vpath_macro; /* VPATH macro */ ++ wchar_t *dll_path; /* DLL Path */ + + wchar_t *lib_python; /* / "pythonX.Y" */ + +@@ -146,7 +152,7 @@ + } PyCalculatePath; + + static const wchar_t delimiter[2] = {DELIM, '\0'}; +-static const wchar_t separator[2] = {SEP, '\0'}; ++static wchar_t separator[2] = {SEP, '\0'}; + + + /* Get file status. Encode the path to the locale encoding. */ +@@ -170,7 +176,7 @@ + reduce(wchar_t *dir) + { + size_t i = wcslen(dir); +- while (i > 0 && dir[i] != SEP) { ++ while (i > 0 && !_Py_issep(dir[i])) { + --i; + } + dir[i] = '\0'; +@@ -224,6 +230,9 @@ + return 1; + } + ++/* ++x86_64-w64-mingw32-gcc -c -Wno-unused-result -Wsign-compare -DNDEBUG -march=x86-64 -mtune=generic -O2 -pipe -fwrapv -D__USE_MINGW_ANSI_STDIO=1 -D_WIN32_WINNT=0x0601 -DNDEBUG -DMS_DLL_ID="\"3.9\"" -flto -fuse-linker-plugin -ffat-lto-objects -flto-partition=none -g -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration -fvisibility=hidden -fprofile-generate -I../Python-3.9.4/Include/internal -IObjects -IInclude -IPython -I. -I../Python-3.9.4/Include -I../Python-3.9.4/PC -D__USE_MINGW_ANSI_STDIO=1 -IC:/msys64/mingw64/include/ncurses -I. -DPy_BUILD_CORE -DPYTHONPATH='""' -DPREFIX='"/mingw64"' -DEXEC_PREFIX='"/mingw64"' -DVERSION='"3.9"' -DVPATH='"../Python-3.9.4"' -o Modules/getpath.o ../Python-3.9.4/Modules/getpath.c ++*/ + + /* Add a path component, by appending stuff to buffer. + buflen: 'buffer' length in characters including trailing NUL. +@@ -242,8 +251,8 @@ + return PATHLEN_ERR(); + } + +- if (n > 0 && path[n-1] != SEP) { +- path[n++] = SEP; ++ if (n > 0 && !_Py_issep(path[n-1])) { ++ path[n++] = Py_GetSepW(path); + } + } + else { +@@ -285,7 +294,7 @@ + } + + size_t len = wcslen(path); +- int add_sep = (len > 0 && path[len - 1] != SEP); ++ int add_sep = (len > 0 && !_Py_issep(path[len - 1])); + len += add_sep; + len += wcslen(path2); + +@@ -334,7 +343,7 @@ + } + return _PyStatus_OK(); + } +- if (path[0] == '.' && path[1] == SEP) { ++ if (path[0] == '.' && _Py_issep(path[1])) { + path += 2; + } + PyStatus status = joinpath(abs_path, path, abs_path_len); +@@ -478,6 +487,7 @@ + return _PyStatus_NO_MEMORY(); + } + ++ Py_NormalizeSepsW(path); + int is_build_dir = isfile(path); + PyMem_RawFree(path); + +@@ -502,6 +512,7 @@ + } + + int module; ++ Py_NormalizeSepsW(prefix); + status = ismodule(prefix, &module); + if (_PyStatus_EXCEPTION(status)) { + return status; +@@ -528,6 +539,7 @@ + } + + int module; ++ Py_NormalizeSepsW(prefix); + status = ismodule(prefix, &module); + if (_PyStatus_EXCEPTION(status)) { + return status; +@@ -551,6 +563,7 @@ + } + + int module; ++ Py_NormalizeSepsW(prefix); + status = ismodule(prefix, &module); + if (_PyStatus_EXCEPTION(status)) { + return status; +@@ -610,6 +623,11 @@ + * return the compiled-in defaults instead. + */ + if (calculate->prefix_found > 0) { ++#ifdef MS_WINDOWS ++ wchar_t drive_root[3]; ++ memset(drive_root, 0, sizeof(drive_root)); ++ wcsncpy(drive_root, calculate->prefix, 3); ++#endif + wchar_t *prefix = _PyMem_RawWcsdup(calculate->prefix); + if (prefix == NULL) { + return _PyStatus_NO_MEMORY(); +@@ -625,7 +643,11 @@ + + /* The prefix is the root directory, but reduce() chopped + off the "/". */ ++#ifdef MS_WINDOWS ++ pathconfig->prefix = _PyMem_RawWcsdup(drive_root); ++#else + pathconfig->prefix = _PyMem_RawWcsdup(separator); ++#endif + if (pathconfig->prefix == NULL) { + return _PyStatus_NO_MEMORY(); + } +@@ -682,6 +704,7 @@ + return PATHLEN_ERR(); + } + status = joinpath(exec_prefix, pybuilddir, exec_prefix_len); ++ Py_NormalizeSepsW(exec_prefix); + PyMem_RawFree(pybuilddir); + if (_PyStatus_EXCEPTION(status)) { + return status; +@@ -730,6 +753,7 @@ + + /* Check for pybuilddir.txt */ + assert(*found == 0); ++ Py_NormalizeSepsW(exec_prefix); + status = calculate_pybuilddir(calculate->argv0_path, + exec_prefix, exec_prefix_len, found); + if (_PyStatus_EXCEPTION(status)) { +@@ -804,6 +828,7 @@ + return status; + } + ++ Py_NormalizeSepsW(exec_prefix); + if (!calculate->exec_prefix_found) { + if (calculate->warnings) { + fprintf(stderr, +@@ -836,6 +861,47 @@ + } + + ++#ifdef MS_WINDOWS ++wchar_t * ++GetWindowsModulePaths(void) ++{ ++ int result = 0; ++ wchar_t program_full_path[MAXPATHLEN+1]; ++ memset(program_full_path, 0, sizeof(program_full_path)); ++ ++ if (GetModuleFileNameW(NULL, program_full_path, MAXPATHLEN)) { ++ result = 1; ++ Py_NormalizeSepsW(program_full_path); ++ } ++ ++ return _PyMem_RawWcsdup(program_full_path); ++} ++ ++ ++wchar_t* ++_Py_GetDLLPath(void) ++{ ++ wchar_t dll_path[MAXPATHLEN+1]; ++ memset(dll_path, 0, sizeof(dll_path)); ++ ++#ifdef Py_ENABLE_SHARED ++ extern HANDLE PyWin_DLLhModule; ++ if (PyWin_DLLhModule) { ++ if (GetModuleFileNameW(PyWin_DLLhModule, dll_path, MAXPATHLEN)) { ++ Py_NormalizeSepsW(dll_path); ++ } else { ++ dll_path[0] = 0; ++ } ++ } ++#else ++ dll_path[0] = 0; ++#endif ++ ++ return _PyMem_RawWcsdup(dll_path); ++} ++#endif /* MS_WINDOWS */ ++ ++ + static PyStatus + calculate_set_exec_prefix(PyCalculatePath *calculate, + _PyPathConfig *pathconfig) +@@ -846,6 +913,12 @@ + return _PyStatus_NO_MEMORY(); + } + ++#ifdef MS_WINDOWS ++ wchar_t drive_root[3]; ++ memset(drive_root, 0, sizeof(drive_root)); ++ wcsncpy(drive_root, calculate->exec_prefix, 3); ++#endif ++ + reduce(exec_prefix); + reduce(exec_prefix); + reduce(exec_prefix); +@@ -859,7 +932,11 @@ + + /* The exec_prefix is the root directory, but reduce() chopped + off the "/". */ ++#ifdef MS_WINDOWS ++ pathconfig->exec_prefix = _PyMem_RawWcsdup(drive_root); ++#else + pathconfig->exec_prefix = _PyMem_RawWcsdup(separator); ++#endif + if (pathconfig->exec_prefix == NULL) { + return _PyStatus_NO_MEMORY(); + } +@@ -964,13 +1041,22 @@ + * other way to find a directory to start the search from. If + * $PATH isn't exported, you lose. + */ +- if (wcschr(pathconfig->program_name, SEP)) { ++ if (wcschr(pathconfig->program_name, Py_GetSepW(pathconfig->program_name))) { + pathconfig->program_full_path = _PyMem_RawWcsdup(pathconfig->program_name); + if (pathconfig->program_full_path == NULL) { + return _PyStatus_NO_MEMORY(); + } + return _PyStatus_OK(); + } ++#ifdef MS_WINDOWS ++ else if(pathconfig->program_full_path == NULL) { ++ pathconfig->program_full_path = GetWindowsModulePaths(); ++ if (pathconfig->program_full_path == NULL) { ++ return _PyStatus_NO_MEMORY(); ++ } ++ return _PyStatus_OK(); ++ } ++#endif /* MS_WINDOWS */ + + #ifdef __APPLE__ + wchar_t *abs_path = NULL; +@@ -1007,7 +1088,7 @@ + + + /* Calculate pathconfig->program_full_path */ +-static PyStatus ++PyStatus + calculate_program(PyCalculatePath *calculate, _PyPathConfig *pathconfig) + { + PyStatus status; +@@ -1173,7 +1254,7 @@ + #endif + + +-static PyStatus ++PyStatus + calculate_argv0_path(PyCalculatePath *calculate, + _PyPathConfig *pathconfig) + { +@@ -1191,10 +1272,12 @@ + } + #endif + ++#if defined(HAVE_READLINK) + status = resolve_symlinks(&calculate->argv0_path); + if (_PyStatus_EXCEPTION(status)) { + return status; + } ++#endif + + reduce(calculate->argv0_path); + +@@ -1328,6 +1411,8 @@ + calculate->zip_path[len - 6] = VERSION[0]; + calculate->zip_path[len - 5] = VERSION[2]; + ++ Py_NormalizeSepsW(calculate->zip_path); ++ + res = _PyStatus_OK(); + + done: +@@ -1367,7 +1452,14 @@ + } + + bufsz += wcslen(calculate->zip_path) + 1; ++/* TODO :: The MS_WINDOWS bit may be unnecessary. */ ++#ifdef MS_WINDOWS ++ if (_Py_isabs(calculate->exec_prefix)) { ++ bufsz += wcslen(calculate->exec_prefix) + 1; ++ } ++#else + bufsz += wcslen(calculate->exec_prefix) + 1; ++#endif + + /* Allocate the buffer */ + wchar_t *buf = PyMem_RawMalloc(bufsz * sizeof(wchar_t)); +@@ -1395,7 +1487,7 @@ + + if (!_Py_isabs(defpath)) { + wcscat(buf, calculate->prefix); +- if (prefixsz >= 2 && calculate->prefix[prefixsz - 2] != SEP && ++ if (prefixsz >= 2 && !_Py_issep(calculate->prefix[prefixsz - 2]) && + defpath[0] != (delim ? DELIM : L'\0')) + { + /* not empty */ +@@ -1417,8 +1509,15 @@ + } + wcscat(buf, delimiter); + ++#ifdef MS_WINDOWS ++ if (_Py_isabs(calculate->exec_prefix)) { ++ wcscat(buf, calculate->exec_prefix); ++ wcscat(buf, delimiter); ++ } ++#else + /* Finally, on goes the directory for dynamic-load modules */ + wcscat(buf, calculate->exec_prefix); ++#endif + + pathconfig->module_search_path = buf; + return _PyStatus_OK(); +@@ -1447,14 +1546,17 @@ + if (!calculate->pythonpath_macro) { + return DECODE_LOCALE_ERR("PYTHONPATH macro", len); + } ++ Py_NormalizeSepsW(calculate->pythonpath_macro); + calculate->prefix_macro = Py_DecodeLocale(PREFIX, &len); + if (!calculate->prefix_macro) { + return DECODE_LOCALE_ERR("PREFIX macro", len); + } ++ Py_NormalizeSepsW(calculate->prefix_macro); + calculate->exec_prefix_macro = Py_DecodeLocale(EXEC_PREFIX, &len); + if (!calculate->exec_prefix_macro) { + return DECODE_LOCALE_ERR("EXEC_PREFIX macro", len); + } ++ Py_NormalizeSepsW(calculate->exec_prefix_macro); + calculate->vpath_macro = Py_DecodeLocale(VPATH, &len); + if (!calculate->vpath_macro) { + return DECODE_LOCALE_ERR("VPATH macro", len); +@@ -1465,6 +1567,7 @@ + if (!pyversion) { + return DECODE_LOCALE_ERR("VERSION macro", len); + } ++ + calculate->lib_python = joinpath2(config->platlibdir, pyversion); + PyMem_RawFree(pyversion); + if (calculate->lib_python == NULL) { +@@ -1481,6 +1584,7 @@ + PyMem_RawFree(calculate->pythonpath_macro); + PyMem_RawFree(calculate->prefix_macro); + PyMem_RawFree(calculate->exec_prefix_macro); ++ PyMem_RawFree(calculate->dll_path); + PyMem_RawFree(calculate->vpath_macro); + PyMem_RawFree(calculate->lib_python); + PyMem_RawFree(calculate->path_env); +@@ -1496,6 +1600,8 @@ + { + PyStatus status; + ++ calculate->dll_path = _Py_GetDLLPath(); ++ + if (pathconfig->program_full_path == NULL) { + status = calculate_program(calculate, pathconfig); + if (_PyStatus_EXCEPTION(status)) { +@@ -1596,6 +1732,7 @@ + { + PyStatus status; + PyCalculatePath calculate; ++ separator[0] = Py_GetSepW(NULL); + memset(&calculate, 0, sizeof(calculate)); + + status = calculate_init(&calculate, config); +diff -Naur Python-3.9.4-orig/Modules/posixmodule.c Python-3.9.4/Modules/posixmodule.c +--- Python-3.9.4-orig/Modules/posixmodule.c 2021-04-04 08:56:53 +0000 ++++ Python-3.9.4/Modules/posixmodule.c 2021-04-25 13:03:43 +0000 +@@ -4007,7 +4007,7 @@ + Py_END_ALLOW_THREADS + /* FindNextFile sets error to ERROR_NO_MORE_FILES if + it got to the end of the directory. */ +- if (!result && GetLastError() != ERROR_NO_MORE_FILES) { ++ if (!result && GetLastError() != 0 && GetLastError() != ERROR_NO_MORE_FILES) { + Py_DECREF(list); + list = path_error(path); + goto exit; +diff -Naur Python-3.9.4-orig/Python/dynload_win.c Python-3.9.4/Python/dynload_win.c +--- Python-3.9.4-orig/Python/dynload_win.c 2021-04-04 08:56:53 +0000 ++++ Python-3.9.4/Python/dynload_win.c 2021-04-25 13:03:43 +0000 +@@ -168,7 +168,9 @@ + char funcname[258], *import_python; + const wchar_t *wpathname; + ++#if defined(_MSC_VER) + _Py_CheckPython3(); ++#endif + + _Py_COMP_DIAG_PUSH + _Py_COMP_DIAG_IGNORE_DEPR_DECLS +--- Python-3.9.5/Include/cpython/fileutils.h.orig 2021-05-14 08:56:28.068122000 +0300 ++++ Python-3.9.5/Include/cpython/fileutils.h 2021-05-14 09:04:20.120420600 +0300 +@@ -136,9 +136,8 @@ + size_t resolved_path_len); + #endif + +-#ifndef MS_WINDOWS + PyAPI_FUNC(int) _Py_isabs(const wchar_t *path); +-#endif ++PyAPI_FUNC(int) _Py_issep(const wchar_t ch); + + PyAPI_FUNC(int) _Py_abspath(const wchar_t *path, wchar_t **abspath_p); + +--- Python-3.9.5/Python/fileutils.c.orig 2021-05-14 08:57:10.254566600 +0300 ++++ Python-3.9.5/Python/fileutils.c 2021-05-14 09:04:13.267070300 +0300 +@@ -1819,13 +1819,31 @@ + #endif + + +-#ifndef MS_WINDOWS + int + _Py_isabs(const wchar_t *path) + { +- return (path[0] == SEP); ++#ifdef MS_WINDOWS ++ size_t i = wcslen(path); ++ if (i >= 3) { ++ if (iswalpha(path[0]) && path[1] == L':' && _Py_issep(path[2])) { ++ return 1; ++ } ++ } ++ return 0; ++#else ++ return _Py_issep(path[0]); ++#endif + } ++ ++int ++_Py_issep(const wchar_t ch) ++{ ++#ifdef MS_WINDOWS ++ return ch == SEP || ch == ALTSEP; ++#else ++ return ch == SEP; + #endif ++} + + + /* Get an absolute path. diff --git a/mingw-w64-python3.9/0565-mingw-add-ModuleFileName-dir-to-PATH.patch b/mingw-w64-python3.9/0565-mingw-add-ModuleFileName-dir-to-PATH.patch new file mode 100644 index 0000000000..fa2fb5ffdf --- /dev/null +++ b/mingw-w64-python3.9/0565-mingw-add-ModuleFileName-dir-to-PATH.patch @@ -0,0 +1,40 @@ +diff -Naur Python-3.9.5-orig/Modules/getpath.c Python-3.9.5/Modules/getpath.c +--- Python-3.9.5-orig/Modules/getpath.c 2019-10-22 10:02:47.765731400 +0300 ++++ Python-3.9.5/Modules/getpath.c 2019-10-22 10:02:49.637734700 +0300 +@@ -1530,6 +1636,36 @@ + return status; + } + ++#ifdef MS_WINDOWS ++ if (calculate->path_env) { ++ wchar_t *module_path, *norm_path; ++ // Add path of executable/dll to system path. This ++ // is so that the correct tcl??.dll and tk??.dll get used. ++ module_path = calculate->dll_path[0] ? calculate->dll_path : pathconfig->program_full_path; ++ norm_path = (wchar_t *)alloca(sizeof(wchar_t) * (wcslen(module_path) + 1)); ++ if (norm_path) { ++ wchar_t *slashes, *end, *new_path; ++ wcscpy(norm_path, module_path); ++ slashes = wcschr(norm_path, L'/'); ++ while (slashes) { ++ *slashes = L'\\'; ++ slashes = wcschr(slashes + 1, L'/'); ++ } ++ end = wcsrchr(norm_path, L'\\') ? wcsrchr(norm_path, L'\\') : norm_path + wcslen(norm_path); ++ end[1] = L'\0'; ++ ++ new_path = (wchar_t *)alloca(sizeof(wchar_t) * (wcslen(L"PATH=") + wcslen(calculate->path_env) + 1 + wcslen(norm_path) + 1)); ++ if (new_path) { ++ wcscpy(new_path, L"PATH="); ++ wcscat(new_path, calculate->path_env); ++ wcscat(new_path, L";"); ++ wcscat(new_path, norm_path); ++ _wputenv(new_path); ++ } ++ } ++ } ++#endif ++ + if ((!calculate->prefix_found || !calculate->exec_prefix_found) + && calculate->warnings) + { diff --git a/mingw-w64-python3.9/0570-mingw-add-BUILDIN_WIN32_MODULEs-time-msvcrt.patch b/mingw-w64-python3.9/0570-mingw-add-BUILDIN_WIN32_MODULEs-time-msvcrt.patch new file mode 100644 index 0000000000..ca32a62e8e --- /dev/null +++ b/mingw-w64-python3.9/0570-mingw-add-BUILDIN_WIN32_MODULEs-time-msvcrt.patch @@ -0,0 +1,9 @@ +diff -Naur Python-3.8.0-orig/Modules/Setup.config.in Python-3.8.0/Modules/Setup.config.in +--- Python-3.8.0-orig/Modules/Setup.config.in 2019-10-22 10:01:08.018156200 +0300 ++++ Python-3.8.0/Modules/Setup.config.in 2019-10-22 10:02:53.303741100 +0300 +@@ -11,4 +11,5 @@ + + # build-in modules for windows platform: + @USE_WIN32_MODULE@winreg ../PC/winreg.c ++@USE_WIN32_MODULE@msvcrt -DPy_BUILD_CORE ../PC/msvcrtmodule.c + diff --git a/mingw-w64-python3.9/0610-msys-cygwin-semi-native-build-sysconfig.patch b/mingw-w64-python3.9/0610-msys-cygwin-semi-native-build-sysconfig.patch new file mode 100644 index 0000000000..76957662b6 --- /dev/null +++ b/mingw-w64-python3.9/0610-msys-cygwin-semi-native-build-sysconfig.patch @@ -0,0 +1,104 @@ +diff -Naur Python-3.8.0-orig/configure.ac Python-3.8.0/configure.ac +--- Python-3.8.0-orig/configure.ac 2019-10-22 10:02:29.123698700 +0300 ++++ Python-3.8.0/configure.ac 2019-10-22 10:02:56.595346900 +0300 +@@ -598,6 +598,65 @@ + AC_DEFINE(_INCLUDE__STDC_A1_SOURCE, 1, Define to include mbstate_t for mbrtowc) + fi + ++# On 'semi-native' build systems (MSYS*/Cygwin targeting MinGW-w64) ++# _sysconfigdata.py will contain paths that are correct only in the ++# build environment. This means external modules will fail to build ++# without setting up the same env and also that the build of Python ++# itself will fail as the paths are not correct for the host tools. ++# ++# Also, getpath.c uses GetModuleFileNameW (replacing \ with /) and ++# compares that with the define VPATH (passed in via command-line) ++# to determine whether it's the build- or the installed-Python. ++# ++# To work around these issues a set of _b2h variables are created: ++# VPATH_b2h, prefix_b2h, srcdir_b2h, abs_srcdir_b2h ++# and abs_builddir_b2h ++# .. where b2h stands for build to host. sysconfig.py replaces path ++# prefixes matching the non-b2h versions with the b2h equivalents. ++# ++# (note this assumes the host compilers are native and *not* cross ++# - in the 'semi-native' scenario only that is.) ++ ++AC_DEFUN([ABS_PATH_HOST], ++[$1=$(cd $$2 && pwd) ++ case $build_os in ++ mingw*) ++ case $host_os in ++ mingw*) $1=$(cd $$2 && pwd -W) ;; ++ *) ;; ++ esac ++ ;; ++ cygwin*) ++ case $host_os in ++ mingw*) $1=$(cygpath -w -m $$2) ;; ++ *) ;; ++ esac ++ ;; ++ esac ++AC_SUBST([$1]) ++]) ++ ++AC_MSG_CHECKING(absolute host location of VPATH) ++ABS_PATH_HOST([VPATH_b2h],[srcdir]) ++AC_MSG_RESULT([$VPATH_b2h]) ++ ++AC_MSG_CHECKING(absolute host location of prefix) ++ABS_PATH_HOST([prefix_b2h],[prefix]) ++AC_MSG_RESULT([$prefix_b2h]) ++ ++AC_MSG_CHECKING(absolute host location of srcdir) ++ABS_PATH_HOST([srcdir_b2h],[srcdir]) ++AC_MSG_RESULT([$srcdir_b2h]) ++ ++AC_MSG_CHECKING(absolute host location of abs_srcdir) ++ABS_PATH_HOST([abs_srcdir_b2h],[srcdir]) ++AC_MSG_RESULT([$abs_srcdir_b2h]) ++ ++my_builddir=. ++AC_MSG_CHECKING(Absolute host location of abs_builddir) ++ABS_PATH_HOST([abs_builddir_b2h],[my_builddir]) ++AC_MSG_RESULT([$abs_builddir_b2h]) ++ + AC_MSG_CHECKING([for init system calls]) + AC_SUBST(INITSYS) + case $host in +diff -Naur Python-3.8.0-orig/Lib/sysconfig.py Python-3.8.0/Lib/sysconfig.py +--- Python-3.8.0-orig/Lib/sysconfig.py 2019-10-22 10:02:09.342863900 +0300 ++++ Python-3.8.0/Lib/sysconfig.py 2019-10-22 10:02:57.000947600 +0300 +@@ -329,6 +329,14 @@ + if isinstance(v, str): + done[k] = v.strip() + ++ # any keys that have one with the same name suffixed with _b2h ++ # need to be replaced with the value of the _b2h key. ++ # This converts from MSYS*/Cygwin paths to Windows paths. ++ for k, v in dict(done).items(): ++ if isinstance(k, str): ++ if k.endswith("_b2h"): ++ done[k[:-4]]=v ++ + # save the results in the global dictionary + vars.update(done) + return vars +diff -Naur Python-3.8.0-orig/Makefile.pre.in Python-3.8.0/Makefile.pre.in +--- Python-3.8.0-orig/Makefile.pre.in 2019-10-22 10:01:28.376191900 +0300 ++++ Python-3.8.0/Makefile.pre.in 2019-10-22 10:02:57.390948300 +0300 +@@ -137,6 +137,13 @@ + # Install prefix for data files + datarootdir= @datarootdir@ + ++# Locations needed for semi-native fixup of sysconfig. ++srcdir_b2h= @srcdir_b2h@ ++VPATH_b2h= @VPATH_b2h@ ++abs_srcdir_b2h= @abs_srcdir_b2h@ ++abs_builddir_b2h= @abs_builddir_b2h@ ++prefix_b2h= @prefix_b2h@ ++ + # Expanded directories + BINDIR= @bindir@ + LIBDIR= @libdir@ diff --git a/mingw-w64-python3.9/0620-mingw-sysconfig-like-posix.patch b/mingw-w64-python3.9/0620-mingw-sysconfig-like-posix.patch new file mode 100644 index 0000000000..33a1a95bc5 --- /dev/null +++ b/mingw-w64-python3.9/0620-mingw-sysconfig-like-posix.patch @@ -0,0 +1,64 @@ +diff -Naur Python-3.8.0-orig/Lib/distutils/command/build_ext.py Python-3.8.0/Lib/distutils/command/build_ext.py +--- Python-3.8.0-orig/Lib/distutils/command/build_ext.py 2019-10-22 10:01:56.348041100 +0300 ++++ Python-3.8.0/Lib/distutils/command/build_ext.py 2019-10-22 10:03:01.072554800 +0300 +@@ -221,9 +221,10 @@ + if sys.platform[:6] == 'cygwin': + if sys.executable.startswith(os.path.join(sys.exec_prefix, "bin")): + # building third party extensions ++ config_dir_name = os.path.basename(sysconfig.get_config_var('LIBPL')) + self.library_dirs.append(os.path.join(sys.prefix, "lib", + "python" + get_python_version(), +- "config")) ++ config_dir_name)) + else: + # building python standard extensions + self.library_dirs.append('.') +diff -Naur Python-3.8.0-orig/Lib/sysconfig.py Python-3.8.0/Lib/sysconfig.py +--- Python-3.8.0-orig/Lib/sysconfig.py 2019-10-22 10:02:59.528152100 +0300 ++++ Python-3.8.0/Lib/sysconfig.py 2019-10-22 10:03:01.462555500 +0300 +@@ -43,23 +43,23 @@ + 'data': '{base}', + }, + 'nt': { +- 'stdlib': '{installed_base}/Lib', +- 'platstdlib': '{base}/Lib', +- 'purelib': '{base}/Lib/site-packages', +- 'platlib': '{base}/Lib/site-packages', +- 'include': '{installed_base}/Include', +- 'platinclude': '{installed_base}/Include', +- 'scripts': '{base}/Scripts', ++ 'stdlib': '{installed_base}/lib/python{py_version_short}', ++ 'platstdlib': '{base}/lib/python{py_version_short}', ++ 'purelib': '{base}/lib/python{py_version_short}', ++ 'platlib': '{base}/lib/python{py_version_short}', ++ 'include': '{installed_base}/include/python{py_version_short}', ++ 'platinclude': '{installed_base}/include/python{py_version_short}', ++ 'scripts': '{base}/bin', + 'data': '{base}', + }, + # NOTE: When modifying "purelib" scheme, update site._get_path() too. + 'nt_user': { +- 'stdlib': '{userbase}/Python{py_version_nodot}', +- 'platstdlib': '{userbase}/Python{py_version_nodot}', +- 'purelib': '{userbase}/Python{py_version_nodot}/site-packages', +- 'platlib': '{userbase}/Python{py_version_nodot}/site-packages', +- 'include': '{userbase}/Python{py_version_nodot}/Include', +- 'scripts': '{userbase}/Python{py_version_nodot}/Scripts', ++ 'stdlib': '{userbase}/lib/python{py_version_short}', ++ 'platstdlib': '{userbase}/lib/python{py_version_short}', ++ 'purelib': '{userbase}/lib/python{py_version_short}/site-packages', ++ 'platlib': '{userbase}/lib/python{py_version_short}/site-packages', ++ 'include': '{userbase}/include/python{py_version_short}', ++ 'scripts': '{userbase}/bin', + 'data': '{userbase}', + }, + 'posix_user': { +@@ -461,7 +461,7 @@ + vars['INCLUDEPY'] = get_path('include') + vars['EXT_SUFFIX'] = '.pyd' + vars['EXE'] = '.exe' +- vars['VERSION'] = _PY_VERSION_SHORT_NO_DOT ++ vars['VERSION'] = _PY_VERSION_SHORT + vars['BINDIR'] = os.path.dirname(_safe_realpath(sys.executable)) + + # diff --git a/mingw-w64-python3.9/0630-mingw-_winapi_as_builtin_for_Popen_in_cygwinccompiler.patch b/mingw-w64-python3.9/0630-mingw-_winapi_as_builtin_for_Popen_in_cygwinccompiler.patch new file mode 100644 index 0000000000..72c9f610af --- /dev/null +++ b/mingw-w64-python3.9/0630-mingw-_winapi_as_builtin_for_Popen_in_cygwinccompiler.patch @@ -0,0 +1,61 @@ +diff -Naur Python-3.8.0-orig/Lib/distutils/cygwinccompiler.py Python-3.8.0/Lib/distutils/cygwinccompiler.py +--- Python-3.8.0-orig/Lib/distutils/cygwinccompiler.py 2019-10-22 10:02:17.798078800 +0300 ++++ Python-3.8.0/Lib/distutils/cygwinccompiler.py 2019-10-22 10:03:04.738561200 +0300 +@@ -58,6 +58,7 @@ + from distutils import log + from distutils.version import LooseVersion + from distutils.spawn import find_executable ++from subprocess import Popen, PIPE, check_output + + def get_msvcr(): + """Include the appropriate MSVC runtime library if Python was built +@@ -373,7 +374,7 @@ + return (CONFIG_H_UNCERTAIN, + "couldn't read '%s': %s" % (fn, exc.strerror)) + +-RE_VERSION = re.compile(br'(\d+\.\d+(\.\d+)*)') ++RE_VERSION = re.compile(br'[\D\s]*(\d+\.\d+(\.\d+)*)[\D\s]*$') + + def _find_exe_version(cmd): + """Find the version of an executable by running `cmd` in the shell. +@@ -402,7 +403,16 @@ + + If not possible it returns None for it. + """ +- commands = ['gcc -dumpversion', 'ld -v', 'dllwrap --version'] ++ gcc = os.environ.get('CC') or 'gcc' ++ ld = 'ld' ++ out = Popen(gcc+' --print-prog-name ld', shell=True, stdout=PIPE).stdout ++ try: ++ ld = test=str(out.read(),encoding='utf-8').strip() ++ finally: ++ out.close() ++ dllwrap = os.environ.get('DLLWRAP') or 'dllwrap' ++ # MinGW64 doesn't have i686-w64-mingw32-ld, so instead we ask gcc. ++ commands = [gcc+' -dumpversion', ld+' -v', dllwrap+' --version'] + return tuple([_find_exe_version(cmd) for cmd in commands]) + + def is_cygwingcc(): +diff -Naur Python-3.8.0-orig/Modules/Setup.config.in Python-3.8.0/Modules/Setup.config.in +--- Python-3.8.0-orig/Modules/Setup.config.in 2019-10-22 10:02:55.456544900 +0300 ++++ Python-3.8.0/Modules/Setup.config.in 2019-10-22 10:03:05.159762000 +0300 +@@ -12,4 +12,5 @@ + # build-in modules for windows platform: + @USE_WIN32_MODULE@winreg ../PC/winreg.c + @USE_WIN32_MODULE@msvcrt -DPy_BUILD_CORE ../PC/msvcrtmodule.c ++@USE_WIN32_MODULE@_winapi _winapi.c + +diff -Naur Python-3.8.0-orig/setup.py Python-3.8.0/setup.py +--- Python-3.8.0-orig/setup.py 2019-10-22 10:02:35.597710000 +0300 ++++ Python-3.8.0/setup.py 2019-10-22 10:03:05.939763300 +0300 +@@ -1545,7 +1545,9 @@ + self.add(Extension('msvcrt', [os.path.join(pc_srcdir, p) + for p in ['msvcrtmodule.c']])) + +- self.add(Extension('_winapi', ['_winapi.c'])) ++ # Added to Setup.config.in as now needed earlier since I ++ # use subprocess (which uses Popen) in cygwinccompiler.py ++ # self.add(Extension('_winapi', ['_winapi.c'])) + + self.add(Extension('_msi', [os.path.join(pc_srcdir, p) + for p in ['_msi.c']], diff --git a/mingw-w64-python3.9/0650-cross-dont-add-multiarch-paths-if-cross-compiling.patch b/mingw-w64-python3.9/0650-cross-dont-add-multiarch-paths-if-cross-compiling.patch new file mode 100644 index 0000000000..45aee2d6af --- /dev/null +++ b/mingw-w64-python3.9/0650-cross-dont-add-multiarch-paths-if-cross-compiling.patch @@ -0,0 +1,15 @@ +diff -Naur Python-3.8.0-orig/setup.py Python-3.8.0/setup.py +--- Python-3.8.0-orig/setup.py 2019-10-22 10:03:08.498167800 +0300 ++++ Python-3.8.0/setup.py 2019-10-22 10:03:12.382574600 +0300 +@@ -654,10 +654,10 @@ + if not CROSS_COMPILING: + add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') + add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') ++ self.add_multiarch_paths() + # only change this for cross builds for 3.3, issues on Mageia + if CROSS_COMPILING: + self.add_cross_compiling_paths() +- self.add_multiarch_paths() + self.add_ldflags_cppflags() + + def init_inc_lib_dirs(self): diff --git a/mingw-w64-python3.9/0660-mingw-use-backslashes-in-compileall-py.patch b/mingw-w64-python3.9/0660-mingw-use-backslashes-in-compileall-py.patch new file mode 100644 index 0000000000..a911f301ec --- /dev/null +++ b/mingw-w64-python3.9/0660-mingw-use-backslashes-in-compileall-py.patch @@ -0,0 +1,12 @@ +diff -Naur Python-3.8.0-orig/Lib/compileall.py Python-3.8.0/Lib/compileall.py +--- Python-3.8.0-orig/Lib/compileall.py 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/Lib/compileall.py 2019-10-22 10:03:15.206179600 +0300 +@@ -36,6 +36,8 @@ + if name == '__pycache__': + continue + fullname = os.path.join(dir, name) ++ if sys.platform == "win32" and sys.version.find("GCC") >= 0: ++ fullname = fullname.replace('\\','/') + if not os.path.isdir(fullname): + yield fullname + elif (maxlevels > 0 and name != os.curdir and name != os.pardir and diff --git a/mingw-w64-python3.9/0670-msys-convert_path-fix-and-root-hack.patch b/mingw-w64-python3.9/0670-msys-convert_path-fix-and-root-hack.patch new file mode 100644 index 0000000000..8785a6ee7b --- /dev/null +++ b/mingw-w64-python3.9/0670-msys-convert_path-fix-and-root-hack.patch @@ -0,0 +1,93 @@ +diff -Naur Python-3.8.0-orig/Lib/distutils/command/install.py Python-3.8.0/Lib/distutils/command/install.py +--- Python-3.8.0-orig/Lib/distutils/command/install.py 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/Lib/distutils/command/install.py 2019-10-22 10:03:18.045384600 +0300 +@@ -341,7 +341,8 @@ + + # Convert directories from Unix /-separated syntax to the local + # convention. +- self.convert_paths('lib', 'purelib', 'platlib', ++ self.convert_paths('base', 'platbase', ++ 'lib', 'purelib', 'platlib', + 'scripts', 'data', 'headers', + 'userbase', 'usersite') + +diff -Naur Python-3.8.0-orig/Lib/distutils/util.py Python-3.8.0/Lib/distutils/util.py +--- Python-3.8.0-orig/Lib/distutils/util.py 2019-10-22 10:01:56.753641800 +0300 ++++ Python-3.8.0/Lib/distutils/util.py 2019-10-22 10:03:18.450985300 +0300 +@@ -130,6 +130,13 @@ + paths.remove('.') + if not paths: + return os.curdir ++ # On Windows, if paths is ['C:','folder','subfolder'] then ++ # os.path.join(*paths) will return 'C:folder\subfolder' which ++ # is thus relative to the CWD on that drive. So we work around ++ # this by adding a \ to path[0] ++ if (len(paths) > 0 and paths[0].endswith(':') and ++ sys.platform == "win32" and sys.version.find("GCC") >= 0): ++ paths[0] += '\\' + return os.path.join(*paths) + + # convert_path () +@@ -140,6 +147,10 @@ + relative, this is equivalent to "os.path.join(new_root,pathname)". + Otherwise, it requires making 'pathname' relative and then joining the + two, which is tricky on DOS/Windows and Mac OS. ++ ++ If on Windows or OS/2 and both new_root and pathname are on different ++ drives, raises DistutilsChangeRootError as this is nonsensical, ++ otherwise use drive which can be in either of new_root or pathname. + """ + if os.name == 'posix': + if not os.path.isabs(pathname): +@@ -149,9 +160,20 @@ + + elif os.name == 'nt': + (drive, path) = os.path.splitdrive(pathname) +- if path[0] == '\\': ++ if path[0] == os.sep: + path = path[1:] +- return os.path.join(new_root, path) ++ (drive_r, path_r) = os.path.splitdrive(new_root) ++ if path_r and path_r[0] == os.sep: ++ path_r = path_r[1:] ++ drive_used = '' ++ if len(drive) == 2 and len(drive_r) == 2 and drive != drive_r: ++ raise DistutilsChangeRootError("root and pathname not on same drive (%s, %s)" ++ % (drive_r,drive)) ++ elif len(drive_r) == 2: ++ drive_used = drive_r+os.sep ++ elif len(drive) == 2: ++ drive_used = drive+os.sep ++ return os.path.join(drive_used+path_r, path) + + else: + raise DistutilsPlatformError("nothing known about platform '%s'" % os.name) +diff -Naur Python-3.8.0-orig/Makefile.pre.in Python-3.8.0/Makefile.pre.in +--- Python-3.8.0-orig/Makefile.pre.in 2019-10-22 10:02:59.949352800 +0300 ++++ Python-3.8.0/Makefile.pre.in 2019-10-22 10:03:18.840986000 +0300 +@@ -1612,6 +1612,12 @@ + else true; \ + fi + ++ifeq ($(shell uname -o),Msys) ++DESTDIRFINAL=$(DESTDIR) ++else ++DESTDIRFINAL=$(DESTDIR)/ ++endif ++ + # Install the dynamically loadable modules + # This goes into $(exec_prefix) + sharedinstall: sharedmods +@@ -1619,9 +1625,9 @@ + --prefix=$(prefix) \ + --install-scripts=$(BINDIR) \ + --install-platlib=$(DESTSHARED) \ +- --root=$(DESTDIR)/ +- -rm $(DESTDIR)$(DESTSHARED)/_sysconfigdata_$(ABIFLAGS)_$(MACHDEP)_$(MULTIARCH).py +- -rm -r $(DESTDIR)$(DESTSHARED)/__pycache__ ++ --root=$(DESTDIRFINAL) ++ -rm $(DESTDIRFINAL)$(DESTSHARED)/_sysconfigdata_$(ABIFLAGS)_$(MACHDEP)_$(MULTIARCH).py ++ -rm -r $(DESTDIRFINAL)$(DESTSHARED)/__pycache__ + + # Here are a couple of targets for MacOSX again, to install a full + # framework-based Python. frameworkinstall installs everything, the diff --git a/mingw-w64-python3.9/0690-allow-static-tcltk.patch b/mingw-w64-python3.9/0690-allow-static-tcltk.patch new file mode 100644 index 0000000000..377abb8fa8 --- /dev/null +++ b/mingw-w64-python3.9/0690-allow-static-tcltk.patch @@ -0,0 +1,69 @@ +diff -Naur Python-3.8.0-orig/setup.py Python-3.8.0/setup.py +--- Python-3.8.0-orig/setup.py 2019-10-22 10:03:14.129777700 +0300 ++++ Python-3.8.0/setup.py 2019-10-22 10:03:22.475792400 +0300 +@@ -703,7 +703,7 @@ + if HOST_PLATFORM == 'hp-ux11': + self.lib_dirs += ['/usr/lib/hpux64', '/usr/lib/hpux32'] + +- if MACOS: ++ if MACOS or MS_WINDOWS: + # This should work on any unixy platform ;-) + # If the user has bothered specifying additional -I and -L flags + # in OPT and LDFLAGS we might as well use them here. +@@ -713,6 +713,8 @@ + # directories with whitespace in the name to store libraries. + cflags, ldflags = sysconfig.get_config_vars( + 'CFLAGS', 'LDFLAGS') ++ cflags = cflags + ' ' + ('',os.environ.get('CC'))[os.environ.get('CC') != None] ++ ldflags = ldflags + ' ' + ('',os.environ.get('LDSHARED'))[os.environ.get('LDSHARED') != None] + for item in cflags.split(): + if item.startswith('-I'): + self.inc_dirs.append(item[2:]) +@@ -1907,14 +1909,19 @@ + # The versions with dots are used on Unix, and the versions without + # dots on Windows, for detection by cygwin. + tcllib = tklib = tcl_includes = tk_includes = None +- for version in ['8.6', '86', '8.5', '85', '8.4', '84', '8.3', '83', +- '8.2', '82', '8.1', '81', '8.0', '80']: +- tklib = self.compiler.find_library_file(self.lib_dirs, +- 'tk' + version) +- tcllib = self.compiler.find_library_file(self.lib_dirs, +- 'tcl' + version) +- if tklib and tcllib: +- # Exit the loop when we've found the Tcl/Tk libraries ++ tcltk_suffix = None ++ for suffix in ['', 's']: ++ for version in ['8.6', '86', '8.5', '85', '8.4', '84', '8.3', '83', ++ '8.2', '82', '8.1', '81', '8.0', '80', '']: ++ tklib = self.compiler.find_library_file(self.lib_dirs, ++ 'tk' + version + suffix) ++ tcllib = self.compiler.find_library_file(self.lib_dirs, ++ 'tcl' + version + suffix) ++ if tklib and tcllib: ++ # Exit the loop when we've found the Tcl/Tk libraries ++ tcltk_suffix = suffix ++ break ++ if tcltk_suffix != None: + break + + # Now check for the header files +@@ -1985,10 +1992,18 @@ + # Add the Tcl/Tk libraries + libs.append('tk'+ version) + libs.append('tcl'+ version) ++ libs.append('tk'+ version + tcltk_suffix) ++ libs.append('tcl'+ version + tcltk_suffix) ++ if MS_WINDOWS: ++ for winlib in ['ws2_32','gdi32','comctl32','comdlg32','imm32','uuid','oleaut32','ole32']: ++ libs.append( winlib ) + + # Finally, link with the X11 libraries (not appropriate on cygwin) +- if not CYGWIN: ++ # ...on those platforms, define STATIC_BUILD if linking to static tcl/tk. ++ if not CYGWIN and not MS_WINDOWS: + libs.append('X11') ++ elif tcllib.endswith('s.a'): ++ defs.append( ('STATIC_BUILD',1) ) + + # XXX handle these, but how to detect? + # *** Uncomment and edit for PIL (TkImaging) extension only: diff --git a/mingw-w64-python3.9/0720-mingw-pdcurses_ISPAD.patch b/mingw-w64-python3.9/0720-mingw-pdcurses_ISPAD.patch new file mode 100644 index 0000000000..e78c029252 --- /dev/null +++ b/mingw-w64-python3.9/0720-mingw-pdcurses_ISPAD.patch @@ -0,0 +1,17 @@ +diff -Naur Python-3.8.0-orig/Include/py_curses.h Python-3.8.0/Include/py_curses.h +--- Python-3.8.0-orig/Include/py_curses.h 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/Include/py_curses.h 2019-10-22 10:03:25.689398000 +0300 +@@ -36,6 +36,13 @@ + #include + #endif + ++#if defined(__MINGW32__) ++#include ++#if !defined(_ISPAD) ++#define _ISPAD 0x10 ++#endif ++#endif ++ + #ifdef HAVE_NCURSES_H + /* configure was checking , but we will + use , which has some or all these features. */ diff --git a/mingw-w64-python3.9/0740-grammar-fixes.patch b/mingw-w64-python3.9/0740-grammar-fixes.patch new file mode 100644 index 0000000000..2262e145b6 --- /dev/null +++ b/mingw-w64-python3.9/0740-grammar-fixes.patch @@ -0,0 +1,25 @@ +diff -Naur Python-3.8.0-orig/Python/graminit.c Python-3.8.0/Python/graminit.c +--- Python-3.8.0-orig/Python/graminit.c 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/Python/graminit.c 2019-10-22 10:03:28.497403000 +0300 +@@ -1,7 +1,8 @@ + /* Generated by Parser/pgen */ + + #include "grammar.h" +-Py_EXPORTED_SYMBOL grammar _PyParser_Grammar; ++#include "pyport.h" ++PyAPI_DATA(grammar) _PyParser_Grammar; + static const arc arcs_0_0[3] = { + {2, 1}, + {3, 2}, +diff -Naur Python-3.8.0-orig/Modules/parsermodule.c Python-3.8.0/Modules/parsermodule.c +--- Python-3.8.0-orig/Modules/parsermodule.c 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/Modules/parsermodule.c 2019-10-22 10:03:28.497403000 +0300 +@@ -38,7 +38,7 @@ + #include "grammar.h" + #include "parsetok.h" + +-extern grammar _PyParser_Grammar; /* From graminit.c */ ++PyAPI_DATA(grammar) _PyParser_Grammar; /* From graminit.c */ + + #ifdef lint + #include diff --git a/mingw-w64-python3.9/0750-builddir-fixes.patch b/mingw-w64-python3.9/0750-builddir-fixes.patch new file mode 100644 index 0000000000..9544f8fa96 --- /dev/null +++ b/mingw-w64-python3.9/0750-builddir-fixes.patch @@ -0,0 +1,49 @@ +diff -Naur Python-3.8.0-orig/Makefile.pre.in Python-3.8.0/Makefile.pre.in +--- Python-3.8.0-orig/Makefile.pre.in 2019-10-22 10:03:21.368190400 +0300 ++++ Python-3.8.0/Makefile.pre.in 2019-10-22 10:03:31.336607900 +0300 +@@ -710,20 +710,20 @@ + + Programs/_freeze_importlib.o: Programs/_freeze_importlib.c Makefile + +-Programs/_freeze_importlib: Programs/_freeze_importlib.o $(LIBRARY_OBJS_OMIT_FROZEN) ++Programs/_freeze_importlib$(EXE): Programs/_freeze_importlib.o $(LIBRARY_OBJS_OMIT_FROZEN) + $(LINKCC) $(PY_CORE_LDFLAGS) -o $@ Programs/_freeze_importlib.o $(LIBRARY_OBJS_OMIT_FROZEN) $(LIBS) $(MODLIBS) $(SYSLIBS) + + .PHONY: regen-importlib +-regen-importlib: Programs/_freeze_importlib ++regen-importlib: Programs/_freeze_importlib$(EXE) + # Regenerate Python/importlib_external.h + # from Lib/importlib/_bootstrap_external.py using _freeze_importlib +- ./Programs/_freeze_importlib importlib._bootstrap_external \ ++ ./Programs/_freeze_importlib$(EXE) importlib._bootstrap_external \ + $(srcdir)/Lib/importlib/_bootstrap_external.py \ + $(srcdir)/Python/importlib_external.h.new + $(UPDATE_FILE) $(srcdir)/Python/importlib_external.h $(srcdir)/Python/importlib_external.h.new + # Regenerate Python/importlib.h from Lib/importlib/_bootstrap.py + # using _freeze_importlib +- ./Programs/_freeze_importlib importlib._bootstrap \ ++ ./Programs/_freeze_importlib$(EXE) importlib._bootstrap \ + $(srcdir)/Lib/importlib/_bootstrap.py \ + $(srcdir)/Python/importlib.h.new + $(UPDATE_FILE) $(srcdir)/Python/importlib.h $(srcdir)/Python/importlib.h.new +@@ -1781,7 +1781,7 @@ + find build -name '*.py[co]' -exec rm -f {} ';' || true + -rm -f pybuilddir.txt + -rm -f Lib/lib2to3/*Grammar*.pickle +- -rm -f Programs/_testembed Programs/_freeze_importlib ++ -rm -f Programs/_testembed Programs/_freeze_importlib$(EXE) + -find build -type f -a ! -name '*.gc??' -exec rm -f {} ';' + -rm -f Include/pydtrace_probes.h + -rm -f profile-gen-stamp +diff -Naur Python-3.8.0-orig/Programs/_freeze_importlib.c Python-3.8.0/Programs/_freeze_importlib.c +--- Python-3.8.0-orig/Programs/_freeze_importlib.c 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/Programs/_freeze_importlib.c 2019-10-22 10:03:31.757808700 +0300 +@@ -20,7 +20,7 @@ + {0, 0, 0} /* sentinel */ + }; + +-#ifndef MS_WINDOWS ++#ifndef _MSC_VER + /* On Windows, this links with the regular pythonXY.dll, so this variable comes + from frozen.obj. In the Makefile, frozen.o is not linked into this executable, + so we define the variable here. */ diff --git a/mingw-w64-python3.9/0760-msys-monkeypatch-os-system-via-sh-exe.patch b/mingw-w64-python3.9/0760-msys-monkeypatch-os-system-via-sh-exe.patch new file mode 100644 index 0000000000..db89e15b76 --- /dev/null +++ b/mingw-w64-python3.9/0760-msys-monkeypatch-os-system-via-sh-exe.patch @@ -0,0 +1,21 @@ +diff -Naur Python-3.8.0-orig/setup.py Python-3.8.0/setup.py +--- Python-3.8.0-orig/setup.py 2019-10-22 10:03:24.597396100 +0300 ++++ Python-3.8.0/setup.py 2019-10-22 10:03:35.002614400 +0300 +@@ -38,6 +38,17 @@ + return sys.platform + + ++# On MSYS, os.system needs to be wrapped with sh.exe ++# as otherwise all the io redirection will fail. ++# Arguably, this could happen inside the real os.system ++# rather than this monkey patch. ++if sys.platform == "win32" and "MSYSTEM" in os.environ: ++ os_system = os.system ++ def msys_system(command): ++ command_in_sh = 'sh.exe -c "%s"' % command.replace("\\", "\\\\") ++ return os_system(command_in_sh) ++ os.system = msys_system ++ + CROSS_COMPILING = ("_PYTHON_HOST_PLATFORM" in os.environ) + HOST_PLATFORM = get_platform() + MS_WINDOWS = (HOST_PLATFORM == 'win32') diff --git a/mingw-w64-python3.9/0770-msys-replace-slashes-used-in-io-redirection.patch b/mingw-w64-python3.9/0770-msys-replace-slashes-used-in-io-redirection.patch new file mode 100644 index 0000000000..4ddc55a242 --- /dev/null +++ b/mingw-w64-python3.9/0770-msys-replace-slashes-used-in-io-redirection.patch @@ -0,0 +1,54 @@ +diff -Naur Python-3.9.4-orig/setup.py Python-3.9.4/setup.py +--- Python-3.9.4-orig/setup.py 2021-04-04 08:56:53 +0000 ++++ Python-3.9.4/setup.py 2021-04-05 21:28:28 +0000 +@@ -629,7 +629,7 @@ + # Debian/Ubuntu multiarch support. + # https://wiki.ubuntu.com/MultiarchSpec + cc = sysconfig.get_config_var('CC') +- tmpfile = os.path.join(self.build_temp, 'multiarch') ++ tmpfile = os.path.join(self.build_temp, 'multiarch').replace('\\','/') + if not os.path.exists(self.build_temp): + os.makedirs(self.build_temp) + ret = run_command( +@@ -654,7 +654,7 @@ + opt = '' + if CROSS_COMPILING: + opt = '-t' + sysconfig.get_config_var('HOST_GNU_TYPE') +- tmpfile = os.path.join(self.build_temp, 'multiarch') ++ tmpfile = os.path.join(self.build_temp, 'multiarch').replace('\\','/') + if not os.path.exists(self.build_temp): + os.makedirs(self.build_temp) + ret = run_command( +@@ -673,7 +673,7 @@ + + def add_cross_compiling_paths(self): + cc = sysconfig.get_config_var('CC') +- tmpfile = os.path.join(self.build_temp, 'ccpaths') ++ tmpfile = os.path.join(self.build_temp, 'ccpaths').replace('\\','/') + if not os.path.exists(self.build_temp): + os.makedirs(self.build_temp) + ret = run_command('%s -E -v - %s 1>/dev/null' % (cc, tmpfile)) +@@ -967,7 +967,7 @@ + readline_termcap_library = "" + curses_library = "" + # Cannot use os.popen here in py3k. +- tmpfile = os.path.join(self.build_temp, 'readline_termcap_lib') ++ tmpfile = os.path.join(self.build_temp, 'readline_termcap_lib').replace('\\','/') + if not os.path.exists(self.build_temp): + os.makedirs(self.build_temp) + # Determine if readline is already linked against curses or tinfo. +@@ -1931,12 +1931,12 @@ + cflags = sysconfig.get_config_vars('CFLAGS')[0] + archs = re.findall(r'-arch\s+(\w+)', cflags) + +- tmpfile = os.path.join(self.build_temp, 'tk.arch') ++ tmpfile = os.path.join(self.build_temp, 'tk.arch').replace('\\','/') + if not os.path.exists(self.build_temp): + os.makedirs(self.build_temp) + + run_command( +- "file {}/Tk.framework/Tk | grep 'for architecture' > {}".format(F, tmpfile) ++ "file {}/Tk.framework/Tk | grep 'for architecture' > {}".format(F, tmpfile).replace('\\','/') + ) + with open(tmpfile) as fp: + detected_archs = [] diff --git a/mingw-w64-python3.9/0800-mingw-install-layout-as-posix.patch b/mingw-w64-python3.9/0800-mingw-install-layout-as-posix.patch new file mode 100644 index 0000000000..597a58b3b5 --- /dev/null +++ b/mingw-w64-python3.9/0800-mingw-install-layout-as-posix.patch @@ -0,0 +1,29 @@ +diff -Naur Python-3.8.0-orig/Lib/distutils/command/install.py Python-3.8.0/Lib/distutils/command/install.py +--- Python-3.8.0-orig/Lib/distutils/command/install.py 2019-10-22 10:03:20.572589000 +0300 ++++ Python-3.8.0/Lib/distutils/command/install.py 2019-10-22 10:03:40.618624200 +0300 +@@ -20,10 +20,10 @@ + HAS_USER_SITE = True + + WINDOWS_SCHEME = { +- 'purelib': '$base/Lib/site-packages', +- 'platlib': '$base/Lib/site-packages', +- 'headers': '$base/Include/$dist_name', +- 'scripts': '$base/Scripts', ++ 'purelib': '$base/lib/python$py_version_short/site-packages', ++ 'platlib': '$base/lib/python$py_version_short/site-packages', ++ 'headers': '$base/include/python$py_version_short$abiflags/$dist_name', ++ 'scripts': '$base/bin', + 'data' : '$base', + } + +@@ -50,8 +50,8 @@ + INSTALL_SCHEMES['nt_user'] = { + 'purelib': '$usersite', + 'platlib': '$usersite', +- 'headers': '$userbase/Python$py_version_nodot/Include/$dist_name', +- 'scripts': '$userbase/Python$py_version_nodot/Scripts', ++ 'headers': '$userbase/include/python$py_version_short$abiflags/$dist_name', ++ 'scripts': '$userbase/bin', + 'data' : '$userbase', + } + diff --git a/mingw-w64-python3.9/0810-remove_path_max.default.patch b/mingw-w64-python3.9/0810-remove_path_max.default.patch new file mode 100644 index 0000000000..101b1921d3 --- /dev/null +++ b/mingw-w64-python3.9/0810-remove_path_max.default.patch @@ -0,0 +1,11 @@ +diff -Naur Python-3.8.0-orig/Include/osdefs.h Python-3.8.0/Include/osdefs.h +--- Python-3.8.0-orig/Include/osdefs.h 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/Include/osdefs.h 2019-10-22 10:03:43.426629200 +0300 +@@ -10,7 +10,6 @@ + #ifdef MS_WINDOWS + #define SEP L'\\' + #define ALTSEP L'/' +-#define MAXPATHLEN 256 + #define DELIM L';' + #endif + diff --git a/mingw-w64-python3.9/0820-dont-link-with-gettext.patch b/mingw-w64-python3.9/0820-dont-link-with-gettext.patch new file mode 100644 index 0000000000..50251a2c4b --- /dev/null +++ b/mingw-w64-python3.9/0820-dont-link-with-gettext.patch @@ -0,0 +1,40 @@ +diff -Naur Python-3.8.0-orig/configure.ac Python-3.8.0/configure.ac +--- Python-3.8.0-orig/configure.ac 2019-10-22 10:02:59.122551400 +0300 ++++ Python-3.8.0/configure.ac 2019-10-22 10:03:46.312634200 +0300 +@@ -3071,10 +3071,19 @@ + fi + + # check if we need libintl for locale functions ++case $host in ++ *-*-mingw*) ++ dnl Native windows build don't use libintl (see _localemodule.c). ++ dnl Also we don't like setup.py to add "intl" library to the list ++ dnl when build _locale module. ++ ;; ++ *) + AC_CHECK_LIB(intl, textdomain, + [AC_DEFINE(WITH_LIBINTL, 1, + [Define to 1 if libintl is needed for locale functions.]) + LIBS="-lintl $LIBS"]) ++ ;; ++esac + + # checks for system dependent C++ extensions support + case "$ac_sys_system" in +diff -Naur Python-3.8.0-orig/Modules/_localemodule.c Python-3.8.0/Modules/_localemodule.c +--- Python-3.8.0-orig/Modules/_localemodule.c 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/Modules/_localemodule.c 2019-10-22 10:03:46.718235000 +0300 +@@ -12,6 +12,13 @@ + #define PY_SSIZE_T_CLEAN + #include "Python.h" + #include "pycore_fileutils.h" ++#ifdef __MINGW32__ ++/* The header libintl.h and library libintl may exist on mingw host. ++ * To be compatible with MSVC build we has to undef some defines. ++ */ ++#undef HAVE_LIBINTL_H ++#undef HAVE_BIND_TEXTDOMAIN_CODESET ++#endif + + #include + #include diff --git a/mingw-w64-python3.9/0830-ctypes-python-dll.patch b/mingw-w64-python3.9/0830-ctypes-python-dll.patch new file mode 100644 index 0000000000..ec7985102c --- /dev/null +++ b/mingw-w64-python3.9/0830-ctypes-python-dll.patch @@ -0,0 +1,14 @@ +diff -Naur Python-3.8.0-orig/Lib/ctypes/__init__.py Python-3.8.0/Lib/ctypes/__init__.py +--- Python-3.8.0-orig/Lib/ctypes/__init__.py 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/Lib/ctypes/__init__.py 2019-10-22 10:03:49.931840600 +0300 +@@ -449,7 +449,9 @@ + cdll = LibraryLoader(CDLL) + pydll = LibraryLoader(PyDLL) + +-if _os.name == "nt": ++if _os.name == "nt" and _sys.version.find('GCC') >= 0: ++ pythonapi = PyDLL("libpython%d.%d%s.dll" % (_sys.version_info[:2] + (_sys.abiflags,)), None) ++elif _os.name == "nt": + pythonapi = PyDLL("python dll", None, _sys.dllhandle) + elif _sys.platform == "cygwin": + pythonapi = PyDLL("libpython%d.%d.dll" % _sys.version_info[:2]) diff --git a/mingw-w64-python3.9/0840-gdbm-module-includes.patch b/mingw-w64-python3.9/0840-gdbm-module-includes.patch new file mode 100644 index 0000000000..7c28266fa8 --- /dev/null +++ b/mingw-w64-python3.9/0840-gdbm-module-includes.patch @@ -0,0 +1,12 @@ +diff -Naur Python-3.8.0-orig/Modules/_gdbmmodule.c Python-3.8.0/Modules/_gdbmmodule.c +--- Python-3.8.0-orig/Modules/_gdbmmodule.c 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/Modules/_gdbmmodule.c 2019-10-22 10:03:53.161046300 +0300 +@@ -11,7 +11,7 @@ + #include + #include "gdbm.h" + +-#if defined(WIN32) && !defined(__CYGWIN__) ++#if defined(WIN32) && !defined(__CYGWIN__) && !defined(__MINGW32__) + #include "gdbmerrno.h" + extern const char * gdbm_strerror(gdbm_error); + #endif diff --git a/mingw-w64-python3.9/0850-use-gnu_printf-in-format.patch b/mingw-w64-python3.9/0850-use-gnu_printf-in-format.patch new file mode 100644 index 0000000000..72d2d884e5 --- /dev/null +++ b/mingw-w64-python3.9/0850-use-gnu_printf-in-format.patch @@ -0,0 +1,60 @@ +diff -Naur Python-3.8.0-orig/Include/bytesobject.h Python-3.8.0/Include/bytesobject.h +--- Python-3.8.0-orig/Include/bytesobject.h 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/Include/bytesobject.h 2019-10-22 10:03:56.031451300 +0300 +@@ -52,9 +52,9 @@ + PyAPI_FUNC(PyObject *) PyBytes_FromString(const char *); + PyAPI_FUNC(PyObject *) PyBytes_FromObject(PyObject *); + PyAPI_FUNC(PyObject *) PyBytes_FromFormatV(const char*, va_list) +- Py_GCC_ATTRIBUTE((format(printf, 1, 0))); ++ Py_PRINTF(1, 0); + PyAPI_FUNC(PyObject *) PyBytes_FromFormat(const char*, ...) +- Py_GCC_ATTRIBUTE((format(printf, 1, 2))); ++ Py_PRINTF(1, 2); + PyAPI_FUNC(Py_ssize_t) PyBytes_Size(PyObject *); + PyAPI_FUNC(char *) PyBytes_AsString(PyObject *); + PyAPI_FUNC(PyObject *) PyBytes_Repr(PyObject *, int); +diff -Naur Python-3.8.0-orig/Include/pyerrors.h Python-3.8.0/Include/pyerrors.h +--- Python-3.8.0-orig/Include/pyerrors.h 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/Include/pyerrors.h 2019-10-22 10:03:56.437052000 +0300 +@@ -319,9 +319,9 @@ + + #include + PyAPI_FUNC(int) PyOS_snprintf(char *str, size_t size, const char *format, ...) +- Py_GCC_ATTRIBUTE((format(printf, 3, 4))); ++ Py_PRINTF(3, 4); + PyAPI_FUNC(int) PyOS_vsnprintf(char *str, size_t size, const char *format, va_list va) +- Py_GCC_ATTRIBUTE((format(printf, 3, 0))); ++ Py_PRINTF(3, 0); + + #ifndef Py_LIMITED_API + # define Py_CPYTHON_ERRORS_H +diff -Naur Python-3.8.0-orig/Include/sysmodule.h Python-3.8.0/Include/sysmodule.h +--- Python-3.8.0-orig/Include/sysmodule.h 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/Include/sysmodule.h 2019-10-22 10:03:56.858252800 +0300 +@@ -15,9 +15,9 @@ + PyAPI_FUNC(void) PySys_SetPath(const wchar_t *); + + PyAPI_FUNC(void) PySys_WriteStdout(const char *format, ...) +- Py_GCC_ATTRIBUTE((format(printf, 1, 2))); ++ Py_PRINTF(1, 2); + PyAPI_FUNC(void) PySys_WriteStderr(const char *format, ...) +- Py_GCC_ATTRIBUTE((format(printf, 1, 2))); ++ Py_PRINTF(1, 2); + PyAPI_FUNC(void) PySys_FormatStdout(const char *format, ...); + PyAPI_FUNC(void) PySys_FormatStderr(const char *format, ...); + +--- Python-3.9.5/Include/pyport.h.orig 2021-05-14 15:30:48.522516700 +0300 ++++ Python-3.9.5/Include/pyport.h 2021-05-14 15:44:47.249415100 +0300 +@@ -796,6 +798,12 @@ + + #define Py_VA_COPY va_copy + ++#if defined(__GNUC__) && ((__GNUC__ == 4 && __GNUC_MINOR__>= 4) || __GNUC__ > 4) ++# define Py_PRINTF(X,Y) Py_GCC_ATTRIBUTE((format(gnu_printf,X,Y))) ++#else ++# define Py_PRINTF(X,Y) Py_GCC_ATTRIBUTE((format(printf,X,Y))) ++#endif ++ + /* + * Convenient macros to deal with endianness of the platform. WORDS_BIGENDIAN is + * detected by configure and defined in pyconfig.h. The code in pyconfig.h diff --git a/mingw-w64-python3.9/0870-mingw-fix-ssl-dont-use-enum_certificates.patch b/mingw-w64-python3.9/0870-mingw-fix-ssl-dont-use-enum_certificates.patch new file mode 100644 index 0000000000..67498a7c3b --- /dev/null +++ b/mingw-w64-python3.9/0870-mingw-fix-ssl-dont-use-enum_certificates.patch @@ -0,0 +1,21 @@ +diff -Naur Python-3.8.0-orig/Lib/ssl.py Python-3.8.0/Lib/ssl.py +--- Python-3.8.0-orig/Lib/ssl.py 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/Lib/ssl.py 2019-10-22 10:04:00.493059100 +0300 +@@ -249,7 +249,7 @@ + CHANGE_CIPHER_SPEC = 0x0101 + + +-if sys.platform == "win32": ++if sys.platform == "win32" and sys.version.find("GCC") == -1: + from _ssl import enum_certificates, enum_crls + + from socket import socket, AF_INET, SOCK_STREAM, create_connection +@@ -569,7 +569,7 @@ + def load_default_certs(self, purpose=Purpose.SERVER_AUTH): + if not isinstance(purpose, _ASN1Object): + raise TypeError(purpose) +- if sys.platform == "win32": ++ if sys.platform == "win32" and sys.version.find("GCC") == -1: + for storename in self._windows_cert_stores: + self._load_windows_store_certs(storename, purpose) + self.set_default_verify_paths() diff --git a/mingw-w64-python3.9/0890-mingw-build-optimized-ext.patch b/mingw-w64-python3.9/0890-mingw-build-optimized-ext.patch new file mode 100644 index 0000000000..5ba3ad4cca --- /dev/null +++ b/mingw-w64-python3.9/0890-mingw-build-optimized-ext.patch @@ -0,0 +1,16 @@ +diff -Naur Python-3.8.0-orig/Lib/distutils/cygwinccompiler.py Python-3.8.0/Lib/distutils/cygwinccompiler.py +--- Python-3.8.0-orig/Lib/distutils/cygwinccompiler.py 2019-10-22 10:03:07.686966400 +0300 ++++ Python-3.8.0/Lib/distutils/cygwinccompiler.py 2019-10-22 10:04:03.316664100 +0300 +@@ -305,9 +305,9 @@ + raise CCompilerError( + 'Cygwin gcc cannot be used with --compiler=mingw32') + +- self.set_executables(compiler='gcc -O -Wall', +- compiler_so='gcc -mdll -O -Wall', +- compiler_cxx='g++ -O -Wall', ++ self.set_executables(compiler='gcc -O2 -Wall', ++ compiler_so='gcc -mdll -O2 -Wall', ++ compiler_cxx='g++ -O2 -Wall', + linker_exe='gcc', + linker_so='%s %s %s' + % (self.linker_dll, shared_option, diff --git a/mingw-w64-python3.9/0900-cygwinccompiler-dont-strip-modules-if-pydebug.patch b/mingw-w64-python3.9/0900-cygwinccompiler-dont-strip-modules-if-pydebug.patch new file mode 100644 index 0000000000..a002f9866d --- /dev/null +++ b/mingw-w64-python3.9/0900-cygwinccompiler-dont-strip-modules-if-pydebug.patch @@ -0,0 +1,12 @@ +diff -Naur Python-3.8.0-orig/Lib/distutils/cygwinccompiler.py Python-3.8.0/Lib/distutils/cygwinccompiler.py +--- Python-3.8.0-orig/Lib/distutils/cygwinccompiler.py 2019-10-22 10:04:05.048267100 +0300 ++++ Python-3.8.0/Lib/distutils/cygwinccompiler.py 2019-10-22 10:04:06.140269100 +0300 +@@ -238,7 +238,7 @@ + # (On my machine: 10KiB < stripped_file < ??100KiB + # unstripped_file = stripped_file + XXX KiB + # ( XXX=254 for a typical python extension)) +- if not debug: ++ if not debug and not hasattr(sys, 'gettotalrefcount'): + extra_preargs.append("-s") + + UnixCCompiler.link(self, target_desc, objects, output_filename, diff --git a/mingw-w64-python3.9/0910-fix-using-dllhandle-and-winver-mingw.patch b/mingw-w64-python3.9/0910-fix-using-dllhandle-and-winver-mingw.patch new file mode 100644 index 0000000000..b2462b7118 --- /dev/null +++ b/mingw-w64-python3.9/0910-fix-using-dllhandle-and-winver-mingw.patch @@ -0,0 +1,21 @@ +diff -Naur Python-3.8.0-orig/Python/sysmodule.c Python-3.8.0/Python/sysmodule.c +--- Python-3.8.0-orig/Python/sysmodule.c 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/Python/sysmodule.c 2019-10-22 10:04:08.995074100 +0300 +@@ -34,7 +34,7 @@ + #include + #endif /* MS_WINDOWS */ + +-#ifdef MS_COREDLL ++#if defined(MS_WINDOWS) && defined(Py_ENABLE_SHARED) + extern void *PyWin_DLLhModule; + /* A string loaded from the DLL at startup: */ + extern const char *PyWin_DLLVersionString; +@@ -2694,7 +2694,7 @@ + PyUnicode_FromString("little")); + #endif + +-#ifdef MS_COREDLL ++#if defined(MS_WINDOWS) && defined(Py_ENABLE_SHARED) + SET_SYS_FROM_STRING("dllhandle", + PyLong_FromVoidPtr(PyWin_DLLhModule)); + SET_SYS_FROM_STRING("winver", diff --git a/mingw-w64-python3.9/0920-mingw-add-LIBPL-to-library-dirs.patch b/mingw-w64-python3.9/0920-mingw-add-LIBPL-to-library-dirs.patch new file mode 100644 index 0000000000..e58e64e3d5 --- /dev/null +++ b/mingw-w64-python3.9/0920-mingw-add-LIBPL-to-library-dirs.patch @@ -0,0 +1,12 @@ +diff -Naur Python-3.8.0-orig/Lib/distutils/command/build_ext.py Python-3.8.0/Lib/distutils/command/build_ext.py +--- Python-3.8.0-orig/Lib/distutils/command/build_ext.py 2019-10-22 10:03:03.194158500 +0300 ++++ Python-3.8.0/Lib/distutils/command/build_ext.py 2019-10-22 10:04:11.803079000 +0300 +@@ -218,7 +218,7 @@ + + # For extensions under Cygwin, Python's library directory must be + # appended to library_dirs +- if sys.platform[:6] == 'cygwin': ++ if sys.platform[:6] == 'cygwin' or self.plat_name.startswith(('mingw')): + if sys.executable.startswith(os.path.join(sys.exec_prefix, "bin")): + # building third party extensions + config_dir_name = os.path.basename(sysconfig.get_config_var('LIBPL')) diff --git a/mingw-w64-python3.9/0970-Add-AMD64-to-sys-config-so-msvccompiler-get_build_version-works.patch b/mingw-w64-python3.9/0970-Add-AMD64-to-sys-config-so-msvccompiler-get_build_version-works.patch new file mode 100644 index 0000000000..023463b4a1 --- /dev/null +++ b/mingw-w64-python3.9/0970-Add-AMD64-to-sys-config-so-msvccompiler-get_build_version-works.patch @@ -0,0 +1,27 @@ +diff -Naur Python-3.8.0-orig/Python/getcompiler.c Python-3.8.0/Python/getcompiler.c +--- Python-3.8.0-orig/Python/getcompiler.c 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/Python/getcompiler.c 2019-10-22 10:04:17.450288900 +0300 +@@ -10,7 +10,22 @@ + #if defined(__clang__) + #define COMPILER "\n[Clang " __clang_version__ "]" + #elif defined(__GNUC__) +-#define COMPILER "\n[GCC " __VERSION__ "]" ++/* To not break compatibility with things that determine ++ CPU arch by calling get_build_version in msvccompiler.py ++ (such as NumPy) add "32 bit" or "64 bit (AMD64)" on Windows ++ and also use a space as a separator rather than a newline. */ ++#if defined(_WIN32) ++#define COMP_SEP " " ++#if defined(__x86_64__) ++#define ARCH_SUFFIX " 64 bit (AMD64)" ++#else ++#define ARCH_SUFFIX " 32 bit" ++#endif ++#else ++#define COMP_SEP "\n" ++#define ARCH_SUFFIX "" ++#endif ++#define COMPILER COMP_SEP "[GCC " __VERSION__ ARCH_SUFFIX "]" + // Generic fallbacks. + #elif defined(__cplusplus) + #define COMPILER "[C++]" diff --git a/mingw-w64-python3.9/0990-MINGW-link-with-additional-library.patch b/mingw-w64-python3.9/0990-MINGW-link-with-additional-library.patch new file mode 100644 index 0000000000..1bee0dbe4f --- /dev/null +++ b/mingw-w64-python3.9/0990-MINGW-link-with-additional-library.patch @@ -0,0 +1,19 @@ +diff -Naur Python-3.8.0-orig/configure.ac Python-3.8.0/configure.ac +--- Python-3.8.0-orig/configure.ac 2019-10-22 10:03:48.434238000 +0300 ++++ Python-3.8.0/configure.ac 2019-10-22 10:04:20.273893900 +0300 +@@ -5668,6 +5668,15 @@ + done + AC_MSG_RESULT(done) + ++# For mingw build need additional library for linking ++case $host in ++ *-*-mingw*) ++ LIBS="$LIBS -lversion -lshlwapi -lpathcch" ++ ;; ++ *) ++ ;; ++esac ++ + # Availability of -O2: + AC_MSG_CHECKING(for -O2) + saved_cflags="$CFLAGS" diff --git a/mingw-w64-python3.9/1010-install-msilib.patch b/mingw-w64-python3.9/1010-install-msilib.patch new file mode 100644 index 0000000000..65a82a0dc0 --- /dev/null +++ b/mingw-w64-python3.9/1010-install-msilib.patch @@ -0,0 +1,11 @@ +diff -Naur Python-3.8.0-orig/Makefile.pre.in Python-3.8.0/Makefile.pre.in +--- Python-3.8.0-orig/Makefile.pre.in 2019-10-22 10:03:33.473811700 +0300 ++++ Python-3.8.0/Makefile.pre.in 2019-10-22 10:04:23.315899200 +0300 +@@ -1404,6 +1404,7 @@ + distutils distutils/command distutils/tests $(XMLLIBSUBDIRS) \ + test/test_tools test/test_warnings test/test_warnings/data \ + turtledemo \ ++ msilib \ + multiprocessing multiprocessing/dummy \ + unittest unittest/test unittest/test/testmock \ + venv venv/scripts venv/scripts/common venv/scripts/posix \ diff --git a/mingw-w64-python3.9/1060-dont-include-system-ncurses-path.patch b/mingw-w64-python3.9/1060-dont-include-system-ncurses-path.patch new file mode 100644 index 0000000000..99f6a8593a --- /dev/null +++ b/mingw-w64-python3.9/1060-dont-include-system-ncurses-path.patch @@ -0,0 +1,22 @@ +diff -Naur Python-3.8.0-orig/configure.ac Python-3.8.0/configure.ac +--- Python-3.8.0-orig/configure.ac 2019-10-22 10:04:22.223897300 +0300 ++++ Python-3.8.0/configure.ac 2019-10-22 10:04:26.170704200 +0300 +@@ -5293,9 +5293,15 @@ + + # first curses header check + ac_save_cppflags="$CPPFLAGS" +-if test "$cross_compiling" = no; then +- CPPFLAGS="$CPPFLAGS -I/usr/include/ncursesw" +-fi ++case $host_os in ++ mingw*) ++ ;; ++ *) ++ if test "$cross_compiling" = no; then ++ CPPFLAGS="$CPPFLAGS -I/usr/include/ncursesw" ++ fi ++ ;; ++esac + + AC_CHECK_HEADERS(curses.h ncurses.h) + diff --git a/mingw-w64-python3.9/1620-fix-signal-module-build.patch b/mingw-w64-python3.9/1620-fix-signal-module-build.patch new file mode 100644 index 0000000000..a35aeec7ae --- /dev/null +++ b/mingw-w64-python3.9/1620-fix-signal-module-build.patch @@ -0,0 +1,12 @@ +diff -Naur Python-3.8.0-orig/Modules/Setup Python-3.8.0/Modules/Setup +--- Python-3.8.0-orig/Modules/Setup 2019-10-22 10:01:07.612555400 +0300 ++++ Python-3.8.0/Modules/Setup 2019-10-22 10:04:29.009909200 +0300 +@@ -111,7 +111,7 @@ + _abc _abc.c # Abstract base classes + itertools itertoolsmodule.c # Functions creating iterators for efficient looping + atexit atexitmodule.c # Register functions to be run at interpreter-shutdown +-_signal -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal signalmodule.c ++_signal -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal signalmodule.c -lws2_32 + _stat _stat.c # stat.h interface + time -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal timemodule.c # -lm # time operations and variables + _thread -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal _threadmodule.c # low-level threading interface diff --git a/mingw-w64-python3.9/1630-build-winconsoleio.patch b/mingw-w64-python3.9/1630-build-winconsoleio.patch new file mode 100644 index 0000000000..196592ad3d --- /dev/null +++ b/mingw-w64-python3.9/1630-build-winconsoleio.patch @@ -0,0 +1,12 @@ +diff -Naur Python-3.8.0-orig/Modules/Setup Python-3.8.0/Modules/Setup +--- Python-3.8.0-orig/Modules/Setup 2019-10-22 10:04:31.147113000 +0300 ++++ Python-3.8.0/Modules/Setup 2019-10-22 10:04:32.223514900 +0300 +@@ -120,7 +120,7 @@ + _locale -DPy_BUILD_CORE_BUILTIN _localemodule.c # -lintl + + # Standard I/O baseline +-_io -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal -I$(srcdir)/Modules/_io _io/_iomodule.c _io/iobase.c _io/fileio.c _io/bytesio.c _io/bufferedio.c _io/textio.c _io/stringio.c ++_io -DPy_BUILD_CORE_BUILTIN -I$(srcdir)/Include/internal -I$(srcdir)/Modules/_io _io/_iomodule.c _io/iobase.c _io/fileio.c _io/bytesio.c _io/bufferedio.c _io/textio.c _io/stringio.c _io/winconsoleio.c + + # faulthandler module + faulthandler faulthandler.c diff --git a/mingw-w64-python3.9/1650-expose-sem_unlink.patch b/mingw-w64-python3.9/1650-expose-sem_unlink.patch new file mode 100644 index 0000000000..16c91759f0 --- /dev/null +++ b/mingw-w64-python3.9/1650-expose-sem_unlink.patch @@ -0,0 +1,12 @@ +diff -Naur Python-3.8.0-orig/Modules/_multiprocessing/multiprocessing.c Python-3.8.0/Modules/_multiprocessing/multiprocessing.c +--- Python-3.8.0-orig/Modules/_multiprocessing/multiprocessing.c 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/Modules/_multiprocessing/multiprocessing.c 2019-10-22 10:04:35.437120500 +0300 +@@ -128,7 +128,7 @@ + {"recv", multiprocessing_recv, METH_VARARGS, ""}, + {"send", multiprocessing_send, METH_VARARGS, ""}, + #endif +-#if !defined(POSIX_SEMAPHORES_NOT_ENABLED) && !defined(__ANDROID__) ++#if defined(MS_WINDOWS) || (!defined(POSIX_SEMAPHORES_NOT_ENABLED) && !defined(__ANDROID__)) + {"sem_unlink", _PyMp_sem_unlink, METH_VARARGS, ""}, + #endif + {NULL} diff --git a/mingw-w64-python3.9/1700-cygpty-isatty.patch b/mingw-w64-python3.9/1700-cygpty-isatty.patch new file mode 100644 index 0000000000..46536dda9c --- /dev/null +++ b/mingw-w64-python3.9/1700-cygpty-isatty.patch @@ -0,0 +1,420 @@ +diff -Naur Python-3.9.4-orig/Include/iscygpty.h Python-3.9.4/Include/iscygpty.h +--- Python-3.9.4-orig/Include/iscygpty.h 1969-12-31 19:00:00 +0000 ++++ Python-3.9.4/Include/iscygpty.h 2021-04-06 21:09:25 +0000 +@@ -0,0 +1,41 @@ ++/* ++ * iscygpty.h -- part of ptycheck ++ * https://github.com/k-takata/ptycheck ++ * ++ * Copyright (c) 2015-2017 K.Takata ++ * ++ * You can redistribute it and/or modify it under the terms of either ++ * the MIT license (as described below) or the Vim license. ++ * ++ * Permission is hereby granted, free of charge, to any person obtaining ++ * a copy of this software and associated documentation files (the ++ * "Software"), to deal in the Software without restriction, including ++ * without limitation the rights to use, copy, modify, merge, publish, ++ * distribute, sublicense, and/or sell copies of the Software, and to ++ * permit persons to whom the Software is furnished to do so, subject to ++ * the following conditions: ++ * ++ * The above copyright notice and this permission notice shall be ++ * included in all copies or substantial portions of the Software. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ++ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. ++ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY ++ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, ++ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE ++ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ++ */ ++ ++#ifndef _ISCYGPTY_H ++#define _ISCYGPTY_H ++ ++#ifdef _WIN32 ++int is_cygpty(int fd); ++int is_cygpty_used(void); ++#else ++#define is_cygpty(fd) 0 ++#define is_cygpty_used() 0 ++#endif ++ ++#endif /* _ISCYGPTY_H */ +diff -Naur Python-3.9.4-orig/Makefile.pre.in Python-3.9.4/Makefile.pre.in +--- Python-3.9.4-orig/Makefile.pre.in 2021-04-04 08:56:53 +0000 ++++ Python-3.9.4/Makefile.pre.in 2021-04-06 21:09:25 +0000 +@@ -362,6 +362,7 @@ + Python/import.o \ + Python/importdl.o \ + Python/initconfig.o \ ++ Python/iscygpty.o \ + Python/marshal.o \ + Python/modsupport.o \ + Python/mysnprintf.o \ +@@ -1045,6 +1046,7 @@ + $(srcdir)/Include/import.h \ + $(srcdir)/Include/interpreteridobject.h \ + $(srcdir)/Include/intrcheck.h \ ++ $(srcdir)/Include/iscygpty.h \ + $(srcdir)/Include/iterobject.h \ + $(srcdir)/Include/listobject.h \ + $(srcdir)/Include/longintrepr.h \ +diff -Naur Python-3.9.4-orig/Modules/_io/fileio.c Python-3.9.4/Modules/_io/fileio.c +--- Python-3.9.4-orig/Modules/_io/fileio.c 2021-04-04 08:56:53 +0000 ++++ Python-3.9.4/Modules/_io/fileio.c 2021-04-06 21:09:25 +0000 +@@ -19,6 +19,7 @@ + #endif + #include /* For offsetof */ + #include "_iomodule.h" ++#include "iscygpty.h" + + /* + * Known likely problems: +@@ -1128,7 +1129,7 @@ + return err_closed(); + Py_BEGIN_ALLOW_THREADS + _Py_BEGIN_SUPPRESS_IPH +- res = isatty(self->fd); ++ res = isatty(self->fd) || is_cygpty(self->fd); + _Py_END_SUPPRESS_IPH + Py_END_ALLOW_THREADS + return PyBool_FromLong(res); +diff -Naur Python-3.9.4-orig/Modules/main.c Python-3.9.4/Modules/main.c +--- Python-3.9.4-orig/Modules/main.c 2021-04-04 08:56:53 +0000 ++++ Python-3.9.4/Modules/main.c 2021-04-06 21:13:33 +0000 +@@ -6,6 +6,7 @@ + #include "pycore_pathconfig.h" // _PyPathConfig_ComputeSysPath0() + #include "pycore_pylifecycle.h" // _Py_PreInitializeFromPyArgv() + #include "pycore_pystate.h" // _PyInterpreterState_GET() ++#include "iscygpty.h" + + /* Includes for exit_sigint() */ + #include // perror() +@@ -91,7 +92,7 @@ + static int + stdin_is_interactive(const PyConfig *config) + { +- return (isatty(fileno(stdin)) || config->interactive); ++ return (isatty(fileno(stdin)) || config->interactive || is_cygpty(fileno(stdin))); + } + + +diff -Naur Python-3.9.4-orig/Modules/posixmodule.c Python-3.9.4/Modules/posixmodule.c +--- Python-3.9.4-orig/Modules/posixmodule.c 2021-04-04 08:56:53 +0000 ++++ Python-3.9.4/Modules/posixmodule.c 2021-04-06 21:09:25 +0000 +@@ -35,6 +35,7 @@ + #ifdef __ANDROID__ + # undef HAVE_FACCESSAT + #endif ++#include "iscygpty.h" + + #include /* needed for ctermid() */ + +@@ -9992,7 +9993,7 @@ + { + int return_value; + _Py_BEGIN_SUPPRESS_IPH +- return_value = isatty(fd); ++ return_value = isatty(fd) || is_cygpty(fd); + _Py_END_SUPPRESS_IPH + return return_value; + } +diff -Naur Python-3.9.4-orig/Objects/fileobject.c Python-3.9.4/Objects/fileobject.c +--- Python-3.9.4-orig/Objects/fileobject.c 2021-04-04 08:56:53 +0000 ++++ Python-3.9.4/Objects/fileobject.c 2021-04-06 21:17:02 +0000 +@@ -2,6 +2,7 @@ + + #define PY_SSIZE_T_CLEAN + #include "Python.h" ++#include "iscygpty.h" + #include "pycore_runtime.h" // _PyRuntime + + #if defined(HAVE_GETC_UNLOCKED) && !defined(_Py_MEMORY_SANITIZER) +@@ -435,7 +436,7 @@ + } + + Py_BEGIN_ALLOW_THREADS +- res = isatty(self->fd); ++ res = isatty(self->fd) || is_cygpty(self->fd); + Py_END_ALLOW_THREADS + + return PyBool_FromLong(res); +diff -Naur Python-3.9.4-orig/Python/bltinmodule.c Python-3.9.4/Python/bltinmodule.c +--- Python-3.9.4-orig/Python/bltinmodule.c 2021-04-04 08:56:53 +0000 ++++ Python-3.9.4/Python/bltinmodule.c 2021-04-06 21:10:56 +0000 +@@ -1,6 +1,7 @@ + /* Built-in functions */ + + #include "Python.h" ++#include "iscygpty.h" + #include + #include "ast.h" + #undef Yield /* undefine macro conflicting with */ +@@ -1980,7 +1981,7 @@ + Py_DECREF(tmp); + if (fd < 0 && PyErr_Occurred()) + return NULL; +- tty = fd == fileno(stdin) && isatty(fd); ++ tty = fd == fileno(stdin) && (isatty(fd) || is_cygpty(fd)); + } + if (tty) { + tmp = _PyObject_CallMethodIdNoArgs(fout, &PyId_fileno); +@@ -1993,7 +1994,7 @@ + Py_DECREF(tmp); + if (fd < 0 && PyErr_Occurred()) + return NULL; +- tty = fd == fileno(stdout) && isatty(fd); ++ tty = fd == fileno(stdout) && (isatty(fd) || is_cygpty(fd)); + } + } + +diff -Naur Python-3.9.4-orig/Python/fileutils.c Python-3.9.4/Python/fileutils.c +--- Python-3.9.4-orig/Python/fileutils.c 2021-04-04 08:56:53 +0000 ++++ Python-3.9.4/Python/fileutils.c 2021-04-06 21:11:24 +0000 +@@ -1,4 +1,5 @@ + #include "Python.h" ++#include "iscygpty.h" + #include "pycore_fileutils.h" + #include "osdefs.h" // SEP + #include +@@ -66,7 +67,7 @@ + #endif + int valid; + _Py_BEGIN_SUPPRESS_IPH +- valid = isatty(fd); ++ valid = isatty(fd) || is_cygpty(fd); + _Py_END_SUPPRESS_IPH + if (!valid) + Py_RETURN_NONE; +diff -Naur Python-3.9.4-orig/Python/frozenmain.c Python-3.9.4/Python/frozenmain.c +--- Python-3.9.4-orig/Python/frozenmain.c 2021-04-04 08:56:53 +0000 ++++ Python-3.9.4/Python/frozenmain.c 2021-04-06 21:09:25 +0000 +@@ -4,6 +4,7 @@ + #include "Python.h" + #include "pycore_runtime.h" // _PyRuntime_Initialize() + #include ++#include "iscygpty.h" + + #ifdef MS_WINDOWS + extern void PyWinFreeze_ExeInit(void); +@@ -107,7 +108,7 @@ + else + sts = 0; + +- if (inspect && isatty((int)fileno(stdin))) ++ if (inspect && (isatty((int)fileno(stdin)) || is_cygpty((int)fileno(stdin)))) + sts = PyRun_AnyFile(stdin, "") != 0; + + #ifdef MS_WINDOWS +diff -Naur Python-3.9.4-orig/Python/iscygpty.c Python-3.9.4/Python/iscygpty.c +--- Python-3.9.4-orig/Python/iscygpty.c 1969-12-31 19:00:00 +0000 ++++ Python-3.9.4/Python/iscygpty.c 2021-04-06 21:09:25 +0000 +@@ -0,0 +1,185 @@ ++/* ++ * iscygpty.c -- part of ptycheck ++ * https://github.com/k-takata/ptycheck ++ * ++ * Copyright (c) 2015-2017 K.Takata ++ * ++ * You can redistribute it and/or modify it under the terms of either ++ * the MIT license (as described below) or the Vim license. ++ * ++ * Permission is hereby granted, free of charge, to any person obtaining ++ * a copy of this software and associated documentation files (the ++ * "Software"), to deal in the Software without restriction, including ++ * without limitation the rights to use, copy, modify, merge, publish, ++ * distribute, sublicense, and/or sell copies of the Software, and to ++ * permit persons to whom the Software is furnished to do so, subject to ++ * the following conditions: ++ * ++ * The above copyright notice and this permission notice shall be ++ * included in all copies or substantial portions of the Software. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ++ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. ++ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY ++ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, ++ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE ++ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ++ */ ++ ++#ifdef _WIN32 ++ ++#include ++#include ++#include ++#include ++ ++#ifdef USE_FILEEXTD ++/* VC 7.1 or earlier doesn't support SAL. */ ++# if !defined(_MSC_VER) || (_MSC_VER < 1400) ++# define __out ++# define __in ++# define __in_opt ++# endif ++/* Win32 FileID API Library: ++ * http://www.microsoft.com/en-us/download/details.aspx?id=22599 ++ * Needed for WinXP. */ ++# include ++#else /* USE_FILEEXTD */ ++/* VC 8 or earlier. */ ++# if defined(_MSC_VER) && (_MSC_VER < 1500) ++# ifdef ENABLE_STUB_IMPL ++# define STUB_IMPL ++# else ++# error "Win32 FileID API Library is required for VC2005 or earlier." ++# endif ++# endif ++#endif /* USE_FILEEXTD */ ++ ++ ++#include "iscygpty.h" ++ ++//#define USE_DYNFILEID ++#ifdef USE_DYNFILEID ++typedef BOOL (WINAPI *pfnGetFileInformationByHandleEx)( ++ HANDLE hFile, ++ FILE_INFO_BY_HANDLE_CLASS FileInformationClass, ++ LPVOID lpFileInformation, ++ DWORD dwBufferSize ++); ++static pfnGetFileInformationByHandleEx pGetFileInformationByHandleEx = NULL; ++ ++# ifndef USE_FILEEXTD ++static BOOL WINAPI stub_GetFileInformationByHandleEx( ++ HANDLE hFile, ++ FILE_INFO_BY_HANDLE_CLASS FileInformationClass, ++ LPVOID lpFileInformation, ++ DWORD dwBufferSize ++ ) ++{ ++ return FALSE; ++} ++# endif ++ ++static void setup_fileid_api(void) ++{ ++ if (pGetFileInformationByHandleEx != NULL) { ++ return; ++ } ++ pGetFileInformationByHandleEx = (pfnGetFileInformationByHandleEx) ++ GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), ++ "GetFileInformationByHandleEx"); ++ if (pGetFileInformationByHandleEx == NULL) { ++# ifdef USE_FILEEXTD ++ pGetFileInformationByHandleEx = GetFileInformationByHandleEx; ++# else ++ pGetFileInformationByHandleEx = stub_GetFileInformationByHandleEx; ++# endif ++ } ++} ++#else ++# define pGetFileInformationByHandleEx GetFileInformationByHandleEx ++# define setup_fileid_api() ++#endif ++ ++ ++#define is_wprefix(s, prefix) \ ++ (wcsncmp((s), (prefix), sizeof(prefix) / sizeof(WCHAR) - 1) == 0) ++ ++/* Check if the fd is a cygwin/msys's pty. */ ++int is_cygpty(int fd) ++{ ++#ifdef STUB_IMPL ++ return 0; ++#else ++ HANDLE h; ++ int size = sizeof(FILE_NAME_INFO) + sizeof(WCHAR) * (MAX_PATH - 1); ++ FILE_NAME_INFO *nameinfo; ++ WCHAR *p = NULL; ++ ++ setup_fileid_api(); ++ ++ h = (HANDLE) _get_osfhandle(fd); ++ if (h == INVALID_HANDLE_VALUE) { ++ return 0; ++ } ++ /* Cygwin/msys's pty is a pipe. */ ++ if (GetFileType(h) != FILE_TYPE_PIPE) { ++ return 0; ++ } ++ nameinfo = malloc(size + sizeof(WCHAR)); ++ if (nameinfo == NULL) { ++ return 0; ++ } ++ /* Check the name of the pipe: ++ * '\{cygwin,msys}-XXXXXXXXXXXXXXXX-ptyN-{from,to}-master' */ ++ if (pGetFileInformationByHandleEx(h, FileNameInfo, nameinfo, size)) { ++ nameinfo->FileName[nameinfo->FileNameLength / sizeof(WCHAR)] = L'\0'; ++ p = nameinfo->FileName; ++ if (is_wprefix(p, L"\\cygwin-")) { /* Cygwin */ ++ p += 8; ++ } else if (is_wprefix(p, L"\\msys-")) { /* MSYS and MSYS2 */ ++ p += 6; ++ } else { ++ p = NULL; ++ } ++ if (p != NULL) { ++ while (*p && isxdigit(*p)) /* Skip 16-digit hexadecimal. */ ++ ++p; ++ if (is_wprefix(p, L"-pty")) { ++ p += 4; ++ } else { ++ p = NULL; ++ } ++ } ++ if (p != NULL) { ++ while (*p && isdigit(*p)) /* Skip pty number. */ ++ ++p; ++ if (is_wprefix(p, L"-from-master")) { ++ //p += 12; ++ } else if (is_wprefix(p, L"-to-master")) { ++ //p += 10; ++ } else { ++ p = NULL; ++ } ++ } ++ } ++ free(nameinfo); ++ return (p != NULL); ++#endif /* STUB_IMPL */ ++} ++ ++/* Check if at least one cygwin/msys pty is used. */ ++int is_cygpty_used(void) ++{ ++ int fd, ret = 0; ++ ++ for (fd = 0; fd < 3; fd++) { ++ ret |= is_cygpty(fd); ++ } ++ return ret; ++} ++ ++#endif /* _WIN32 */ ++ ++/* vim: set ts=4 sw=4: */ +diff -Naur Python-3.9.4-orig/Python/pylifecycle.c Python-3.9.4/Python/pylifecycle.c +--- Python-3.9.4-orig/Python/pylifecycle.c 2021-04-04 08:56:53 +0000 ++++ Python-3.9.4/Python/pylifecycle.c 2021-04-06 21:15:46 +0000 +@@ -19,6 +19,7 @@ + #include "pycore_traceback.h" // _Py_DumpTracebackThreads() + + #include "grammar.h" // PyGrammar_RemoveAccelerators() ++#include "iscygpty.h" + #include // setlocale() + + #ifdef HAVE_SIGNAL_H +@@ -2470,7 +2471,7 @@ + int + Py_FdIsInteractive(FILE *fp, const char *filename) + { +- if (isatty((int)fileno(fp))) ++ if (isatty((int)fileno(fp)) || is_cygpty((int)fileno(fp))) + return 1; + if (!Py_InteractiveFlag) + return 0; diff --git a/mingw-w64-python3.9/1701-disable-broken-gdbm-module.patch b/mingw-w64-python3.9/1701-disable-broken-gdbm-module.patch new file mode 100644 index 0000000000..bde9685754 --- /dev/null +++ b/mingw-w64-python3.9/1701-disable-broken-gdbm-module.patch @@ -0,0 +1,12 @@ +diff -Naur Python-3.8.0-orig/setup.py Python-3.8.0/setup.py +--- Python-3.8.0-orig/setup.py 2019-10-22 10:04:16.342687000 +0300 ++++ Python-3.8.0/setup.py 2019-10-22 10:04:48.353943200 +0300 +@@ -1331,7 +1331,7 @@ + if dbm_args: + dbm_order = [arg.split('=')[-1] for arg in dbm_args][-1].split(":") + else: +- dbm_order = "ndbm:gdbm:bdb".split(":") ++ dbm_order = [] + dbmext = None + for cand in dbm_order: + if cand == "ndbm": diff --git a/mingw-w64-python3.9/1800-link-win-resource-files-and-build-pythonw.patch b/mingw-w64-python3.9/1800-link-win-resource-files-and-build-pythonw.patch new file mode 100644 index 0000000000..c290d11f13 --- /dev/null +++ b/mingw-w64-python3.9/1800-link-win-resource-files-and-build-pythonw.patch @@ -0,0 +1,114 @@ +--- Python-3.8.7/configure.ac.orig 2021-02-14 08:44:30.296278300 +0100 ++++ Python-3.8.7/configure.ac 2021-02-14 08:44:39.824214800 +0100 +@@ -1320,6 +1320,9 @@ + + AC_MSG_RESULT($LDLIBRARY) + ++AC_SUBST(WINDRES) ++AC_CHECK_TOOL(WINDRES, windres) ++ + AC_SUBST(AR) + AC_CHECK_TOOLS(AR, ar aal, ar) + +@@ -5858,10 +5858,17 @@ + case $host in + *-*-mingw*) + LIBS="$LIBS -lversion -lshlwapi -lpathcch" ++ RCFLAGS="$RCFLAGS -O COFF" ++ case $host in ++ i686*) RCFLAGS="$RCFLAGS --target=pe-i386" ;; ++ x86_64*) RCFLAGS="$RCFLAGS --target=pe-x86-64" ;; ++ *) ;; ++ esac + ;; + *) + ;; + esac ++AC_SUBST(RCFLAGS) + + # Availability of -O2: + AC_MSG_CHECKING(for -O2) +diff -Naur Python-3.8.0-orig/Makefile.pre.in Python-3.8.0/Makefile.pre.in +--- Python-3.8.0-orig/Makefile.pre.in 2019-10-22 10:04:44.812737000 +0300 ++++ Python-3.8.0/Makefile.pre.in 2019-10-22 10:04:51.177548200 +0300 +@@ -38,6 +38,7 @@ + MAINCC= @MAINCC@ + LINKCC= @LINKCC@ + AR= @AR@ ++WINDRES= @WINDRES@ + READELF= @READELF@ + SOABI= @SOABI@ + LDVERSION= @LDVERSION@ +@@ -119,6 +119,7 @@ + PY_CORE_LDFLAGS=$(PY_LDFLAGS) $(PY_LDFLAGS_NODIST) + # Strict or non-strict aliasing flags used to compile dtoa.c, see above + CFLAGS_ALIASING=@CFLAGS_ALIASING@ ++RCFLAGS=@RCFLAGS@ + + + # Machine-dependent subdirectories +@@ -257,6 +258,7 @@ + + PYTHON= python$(EXE) + BUILDPYTHON= python$(BUILDEXE) ++BUILDPYTHONW= pythonw$(BUILDEXE) + + PYTHON_FOR_REGEN?=@PYTHON_FOR_REGEN@ + UPDATE_FILE=@PYTHON_FOR_REGEN@ $(srcdir)/Tools/scripts/update_file.py +@@ -479,7 +481,7 @@ + + # Default target + all: @DEF_MAKE_ALL_RULE@ +-build_all: check-clean-src $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks \ ++build_all: check-clean-src $(BUILDPYTHON) $(BUILDPYTHONW) oldsharedmods sharedmods gdbhooks \ + Programs/_testembed python-config + + # Check that the source is clean when building out of source. +@@ -593,9 +595,24 @@ + clinic: check-clean-src $(srcdir)/Modules/_blake2/blake2s_impl.c + $(PYTHON_FOR_REGEN) $(srcdir)/Tools/clinic/clinic.py --make --srcdir $(srcdir) + ++pythonnt_rc.h: ++ @echo '#define PYTHON_DLL_NAME "$(DLLLIBRARY)"' >> $@ ++ ++python_exe.o: pythonnt_rc.h $(srcdir)/PC/python_exe.rc ++ $(WINDRES) $(RCFLAGS) -I$(srcdir)/Include -I$(srcdir)/PC -I. $(srcdir)/PC/python_exe.rc $@ ++ ++pythonw_exe.o: pythonnt_rc.h $(srcdir)/PC/pythonw_exe.rc ++ $(WINDRES) $(RCFLAGS) -I$(srcdir)/Include -I$(srcdir)/PC -I. $(srcdir)/PC/pythonw_exe.rc $@ ++ ++python_nt.o: pythonnt_rc.h $(srcdir)/PC/python_nt.rc ++ $(WINDRES) $(RCFLAGS) -I$(srcdir)/Include -I$(srcdir)/PC -I. $(srcdir)/PC/python_nt.rc $@ ++ ++$(BUILDPYTHONW): Programs/python.o $(LIBRARY) $(LDLIBRARY) $(PY3LIBRARY) pythonw_exe.o ++ $(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -municode -mwindows -o $@ Programs/python.o $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) pythonw_exe.o ++ + # Build the interpreter +-$(BUILDPYTHON): Programs/python.o $(LIBRARY) $(LDLIBRARY) $(PY3LIBRARY) $(EXPORTSYMS) +- $(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/python.o $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) ++$(BUILDPYTHON): Programs/python.o $(LIBRARY) $(LDLIBRARY) $(PY3LIBRARY) python_exe.o ++ $(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -municode -o $@ Programs/python.o $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) python_exe.o + + platform: $(BUILDPYTHON) pybuilddir.txt + $(RUNSHARED) $(PYTHON_FOR_BUILD) -c 'import sys ; from sysconfig import get_platform ; print("%s-%d.%d" % (get_platform(), *sys.version_info[:2]))' >platform +@@ -705,10 +725,10 @@ + + # This rule builds the Cygwin Python DLL and import library if configured + # for a shared core library; otherwise, this rule is a noop. +-$(DLLLIBRARY) libpython$(LDVERSION).dll.a: $(LIBRARY_OBJS) ++$(DLLLIBRARY) libpython$(LDVERSION).dll.a: $(LIBRARY_OBJS) python_nt.o + if test -n "$(DLLLIBRARY)"; then \ + $(LDSHARED) -Wl,--out-implib=$@ -o $(DLLLIBRARY) $^ \ +- $(LIBS) $(MODLIBS) $(SYSLIBS); \ ++ $(LIBS) $(MODLIBS) $(SYSLIBS) python_nt.o; \ + else true; \ + fi + +@@ -1315,6 +1335,7 @@ + done + if test "$(PYTHONFRAMEWORKDIR)" = "no-framework" ; then \ + $(INSTALL_PROGRAM) $(BUILDPYTHON) $(DESTDIR)$(BINDIR)/python$(LDVERSION)$(EXE); \ ++ $(INSTALL_PROGRAM) $(BUILDPYTHONW) $(DESTDIR)$(BINDIR)/python3w$(EXE); \ + else \ + $(INSTALL_PROGRAM) $(STRIPFLAG) Mac/pythonw $(DESTDIR)$(BINDIR)/python$(LDVERSION)$(EXE); \ + fi diff --git a/mingw-w64-python3.9/1810-3.7-mpdec-mingw.patch b/mingw-w64-python3.9/1810-3.7-mpdec-mingw.patch new file mode 100644 index 0000000000..27c1f6bdeb --- /dev/null +++ b/mingw-w64-python3.9/1810-3.7-mpdec-mingw.patch @@ -0,0 +1,12 @@ +diff -Naur Python-3.8.0-orig/setup.py Python-3.8.0/setup.py +--- Python-3.8.0-orig/setup.py 2019-10-22 10:04:50.085546300 +0300 ++++ Python-3.8.0/setup.py 2019-10-22 10:04:54.016753200 +0300 +@@ -2165,7 +2165,7 @@ + undef_macros = [] + if '--with-system-libmpdec' in sysconfig.get_config_var("CONFIG_ARGS"): + include_dirs = [] +- libraries = [':libmpdec.so.2'] ++ libraries = [':libmpdec.dll.a'] + sources = ['_decimal/_decimal.c'] + depends = ['_decimal/docstrings.h'] + else: diff --git a/mingw-w64-python3.9/1850-disable-readline.patch b/mingw-w64-python3.9/1850-disable-readline.patch new file mode 100644 index 0000000000..4e0b4193d0 --- /dev/null +++ b/mingw-w64-python3.9/1850-disable-readline.patch @@ -0,0 +1,15 @@ +diff -Naur Python-3.8.0-orig/setup.py Python-3.8.0/setup.py +--- Python-3.8.0-orig/setup.py 2019-10-22 10:04:55.763956200 +0300 ++++ Python-3.8.0/setup.py 2019-10-22 10:04:59.804363300 +0300 +@@ -911,7 +911,10 @@ + + def detect_readline_curses(self): + # readline +- do_readline = self.compiler.find_library_file(self.lib_dirs, 'readline') ++ if not MS_WINDOWS: ++ do_readline = self.compiler.find_library_file(self.lib_dirs, 'readline') ++ else: ++ do_readline = False + readline_termcap_library = "" + curses_library = "" + # Cannot use os.popen here in py3k. diff --git a/mingw-w64-python3.9/1860-fix-isselectable.patch b/mingw-w64-python3.9/1860-fix-isselectable.patch new file mode 100644 index 0000000000..47ad5c7f69 --- /dev/null +++ b/mingw-w64-python3.9/1860-fix-isselectable.patch @@ -0,0 +1,12 @@ +diff -Naur Python-3.8.0-orig/Include/fileobject.h Python-3.8.0/Include/fileobject.h +--- Python-3.8.0-orig/Include/fileobject.h 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/Include/fileobject.h 2019-10-22 10:05:02.627968300 +0300 +@@ -23,7 +23,7 @@ + PyAPI_DATA(int) Py_HasFileSystemDefaultEncoding; + + /* A routine to check if a file descriptor can be select()-ed. */ +-#ifdef _MSC_VER ++#ifdef MS_WINDOWS + /* On Windows, any socket fd can be select()-ed, no matter how high */ + #define _PyIsSelectable_fd(FD) (1) + #else diff --git a/mingw-w64-python3.9/1870-use-_wcsnicmp-instead-wcsncasecmp.patch b/mingw-w64-python3.9/1870-use-_wcsnicmp-instead-wcsncasecmp.patch new file mode 100644 index 0000000000..201fb8814a --- /dev/null +++ b/mingw-w64-python3.9/1870-use-_wcsnicmp-instead-wcsncasecmp.patch @@ -0,0 +1,12 @@ +diff -Naur Python-3.9.5-orig/Modules/getpath.c Python-3.9.5/Modules/getpath.c +--- Python-3.9.5-orig/Modules/getpath.c 2019-10-22 10:02:51.821738500 +0300 ++++ Python-3.9.5/Modules/getpath.c 2019-10-22 10:05:05.467173300 +0300 +@@ -418,7 +427,7 @@ + /* Check for already have an executable suffix */ + size_t n = wcslen(progpath); + size_t s = wcslen(EXE_SUFFIX); +- if (wcsncasecmp(EXE_SUFFIX, progpath + n - s, s) == 0) { ++ if (_wcsnicmp(EXE_SUFFIX, progpath + n - s, s) == 0) { + return _PyStatus_OK(); + } + diff --git a/mingw-w64-python3.9/1890-_xxsubinterpretersmodule.patch b/mingw-w64-python3.9/1890-_xxsubinterpretersmodule.patch new file mode 100644 index 0000000000..0366172e30 --- /dev/null +++ b/mingw-w64-python3.9/1890-_xxsubinterpretersmodule.patch @@ -0,0 +1,11 @@ +--- Python-3.8.0/Modules/_xxsubinterpretersmodule.c.orig 2019-10-22 13:34:28.145872500 +0300 ++++ Python-3.8.0/Modules/_xxsubinterpretersmodule.c 2019-10-22 13:34:49.299509600 +0300 +@@ -1749,7 +1749,7 @@ + "A channel ID identifies a channel and may be used as an int."); + + static PyTypeObject ChannelIDtype = { +- PyVarObject_HEAD_INIT(&PyType_Type, 0) ++ PyVarObject_HEAD_INIT(NULL, 0) + "_xxsubinterpreters.ChannelID", /* tp_name */ + sizeof(channelid), /* tp_basicsize */ + 0, /* tp_itemsize */ diff --git a/mingw-w64-python3.9/1891-sqlite3-module-defines.patch b/mingw-w64-python3.9/1891-sqlite3-module-defines.patch new file mode 100644 index 0000000000..6682997a57 --- /dev/null +++ b/mingw-w64-python3.9/1891-sqlite3-module-defines.patch @@ -0,0 +1,14 @@ +--- Python-3.9.5/setup.py.orig 2021-05-13 08:59:26.086368300 +0300 ++++ Python-3.9.5/setup.py 2021-05-13 08:59:44.897106500 +0300 +@@ -1558,10 +1558,7 @@ + '_sqlite/util.c', ] + + sqlite_defines = [] +- if not MS_WINDOWS: +- sqlite_defines.append(('MODULE_NAME', '"sqlite3"')) +- else: +- sqlite_defines.append(('MODULE_NAME', '\\"sqlite3\\"')) ++ sqlite_defines.append(('MODULE_NAME', '"sqlite3"')) + + # Enable support for loadable extensions in the sqlite3 module + # if --enable-loadable-sqlite-extensions configure option is used. diff --git a/mingw-w64-python3.9/2010-configure-have-inet-pton.patch b/mingw-w64-python3.9/2010-configure-have-inet-pton.patch new file mode 100644 index 0000000000..f7b1d3a220 --- /dev/null +++ b/mingw-w64-python3.9/2010-configure-have-inet-pton.patch @@ -0,0 +1,18 @@ +diff -Naur Python-3.8.0-orig/configure.ac Python-3.8.0/configure.ac +--- Python-3.8.0-orig/configure.ac 2019-10-22 10:04:27.917907300 +0300 ++++ Python-3.8.0/configure.ac 2019-10-22 10:05:14.312388800 +0300 +@@ -4110,10 +4110,14 @@ + + AC_MSG_CHECKING(for inet_pton) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ++#ifdef _WIN32 ++#include ++#else + #include + #include + #include + #include ++#endif + ]], [[void* p = inet_pton]])], + [AC_DEFINE(HAVE_INET_PTON, 1, Define if you have the 'inet_pton' function.) + AC_MSG_RESULT(yes)], diff --git a/mingw-w64-python3.9/2030-fix-msvc9-import.patch b/mingw-w64-python3.9/2030-fix-msvc9-import.patch new file mode 100644 index 0000000000..e2d49816e6 --- /dev/null +++ b/mingw-w64-python3.9/2030-fix-msvc9-import.patch @@ -0,0 +1,21 @@ +diff -Naur Python-3.8.0-orig/Lib/distutils/msvc9compiler.py Python-3.8.0/Lib/distutils/msvc9compiler.py +--- Python-3.8.0-orig/Lib/distutils/msvc9compiler.py 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/Lib/distutils/msvc9compiler.py 2019-10-22 10:05:17.120393700 +0300 +@@ -292,8 +292,6 @@ + + # More globals + VERSION = get_build_version() +-if VERSION < 8.0: +- raise DistutilsPlatformError("VC %0.1f is not supported by this module" % VERSION) + # MACROS = MacroExpander(VERSION) + + class MSVCCompiler(CCompiler) : +@@ -328,6 +326,8 @@ + + def __init__(self, verbose=0, dry_run=0, force=0): + CCompiler.__init__ (self, verbose, dry_run, force) ++ if VERSION < 8.0: ++ raise DistutilsPlatformError("VC %0.1f is not supported by this module" % VERSION) + self.__version = VERSION + self.__root = r"Software\Microsoft\VisualStudio" + # self.__macros = MACROS diff --git a/mingw-w64-python3.9/2051-set-venv-activate-path-unix.patch b/mingw-w64-python3.9/2051-set-venv-activate-path-unix.patch new file mode 100644 index 0000000000..269582db89 --- /dev/null +++ b/mingw-w64-python3.9/2051-set-venv-activate-path-unix.patch @@ -0,0 +1,12 @@ +diff -Naur Python-3.8.0-orig/Lib/venv/scripts/common/activate Python-3.8.0/Lib/venv/scripts/common/activate +--- Python-3.8.0-orig/Lib/venv/scripts/common/activate 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/Lib/venv/scripts/common/activate 2019-10-22 10:05:22.783203700 +0300 +@@ -37,7 +37,7 @@ + # unset irrelevant variables + deactivate nondestructive + +-VIRTUAL_ENV="__VENV_DIR__" ++VIRTUAL_ENV=$(cygpath "__VENV_DIR__") + export VIRTUAL_ENV + + _OLD_VIRTUAL_PATH="$PATH" diff --git a/mingw-w64-python3.9/2052-venv-creation-fixes.patch b/mingw-w64-python3.9/2052-venv-creation-fixes.patch new file mode 100644 index 0000000000..3c3cc19627 --- /dev/null +++ b/mingw-w64-python3.9/2052-venv-creation-fixes.patch @@ -0,0 +1,62 @@ +Don't copy the whole /bin when symlinking. +Also provide python3.exe for backwards compat. +Unset MSYSTEM, to fix some path comparisons due to os.sep differences. +Skip some msvc build specifics +diff -Naur Python-3.8.0-orig/Lib/venv/__init__.py Python-3.8.0/Lib/venv/__init__.py +--- Python-3.8.0-orig/Lib/venv/__init__.py 2019-10-22 10:05:21.691201800 +0300 ++++ Python-3.8.0/Lib/venv/__init__.py 2019-10-22 10:05:25.591208600 +0300 +@@ -11,6 +11,7 @@ + import sys + import sysconfig + import types ++from sysconfig import _POSIX_BUILD + + logger = logging.getLogger(__name__) + +@@ -110,7 +111,7 @@ + context.executable = executable + context.python_dir = dirname + context.python_exe = exename +- if sys.platform == 'win32': ++ if sys.platform == 'win32' and not _POSIX_BUILD: + binname = 'Scripts' + incpath = 'Include' + libpath = os.path.join(env_dir, 'Lib', 'site-packages') +@@ -244,7 +244,7 @@ + if not os.path.islink(path): + os.chmod(path, 0o755) + else: +- if self.symlinks: ++ if self.symlinks and not _POSIX_BUILD: + # For symlinking, we need a complete copy of the root directory + # If symlinks fail, you'll get unnecessary copies of files, but + # we assume that if you've opted into symlinks on Windows then +@@ -266,7 +267,13 @@ + if os.path.lexists(src): + copier(src, os.path.join(binpath, suffix)) + +- if sysconfig.is_python_build(True): ++ if _POSIX_BUILD: ++ # copy from python/pythonw so the venvlauncher magic in symlink_or_copy triggers ++ copier(os.path.join(dirname, 'python.exe'), os.path.join(binpath, 'python3.exe')) ++ copier(os.path.join(dirname, 'python.exe'), os.path.join(binpath, 'python%d.%d.exe' % sys.version_info[:2])) ++ copier(os.path.join(dirname, 'pythonw.exe'), os.path.join(binpath, 'python3w.exe')) ++ ++ if sysconfig.is_python_build(True) and not _POSIX_BUILD: + # copy init.tcl + for root, dirs, files in os.walk(context.python_dir): + if 'init.tcl' in files: +@@ -285,9 +285,11 @@ + # We run ensurepip in isolated mode to avoid side effects from + # environment vars, the current directory and anything else + # intended for the global Python environment ++ env = os.environ.copy() ++ env.pop("MSYSTEM", None) + cmd = [context.env_exe, '-Im', 'ensurepip', '--upgrade', +- '--default-pip'] +- subprocess.check_output(cmd, stderr=subprocess.STDOUT) ++ '--default-pip'] ++ subprocess.check_call(cmd, stderr=subprocess.STDOUT, env=env) + + def setup_scripts(self, context): + """ diff --git a/mingw-w64-python3.9/2060-pass-gen-profile-ldflags.patch b/mingw-w64-python3.9/2060-pass-gen-profile-ldflags.patch new file mode 100644 index 0000000000..c033a9d221 --- /dev/null +++ b/mingw-w64-python3.9/2060-pass-gen-profile-ldflags.patch @@ -0,0 +1,12 @@ +diff -Naur Python-3.8.0-orig/Makefile.pre.in Python-3.8.0/Makefile.pre.in +--- Python-3.8.0-orig/Makefile.pre.in 2019-10-22 10:05:10.396781900 +0300 ++++ Python-3.8.0/Makefile.pre.in 2019-10-22 10:05:28.430413600 +0300 +@@ -699,7 +699,7 @@ + $(DLLLIBRARY) libpython$(LDVERSION).dll.a: $(LIBRARY_OBJS) python_nt.o + if test -n "$(DLLLIBRARY)"; then \ + $(LDSHARED) -Wl,--out-implib=$@ -o $(DLLLIBRARY) $^ \ +- $(LIBS) $(MODLIBS) $(SYSLIBS) python_nt.o; \ ++ $(LIBS) $(LDFLAGS_NODIST) $(MODLIBS) $(SYSLIBS) python_nt.o; \ + else true; \ + fi + diff --git a/mingw-w64-python3.9/2070-distutils-add-windmc-to-cygwinccompiler.patch b/mingw-w64-python3.9/2070-distutils-add-windmc-to-cygwinccompiler.patch new file mode 100644 index 0000000000..5f81526a1a --- /dev/null +++ b/mingw-w64-python3.9/2070-distutils-add-windmc-to-cygwinccompiler.patch @@ -0,0 +1,44 @@ +diff -Naur Python-3.8.0-orig/Lib/distutils/cygwinccompiler.py Python-3.8.0/Lib/distutils/cygwinccompiler.py +--- Python-3.8.0-orig/Lib/distutils/cygwinccompiler.py 2019-10-22 10:04:07.887472100 +0300 ++++ Python-3.8.0/Lib/distutils/cygwinccompiler.py 2019-10-22 10:05:31.254018600 +0300 +@@ -165,6 +165,28 @@ + self.spawn(["windres", "-i", src, "-o", obj]) + except DistutilsExecError as msg: + raise CompileError(msg) ++ elif ext == '.mc': ++ # Adapted from msvc9compiler: ++ # ++ # Compile .MC to .RC file to .RES file. ++ # * '-h dir' specifies the directory for the generated include file ++ # * '-r dir' specifies the target directory of the generated RC file and the binary message resource it includes ++ # ++ # For now (since there are no options to change this), ++ # we use the source-directory for the include file and ++ # the build directory for the RC file and message ++ # resources. This works at least for win32all. ++ h_dir = os.path.dirname(src) ++ rc_dir = os.path.dirname(obj) ++ try: ++ # first compile .MC to .RC and .H file ++ self.spawn(['windmc'] + ['-h', h_dir, '-r', rc_dir] + [src]) ++ base, _ = os.path.splitext(os.path.basename(src)) ++ rc_file = os.path.join(rc_dir, base + '.rc') ++ # then compile .RC to .RES file ++ self.spawn(['windres', '-i', rc_file, '-o', obj]) ++ except DistutilsExecError as msg: ++ raise CompileError(msg) + else: # for other files use the C-compiler + try: + self.spawn(self.compiler_so + cc_args + [src, '-o', obj] + +@@ -259,9 +281,9 @@ + base, ext = os.path.splitext(src_name) + # use 'normcase' only for resource suffixes + ext_normcase = os.path.normcase(ext) +- if ext_normcase in ['.rc','.res']: ++ if ext_normcase in ['.rc', '.res', '.mc']: + ext = ext_normcase +- if ext not in (self.src_extensions + ['.rc','.res']): ++ if ext not in (self.src_extensions + ['.rc', '.res', '.mc']): + raise UnknownFileError("unknown file type '%s' (from '%s')" % \ + (ext, src_name)) + base = os.path.splitdrive(base)[1] # Chop off the drive diff --git a/mingw-w64-python3.9/2080-pkg-config-windows-must-link-ext-with-python-lib.patch b/mingw-w64-python3.9/2080-pkg-config-windows-must-link-ext-with-python-lib.patch new file mode 100644 index 0000000000..af2751206c --- /dev/null +++ b/mingw-w64-python3.9/2080-pkg-config-windows-must-link-ext-with-python-lib.patch @@ -0,0 +1,20 @@ +--- Python-3.8.0/configure.ac.orig 2019-10-24 13:55:46.684382200 +0300 ++++ Python-3.8.0/configure.ac 2019-10-24 13:55:55.334394400 +0300 +@@ -4990,7 +4990,7 @@ + + # On Android and Cygwin the shared libraries must be linked with libpython. + AC_SUBST(LIBPYTHON) +-if test -n "$ANDROID_API_LEVEL" -o "$MACHDEP" = "cygwin"; then ++if test -n "$ANDROID_API_LEVEL" -o "$MACHDEP" = "cygwin" -o "$MACHDEP" = "win"; then + LIBPYTHON="-lpython${VERSION}${ABIFLAGS}" + else + LIBPYTHON='' +--- Python-3.8.0/Misc/python.pc.in.orig 2019-10-24 13:55:46.684382200 +0300 ++++ Python-3.8.0/Misc/python.pc.in 2019-10-24 13:55:55.334394400 +0300 +@@ -9,5 +9,5 @@ + Requires: + Version: @VERSION@ + Libs.private: @LIBS@ +-Libs: ++Libs: -L${libdir} -lpython@VERSION@@ABIFLAGS@ + Cflags: -I${includedir}/python@VERSION@@ABIFLAGS@ diff --git a/mingw-w64-python3.9/3000-importlib-bootstrap-path-sep.patch b/mingw-w64-python3.9/3000-importlib-bootstrap-path-sep.patch new file mode 100644 index 0000000000..b77fbf78a7 --- /dev/null +++ b/mingw-w64-python3.9/3000-importlib-bootstrap-path-sep.patch @@ -0,0 +1,13 @@ +--- Python-3.9.4/Lib/importlib/_bootstrap_external.py.orig 2021-04-07 19:17:30 +0000 ++++ Python-3.9.4/Lib/importlib/_bootstrap_external.py 2021-04-07 19:19:46 +0000 +@@ -1604,6 +1604,10 @@ + else: + raise ImportError('importlib requires posix or nt') + ++ if 'MSYSTEM' in os_module.environ: ++ path_separators = path_separators[::-1] ++ path_sep = path_separators[0] ++ + setattr(self_module, '_os', os_module) + setattr(self_module, 'path_sep', path_sep) + setattr(self_module, 'path_separators', ''.join(path_separators)) diff --git a/mingw-w64-python3.9/3001-pathlib-path-sep.patch b/mingw-w64-python3.9/3001-pathlib-path-sep.patch new file mode 100644 index 0000000000..be5d188e26 --- /dev/null +++ b/mingw-w64-python3.9/3001-pathlib-path-sep.patch @@ -0,0 +1,11 @@ +--- Python-3.8.1/Lib/pathlib.py.orig 2019-12-18 18:21:23.000000000 +0100 ++++ Python-3.8.1/Lib/pathlib.py 2019-12-23 11:17:46.731915100 +0100 +@@ -122,6 +122,8 @@ + + sep = '\\' + altsep = '/' ++ if 'MSYSTEM' in os.environ: ++ sep, altsep = altsep, sep + has_drv = True + pathmod = ntpath + diff --git a/mingw-w64-python3.9/3011-fix-build-testinternalcapi.patch b/mingw-w64-python3.9/3011-fix-build-testinternalcapi.patch new file mode 100644 index 0000000000..d06b0ffef3 --- /dev/null +++ b/mingw-w64-python3.9/3011-fix-build-testinternalcapi.patch @@ -0,0 +1,14 @@ +--- Python-3.8.7/setup.py.orig 2020-12-26 07:15:03.663309900 +0100 ++++ Python-3.8.7/setup.py 2020-12-26 07:51:28.765752400 +0100 +@@ -892,7 +892,11 @@ + depends=['testcapi_long.h'])) + + # Python Internal C API test module ++ macros = [] ++ if MS_WINDOWS: ++ macros.append(('PY3_DLLNAME', 'L"%s"' % sysconfig.get_config_var('DLLLIBRARY'))) + self.add(Extension('_testinternalcapi', ['_testinternalcapi.c'], ++ define_macros=macros, + extra_compile_args=['-DPy_BUILD_CORE_MODULE'])) + + # Python PEP-3118 (buffer protocol) test module \ No newline at end of file diff --git a/mingw-w64-python3.9/3020-extend-MS_WINDOWS-flag.patch b/mingw-w64-python3.9/3020-extend-MS_WINDOWS-flag.patch new file mode 100644 index 0000000000..07ec022943 --- /dev/null +++ b/mingw-w64-python3.9/3020-extend-MS_WINDOWS-flag.patch @@ -0,0 +1,11 @@ +--- cpython-msys2/setup.py 2021-01-24 12:00:01.170000000 +0700 ++++ cpython/setup.py 2021-01-24 10:50:57.710000000 +0700 +@@ -51,7 +51,7 @@ + + CROSS_COMPILING = ("_PYTHON_HOST_PLATFORM" in os.environ) + HOST_PLATFORM = get_platform() +-MS_WINDOWS = (HOST_PLATFORM == 'win32') ++MS_WINDOWS = (HOST_PLATFORM == 'win32' or HOST_PLATFORM == 'mingw') + CYGWIN = (HOST_PLATFORM == 'cygwin') + MACOS = (HOST_PLATFORM == 'darwin') + AIX = (HOST_PLATFORM.startswith('aix')) diff --git a/mingw-w64-python3.9/4000-clang-arm64.patch b/mingw-w64-python3.9/4000-clang-arm64.patch new file mode 100644 index 0000000000..10e5d021e5 --- /dev/null +++ b/mingw-w64-python3.9/4000-clang-arm64.patch @@ -0,0 +1,46 @@ +--- Python-3.8.7/Python/getcompiler.c.orig 2021-01-21 00:00:29.237009400 -0800 ++++ Python-3.8.7/Python/getcompiler.c 2021-01-21 00:08:07.812256200 -0800 +@@ -7,7 +7,7 @@ + + // Note the __clang__ conditional has to come before the __GNUC__ one because + // clang pretends to be GCC. +-#if defined(__clang__) ++#if defined(__clang__) && !defined(_WIN32) + #define COMPILER "\n[Clang " __clang_version__ "]" + #elif defined(__GNUC__) + /* To not break compatibility with things that determine +@@ -18,6 +18,8 @@ + #define COMP_SEP " " + #if defined(__x86_64__) + #define ARCH_SUFFIX " 64 bit (AMD64)" ++#elif defined(__aarch64__) ++#define ARCH_SUFFIX " 64 bit (ARM64)" + #else + #define ARCH_SUFFIX " 32 bit" + #endif +@@ -25,7 +27,14 @@ + #define COMP_SEP "\n" + #define ARCH_SUFFIX "" + #endif ++#if defined(__clang__) ++#define str(x) #x ++#define xstr(x) str(x) ++#define COMPILER COMP_SEP "[GCC Clang " xstr(__clang_major__) "." \ ++ xstr(__clang_minor__) "." xstr(__clang_patchlevel__) ARCH_SUFFIX "]" ++#else + #define COMPILER COMP_SEP "[GCC " __VERSION__ ARCH_SUFFIX "]" ++#endif + // Generic fallbacks. + #elif defined(__cplusplus) + #define COMPILER "[C++]" +--- Python-3.8.7/Lib/distutils/cygwinccompiler.py~ 2021-01-21 00:32:02.844891200 -0800 ++++ Python-3.8.7/Lib/distutils/cygwinccompiler.py 2021-01-21 10:58:17.540398500 -0800 +@@ -396,7 +396,7 @@ + return (CONFIG_H_UNCERTAIN, + "couldn't read '%s': %s" % (fn, exc.strerror)) + +-RE_VERSION = re.compile(br'[\D\s]*(\d+\.\d+(\.\d+)*)[\D\s]*$') ++RE_VERSION = re.compile(br'[\D\s]*(\d+\.\d+(\.\d+)*)[\D\s]*') + + def _find_exe_version(cmd): + """Find the version of an executable by running `cmd` in the shell. diff --git a/mingw-w64-python3.9/5000-warnings-fixes.patch b/mingw-w64-python3.9/5000-warnings-fixes.patch new file mode 100644 index 0000000000..1961724f8e --- /dev/null +++ b/mingw-w64-python3.9/5000-warnings-fixes.patch @@ -0,0 +1,105 @@ +diff -Naur Python-3.8.0-orig/Modules/_winapi.c Python-3.8.0/Modules/_winapi.c +--- Python-3.8.0-orig/Modules/_winapi.c 2019-10-22 10:01:51.434032500 +0300 ++++ Python-3.8.0/Modules/_winapi.c 2019-10-22 10:05:34.654824500 +0300 +@@ -951,7 +951,7 @@ + DWORD err; + BOOL result; + PyObject *value; +- Py_ssize_t handle_list_size; ++ Py_ssize_t handle_list_size = 0; + DWORD attribute_count = 0; + SIZE_T attribute_list_size = 0; + +diff -Naur Python-3.8.0-orig/Modules/posixmodule.c Python-3.8.0/Modules/posixmodule.c +--- Python-3.8.0-orig/Modules/posixmodule.c 2019-10-22 10:04:46.029539100 +0300 ++++ Python-3.8.0/Modules/posixmodule.c 2019-10-22 10:05:35.076025300 +0300 +@@ -4804,7 +4804,7 @@ + /*[clinic end generated code: output=cfcac69d027b82cf input=2fbd62a2f228f8f4]*/ + { + #ifdef MS_WINDOWS +- HANDLE hFile; ++ HANDLE hFile = 0; + FILETIME atime, mtime; + #else + int result; +@@ -13489,7 +13491,7 @@ + loaded. */ + Py_BEGIN_ALLOW_THREADS + if (!(hKernel32 = GetModuleHandleW(L"kernel32")) || +- !(AddDllDirectory = (PAddDllDirectory)GetProcAddress( ++ !(AddDllDirectory = (PAddDllDirectory)(void *)GetProcAddress( + hKernel32, "AddDllDirectory")) || + !(cookie = (*AddDllDirectory)(path->wide))) { + err = GetLastError(); +@@ -13539,7 +13541,7 @@ + loaded. */ + Py_BEGIN_ALLOW_THREADS + if (!(hKernel32 = GetModuleHandleW(L"kernel32")) || +- !(RemoveDllDirectory = (PRemoveDllDirectory)GetProcAddress( ++ !(RemoveDllDirectory = (PRemoveDllDirectory)(void *)GetProcAddress( + hKernel32, "RemoveDllDirectory")) || + !(*RemoveDllDirectory)(cookieValue)) { + err = GetLastError(); +diff -Naur Python-3.8.0-orig/Modules/socketmodule.h Python-3.8.0/Modules/socketmodule.h +--- Python-3.8.0-orig/Modules/socketmodule.h 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/Modules/socketmodule.h 2019-10-22 10:05:35.466026000 +0300 +@@ -29,8 +29,10 @@ + */ + # ifdef SIO_GET_MULTICAST_FILTER + # include /* for SIO_RCVALL */ ++#ifndef __MINGW32__ /* resolve by configure */ + # define HAVE_ADDRINFO + # define HAVE_SOCKADDR_STORAGE ++#endif + # define HAVE_GETADDRINFO + # define HAVE_GETNAMEINFO + # define ENABLE_IPV6 +diff -Naur Python-3.8.0-orig/PC/python_exe.rc Python-3.8.0/PC/python_exe.rc +--- Python-3.8.0-orig/PC/python_exe.rc 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/PC/python_exe.rc 2019-10-22 10:05:35.871626700 +0300 +@@ -7,7 +7,7 @@ + #include + 1 RT_MANIFEST "python.manifest" + +-1 ICON DISCARDABLE "icons\python.ico" ++1 ICON DISCARDABLE "icons/python.ico" + + + ///////////////////////////////////////////////////////////////////////////// +diff -Naur Python-3.8.0-orig/PC/pythonw_exe.rc Python-3.8.0/PC/pythonw_exe.rc +--- Python-3.8.0-orig/PC/pythonw_exe.rc 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/PC/pythonw_exe.rc 2019-10-22 10:05:36.277227400 +0300 +@@ -7,7 +7,7 @@ + #include + 1 RT_MANIFEST "python.manifest" + +-1 ICON DISCARDABLE "icons\pythonw.ico" ++1 ICON DISCARDABLE "icons/pythonw.ico" + + + ///////////////////////////////////////////////////////////////////////////// +diff -Naur Python-3.8.0-orig/PC/winreg.c Python-3.8.0/PC/winreg.c +--- Python-3.8.0-orig/PC/winreg.c 2019-10-22 10:01:02.698546800 +0300 ++++ Python-3.8.0/PC/winreg.c 2019-10-22 10:05:36.682828100 +0300 +@@ -800,6 +800,7 @@ + case REG_BINARY: + /* ALSO handle ALL unknown data types here. Even if we can't + support it natively, we should handle the bits. */ ++ /* fallthrough */ + default: + if (retDataSize == 0) { + Py_INCREF(Py_None); +diff -Naur Python-3.8.0-orig/Python/thread_nt.h Python-3.8.0/Python/thread_nt.h +--- Python-3.8.0-orig/Python/thread_nt.h 2019-10-14 16:34:47.000000000 +0300 ++++ Python-3.8.0/Python/thread_nt.h 2019-10-22 10:05:37.088428800 +0300 +@@ -342,8 +342,9 @@ + { + dprintf(("%lu: PyThread_release_lock(%p) called\n", PyThread_get_thread_ident(),aLock)); + +- if (!(aLock && LeaveNonRecursiveMutex((PNRMUTEX) aLock))) ++ if (!(aLock && LeaveNonRecursiveMutex((PNRMUTEX) aLock))) { + dprintf(("%lu: Could not PyThread_release_lock(%p) error: %ld\n", PyThread_get_thread_ident(), aLock, GetLastError())); ++ } + } + + /* minimum/maximum thread stack sizes supported */ diff --git a/mingw-w64-python3.9/PKGBUILD b/mingw-w64-python3.9/PKGBUILD new file mode 100644 index 0000000000..f56eefe463 --- /dev/null +++ b/mingw-w64-python3.9/PKGBUILD @@ -0,0 +1,615 @@ +# Maintainer: Alexey Pavlov +# Maintainer: Ray Donnelly +# Contributor: Saul Ibarra Corretge +# Contributor: Frode Solheim + +# TODO :: subprocess.Popen .. specifically list2cmdline in subprocess.py +# needs a fix so it can handle running MSYS2 executables better. +# Arguments should not be quoted in the Windows fashion as-per: +# http://www.daviddeley.com/autohotkey/parameters/parameters.htm +# but instead how Cygwin expects them to be quoted. Checking for +# {cygwin,msys-2.0}.dll in the executable is the only way that I +# can think to do this at present. +# Any double quoted string will cause problems, e.g. +# -DGNOMELOCALEDIR=\"/mingw64/share/locale\" + +_primary_python="no" +_pybasever=3.9 +_realname=python + +if [[ "${_primary_python}" == "yes" ]]; then + pkgbase="mingw-w64-${_realname}" + pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}") + provides=("${MINGW_PACKAGE_PREFIX}-python3=${pkgver}") + conflicts=("${MINGW_PACKAGE_PREFIX}-python3" + "${MINGW_PACKAGE_PREFIX}-python2<2.7.16-7") + replaces=("${MINGW_PACKAGE_PREFIX}-python3") +else + pkgbase="mingw-w64-${_realname}${_pybasever}" + pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}${_pybasever}") +fi +pkgver=${_pybasever}.5 +pkgrel=2 +pkgdesc="A high-level scripting language (mingw-w64)" +arch=('any') +mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64') +license=('PSF') +url="https://www.python.org/" +depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs" + "${MINGW_PACKAGE_PREFIX}-expat" + "${MINGW_PACKAGE_PREFIX}-bzip2" + "${MINGW_PACKAGE_PREFIX}-libffi" + "${MINGW_PACKAGE_PREFIX}-mpdecimal" + "${MINGW_PACKAGE_PREFIX}-ncurses" + "${MINGW_PACKAGE_PREFIX}-openssl" + "${MINGW_PACKAGE_PREFIX}-sqlite3" + "${MINGW_PACKAGE_PREFIX}-tcl" + "${MINGW_PACKAGE_PREFIX}-tk" + "${MINGW_PACKAGE_PREFIX}-zlib" + "${MINGW_PACKAGE_PREFIX}-xz") +makedepends=( + "${MINGW_PACKAGE_PREFIX}-gcc" + "${MINGW_PACKAGE_PREFIX}-pkg-config" + "autoconf-archive" +) +options=('makeflags') # 'debug' '!strip') +source=("https://www.python.org/ftp/python/${pkgver%rc?}/Python-${pkgver}.tar.xz" + 0000-make-_sysconfigdata.py-relocatable.patch + 0002-restore-setup-config.patch + 0100-MINGW-BASE-use-NT-thread-model.patch + 0110-MINGW-translate-gcc-internal-defines-to-python-platf.patch + 0130-MINGW-configure-MACHDEP-and-platform-for-build.patch + 0140-MINGW-preset-configure-defaults.patch + 0150-MINGW-configure-largefile-support-for-windows-builds.patch + 0170-MINGW-add-srcdir-PC-to-CPPFLAGS.patch + 0180-MINGW-init-system-calls.patch + 0200-MINGW-build-in-windows-modules-winreg.patch + 0210-MINGW-determine-if-pwdmodule-should-be-used.patch + 0250-MINGW-compiler-customize-mingw-cygwin-compilers.patch + 0260-MINGW-compiler-enable-new-dtags.patch + 0290-issue6672-v2-Add-Mingw-recognition-to-pyport.h-to-al.patch + 0300-MINGW-configure-for-shared-build.patch + 0310-MINGW-dynamic-loading-support.patch + 0330-MINGW-ignore-main-program-for-frozen-scripts.patch + 0350-MINGW-setup-_multiprocessing-module.patch + 0360-MINGW-setup-select-module.patch + 0370-MINGW-setup-_ctypes-module-with-system-libffi.patch + 0380-MINGW-defect-winsock2-and-setup-_socket-module.patch + 0390-MINGW-exclude-unix-only-modules.patch + 0400-MINGW-setup-msvcrt-and-_winapi-modules.patch + 0410-MINGW-build-extensions-with-GCC.patch + 0420-MINGW-use-Mingw32CCompiler-as-default-compiler-for-m.patch + 0430-MINGW-find-import-library.patch + 0440-MINGW-setup-_ssl-module.patch + 0460-MINGW-generalization-of-posix-build-in-sysconfig.py.patch + 0462-MINGW-support-stdcall-without-underscore.patch + 0464-use-replace-instead-rename-to-avoid-failure-on-windo.patch + 0470-MINGW-avoid-circular-dependency-from-time-module-dur.patch + 0480-MINGW-generalization-of-posix-build-in-distutils-sys.patch + 0490-MINGW-customize-site.patch + 0500-add-python-config-sh.patch + 0510-cross-darwin-feature.patch + 0520-py3k-mingw-ntthreads-vs-pthreads.patch + 0530-mingw-system-libffi.patch + 0555-msys-mingw-prefer-unix-sep-if-MSYSTEM.patch + 0560-mingw-use-posix-getpath.patch + 0565-mingw-add-ModuleFileName-dir-to-PATH.patch + 0570-mingw-add-BUILDIN_WIN32_MODULEs-time-msvcrt.patch + 0610-msys-cygwin-semi-native-build-sysconfig.patch + 0620-mingw-sysconfig-like-posix.patch + 0630-mingw-_winapi_as_builtin_for_Popen_in_cygwinccompiler.patch + 0650-cross-dont-add-multiarch-paths-if-cross-compiling.patch + 0660-mingw-use-backslashes-in-compileall-py.patch + 0670-msys-convert_path-fix-and-root-hack.patch + 0690-allow-static-tcltk.patch + 0720-mingw-pdcurses_ISPAD.patch + 0740-grammar-fixes.patch + 0750-builddir-fixes.patch + 0760-msys-monkeypatch-os-system-via-sh-exe.patch + 0770-msys-replace-slashes-used-in-io-redirection.patch + 0800-mingw-install-layout-as-posix.patch + 0810-remove_path_max.default.patch + 0820-dont-link-with-gettext.patch + 0830-ctypes-python-dll.patch + 0840-gdbm-module-includes.patch + 0850-use-gnu_printf-in-format.patch + 0870-mingw-fix-ssl-dont-use-enum_certificates.patch + 0890-mingw-build-optimized-ext.patch + 0900-cygwinccompiler-dont-strip-modules-if-pydebug.patch + 0910-fix-using-dllhandle-and-winver-mingw.patch + 0920-mingw-add-LIBPL-to-library-dirs.patch + 0970-Add-AMD64-to-sys-config-so-msvccompiler-get_build_version-works.patch + 0990-MINGW-link-with-additional-library.patch + 1010-install-msilib.patch + 1060-dont-include-system-ncurses-path.patch + 1620-fix-signal-module-build.patch + 1630-build-winconsoleio.patch + 1650-expose-sem_unlink.patch + 1700-cygpty-isatty.patch + 1701-disable-broken-gdbm-module.patch + 1800-link-win-resource-files-and-build-pythonw.patch + 1810-3.7-mpdec-mingw.patch + 1850-disable-readline.patch + 1860-fix-isselectable.patch + 1870-use-_wcsnicmp-instead-wcsncasecmp.patch + 1890-_xxsubinterpretersmodule.patch + 1891-sqlite3-module-defines.patch + 2010-configure-have-inet-pton.patch + 2030-fix-msvc9-import.patch + 2051-set-venv-activate-path-unix.patch + 2052-venv-creation-fixes.patch + 2060-pass-gen-profile-ldflags.patch + 2070-distutils-add-windmc-to-cygwinccompiler.patch + 2080-pkg-config-windows-must-link-ext-with-python-lib.patch + 3000-importlib-bootstrap-path-sep.patch + 3001-pathlib-path-sep.patch + 3011-fix-build-testinternalcapi.patch + 3020-extend-MS_WINDOWS-flag.patch + 4000-clang-arm64.patch + 5000-warnings-fixes.patch + smoketests.py) + +# Helper macros to help make tasks easier # +apply_patch_with_msg() { + for _patch in "$@" + do + msg2 "Applying ${_patch}" + patch -Nbp1 -i "${srcdir}/${_patch}" + done +} + +del_file_exists() { + for _fname in "$@" + do + if [ -f ${_fname} ]; then + rm -rf ${_fname} + fi + done +} +# =========================================== # + +prepare() { + cd "${srcdir}/Python-${pkgver}" + + plain "Apply Ray Donnelly's should-be-upstreamed patches" + apply_patch_with_msg \ + 0000-make-_sysconfigdata.py-relocatable.patch \ + 0002-restore-setup-config.patch + + plain "Apply Roumen Petrov's core patches (10)" + apply_patch_with_msg \ + 0100-MINGW-BASE-use-NT-thread-model.patch \ + 0110-MINGW-translate-gcc-internal-defines-to-python-platf.patch \ + 0130-MINGW-configure-MACHDEP-and-platform-for-build.patch \ + 0140-MINGW-preset-configure-defaults.patch \ + 0150-MINGW-configure-largefile-support-for-windows-builds.patch \ + 0170-MINGW-add-srcdir-PC-to-CPPFLAGS.patch \ + 0180-MINGW-init-system-calls.patch \ + 0200-MINGW-build-in-windows-modules-winreg.patch \ + 0210-MINGW-determine-if-pwdmodule-should-be-used.patch + + plain "Apply Roumen Petrov's compiler patch (2)" + apply_patch_with_msg \ + 0250-MINGW-compiler-customize-mingw-cygwin-compilers.patch \ + 0260-MINGW-compiler-enable-new-dtags.patch + + plain "Apply Roumen Petrov's extensions patches (21)" + apply_patch_with_msg \ + 0290-issue6672-v2-Add-Mingw-recognition-to-pyport.h-to-al.patch \ + 0300-MINGW-configure-for-shared-build.patch \ + 0310-MINGW-dynamic-loading-support.patch \ + 0330-MINGW-ignore-main-program-for-frozen-scripts.patch \ + 0350-MINGW-setup-_multiprocessing-module.patch \ + 0360-MINGW-setup-select-module.patch \ + 0370-MINGW-setup-_ctypes-module-with-system-libffi.patch \ + 0380-MINGW-defect-winsock2-and-setup-_socket-module.patch \ + 0390-MINGW-exclude-unix-only-modules.patch \ + 0400-MINGW-setup-msvcrt-and-_winapi-modules.patch \ + 0410-MINGW-build-extensions-with-GCC.patch \ + 0420-MINGW-use-Mingw32CCompiler-as-default-compiler-for-m.patch \ + 0430-MINGW-find-import-library.patch \ + 0440-MINGW-setup-_ssl-module.patch \ + 0460-MINGW-generalization-of-posix-build-in-sysconfig.py.patch \ + 0462-MINGW-support-stdcall-without-underscore.patch \ + 0464-use-replace-instead-rename-to-avoid-failure-on-windo.patch \ + 0470-MINGW-avoid-circular-dependency-from-time-module-dur.patch \ + 0480-MINGW-generalization-of-posix-build-in-distutils-sys.patch \ + 0490-MINGW-customize-site.patch + + plain "Apply Ray Donnelly's general/cross patches (42)" + apply_patch_with_msg \ + 0500-add-python-config-sh.patch \ + 0510-cross-darwin-feature.patch \ + 0520-py3k-mingw-ntthreads-vs-pthreads.patch \ + 0530-mingw-system-libffi.patch \ + 0555-msys-mingw-prefer-unix-sep-if-MSYSTEM.patch \ + 0560-mingw-use-posix-getpath.patch \ + 0565-mingw-add-ModuleFileName-dir-to-PATH.patch \ + 0570-mingw-add-BUILDIN_WIN32_MODULEs-time-msvcrt.patch + + apply_patch_with_msg \ + 0610-msys-cygwin-semi-native-build-sysconfig.patch \ + 0620-mingw-sysconfig-like-posix.patch \ + 0630-mingw-_winapi_as_builtin_for_Popen_in_cygwinccompiler.patch \ + 0650-cross-dont-add-multiarch-paths-if-cross-compiling.patch \ + 0660-mingw-use-backslashes-in-compileall-py.patch \ + 0670-msys-convert_path-fix-and-root-hack.patch \ + 0690-allow-static-tcltk.patch + + apply_patch_with_msg \ + 0720-mingw-pdcurses_ISPAD.patch \ + 0740-grammar-fixes.patch \ + 0750-builddir-fixes.patch \ + 0760-msys-monkeypatch-os-system-via-sh-exe.patch \ + 0770-msys-replace-slashes-used-in-io-redirection.patch \ + 0800-mingw-install-layout-as-posix.patch \ + 0810-remove_path_max.default.patch \ + 0820-dont-link-with-gettext.patch \ + 0830-ctypes-python-dll.patch \ + 0840-gdbm-module-includes.patch \ + 0850-use-gnu_printf-in-format.patch \ + 0870-mingw-fix-ssl-dont-use-enum_certificates.patch \ + 0890-mingw-build-optimized-ext.patch \ + 0900-cygwinccompiler-dont-strip-modules-if-pydebug.patch \ + 0910-fix-using-dllhandle-and-winver-mingw.patch \ + 0920-mingw-add-LIBPL-to-library-dirs.patch \ + 0970-Add-AMD64-to-sys-config-so-msvccompiler-get_build_version-works.patch \ + 0990-MINGW-link-with-additional-library.patch \ + 1010-install-msilib.patch \ + 1060-dont-include-system-ncurses-path.patch + + plain "New patches added for the update from 3.5.3 to 3.6.1" + apply_patch_with_msg \ + 1620-fix-signal-module-build.patch \ + 1630-build-winconsoleio.patch \ + 1650-expose-sem_unlink.patch + + # Extend some isatty calls to check for mintty when checking for + # a terminal output. + # https://github.com/Alexpux/MINGW-packages/issues/2645 + apply_patch_with_msg \ + 1700-cygpty-isatty.patch + + # gdbm is broken and as a result breaks dbm/shelve. + # Don't include it so the dbm.dumb backend is used instead, + # like with the official CPython build. + apply_patch_with_msg \ + 1701-disable-broken-gdbm-module.patch + + # https://github.com/Alexpux/MINGW-packages/issues/3139 + apply_patch_with_msg \ + 1800-link-win-resource-files-and-build-pythonw.patch + + apply_patch_with_msg \ + 1810-3.7-mpdec-mingw.patch \ + 1850-disable-readline.patch \ + 1860-fix-isselectable.patch \ + 1870-use-_wcsnicmp-instead-wcsncasecmp.patch \ + 1890-_xxsubinterpretersmodule.patch \ + 1891-sqlite3-module-defines.patch + + # https://github.com/msys2/MINGW-packages/issues/5184 + apply_patch_with_msg 2010-configure-have-inet-pton.patch + + # https://github.com/msys2/MINGW-packages/issues/5155 + apply_patch_with_msg 2030-fix-msvc9-import.patch + + # https://github.com/msys2/MINGW-packages/issues/5001 + apply_patch_with_msg 2051-set-venv-activate-path-unix.patch + apply_patch_with_msg 2052-venv-creation-fixes.patch + + apply_patch_with_msg 2060-pass-gen-profile-ldflags.patch + + apply_patch_with_msg 2070-distutils-add-windmc-to-cygwinccompiler.patch + apply_patch_with_msg 2080-pkg-config-windows-must-link-ext-with-python-lib.patch + + # https://github.com/msys2/MINGW-packages/issues/6035 + apply_patch_with_msg 3000-importlib-bootstrap-path-sep.patch + apply_patch_with_msg 3001-pathlib-path-sep.patch + + apply_patch_with_msg 5000-warnings-fixes.patch + + apply_patch_with_msg 3011-fix-build-testinternalcapi.patch + + apply_patch_with_msg 3020-extend-MS_WINDOWS-flag.patch + + apply_patch_with_msg 4000-clang-arm64.patch + + autoreconf -vfi +} + +check() { + cd "${srcdir}/build-${CARCH}" + + # Some basic tests to ensure nothing major or MSYS2 specific features are + # broken + ./python.exe "${srcdir}/smoketests.py" + MSYSTEM= ./python.exe "${srcdir}/smoketests.py" + + # make test EXTRATESTOPTS="-v" +} + +build() { + local PREFIX_WIN=$(cygpath -wm ${MINGW_PREFIX}) + + if [[ $MINGW_PACKAGE_PREFIX == *-clang-* ]]; then + export CC=clang CXX=clang++ + fi + + CFLAGS+=" -fwrapv -D__USE_MINGW_ANSI_STDIO=1 -D_WIN32_WINNT=0x0601" + CXXFLAGS+=" -fwrapv -D__USE_MINGW_ANSI_STDIO=1 -D_WIN32_WINNT=0x0601" + CPPFLAGS+=" -I${PREFIX_WIN}/include/ncurses " + + declare -a _extra_config + if check_option "debug" "n"; then + CFLAGS+=" -DNDEBUG " + CXXFLAGS+=" -DNDEBUG " + _extra_config+=("--enable-optimizations") + # _extra_config+=("--with-lto") + else + CFLAGS+=" -O0 -ggdb" + CXXFLAGS+=" -O0 -ggdb" + _extra_config+=("--with-pydebug") + fi + + + # Fix MS_DLL_ID undeclared in PC/dl_nt.c + local f3f=0 + local re='^[0-9]+$' + local part3=${pkgver##*.} + if ! [[ $part3 =~ $re ]] ; then + local c= + while test -n "$part3"; do + local b=${part3:0:1} + if ! [[ $b =~ $re ]] ; then + break + fi + c+=${b} + part3=${part3:1} + done + f3f=$((f3f + 1000 * $((${c})))) + local part3Len=${#part3} + if [ "$part3Len" -ge "1" ] ; then + f3f=$((f3f + 10 * $((0x${part3:0:1})))) + if [ "$part3Len" -ge "2" ] ; then + f3f=$((f3f + ${part3:1:1})) + fi + fi + else + f3f=$((f3f + 1000 * ${part3})) + fi + CFLAGS+=" -DMS_DLL_ID=\\\"${_pybasever}\\\"" + CFLAGS+=" -DFIELD3=${f3f}" + CFLAGS+=" -DORIGINAL_FILENAME=\\\"libpython${_pybasever}.dll\\\"" + local rc_flags=" -DMS_DLL_ID=\\\\\\\"${_pybasever}\\\\\\\" -DFIELD3=${f3f} -DORIGINAL_FILENAME=\\\\\\\"libpython${_pybasever}.dll\\\\\\\"" + + # Workaround for conftest error on 64-bit builds + export ac_cv_working_tzset=no + + # Workaround for when dlfcn exists on Windows, which causes + # some conftests to succeed when they shouldn't (we don't use dlfcn). + export ac_cv_header_dlfcn_h=no + export ac_cv_lib_dl_dlopen=no + export ac_cv_have_decl_RTLD_GLOBAL=no + export ac_cv_have_decl_RTLD_LAZY=no + export ac_cv_have_decl_RTLD_LOCAL=no + export ac_cv_have_decl_RTLD_NOW=no + export ac_cv_have_decl_RTLD_DEEPBIND=no + export ac_cv_have_decl_RTLD_MEMBER=no + export ac_cv_have_decl_RTLD_NODELETE=no + export ac_cv_have_decl_RTLD_NOLOAD=no + + [[ -d "${srcdir}/build-${CARCH}" ]] && rm -rf "${srcdir}/build-${CARCH}" + mkdir -p "${srcdir}/build-${CARCH}" && cd "${srcdir}/build-${CARCH}" + + MSYSTEM=MINGW ../Python-${pkgver}/configure \ + --prefix=${MINGW_PREFIX} \ + --host=${MINGW_CHOST} \ + --build=${MINGW_CHOST} \ + --enable-shared \ + --with-nt-threads \ + --with-system-expat \ + --with-system-ffi \ + --with-system-libmpdec \ + --without-ensurepip \ + --without-c-locale-coercion \ + --enable-loadable-sqlite-extensions \ + "${_extra_config[@]}" \ + RCFLAGS="$rc_flags" \ + OPT="" + + # We patch importlib which is embedded in C headers, so regenerate them + make regen-importlib + + make + + # Add missing venvlauncher files (issue #7014) + # FIXME: build these from PC/launcher.c instead + cp python.exe venvlauncher.exe + cp pythonw.exe venvwlauncher.exe +} + +package() { + cd "${srcdir}/build-${CARCH}" + + local PREFIX_WIN=$(cygpath -wm ${MINGW_PREFIX}) + MSYSTEM=MINGW \ + MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \ + make -j1 install DESTDIR="${pkgdir}" + if check_option "debug" "n"; then + VERABI=${_pybasever} + else + VERABI=${_pybasever}d + fi + + # gdb pretty printers for debugging Python itself; to use: + # python + # sys.path.append('C:/msys64/mingw64/share/gdb/python3') + # import python_gdb + # reload(python_gdb) + # end + if [[ "${_primary_python}" == "yes" ]]; then + [[ -d "${pkgdir}${MINGW_PREFIX}"/share/gdb/python3/ ]] || mkdir -p "${pkgdir}${MINGW_PREFIX}"/share/gdb/python3/ + cp -f python.exe-gdb.py "${pkgdir}${MINGW_PREFIX}"/share/gdb/python3/python_gdb.py + fi + + cp -f "${pkgdir}${MINGW_PREFIX}"/lib/python${_pybasever}/config-${VERABI}/libpython${VERABI}.dll.a "${pkgdir}${MINGW_PREFIX}"/lib/libpython${VERABI}.dll.a + + # Need for building boost python module + cp -f "${pkgdir}${MINGW_PREFIX}"/lib/python${_pybasever}/config-${VERABI}/libpython${VERABI}.dll.a "${pkgdir}${MINGW_PREFIX}"/lib/libpython${_pybasever}.dll.a + + # some useful "stuff" + install -dm755 "${pkgdir}${MINGW_PREFIX}"/lib/python${_pybasever}/Tools/{i18n,scripts} + install -m755 "${srcdir}/Python-${pkgver}"/Tools/i18n/{msgfmt,pygettext}.py "${pkgdir}${MINGW_PREFIX}"/lib/python${_pybasever}/Tools/i18n/ + install -m755 "${srcdir}/Python-${pkgver}"/Tools/scripts/{README,*py} "${pkgdir}${MINGW_PREFIX}"/lib/python${_pybasever}/Tools/scripts/ + + # clean up #!s + find "${pkgdir}${MINGW_PREFIX}"/lib/python${_pybasever}/ -name '*.py' | \ + xargs sed -i "s|#[ ]*![ ]*/usr/bin/env python$|#!/usr/bin/env python|" + + # clean-up reference to build directory + sed -i "s#${srcdir}/Python-${pkgver}:##" "${pkgdir}${MINGW_PREFIX}"/lib/python${_pybasever}/config-${VERABI}/Makefile + + for fscripts in 2to3 2to3-${_pybasever} idle3 idle${_pybasever} pydoc3 pydoc${_pybasever}; do + sed -i "s|$(cygpath -w ${MINGW_PREFIX} | sed 's|\\|\\\\|g')/bin/python${_pybasever}.exe|/usr/bin/env python${_pybasever}.exe|g" "${pkgdir}${MINGW_PREFIX}"/bin/${fscripts} + done + + if [[ "${_primary_python}" == "yes" ]]; then + # Default names are aliases for Python now + cp "${pkgdir}${MINGW_PREFIX}"/bin/python3.exe "${pkgdir}${MINGW_PREFIX}"/bin/python.exe + cp "${pkgdir}${MINGW_PREFIX}"/bin/python3w.exe "${pkgdir}${MINGW_PREFIX}"/bin/pythonw.exe + cp "${pkgdir}${MINGW_PREFIX}"/bin/python3-config "${pkgdir}${MINGW_PREFIX}"/bin/python-config + cp "${pkgdir}${MINGW_PREFIX}"/bin/idle3 "${pkgdir}${MINGW_PREFIX}"/bin/idle + cp "${pkgdir}${MINGW_PREFIX}"/bin/pydoc3 "${pkgdir}${MINGW_PREFIX}"/bin/pydoc + else + rm "${pkgdir}${MINGW_PREFIX}"/bin/python3.exe + rm "${pkgdir}${MINGW_PREFIX}"/bin/python3w.exe + rm "${pkgdir}${MINGW_PREFIX}"/bin/python3-config + rm "${pkgdir}${MINGW_PREFIX}"/bin/idle3 + rm "${pkgdir}${MINGW_PREFIX}"/bin/pydoc3 + rm "${pkgdir}${MINGW_PREFIX}"/bin/2to3 + rm "${pkgdir}${MINGW_PREFIX}"/lib/pkgconfig/python3-embed.pc + rm "${pkgdir}${MINGW_PREFIX}"/lib/pkgconfig/python3.pc + rm "${pkgdir}${MINGW_PREFIX}"/share/man/man1/python3.1 + fi + + sed -i "s|#!${pkgdir}${MINGW_PREFIX}/bin/python${VERABI}.exe|#!/usr/bin/env python${_pybasever}.exe|" "${pkgdir}${MINGW_PREFIX}"/lib/python${_pybasever}/config-${VERABI}/python-config.py + + # fix permissons + find ${pkgdir}${MINGW_PREFIX} -type f \( -name "*.dll" -o -name "*.exe" \) | xargs chmod 0755 + + # Fix up two instances of MSYS2 paths in python-config.sh in-case the final consumer of the results are native executables. + sed -e "s|${MINGW_PREFIX}|${PREFIX_WIN}|" \ + -i "${pkgdir}${MINGW_PREFIX}"/bin/python${VERABI}-config + if [[ "${_primary_python}" == "yes" ]]; then + sed -e "s|${MINGW_PREFIX}|${PREFIX_WIN}|" \ + -i "${pkgdir}${MINGW_PREFIX}"/bin/python3-config \ + -i "${pkgdir}${MINGW_PREFIX}"/bin/python-config + fi + + # replace paths in sysconfig + sed -i "s|${pkgdir}${MINGW_PREFIX}|${MINGW_PREFIX}|g" \ + "${pkgdir}${MINGW_PREFIX}"/lib/python${_pybasever}/lib-dynload/_sysconfigdata*.py \ + "${pkgdir}${MINGW_PREFIX}"/lib/python${_pybasever}/smtpd.py + + # install venv launchers + mkdir -p "${pkgdir}${MINGW_PREFIX}"/lib/python${_pybasever}/venv/scripts/nt + cp venvlauncher.exe "${pkgdir}${MINGW_PREFIX}"/lib/python${_pybasever}/venv/scripts/nt/python.exe + cp venvwlauncher.exe "${pkgdir}${MINGW_PREFIX}"/lib/python${_pybasever}/venv/scripts/nt/pythonw.exe +} + +sha256sums=('0c5a140665436ec3dbfbb79e2dfb6d192655f26ef4a29aeffcb6d1820d716d83' + '0ee1acf745d38d41fd098487b9595705fd8f6666d7b154d54ddba32d14f1253b' + 'd2d73d9fb9db48fecb3a6856e4606f444eaac7637fd4f65e192701e53ac422eb' + 'abed03b63e0b498804b44d1cdf8b1ff0c3c4329d3ea9c0323b2512adcacb9b57' + 'c2fb01aacfc5d96bdb69ef37282f300ecd8bfa3e11921caa1fce8e871f5a31f8' + '6446e0a5255d317d93c5c55094d4c797cf68fbd14bb08d38c94d7080837d1380' + '8e90c38ac27316781f8853fcbce300526d92732edf4cd08d1dc2a0438fd2d694' + '36f6e8b4320ee79b6ff7e84aefec3aec57293bcbacf08ea7847f3147d459b4a9' + '2fbb3642720783c0edef2a79755974e9d85e22735885af8797956f56005a846c' + '960f0c795a452d8446b60fd50505c7696c5166b3d0250660f8312d71222baeb7' + '910c84eb01cfe2207ee7fd8549247d9498be8b58c4dbbb6eaa2118037e77730e' + 'da5057e58a4866e20c3c604153febb2b57a089d327a954ee5b51830af8204e17' + '265a3c99923b76210e0401bc0cafa88b99328343aec43d64aa94cb84fcdda6d8' + '4f1db216d6a2dad137b07ccdd4b2d71c37169083706addf90c3b0b850312632a' + '12a93452bac4950baee85baaf95e67e2c63d2f022b0199d0aa4720321189f890' + '9f05613753a8b4ad8c5a6b32c257a318e9ff416345f4ebef3e69f56cf9a51578' + '9269a4d4dab6a0e93b8a0b5ed84c3e93bdfbaf99148e467daf993f6f767c8d45' + '1e89597d37838ad7c18463b83476b3cc6bec1480a052e757b9fbfb3264d4d890' + '03891c0fe4ad90a9926c0e04dc7bb0efbf0022cd6d7746cf2d173dbd739f6142' + '3b85b18922d21e8fc6e07a12e1c8d79c7ec271dddb75ed0fb4f44148b030b360' + '6d0119cd216b944927254598cfec1b85757000ab39f5ba987a86ed2216d6351b' + 'ed8d88979198f3262b74fd3b214e868589251162e073dfd8c801bef93353fcc8' + '9c6e64ba27d72e912be3486a0cc65d9f59f5d7ba71fb634fef0860a00311d12c' + '3842234d2c3aeece0416a670c789801ef76ce31841a9c1bfcbb26340aa346712' + '194ef359356d4d58bb15bafe8738c0586350d26e85cc39f5db833f428d67b41d' + '48d5dac961a363cbd1f3d2acf0100552d5f8b0974ab96ccb3d81058781d6a277' + 'f7729d39c8eadce379b2b21cd253c604bfe3e4293945b4d6def9bf0c9b3c8f4f' + '7bd7cac5cc9424b934ae31e6aebf7a960fca8d6ac82778f107a4b16a4e7865c8' + '0ade7802219389ec80969a934a95e577d4ed03ac705dcaf328c276731de3f7ab' + '4804d854bb9fb3e6ff11c23e420b6ff34266bbc93ce33115129bf838171d49ee' + 'a26997445938dd01a03a16a622d19adbc270e679df195407436c97246c96f99a' + '269fc7d93aeefc286009612604385ac2ec1d0304b97c858ffe123c282be8d94c' + '20743252b0f3ec2a1ba7bdfaa6f3164fc262a50b806ce38d77ee14d48b029ee1' + '059b2eff79cb071b45d7c9d054c9954df2f828ae84bb064a4fa04f27def8a4fd' + '1b3a27ea33b66efe3131dcb9951030aa7d4c18f9ec851e89a4582b69f8e673e7' + '60a6f06c9346fad616e1b204f610edae24ba1182bd803492899bd9fbc5c4b605' + '840cbf8fafa2cc230dd8a9f667dbad80d54ad573f929f9970252722b9183688b' + '75dee4296d425f9d090130b76efd0a8f25704650241e77f690e3898511e23efe' + '226625cf55d9cd6db68030c6b82943fb18a343ae763ab035cb55b4ac3ae3453f' + 'db13ff9d60ebac17e712609e6d7edfdc7301501116622320ea3cf2caf82af36d' + '253f3286e3c34d1da938b82671c73b9b3c8b8e484905a1d042bd8996274d0a34' + '65aff7e831f3bb4b37ed5d4db5dfa75ab6bd582d132dd197e658ccb699dbfac7' + 'f2a7b6dce11311e3d318d5729258935a520dcb7ce4dc879ecb1738a2f8bfe434' + '0a81aa7fd5fa0b511fda81ce3345f3199d3be1c83fc660f7f365ef4ede88f3f7' + '27122f9db1be8b1efbccd6ab263313aa66c97dfcd0acb9499434a1fa4ecbb2bd' + 'cef46c7e1afcaf9b6bacf723d5ae22f3f42045eb93bbd9bf5d2b1dba7638028a' + '4a5867faabf973e96e195427097f8d34b5e4776c3af9598e15c21957f366b9eb' + 'f33d70071a232a2a3930aa0a2b3f032ef6a17e07acc7412000ceb25bdd339ade' + '5c56aa13fd3f18bd4b327d8cd540ff7fd9e0145e6358d6330103938655d3dfd7' + 'ca3eea7fac20d160d9aa3a8e17c0b9ab169cfe16a685f78d2c4d1fd52f8f6784' + '5184144968a2e354bf6acf3a8c73c353fa705e3f9f5fe8d8cf7e82241eb74d85' + 'a55bd3b222d08dc6bb68d4e30ec3e544b303d93330131a310f3a2e20ca93f4b9' + '2b4e223aed8ec9df431806c54bd3df923dbd34805e311006aba3f62682eeca56' + '1cb05a1596b2ae3a5b9d8f51c1749150d2847a5c60f174ae52538902f38ec2d7' + '5d1a85e93b4c7626aa2cfa68201c2d93574647ab6ef0679d3ff4b4cc5c2ba042' + 'd06065357943599d515b7ea081da99981b68c4c6a9a5e6bb5e0f1019fea80104' + 'b323e44874873591b763b1926cac00d354323d32ff06941eefa415dbdb643cfb' + '26fe3548c0e3997aa09077a5f4d1b4152c98c6c6e7ed64e26557704cc4758f73' + '2b33a669fc281b69d6d3683402ea8d83a86f6bf625a14944d0ac553f414688d3' + 'f55377c77d7345c0064ef4de71303735af9af0fead1eb3dcd701feb7057a117c' + 'd817ee8eeb04450de6c313db4cde76cca92236e14b60fb0fdb30014250b76fdb' + 'a8d7416f819963fb7d2e6800d51d27f5fdc74d804d2b559528eb6867c9e3b88a' + 'a492d1366f130122e4e54bee722b65a3d8a2afb30768026e2922edec0d11c9e4' + '16ab24a074e2e06e6cee4bc06373b2b71e5d7990b71f60fa613a6e9bf55d6c12' + '3245dc7c2e65e15c981b5a9c6372210dae582e7c7dfee632ec92a40868f3a63b' + '168172f22ea13879b958179fee20d0b2d78136bc755501f108840a14a0b521f6' + 'd6aa0cbe43c023cf8ee742b4a1d4527f955193f86c39cc6d518707990e967180' + '84d2457f89057d1f4c48cfe85a1fe4f397eaa6a4f2dd0bad36beccf9dfdb5819' + '8fe0d9cb7b36faa27d2bb41661f4f9ea0298901d261c5daf702e29e97e46bd4c' + '7e2652a26a8e7198b9b6fd2bfd476c514362f347ba75b1dd014faac443266fd7' + '8ea5b335b10bfb4e492646902db043aee06c953941b3eca7fe24603a3238abf8' + 'a9977459a8e6c31f1643da7ede6ac7199dee96559d74188f5c9d3799787ac4fa' + '70b450a5af36b54aed3bbe8704a67a0a2d53e9e729d0f97d1dc1857b03635931' + '551047905350e113384f99e0e929e9381dc0a4ed514ca4ebe279dcdad798edce' + 'bf204c06af11615f00fa5aaecf0012b6993b0264f17ebffa47f9c558299a9a8a' + 'fc6164a90f0ca2a9341aaf4448b4334c3393459ca5cbad6d7149f8bcf70da5fe' + '181672743d9e2449064a1b18764fa400af5d3cd268098e7b7e5069d0b128caa2' + '6f2032347bb40e2ebe9b3a03062147ffa2f656d47c87821623c3b7d46dc15ddb' + '0218d68cb27f34ab0a7a21728f91cf0e91ab4becedc494bde48632f85adc1817' + '17bf1ea04f476ee66555bc4386ffbebfe6be6f75e67947b7f85511241ac46407' + '9e049d49f160fece88887f8e72366f63ba19dbc4d886f68a1c887e134eef5e21' + '0ded9e2792b95902d898aba91020103875f2987a9566b353f3e6988b08848f4a' + 'd3a0669c83e4df5d33606b4c3443d2c6c71b76cb4f6421d6d54ee630023be6c2' + 'a7fbf65a86889f95138360ca4dbd4e51de2e214384ee39740d9c6c381ff997d9' + 'ac0400fd7c9ceada1356fe4b7eae3892f35652f09f488b31fd011e0642d373a3' + '6f1a48380445406709ba5c6b4b9c6f0301ea645324feb429f3719dc29b8f28ff' + 'b2f4083ada35c18876edf38220d84ca757cf710bc5c2d80ee8b5083dc6c2609f' + '487c92837717975ad6c63fe2a1f8e8c5c9e0554e96000102d83c82f4a77fd9bd' + 'ef4c4e4eccf7178c2b4bee12d4b7ae45c83dd7f0e0708c9ad668d7da7746338e' + '6efc39323d14239f2a55576a8b3f32cb79eeefdd5881ba813493c14be2939f3c' + '005381222cfef42ccc21151845b6d43d25c861f35c2192e5e23c2a14df7938f0' + 'b6b3f8f2c809dc7ef43bc26306516edf4a5d1e038343ad8c7a45f666011c2e8b' + '717167e9ca5563e04103871a3e489dd1cef77a83c5c6d20e7bda6dced7f3fc42' + '07877afd83c941c125064bebea8bdf6f94c15b24ebceaf1e100c05a4f93d782b' + '7188e017a1efba4a87cb64a38b63ed2d8a469e2e74c3fd35b6538d5bc6e370e5') diff --git a/mingw-w64-python3.9/smoketests.py b/mingw-w64-python3.9/smoketests.py new file mode 100644 index 0000000000..e9c607e918 --- /dev/null +++ b/mingw-w64-python3.9/smoketests.py @@ -0,0 +1,132 @@ +#!/usr/bin/env python3 +# Copyright 2017 Christoph Reiter +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +"""The goal of this test suite is collect tests for update regressions +and to test msys2 related modifications like for path handling. +Feel free to extend. +""" + +import os +import unittest + +if "MSYSTEM" in os.environ: + SEP = "/" +else: + SEP = "\\" + + +class Tests(unittest.TestCase): + + def test_sep(self): + self.assertEqual(os.sep, SEP) + + def test_module_file_path(self): + import asyncio + import zlib + self.assertEqual(zlib.__file__, os.path.normpath(zlib.__file__)) + self.assertEqual(asyncio.__file__, os.path.normpath(asyncio.__file__)) + + def test_importlib_frozen_path_sep(self): + import importlib._bootstrap_external + self.assertEqual(importlib._bootstrap_external.path_sep, SEP) + + def test_os_commonpath(self): + self.assertEqual( + os.path.commonpath( + [os.path.join("C:", os.sep, "foo", "bar"), + os.path.join("C:", os.sep, "foo")]), + os.path.join("C:", os.sep, "foo")) + + def test_pathlib(self): + import pathlib + + p = pathlib.Path("foo") / pathlib.Path("foo") + self.assertEqual(str(p), os.path.normpath(p)) + + def test_modules_import(self): + import sqlite3 + import ssl + import ctypes + + def test_socket_inet_ntop(self): + import socket + self.assertTrue(hasattr(socket, "inet_ntop")) + + def test_socket_inet_pton(self): + import socket + self.assertTrue(hasattr(socket, "inet_pton")) + + def test_multiprocessing_queue(self): + from multiprocessing import Queue + Queue(0) + + def test_socket_timout_normal_error(self): + import urllib.request + from urllib.error import URLError + + try: + urllib.request.urlopen( + 'http://localhost', timeout=0.0001).close() + except URLError: + pass + + def test_threads(self): + from concurrent.futures import ThreadPoolExecutor + + with ThreadPoolExecutor(1) as pool: + for res in pool.map(lambda *x: None, range(10000)): + pass + + def test_sysconfig(self): + import sysconfig + # This should be able to execute without exceptions + sysconfig.get_config_vars() + + def test_sqlite_enable_load_extension(self): + # Make sure --enable-loadable-sqlite-extensions is used + import sqlite3 + self.assertTrue(sqlite3.Connection.enable_load_extension) + + def test_venv_creation(self): + import tempfile + import venv + import subprocess + import shutil + with tempfile.TemporaryDirectory() as tmp: + builder = venv.EnvBuilder() + builder.create(tmp) + assert os.path.exists(os.path.join(tmp, "bin", "activate")) + assert os.path.exists(os.path.join(tmp, "bin", "python.exe")) + assert os.path.exists(os.path.join(tmp, "bin", "python3.exe")) + subprocess.check_call([shutil.which("bash.exe"), os.path.join(tmp, "bin", "activate")]) + + def test_has_mktime(self): + from time import mktime, gmtime + mktime(gmtime()) + + +def suite(): + return unittest.TestLoader().loadTestsFromName(__name__) + + +if __name__ == '__main__': + unittest.main(defaultTest='suite')