From 8da033c9b96ec162b1e8a1da31d05ca9eb11ad45 Mon Sep 17 00:00:00 2001 From: Naveen M K Date: Mon, 5 Aug 2024 12:43:35 +0530 Subject: [PATCH] python3.12: new package --- mingw-w64-python3.12/.gitignore | 2 + ...g-make-_sysconfigdata.py-relocatable.patch | 57 ++ ...t-threads-and-make-it-default-on-min.patch | 290 ++++++++ ...S-and-others-when-compiling-with-MIN.patch | 72 ++ ...re-add-MACHDEP-and-platform-on-MINGW.patch | 61 ++ ...-Add-default-configuration-for-MINGW.patch | 87 +++ ...-largefile-support-by-default-for-Mi.patch | 34 + ...-to-CPPFLAGS-and-to-SRCDIRS-on-Mingw.patch | 44 ++ ...fine-necessary-headers-for-compiling.patch | 114 +++ ...-by-default-when-compiling-for-MINGW.patch | 77 ++ .../0010-pyport.h-Add-support-for-MINGW.patch | 64 ++ ...tions-so-that-shared-build-is-possib.patch | 59 ++ ...dd-dynamic-loading-support-for-MINGW.patch | 101 +++ ...-program-for-frozen-scripts-on-MINGW.patch | 49 ++ ...k2-and-setup-_socket-module-on-MINGW.patch | 161 +++++ ...Enable-some-windows-specific-modules.patch | 104 +++ ...nfig-MINGW-build-extensions-with-GCC.patch | 22 + ...g-treat-MINGW-builds-as-POSIX-builds.patch | 88 +++ ...pport-for-stdcall-without-underscore.patch | 53 ++ .../0019-Customize-site-for-MINGW.patch | 59 ++ .../0020-add-python-config-sh.patch | 159 ++++ ...x-sep-if-MSYSTEM-environment-variabl.patch | 459 ++++++++++++ ...s-cygwin-semi-native-build-sysconfig.patch | 123 ++++ ...sysconfig-mingw-sysconfig-like-posix.patch | 62 ++ ...ngw-use-backslashes-in-compileall-py.patch | 27 + .../0025-mingw-pdcurses_ISPAD.patch | 32 + .../0026-remove_path_max.default.patch | 26 + .../0027-dont-link-with-gettext.patch | 57 ++ .../0028-ctypes-python-dll.patch | 30 + .../0029-gdbm-module-includes.patch | 27 + .../0030-use-gnu_printf-in-format.patch | 82 +++ ...w-fix-ssl-dont-use-enum_certificates.patch | 36 + ...fix-using-dllhandle-and-winver-mingw.patch | 36 + ...-config-so-msvccompiler-get_build_ve.patch | 39 + ...4-MINGW-link-with-additional-library.patch | 30 + .../0035-install-msilib.patch | 27 + .../0036-fix-signal-module-build.patch | 27 + ...-build-winconsoleio-and-_testconsole.patch | 53 ++ .../0038-expose-sem_unlink.patch | 26 + .../0039-Use-cygpty-while-using-isatty.patch | 485 +++++++++++++ ...win-resource-files-and-build-pythonw.patch | 145 ++++ .../0041-fix-isselectable.patch | 26 + ...042-configure.ac-fix-inet_pton-check.patch | 32 + .../0043-pass-gen-profile-ldflags.patch | 26 + ...indows-must-link-ext-with-python-lib.patch | 23 + .../0045-importlib-bootstrap-path-sep.patch | 29 + .../0046-warnings-fixes.patch | 94 +++ .../0047-fix-build-testinternalcapi.patch | 22 + mingw-w64-python3.12/0048-clang-arm64.patch | 47 ++ ...configure.ac-set-MINGW-stack-reserve.patch | 25 + ...050-Don-t-use-os.pathsep-to-find-EOF.patch | 24 + ...ion-suffix-for-c-extensions-on-mingw.patch | 179 +++++ ...the-get_platform-method-in-sysconfig.patch | 61 ++ ...53-build-Fix-ncursesw-include-lookup.patch | 51 ++ .../0054-tests-fix-test_bytes.patch | 24 + ...e-not-raising-for-invalid-year-value.patch | 25 + ...brary-c-should-return-None-with-ucrt.patch | 38 + ...uild-Disable-checks-for-dlopen-dlfcn.patch | 64 ++ ...stall-location-of-the-import-library.patch | 22 + ...venvlauncher-build-installation-into.patch | 76 ++ ...onfigure.ac-set-_WIN32_WINNT-version.patch | 25 + ....ac-don-t-check-for-clock_-functions.patch | 33 + ...-normpath-paths-coming-from-env-vars.patch | 32 + ...ld-and-add-some-mingw-specific-tests.patch | 680 ++++++++++++++++++ ...0064-Define-PY3_DLLNAME-to-fix-build.patch | 26 + ...5-_testconsole.c-Fix-casing-path-sep.patch | 22 + ...t-architecture-markers-for-python-on.patch | 52 ++ ...sesw-pkg-config-when-cross-compiling.patch | 36 + ...mingw_smoketests-fix-_UCRT-condition.patch | 23 + ...-Modify-sys.winver-to-match-upstream.patch | 69 ++ ...-packages-path-to-include-the-enviro.patch | 119 +++ ...e-a-header-in-the-check-for-_beginth.patch | 33 + ...ault-to-without-c-locale-coercion-on.patch | 37 + .../0073-Fix-failing-tests.patch | 136 ++++ ...sep-with-an-empty-MSYSTEM-env-var-no.patch | 132 ++++ ...TH-when-compiling-Python-sysmodule.c.patch | 21 + .../0076-Make-_Py_CheckPython3-extern.patch | 38 + .../0077-link-with-bcrypt.patch | 22 + .../0078-correctly-find-native-python.patch | 27 + ...dd-extra-flags-for-_bootstrap_python.patch | 22 + ...80-posixmodule-undefine-HAVE_OPENDIR.patch | 31 + ...081-getpath.py-add-support-for-mingw.patch | 341 +++++++++ ...-t-build-_posixsubprocess-on-Windows.patch | 29 + .../0083-_ssl-link-with-ws2_32.patch | 22 + ...084-Always-normalize-path-in-abspath.patch | 22 + ...k.h-when-checking-for-netdb-function.patch | 46 ++ ...multiprocessing-semaphore.c-on-win32.patch | 24 + ...configure-build-mmap-module-on-win32.patch | 24 + .../0088-venv-creation-fixes.patch | 52 ++ ...n-function-where-winsock.h-is-includ.patch | 31 + ...figure.ac-set-BUILDEXEEXT-and-EXEEXT.patch | 32 + ...re.ac-fix-building-some-test-modules.patch | 53 ++ ...sconfig.get_config_var-VPATH-to-an-a.patch | 53 ++ ...o-before-passing-though-pathcch-func.patch | 102 +++ ...-venvlauncher.exe-from-PC-launcher.c.patch | 194 +++++ .../0095-getpath.py-fix-dirname.patch | 55 ++ ...-use-normpath-on-all-generated-paths.patch | 154 ++++ .../0097-pathconfig-normpath-sys.path-0.patch | 24 + ...ts-add-some-tests-for-sys-site-paths.patch | 43 ++ ...-on-paths-added-using-add_dll_direct.patch | 134 ++++ ...100-Build-and-install-libpython3.dll.patch | 108 +++ .../0101-Port-GetPythonImport-to-mingw.patch | 74 ++ ...ake-sure-to-only-use-backslashes-for.patch | 47 ++ ...-add-a-test-to-check-if-sysconfig-re.patch | 46 ++ ...g-library-for-multiprocessing-module.patch | 37 + ...5-selectmodule-add-support-for-MINGW.patch | 60 ++ .../0106-readline-disable-on-MINGW.patch | 21 + ...es-to-fix-compile-of-ctypes-on-MINGW.patch | 44 ++ ...lpython-version-while-linking-stdlib.patch | 41 ++ .../0109-Enable-_uuid-on-MINGW.patch | 37 + .../0110-Enable-curses-library-on-MINGW.patch | 28 + ...ests-disable-distutils-related-tests.patch | 56 ++ ...-skip-test_c_ext_build-for-in-tree-b.patch | 25 + .../0113-configure.ac-use-autoconf-2.69.patch | 23 + ...lose-writer-pipe-in-multiprocessing..patch | 67 ++ ...ix-tests-for-XMLPullParser-with-Expa.patch | 109 +++ .../0116-CI-clean-up-ignored-tests.patch | 258 +++++++ ...ncompatible-pointer-types-as-warning.patch | 48 ++ mingw-w64-python3.12/PKGBUILD | 522 ++++++++++++++ mingw-w64-python3.12/README.md | 4 + mingw-w64-python3.12/update-patches.sh | 81 +++ 121 files changed, 9261 insertions(+) create mode 100644 mingw-w64-python3.12/.gitignore create mode 100644 mingw-w64-python3.12/0001-sysconfig-make-_sysconfigdata.py-relocatable.patch create mode 100644 mingw-w64-python3.12/0002-build-add-with-nt-threads-and-make-it-default-on-min.patch create mode 100644 mingw-w64-python3.12/0003-Define-MS_WINDOWS-and-others-when-compiling-with-MIN.patch create mode 100644 mingw-w64-python3.12/0004-configure-add-MACHDEP-and-platform-on-MINGW.patch create mode 100644 mingw-w64-python3.12/0005-Add-default-configuration-for-MINGW.patch create mode 100644 mingw-w64-python3.12/0006-configure-enable-largefile-support-by-default-for-Mi.patch create mode 100644 mingw-w64-python3.12/0007-Add-PC-to-CPPFLAGS-and-to-SRCDIRS-on-Mingw.patch create mode 100644 mingw-w64-python3.12/0008-posixmodule.c-Define-necessary-headers-for-compiling.patch create mode 100644 mingw-w64-python3.12/0009-Build-winreg-by-default-when-compiling-for-MINGW.patch create mode 100644 mingw-w64-python3.12/0010-pyport.h-Add-support-for-MINGW.patch create mode 100644 mingw-w64-python3.12/0011-configure-add-options-so-that-shared-build-is-possib.patch create mode 100644 mingw-w64-python3.12/0012-Add-dynamic-loading-support-for-MINGW.patch create mode 100644 mingw-w64-python3.12/0013-Ignore-main-program-for-frozen-scripts-on-MINGW.patch create mode 100644 mingw-w64-python3.12/0014-Detect-winsock2-and-setup-_socket-module-on-MINGW.patch create mode 100644 mingw-w64-python3.12/0015-Enable-some-windows-specific-modules.patch create mode 100644 mingw-w64-python3.12/0016-sysconfig-MINGW-build-extensions-with-GCC.patch create mode 100644 mingw-w64-python3.12/0017-sysconfig-treat-MINGW-builds-as-POSIX-builds.patch create mode 100644 mingw-w64-python3.12/0018-Add-support-for-stdcall-without-underscore.patch create mode 100644 mingw-w64-python3.12/0019-Customize-site-for-MINGW.patch create mode 100644 mingw-w64-python3.12/0020-add-python-config-sh.patch create mode 100644 mingw-w64-python3.12/0021-mingw-prefer-unix-sep-if-MSYSTEM-environment-variabl.patch create mode 100644 mingw-w64-python3.12/0022-msys-cygwin-semi-native-build-sysconfig.patch create mode 100644 mingw-w64-python3.12/0023-sysconfig-mingw-sysconfig-like-posix.patch create mode 100644 mingw-w64-python3.12/0024-mingw-use-backslashes-in-compileall-py.patch create mode 100644 mingw-w64-python3.12/0025-mingw-pdcurses_ISPAD.patch create mode 100644 mingw-w64-python3.12/0026-remove_path_max.default.patch create mode 100644 mingw-w64-python3.12/0027-dont-link-with-gettext.patch create mode 100644 mingw-w64-python3.12/0028-ctypes-python-dll.patch create mode 100644 mingw-w64-python3.12/0029-gdbm-module-includes.patch create mode 100644 mingw-w64-python3.12/0030-use-gnu_printf-in-format.patch create mode 100644 mingw-w64-python3.12/0031-mingw-fix-ssl-dont-use-enum_certificates.patch create mode 100644 mingw-w64-python3.12/0032-fix-using-dllhandle-and-winver-mingw.patch create mode 100644 mingw-w64-python3.12/0033-Add-AMD64-to-sys-config-so-msvccompiler-get_build_ve.patch create mode 100644 mingw-w64-python3.12/0034-MINGW-link-with-additional-library.patch create mode 100644 mingw-w64-python3.12/0035-install-msilib.patch create mode 100644 mingw-w64-python3.12/0036-fix-signal-module-build.patch create mode 100644 mingw-w64-python3.12/0037-build-build-winconsoleio-and-_testconsole.patch create mode 100644 mingw-w64-python3.12/0038-expose-sem_unlink.patch create mode 100644 mingw-w64-python3.12/0039-Use-cygpty-while-using-isatty.patch create mode 100644 mingw-w64-python3.12/0040-build-link-win-resource-files-and-build-pythonw.patch create mode 100644 mingw-w64-python3.12/0041-fix-isselectable.patch create mode 100644 mingw-w64-python3.12/0042-configure.ac-fix-inet_pton-check.patch create mode 100644 mingw-w64-python3.12/0043-pass-gen-profile-ldflags.patch create mode 100644 mingw-w64-python3.12/0044-pkg-config-windows-must-link-ext-with-python-lib.patch create mode 100644 mingw-w64-python3.12/0045-importlib-bootstrap-path-sep.patch create mode 100644 mingw-w64-python3.12/0046-warnings-fixes.patch create mode 100644 mingw-w64-python3.12/0047-fix-build-testinternalcapi.patch create mode 100644 mingw-w64-python3.12/0048-clang-arm64.patch create mode 100644 mingw-w64-python3.12/0049-configure.ac-set-MINGW-stack-reserve.patch create mode 100644 mingw-w64-python3.12/0050-Don-t-use-os.pathsep-to-find-EOF.patch create mode 100644 mingw-w64-python3.12/0051-Fix-extension-suffix-for-c-extensions-on-mingw.patch create mode 100644 mingw-w64-python3.12/0052-Change-the-get_platform-method-in-sysconfig.patch create mode 100644 mingw-w64-python3.12/0053-build-Fix-ncursesw-include-lookup.patch create mode 100644 mingw-w64-python3.12/0054-tests-fix-test_bytes.patch create mode 100644 mingw-w64-python3.12/0055-time-fix-strftime-not-raising-for-invalid-year-value.patch create mode 100644 mingw-w64-python3.12/0056-ctypes-find_library-c-should-return-None-with-ucrt.patch create mode 100644 mingw-w64-python3.12/0057-build-Disable-checks-for-dlopen-dlfcn.patch create mode 100644 mingw-w64-python3.12/0058-Fix-install-location-of-the-import-library.patch create mode 100644 mingw-w64-python3.12/0059-build-Integrate-venvlauncher-build-installation-into.patch create mode 100644 mingw-w64-python3.12/0060-configure.ac-set-_WIN32_WINNT-version.patch create mode 100644 mingw-w64-python3.12/0061-configure.ac-don-t-check-for-clock_-functions.patch create mode 100644 mingw-w64-python3.12/0062-expanduser-normpath-paths-coming-from-env-vars.patch create mode 100644 mingw-w64-python3.12/0063-CI-test-the-build-and-add-some-mingw-specific-tests.patch create mode 100644 mingw-w64-python3.12/0064-Define-PY3_DLLNAME-to-fix-build.patch create mode 100644 mingw-w64-python3.12/0065-_testconsole.c-Fix-casing-path-sep.patch create mode 100644 mingw-w64-python3.12/0066-Return-consistent-architecture-markers-for-python-on.patch create mode 100644 mingw-w64-python3.12/0067-handle-ncursesw-pkg-config-when-cross-compiling.patch create mode 100644 mingw-w64-python3.12/0068-mingw_smoketests-fix-_UCRT-condition.patch create mode 100644 mingw-w64-python3.12/0069-Modify-sys.winver-to-match-upstream.patch create mode 100644 mingw-w64-python3.12/0070-Change-user-site-packages-path-to-include-the-enviro.patch create mode 100644 mingw-w64-python3.12/0071-configure-Include-a-header-in-the-check-for-_beginth.patch create mode 100644 mingw-w64-python3.12/0072-configure.ac-Default-to-without-c-locale-coercion-on.patch create mode 100644 mingw-w64-python3.12/0073-Fix-failing-tests.patch create mode 100644 mingw-w64-python3.12/0074-Don-t-change-os.sep-with-an-empty-MSYSTEM-env-var-no.patch create mode 100644 mingw-w64-python3.12/0075-def-VPATH-when-compiling-Python-sysmodule.c.patch create mode 100644 mingw-w64-python3.12/0076-Make-_Py_CheckPython3-extern.patch create mode 100644 mingw-w64-python3.12/0077-link-with-bcrypt.patch create mode 100644 mingw-w64-python3.12/0078-correctly-find-native-python.patch create mode 100644 mingw-w64-python3.12/0079-Add-extra-flags-for-_bootstrap_python.patch create mode 100644 mingw-w64-python3.12/0080-posixmodule-undefine-HAVE_OPENDIR.patch create mode 100644 mingw-w64-python3.12/0081-getpath.py-add-support-for-mingw.patch create mode 100644 mingw-w64-python3.12/0082-Don-t-build-_posixsubprocess-on-Windows.patch create mode 100644 mingw-w64-python3.12/0083-_ssl-link-with-ws2_32.patch create mode 100644 mingw-w64-python3.12/0084-Always-normalize-path-in-abspath.patch create mode 100644 mingw-w64-python3.12/0085-Include-winsock.h-when-checking-for-netdb-function.patch create mode 100644 mingw-w64-python3.12/0086-include-_multiprocessing-semaphore.c-on-win32.patch create mode 100644 mingw-w64-python3.12/0087-configure-build-mmap-module-on-win32.patch create mode 100644 mingw-w64-python3.12/0088-venv-creation-fixes.patch create mode 100644 mingw-w64-python3.12/0089-move-the-shutdown-function-where-winsock.h-is-includ.patch create mode 100644 mingw-w64-python3.12/0090-configure.ac-set-BUILDEXEEXT-and-EXEEXT.patch create mode 100644 mingw-w64-python3.12/0091-configure.ac-fix-building-some-test-modules.patch create mode 100644 mingw-w64-python3.12/0092-Don-t-convert-sysconfig.get_config_var-VPATH-to-an-a.patch create mode 100644 mingw-w64-python3.12/0093-Always-convert-to-before-passing-though-pathcch-func.patch create mode 100644 mingw-w64-python3.12/0094-Build-venvlauncher.exe-from-PC-launcher.c.patch create mode 100644 mingw-w64-python3.12/0095-getpath.py-fix-dirname.patch create mode 100644 mingw-w64-python3.12/0096-getpath-use-normpath-on-all-generated-paths.patch create mode 100644 mingw-w64-python3.12/0097-pathconfig-normpath-sys.path-0.patch create mode 100644 mingw-w64-python3.12/0098-smoketests-add-some-tests-for-sys-site-paths.patch create mode 100644 mingw-w64-python3.12/0099-Search-DLLs-only-on-paths-added-using-add_dll_direct.patch create mode 100644 mingw-w64-python3.12/0100-Build-and-install-libpython3.dll.patch create mode 100644 mingw-w64-python3.12/0101-Port-GetPythonImport-to-mingw.patch create mode 100644 mingw-w64-python3.12/0102-LoadLibraryExW-make-sure-to-only-use-backslashes-for.patch create mode 100644 mingw-w64-python3.12/0103-mingw_smoketests-add-a-test-to-check-if-sysconfig-re.patch create mode 100644 mingw-w64-python3.12/0104-Add-missing-library-for-multiprocessing-module.patch create mode 100644 mingw-w64-python3.12/0105-selectmodule-add-support-for-MINGW.patch create mode 100644 mingw-w64-python3.12/0106-readline-disable-on-MINGW.patch create mode 100644 mingw-w64-python3.12/0107-Add-libraries-to-fix-compile-of-ctypes-on-MINGW.patch create mode 100644 mingw-w64-python3.12/0108-Add-lpython-version-while-linking-stdlib.patch create mode 100644 mingw-w64-python3.12/0109-Enable-_uuid-on-MINGW.patch create mode 100644 mingw-w64-python3.12/0110-Enable-curses-library-on-MINGW.patch create mode 100644 mingw-w64-python3.12/0111-mingw_smoketests-disable-distutils-related-tests.patch create mode 100644 mingw-w64-python3.12/0112-mingw_smoketests-skip-test_c_ext_build-for-in-tree-b.patch create mode 100644 mingw-w64-python3.12/0113-configure.ac-use-autoconf-2.69.patch create mode 100644 mingw-w64-python3.12/0114-3.12-gh-114440-Close-writer-pipe-in-multiprocessing..patch create mode 100644 mingw-w64-python3.12/0115-3.12-gh-115133-Fix-tests-for-XMLPullParser-with-Expa.patch create mode 100644 mingw-w64-python3.12/0116-CI-clean-up-ignored-tests.patch create mode 100644 mingw-w64-python3.12/0117-gcc-make-incompatible-pointer-types-as-warning.patch create mode 100644 mingw-w64-python3.12/PKGBUILD create mode 100644 mingw-w64-python3.12/README.md create mode 100644 mingw-w64-python3.12/update-patches.sh diff --git a/mingw-w64-python3.12/.gitignore b/mingw-w64-python3.12/.gitignore new file mode 100644 index 0000000000..90fadbd318 --- /dev/null +++ b/mingw-w64-python3.12/.gitignore @@ -0,0 +1,2 @@ +cpython/ + diff --git a/mingw-w64-python3.12/0001-sysconfig-make-_sysconfigdata.py-relocatable.patch b/mingw-w64-python3.12/0001-sysconfig-make-_sysconfigdata.py-relocatable.patch new file mode 100644 index 0000000000..c77bcc5efc --- /dev/null +++ b/mingw-w64-python3.12/0001-sysconfig-make-_sysconfigdata.py-relocatable.patch @@ -0,0 +1,57 @@ +From b9c69bf57cd419396c4bf6c566c556303421ada4 Mon Sep 17 00:00:00 2001 +From: Ray Donnelly +Date: Thu, 17 Jun 2021 18:51:10 +0530 +Subject: [PATCH 001/N] sysconfig: make _sysconfigdata.py relocatable +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Co-authored-by: Алексей +Co-authored-by: lovetox <8661218+lovetox@users.noreply.github.com> +--- + Lib/sysconfig.py | 20 ++++++++++++++++++++ + 1 file changed, 20 insertions(+) + +diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py +index 122d441..8122a7a 100644 +--- a/Lib/sysconfig.py ++++ b/Lib/sysconfig.py +@@ -2,6 +2,7 @@ + + import os + import sys ++import textwrap + import threading + from os.path import realpath + +@@ -519,11 +520,30 @@ def _generate_posix_vars(): + 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', ++ 'TZPATH', ++ ] ++ ++ 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.base_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.12/0002-build-add-with-nt-threads-and-make-it-default-on-min.patch b/mingw-w64-python3.12/0002-build-add-with-nt-threads-and-make-it-default-on-min.patch new file mode 100644 index 0000000000..c2b9899264 --- /dev/null +++ b/mingw-w64-python3.12/0002-build-add-with-nt-threads-and-make-it-default-on-min.patch @@ -0,0 +1,290 @@ +From c349719ad44b2b32e41822cf758b67a4b98765be Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?= + +Date: Thu, 17 Jun 2021 18:51:12 +0530 +Subject: [PATCH 002/N] build: add --with-nt-threads and make it default on + mingw +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Co-authored-by: Naveen M K +Co-authored-by: Алексей +Co-authored-by: Christoph Reiter +--- + Include/internal/pycore_condvar.h | 10 ++ + Include/pythread.h | 6 ++ + Modules/_multiprocessing/multiprocessing.h | 5 +- + configure.ac | 102 ++++++++++++++++++++- + pyconfig.h.in | 3 + + 5 files changed, 122 insertions(+), 4 deletions(-) + +diff --git a/Include/internal/pycore_condvar.h b/Include/internal/pycore_condvar.h +index 981c962..ed9e6a7 100644 +--- a/Include/internal/pycore_condvar.h ++++ b/Include/internal/pycore_condvar.h +@@ -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 +@@ -39,6 +45,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 --git a/Include/pythread.h b/Include/pythread.h +index 6371443..5e84e3c 100644 +--- a/Include/pythread.h ++++ b/Include/pythread.h +@@ -7,6 +7,12 @@ typedef void *PyThread_type_lock; + 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/Modules/_multiprocessing/multiprocessing.h b/Modules/_multiprocessing/multiprocessing.h +index dfc2a8e..dc92a23 100644 +--- a/Modules/_multiprocessing/multiprocessing.h ++++ b/Modules/_multiprocessing/multiprocessing.h +@@ -23,7 +23,10 @@ + # endif + # define SEM_HANDLE HANDLE + # define SEM_VALUE_MAX LONG_MAX +-# define HAVE_MP_SEMAPHORE ++# define HAVE_MP_SEMAPHORE ++# 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 --git a/configure.ac b/configure.ac +index bd2be94..2979f2a 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -2689,6 +2689,53 @@ then + 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 --with-nt-threads]) ++AC_ARG_WITH(nt-threads, ++ AS_HELP_STRING([--with-nt-threads], [build with windows threads (default is system-dependent)]), ++[ ++ case $withval in ++ no) with_nt_threads=no;; ++ yes) with_nt_threads=yes;; ++ *) with_nt_threads=yes;; ++ esac ++], [ ++ case $host in ++ *-*-mingw*) with_nt_threads=yes;; ++ *) with_nt_threads=no;; ++ esac ++]) ++AC_MSG_RESULT([$with_nt_threads]) ++ ++if test $with_nt_threads = yes ; then ++AC_MSG_CHECKING([whether linking with nt-threads work]) ++AC_LINK_IFELSE([ ++ AC_LANG_PROGRAM([[]],[[_beginthread(0, 0, 0);]]) ++ ], ++ [AC_MSG_RESULT([yes])], ++ [AC_MSG_ERROR([failed to link with nt-threads])]) ++fi ++ ++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). +@@ -2800,6 +2847,8 @@ int main(void){ + CC="$ac_save_cc"]) + fi + ++fi ++ + # If we have set a CC compiler flag for thread support then + # check if it works for CXX, too. + if test ! -z "$CXX" +@@ -2819,6 +2868,10 @@ elif test "$ac_cv_pthread" = "yes" + 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 + else + ac_cv_cxx_thread=no + fi +@@ -2860,8 +2913,8 @@ AC_CHECK_HEADERS([ \ + alloca.h asm/types.h bluetooth.h conio.h crypt.h direct.h dlfcn.h endian.h errno.h fcntl.h grp.h \ + ieeefp.h io.h langinfo.h libintl.h libutil.h linux/auxvec.h sys/auxv.h linux/fs.h linux/limits.h linux/memfd.h \ + linux/random.h linux/soundcard.h \ +- linux/tipc.h linux/wait.h netdb.h net/ethernet.h netinet/in.h netpacket/packet.h poll.h process.h pthread.h pty.h \ +- sched.h setjmp.h shadow.h signal.h spawn.h stropts.h sys/audioio.h sys/bsdtty.h sys/devpoll.h \ ++ linux/tipc.h linux/wait.h netdb.h net/ethernet.h netinet/in.h netpacket/packet.h poll.h process.h pty.h \ ++ setjmp.h shadow.h signal.h spawn.h stropts.h sys/audioio.h sys/bsdtty.h sys/devpoll.h \ + sys/endian.h sys/epoll.h sys/event.h sys/eventfd.h sys/file.h sys/ioctl.h sys/kern_control.h \ + sys/loadavg.h sys/lock.h sys/memfd.h sys/mkdev.h sys/mman.h sys/modem.h sys/param.h sys/poll.h \ + sys/random.h sys/resource.h sys/select.h sys/sendfile.h sys/socket.h sys/soundcard.h sys/stat.h \ +@@ -2872,6 +2925,14 @@ AC_CHECK_HEADERS([ \ + 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 +@@ -3084,6 +3145,10 @@ elif test "$ac_cv_pthread" = "yes" + then CC="$CC -pthread" + fi + ++if test $with_nt_threads = yes ; then ++ dnl skip check for pthread_t if NT-thread model is enabled ++ ac_cv_have_pthread_t=skip ++else + AC_CACHE_CHECK([for pthread_t], [ac_cv_have_pthread_t], [ + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[@%:@include ]], [[pthread_t x; x = *(pthread_t*)0;]]) +@@ -3115,7 +3180,7 @@ AS_VAR_IF([ac_cv_pthread_key_t_is_arithmetic_type], [yes], [ + AC_DEFINE([PTHREAD_KEY_T_IS_COMPATIBLE_WITH_INT], [1], + [Define if pthread_key_t is compatible with int.]) + ]) +- ++fi + CC="$ac_save_cc" + + AC_MSG_CHECKING([for --enable-framework]) +@@ -3629,10 +3694,15 @@ AS_VAR_IF([have_uuid], [missing], [ + + AS_VAR_IF([have_uuid], [missing], [have_uuid=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], +@@ -4352,6 +4422,11 @@ then + 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" +@@ -4868,6 +4943,15 @@ else + 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([ \ + accept4 alarm bind_textdomain_codeset chmod chown clock close_range confstr \ + copy_file_range ctermid dup dup3 execv explicit_bzero explicit_memset \ +@@ -5763,6 +5847,10 @@ dnl actually works. For FreeBSD versions <= 7.2, + dnl the kernel module that provides POSIX semaphores + dnl isn't loaded by default, so an attempt to call + dnl 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_CACHE_CHECK([whether POSIX semaphores are enabled], [ac_cv_posix_semaphores_enabled], + AC_RUN_IFELSE([ + AC_LANG_SOURCE([ +@@ -5796,6 +5884,14 @@ AS_VAR_IF([ac_cv_posix_semaphores_enabled], [no], [ + ]) + + dnl Multiprocessing check 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_CHECK([for broken sem_getvalue], [ac_cv_broken_sem_getvalue], + AC_RUN_IFELSE([ + AC_LANG_SOURCE([ +diff --git a/pyconfig.h.in b/pyconfig.h.in +index 6d370f6..0321d25 100644 +--- a/pyconfig.h.in ++++ b/pyconfig.h.in +@@ -1553,6 +1553,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.12/0003-Define-MS_WINDOWS-and-others-when-compiling-with-MIN.patch b/mingw-w64-python3.12/0003-Define-MS_WINDOWS-and-others-when-compiling-with-MIN.patch new file mode 100644 index 0000000000..e2e53c4208 --- /dev/null +++ b/mingw-w64-python3.12/0003-Define-MS_WINDOWS-and-others-when-compiling-with-MIN.patch @@ -0,0 +1,72 @@ +From 54c49640c27b4f838fe30aee43041a3be79ecd5c Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?= + +Date: Thu, 17 Jun 2021 18:51:13 +0530 +Subject: [PATCH 003/N] Define `MS_WINDOWS` (and others) when compiling with + MINGW +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This is used throughout the Python code but is not defined +when compiling with Mingw-w64 compilers, so define it. +In MSVC these are defined in PC/pyconfig.h, we have to +define it manually because pyconfig.h is created by +autotools. + +Co-authored-by: Алексей +Co-authored-by: Christoph Reiter +Co-authored-by: Naveen M K +--- + Include/pyport.h | 38 ++++++++++++++++++++++++++++++++++++++ + 1 file changed, 38 insertions(+) + +diff --git a/Include/pyport.h b/Include/pyport.h +index 35eca72..82e848e 100644 +--- a/Include/pyport.h ++++ b/Include/pyport.h +@@ -53,6 +53,44 @@ + #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 ++ ++#if defined(Py_BUILD_CORE) || defined(Py_BUILD_CORE_BUILTIN) || defined(Py_BUILD_CORE_MODULE) ++#include ++ ++#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) ++#define MS_WINDOWS_DESKTOP ++#endif ++#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) ++#define MS_WINDOWS_APP ++#endif ++#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_SYSTEM) ++#define MS_WINDOWS_SYSTEM ++#endif ++#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_GAMES) ++#define MS_WINDOWS_GAMES ++#endif ++ ++/* Define to 1 if you support windows console io */ ++#if defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_APP) || defined(MS_WINDOWS_SYSTEM) ++#define HAVE_WINDOWS_CONSOLE_IO 1 ++#endif ++#endif /* Py_BUILD_CORE || Py_BUILD_CORE_BUILTIN || Py_BUILD_CORE_MODULE */ ++ ++#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.12/0004-configure-add-MACHDEP-and-platform-on-MINGW.patch b/mingw-w64-python3.12/0004-configure-add-MACHDEP-and-platform-on-MINGW.patch new file mode 100644 index 0000000000..f1137038fa --- /dev/null +++ b/mingw-w64-python3.12/0004-configure-add-MACHDEP-and-platform-on-MINGW.patch @@ -0,0 +1,61 @@ +From 4f7786cbf80ab351640db780bca57829dbc00419 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?= + +Date: Thu, 17 Jun 2021 18:51:14 +0530 +Subject: [PATCH 004/N] configure: add `MACHDEP` and `platform` on MINGW +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Co-authored-by: Алексей +--- + configure.ac | 15 +++++++++++++++ + 1 file changed, 15 insertions(+) + +diff --git a/configure.ac b/configure.ac +index 2979f2a..aa28593 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -550,6 +550,9 @@ then + *-*-cygwin*) + ac_sys_system=Cygwin + ;; ++ *-*-mingw*) ++ ac_sys_system=MINGW ++ ;; + *-*-vxworks*) + ac_sys_system=VxWorks + ;; +@@ -585,6 +588,7 @@ then + linux*) MACHDEP="linux";; + cygwin*) MACHDEP="cygwin";; + darwin*) MACHDEP="darwin";; ++ mingw*) MACHDEP="win32";; + '') MACHDEP="unknown";; + esac + +@@ -618,6 +622,9 @@ if test "$cross_compiling" = yes; then + ;; + wasm32-*-* | wasm64-*-*) + _host_cpu=$host_cpu ++ ;; ++ *-*-mingw*) ++ _host_cpu= + ;; + *) + # for now, limit cross builds to known configurations +@@ -625,6 +632,14 @@ if test "$cross_compiling" = yes; then + 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 --git a/mingw-w64-python3.12/0005-Add-default-configuration-for-MINGW.patch b/mingw-w64-python3.12/0005-Add-default-configuration-for-MINGW.patch new file mode 100644 index 0000000000..82dbf95333 --- /dev/null +++ b/mingw-w64-python3.12/0005-Add-default-configuration-for-MINGW.patch @@ -0,0 +1,87 @@ +From 0c2a00c27aa730a861db559b8d4271ff03993c4b Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?= + +Date: Thu, 17 Jun 2021 18:51:15 +0530 +Subject: [PATCH 005/N] Add default configuration for MINGW +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Co-authored-by: Алексей +Co-authored-by: Christoph Reiter +--- + Misc/config_mingw | 12 ++++++++++++ + Misc/cross_mingw32 | 11 +++++++++++ + configure.ac | 22 ++++++++++++++++++++++ + 3 files changed, 45 insertions(+) + create mode 100644 Misc/config_mingw + create mode 100644 Misc/cross_mingw32 + +diff --git a/Misc/config_mingw b/Misc/config_mingw +new file mode 100644 +index 0000000..513065d +--- /dev/null ++++ b/Misc/config_mingw +@@ -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 --git a/Misc/cross_mingw32 b/Misc/cross_mingw32 +new file mode 100644 +index 0000000..03fde9e +--- /dev/null ++++ b/Misc/cross_mingw32 +@@ -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/configure.ac b/configure.ac +index aa28593..e214b00 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -1205,6 +1205,28 @@ AC_CACHE_CHECK([for -Wl,--no-as-needed], [ac_cv_wl_no_as_needed], [ + ]) + AC_SUBST([NO_AS_NEEDED]) + ++# 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 the Android API level]) + cat > conftest.c < +Date: Thu, 17 Jun 2021 18:51:16 +0530 +Subject: [PATCH 006/N] configure: enable largefile support by default for + Mingw +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Largefile is supported on Windows. + +Co-authored-by: Naveen M K +Co-authored-by: Алексей +Co-authored-by: Christoph Reiter +--- + configure.ac | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/configure.ac b/configure.ac +index e214b00..16c7164 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -3152,6 +3152,10 @@ dnl LFS does not work with Emscripten 3.1 + AS_CASE([$ac_sys_system], + [Emscripten], [have_largefile_support="no"] + ) ++dnl Activate on windows platforms (32&64-bit) where off_t(4) < fpos_t(8) ++AS_CASE([$ac_sys_system], ++ [MINGW], [have_largefile_support="yes"] ++) + AS_VAR_IF([have_largefile_support], [yes], [ + AC_DEFINE([HAVE_LARGEFILE_SUPPORT], [1], + [Defined to enable large file support when an off_t is bigger than a long diff --git a/mingw-w64-python3.12/0007-Add-PC-to-CPPFLAGS-and-to-SRCDIRS-on-Mingw.patch b/mingw-w64-python3.12/0007-Add-PC-to-CPPFLAGS-and-to-SRCDIRS-on-Mingw.patch new file mode 100644 index 0000000000..38fbc1d698 --- /dev/null +++ b/mingw-w64-python3.12/0007-Add-PC-to-CPPFLAGS-and-to-SRCDIRS-on-Mingw.patch @@ -0,0 +1,44 @@ +From 37424ab3b952ded46011f744b709ce44a281fa5d Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?= + +Date: Thu, 17 Jun 2021 18:51:18 +0530 +Subject: [PATCH 007/N] Add `PC/` to `CPPFLAGS` and to `SRCDIRS` on Mingw + +Co-authored-by: Naveen M K +--- + configure.ac | 15 +++++++++++++++ + 1 file changed, 15 insertions(+) + +diff --git a/configure.ac b/configure.ac +index 16c7164..a3904b3 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -6862,6 +6862,16 @@ do + 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="\ + Modules \ +@@ -6884,6 +6894,11 @@ SRCDIRS="\ + Python \ + Python/frozen_modules \ + Python/deepfreeze" ++ ++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.12/0008-posixmodule.c-Define-necessary-headers-for-compiling.patch b/mingw-w64-python3.12/0008-posixmodule.c-Define-necessary-headers-for-compiling.patch new file mode 100644 index 0000000000..0abaef6d60 --- /dev/null +++ b/mingw-w64-python3.12/0008-posixmodule.c-Define-necessary-headers-for-compiling.patch @@ -0,0 +1,114 @@ +From 63c64473df6079c92cf5548a0560303db0f2f22c Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?= + +Date: Thu, 17 Jun 2021 18:51:19 +0530 +Subject: [PATCH 008/N] posixmodule.c: Define necessary headers for compiling + on MINGW +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Also, build `nt` module instead of `posix` when compiling +with MINGW. + +Co-authored-by: Naveen M K +Co-authored-by: Алексей +--- + Modules/Setup.bootstrap.in | 2 +- + Modules/posixmodule.c | 28 ++++++++++++++++++++++++---- + configure.ac | 8 ++++++++ + 3 files changed, 33 insertions(+), 5 deletions(-) + +diff --git a/Modules/Setup.bootstrap.in b/Modules/Setup.bootstrap.in +index 8ef0f20..1f21d35 100644 +--- a/Modules/Setup.bootstrap.in ++++ b/Modules/Setup.bootstrap.in +@@ -8,7 +8,7 @@ + # module C APIs are used in core + atexit atexitmodule.c + faulthandler faulthandler.c +-posix posixmodule.c ++@INITSYS@ posixmodule.c + _signal signalmodule.c + _tracemalloc _tracemalloc.c + +diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c +index 0ac5a8d..0d6bb01 100644 +--- a/Modules/posixmodule.c ++++ b/Modules/posixmodule.c +@@ -361,6 +361,26 @@ corresponding Unix manual entries for more information on calls."); + # define HAVE_PIPE 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 ++# ifndef _MAX_ENV ++# define _MAX_ENV 32767 ++# endif + #endif /* ! __WATCOMC__ || __QNX__ */ + + /*[clinic input] +@@ -438,7 +458,7 @@ extern char *ctermid_r(char *); + # endif + #endif + +-#ifdef _MSC_VER ++#ifdef MS_WINDOWS + # ifdef HAVE_DIRECT_H + # include + # endif +@@ -449,7 +469,7 @@ extern char *ctermid_r(char *); + # include + # endif + # include +-#endif /* _MSC_VER */ ++#endif /* MS_WINDOWS */ + + #ifndef MAXPATHLEN + # if defined(PATH_MAX) && PATH_MAX > 1024 +@@ -1536,9 +1556,9 @@ _Py_Sigset_Converter(PyObject *obj, void *addr) + ** 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 --git a/configure.ac b/configure.ac +index a3904b3..9372127 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -755,6 +755,14 @@ then + [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 diff --git a/mingw-w64-python3.12/0009-Build-winreg-by-default-when-compiling-for-MINGW.patch b/mingw-w64-python3.12/0009-Build-winreg-by-default-when-compiling-for-MINGW.patch new file mode 100644 index 0000000000..38029d7987 --- /dev/null +++ b/mingw-w64-python3.12/0009-Build-winreg-by-default-when-compiling-for-MINGW.patch @@ -0,0 +1,77 @@ +From 6ae67a8b1f0df130fc9e29db25e7c5ec2b30eaac Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?= + +Date: Thu, 17 Jun 2021 18:51:20 +0530 +Subject: [PATCH 009/N] Build winreg by default when compiling for MINGW +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Co-authored-by: Алексей +Co-authored-by: Christoph Reiter +Co-authored-by: Naveen M K +--- + Modules/Setup.bootstrap.in | 3 +++ + PC/winreg.c | 19 +++++++++++++++++++ + configure.ac | 7 +++++++ + 3 files changed, 29 insertions(+) + +diff --git a/Modules/Setup.bootstrap.in b/Modules/Setup.bootstrap.in +index 1f21d35..3def7e8 100644 +--- a/Modules/Setup.bootstrap.in ++++ b/Modules/Setup.bootstrap.in +@@ -34,3 +34,6 @@ _symtable symtablemodule.c + + # for systems without $HOME env, used by site._getuserbase() + @MODULE_PWD_TRUE@pwd pwdmodule.c ++ ++# build-in modules for windows platform: ++@USE_WIN32_MODULE@winreg ../PC/winreg.c +diff --git a/PC/winreg.c b/PC/winreg.c +index e2d5322..368291d 100644 +--- a/PC/winreg.c ++++ b/PC/winreg.c +@@ -19,6 +19,25 @@ + #include "structmember.h" // PyMemberDef + #include + ++#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 ++ + #if defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) || defined(MS_WINDOWS_GAMES) + + typedef struct { +diff --git a/configure.ac b/configure.ac +index 9372127..5a936ea 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -4437,6 +4437,13 @@ done + IFS=$as_save_IFS + AC_MSG_RESULT([$DBM_CFLAGS $DBM_LIBS]) + ++# 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 --git a/mingw-w64-python3.12/0010-pyport.h-Add-support-for-MINGW.patch b/mingw-w64-python3.12/0010-pyport.h-Add-support-for-MINGW.patch new file mode 100644 index 0000000000..0620272da3 --- /dev/null +++ b/mingw-w64-python3.12/0010-pyport.h-Add-support-for-MINGW.patch @@ -0,0 +1,64 @@ +From e64166a220e620d1f8f96ea674ed2e2961cc8fa9 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?= + +Date: Thu, 17 Jun 2021 18:51:23 +0530 +Subject: [PATCH 010/N] pyport.h: Add support for MINGW +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Co-authored-by: Алексей +--- + Include/pyport.h | 20 +++++++++++--------- + 1 file changed, 11 insertions(+), 9 deletions(-) + +diff --git a/Include/pyport.h b/Include/pyport.h +index 82e848e..b7f3e66 100644 +--- a/Include/pyport.h ++++ b/Include/pyport.h +@@ -532,12 +532,12 @@ extern char * _getpty(int *, int, mode_t, int); + */ + + /* +- 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 + +@@ -550,21 +550,23 @@ extern char * _getpty(int *, int, mode_t, int); + # 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 --git a/mingw-w64-python3.12/0011-configure-add-options-so-that-shared-build-is-possib.patch b/mingw-w64-python3.12/0011-configure-add-options-so-that-shared-build-is-possib.patch new file mode 100644 index 0000000000..0c6e1233d3 --- /dev/null +++ b/mingw-w64-python3.12/0011-configure-add-options-so-that-shared-build-is-possib.patch @@ -0,0 +1,59 @@ +From 175caef177d1d8c2a86160fbb8c51b8158d7bf1b Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?= + +Date: Thu, 17 Jun 2021 18:51:24 +0530 +Subject: [PATCH 011/N] configure: add options so that shared build is + possible on MINGW + +Co-authored-by: Naveen M K +--- + configure.ac | 15 ++++++++++++++- + 1 file changed, 14 insertions(+), 1 deletion(-) + +diff --git a/configure.ac b/configure.ac +index 5a936ea..1eb61be 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -1549,6 +1549,11 @@ if test $enable_shared = "yes"; then + LDLIBRARY='libpython$(LDVERSION).dll.a' + DLLLIBRARY='libpython$(LDVERSION).dll' + ;; ++ MINGW*) ++ LDLIBRARY='libpython$(LDVERSION).dll.a' ++ DLLLIBRARY='libpython$(LDVERSION).dll' ++ BLDLIBRARY='-L. -lpython$(LDVERSION)' ++ ;; + SunOS*) + LDLIBRARY='libpython$(LDVERSION).so' + BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(LDVERSION)' +@@ -1599,6 +1604,9 @@ else # shared is disabled + BLDLIBRARY='$(LIBRARY)' + LDLIBRARY='libpython$(LDVERSION).dll.a' + ;; ++ MINGW*) ++ LDLIBRARY='libpython$(LDVERSION).a' ++ ;; + esac + fi + +@@ -3495,6 +3503,10 @@ then + CYGWIN*) + LDSHARED="gcc -shared -Wl,--enable-auto-image-base" + LDCXXSHARED="g++ -shared -Wl,--enable-auto-image-base";; ++ MINGW*) ++ LDSHARED='$(CC) -shared -Wl,--enable-auto-image-base' ++ LDCXXSHARED='$(CXX) -shared -Wl,--enable-auto-image-base' ++ ;; + *) LDSHARED="ld";; + esac + fi +@@ -6883,7 +6895,8 @@ case $host in + 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.12/0012-Add-dynamic-loading-support-for-MINGW.patch b/mingw-w64-python3.12/0012-Add-dynamic-loading-support-for-MINGW.patch new file mode 100644 index 0000000000..ce6dd111e0 --- /dev/null +++ b/mingw-w64-python3.12/0012-Add-dynamic-loading-support-for-MINGW.patch @@ -0,0 +1,101 @@ +From 7d2d590da71ea6ef2be339ef5b43238859bc5bcf Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?= + +Date: Thu, 17 Jun 2021 18:51:25 +0530 +Subject: [PATCH 012/N] Add dynamic loading support for MINGW +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Co-authored-by: Алексей +--- + Makefile.pre.in | 6 ++++++ + Python/dynload_win.c | 9 +++++++-- + configure.ac | 16 ++++++++++++++++ + 3 files changed, 29 insertions(+), 2 deletions(-) + +diff --git a/Makefile.pre.in b/Makefile.pre.in +index 7af1845..664e270 100644 +--- a/Makefile.pre.in ++++ b/Makefile.pre.in +@@ -1374,6 +1374,12 @@ Python/dynload_hpux.o: $(srcdir)/Python/dynload_hpux.c Makefile + -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 --git a/Python/dynload_win.c b/Python/dynload_win.c +index acab05e..4bb90ba 100644 +--- a/Python/dynload_win.c ++++ b/Python/dynload_win.c +@@ -29,6 +29,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 +@@ -251,8 +257,7 @@ dl_funcptr _PyImport_FindSharedFuncptrWindows(const char *prefix, + 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 + PyMem_Free(wpathname); + +diff --git a/configure.ac b/configure.ac +index 1eb61be..c5446af 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -3374,6 +3374,9 @@ if test -z "$SHLIB_SUFFIX"; then + CYGWIN*) SHLIB_SUFFIX=.dll;; + *) SHLIB_SUFFIX=.so;; + esac ++ case $host_os in ++ mingw*) SHLIB_SUFFIX=.dll;; ++ esac + fi + AC_MSG_RESULT([$SHLIB_SUFFIX]) + +@@ -4986,6 +4989,13 @@ then + fi + ;; + esac ++ case $host in ++ *-*-mingw*) ++ DYNLOADFILE="dynload_win.o" ++ extra_machdep_objs="$extra_machdep_objs PC/dl_nt.o" ++ CFLAGS_NODIST="$CFLAGS_NODIST -DMS_DLL_ID='\"$VERSION\"'" ++ ;; ++ esac + fi + AC_MSG_RESULT([$DYNLOADFILE]) + if test "$DYNLOADFILE" != "dynload_stub.o" +@@ -6874,6 +6884,12 @@ case "$ac_cv_computed_gotos" in yes*) + AC_DEFINE([HAVE_COMPUTED_GOTOS], [1], + [Define if the C compiler supports computed gotos.]) + 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 + + case $ac_sys_system in + AIX*) diff --git a/mingw-w64-python3.12/0013-Ignore-main-program-for-frozen-scripts-on-MINGW.patch b/mingw-w64-python3.12/0013-Ignore-main-program-for-frozen-scripts-on-MINGW.patch new file mode 100644 index 0000000000..dede25718f --- /dev/null +++ b/mingw-w64-python3.12/0013-Ignore-main-program-for-frozen-scripts-on-MINGW.patch @@ -0,0 +1,49 @@ +From 2cef9a90220147f25ba63e97482d258f61cda395 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?= + +Date: Thu, 17 Jun 2021 18:51:26 +0530 +Subject: [PATCH 013/N] Ignore main program for frozen scripts on MINGW +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Co-authored-by: Алексей +--- + Makefile.pre.in | 2 +- + configure.ac | 10 ++++++++++ + 2 files changed, 11 insertions(+), 1 deletion(-) + +diff --git a/Makefile.pre.in b/Makefile.pre.in +index 664e270..d16afef 100644 +--- a/Makefile.pre.in ++++ b/Makefile.pre.in +@@ -383,7 +383,7 @@ PYTHON_OBJS= \ + Python/errors.o \ + Python/flowgraph.o \ + Python/frame.o \ +- Python/frozenmain.o \ ++ @PYTHON_OBJS_FROZENMAIN@ \ + Python/future.o \ + Python/getargs.o \ + Python/getcompiler.o \ +diff --git a/configure.ac b/configure.ac +index c5446af..fe251c4 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -6916,6 +6916,16 @@ case $host in + ;; + 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="\ + Modules \ diff --git a/mingw-w64-python3.12/0014-Detect-winsock2-and-setup-_socket-module-on-MINGW.patch b/mingw-w64-python3.12/0014-Detect-winsock2-and-setup-_socket-module-on-MINGW.patch new file mode 100644 index 0000000000..781f1af0a8 --- /dev/null +++ b/mingw-w64-python3.12/0014-Detect-winsock2-and-setup-_socket-module-on-MINGW.patch @@ -0,0 +1,161 @@ +From 1da317ac6e345b84c424d2d4aa3c049d4fad5f6d Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?= + +Date: Thu, 17 Jun 2021 18:51:30 +0530 +Subject: [PATCH 014/N] Detect winsock2 and setup _socket module on MINGW +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Co-authored-by: Алексей +Co-authored-by: Naveen M K +--- + Misc/config_mingw | 3 +++ + Modules/socketmodule.c | 6 ++++++ + configure.ac | 38 ++++++++++++++++++++++++++++++++------ + pyconfig.h.in | 4 ++-- + 4 files changed, 43 insertions(+), 8 deletions(-) + +diff --git a/Misc/config_mingw b/Misc/config_mingw +index 513065d..9be43fd 100644 +--- a/Misc/config_mingw ++++ b/Misc/config_mingw +@@ -10,3 +10,6 @@ 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 ++ ++# force detection of winsock2 functionality - require wxp or newer ++ac_cv_func_getpeername=yes +diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c +index de7229d..4b521ca 100644 +--- a/Modules/socketmodule.c ++++ b/Modules/socketmodule.c +@@ -282,6 +282,7 @@ shutdown(how) -- shut down traffic in one or both directions\n\ + # include + + /* Macros based on the IPPROTO enum, see: https://bugs.python.org/issue29515 */ ++#ifdef _MSC_VER + #define IPPROTO_ICMP IPPROTO_ICMP + #define IPPROTO_IGMP IPPROTO_IGMP + #define IPPROTO_GGP IPPROTO_GGP +@@ -312,6 +313,7 @@ shutdown(how) -- shut down traffic in one or both directions\n\ + #define IPPROTO_PGM IPPROTO_PGM // WinSock2 only + #define IPPROTO_L2TP IPPROTO_L2TP // WinSock2 only + #define IPPROTO_SCTP IPPROTO_SCTP // WinSock2 only ++#endif /* _MSC_VER */ + + /* Provides the IsWindows7SP1OrGreater() function */ + #include +@@ -426,6 +428,10 @@ remove_unusable_flags(PyObject *m) + /* 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 --git a/configure.ac b/configure.ac +index fe251c4..e193452 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -4138,6 +4138,12 @@ AS_CASE([$ac_sys_system], + [OSSAUDIODEV_LIBS=""] + ) + ++dnl On MINGW, you need to link against ws2_32 and iphlpapi for sockets to work ++AS_CASE([$MACHDEP], ++ [win32], [SOCKET_LIBS="-lws2_32 -liphlpapi -lrpcrt4"], ++ [SOCKET_LIBS=""] ++) ++ + dnl detect sqlite3 from Emscripten emport + PY_CHECK_EMSCRIPTEN_PORT([LIBSQLITE3], [-sUSE_SQLITE3]) + +@@ -5598,18 +5604,33 @@ if test $ac_cv_header_time_altzone = yes; then + [Define this if your time.h defines altzone.]) + fi + ++AC_CHECK_HEADERS([ws2tcpip.h]) + AC_CACHE_CHECK([for addrinfo], [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])) + 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_CACHE_CHECK([for sockaddr_storage], [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])) + if test $ac_cv_struct_sockaddr_storage = yes; then +@@ -6804,8 +6825,11 @@ 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 +@@ -7601,7 +7625,9 @@ PY_STDLIB_MOD([mmap], + PY_STDLIB_MOD([_socket], + [], m4_flatten([test "$ac_cv_header_sys_socket_h" = "yes" + -a "$ac_cv_header_sys_types_h" = "yes" +- -a "$ac_cv_header_netinet_in_h" = "yes"])) ++ -a "$ac_cv_header_netinet_in_h" = "yes" ++ -o "$MACHDEP" = "win32"]), ++ [], [$SOCKET_LIBS]) + + dnl platform specific extensions + PY_STDLIB_MOD([grp], [], [test "$ac_cv_func_getgrgid" = yes -o "$ac_cv_func_getgrgid_r" = yes]) +diff --git a/pyconfig.h.in b/pyconfig.h.in +index 0321d25..fc5200c 100644 +--- a/pyconfig.h.in ++++ b/pyconfig.h.in +@@ -63,7 +63,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. */ +@@ -1927,7 +1927,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 --git a/mingw-w64-python3.12/0015-Enable-some-windows-specific-modules.patch b/mingw-w64-python3.12/0015-Enable-some-windows-specific-modules.patch new file mode 100644 index 0000000000..71d7dbd11c --- /dev/null +++ b/mingw-w64-python3.12/0015-Enable-some-windows-specific-modules.patch @@ -0,0 +1,104 @@ +From d53eb47f222dfe154720f67e4560c6b756c69cb7 Mon Sep 17 00:00:00 2001 +From: Naveen M K +Date: Tue, 14 Feb 2023 20:40:42 +0530 +Subject: [PATCH 015/N] Enable some windows specific modules + +--- + Modules/Setup.bootstrap.in | 2 ++ + Modules/Setup.stdlib.in | 7 +++++++ + Modules/_winapi.c | 2 ++ + PC/msvcrtmodule.c | 2 ++ + Python/dynamic_annotations.c | 2 +- + configure.ac | 10 ++++++++++ + 6 files changed, 24 insertions(+), 1 deletion(-) + +diff --git a/Modules/Setup.bootstrap.in b/Modules/Setup.bootstrap.in +index 3def7e8..d8b41ee 100644 +--- a/Modules/Setup.bootstrap.in ++++ b/Modules/Setup.bootstrap.in +@@ -37,3 +37,5 @@ _symtable symtablemodule.c + + # build-in modules for windows platform: + @USE_WIN32_MODULE@winreg ../PC/winreg.c ++@MODULE_MSVCRT_TRUE@msvcrt -DPy_BUILD_CORE ../PC/msvcrtmodule.c ++@MODULE__WINAPI_TRUE@_winapi _winapi.c +diff --git a/Modules/Setup.stdlib.in b/Modules/Setup.stdlib.in +index 3360805..202a55e 100644 +--- a/Modules/Setup.stdlib.in ++++ b/Modules/Setup.stdlib.in +@@ -160,6 +160,13 @@ + # _scproxy needs SystemConfiguration and CoreFoundation framework + @MODULE__SCPROXY_TRUE@_scproxy _scproxy.c + ++############################################################################ ++# Windows specific modules ++ ++@MODULE__OVERLAPPED_TRUE@_overlapped overlapped.c ++@MODULE__MSI_TRUE@_msi ../PC/_msi.c ++@MODULE_WINSOUND_TRUE@winsound ../PC/winsound.c ++ + + ############################################################################ + # Test modules +diff --git a/Modules/_winapi.c b/Modules/_winapi.c +index 7727540..fda1171 100644 +--- a/Modules/_winapi.c ++++ b/Modules/_winapi.c +@@ -44,7 +44,9 @@ + #endif + #include "windows.h" + #include ++#if defined(Py_DEBUG) + #include ++#endif + #include "winreparse.h" + + #if defined(MS_WIN32) && !defined(MS_WIN64) +diff --git a/PC/msvcrtmodule.c b/PC/msvcrtmodule.c +index 53ef26b..10cf782 100644 +--- a/PC/msvcrtmodule.c ++++ b/PC/msvcrtmodule.c +@@ -22,7 +22,9 @@ + #include + #include + #include ++#ifdef _DEBUG + #include ++#endif + #include + + #ifdef _MSC_VER +diff --git a/Python/dynamic_annotations.c b/Python/dynamic_annotations.c +index 7febaa0..70d5b3d 100644 +--- a/Python/dynamic_annotations.c ++++ b/Python/dynamic_annotations.c +@@ -27,7 +27,7 @@ + * Author: Kostya Serebryany + */ + +-#ifdef _MSC_VER ++#ifdef MS_WINDOWS + # include + #endif + +diff --git a/configure.ac b/configure.ac +index e193452..f1bcf82 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -7727,6 +7727,16 @@ PY_STDLIB_MOD([_ssl], [], [test "$ac_cv_working_openssl_ssl" = yes], + PY_STDLIB_MOD([_hashlib], [], [test "$ac_cv_working_openssl_hashlib" = yes], + [$OPENSSL_INCLUDES], [$OPENSSL_LDFLAGS $OPENSSL_LDFLAGS_RPATH $LIBCRYPTO_LIBS]) + ++dnl windows specific modules ++PY_STDLIB_MOD([msvcrt], [test "$MACHDEP" = "win32"]) ++PY_STDLIB_MOD([_winapi], [test "$MACHDEP" = "win32"]) ++PY_STDLIB_MOD([_msi], [test "$MACHDEP" = "win32"], [], [], ++ [-lmsi -lcabinet -lrpcrt4]) ++PY_STDLIB_MOD([winsound], [test "$MACHDEP" = "win32"], [], [], ++ [-lwinmm]) ++PY_STDLIB_MOD([_overlapped], [test "$MACHDEP" = "win32"], [], [], ++ [-lws2_32]) ++ + dnl test modules + PY_STDLIB_MOD([_testcapi], [test "$TEST_MODULES" = yes]) + PY_STDLIB_MOD([_testclinic], [test "$TEST_MODULES" = yes]) diff --git a/mingw-w64-python3.12/0016-sysconfig-MINGW-build-extensions-with-GCC.patch b/mingw-w64-python3.12/0016-sysconfig-MINGW-build-extensions-with-GCC.patch new file mode 100644 index 0000000000..1c1d667968 --- /dev/null +++ b/mingw-w64-python3.12/0016-sysconfig-MINGW-build-extensions-with-GCC.patch @@ -0,0 +1,22 @@ +From 10149a78b035a7d41391aed4d8f4ddf46e592b85 Mon Sep 17 00:00:00 2001 +From: Christoph Reiter +Date: Tue, 21 Sep 2021 20:52:42 +0200 +Subject: [PATCH 016/N] sysconfig: MINGW build extensions with GCC + +--- + Lib/sysconfig.py | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py +index 8122a7a..3710a83 100644 +--- a/Lib/sysconfig.py ++++ b/Lib/sysconfig.py +@@ -782,6 +782,8 @@ def get_platform(): + + """ + 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.12/0017-sysconfig-treat-MINGW-builds-as-POSIX-builds.patch b/mingw-w64-python3.12/0017-sysconfig-treat-MINGW-builds-as-POSIX-builds.patch new file mode 100644 index 0000000000..bb8bfc2150 --- /dev/null +++ b/mingw-w64-python3.12/0017-sysconfig-treat-MINGW-builds-as-POSIX-builds.patch @@ -0,0 +1,88 @@ +From 77e7dad5d1dca5e397855159593fbe4e99fccbbb Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?= + +Date: Thu, 17 Jun 2021 18:51:38 +0530 +Subject: [PATCH 017/N] sysconfig: treat MINGW builds as POSIX builds +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Co-authored-by: Алексей +Co-authored-by: Naveen M K +--- + Lib/sysconfig.py | 19 ++++++++++++------- + 1 file changed, 12 insertions(+), 7 deletions(-) + +diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py +index 3710a83..ce900b3 100644 +--- a/Lib/sysconfig.py ++++ b/Lib/sysconfig.py +@@ -99,13 +99,18 @@ + }, + } + ++# GCC[mingw*] use posix build system ++_POSIX_BUILD = os.name == 'posix' or \ ++ (os.name == "nt" and 'GCC' in sys.version) ++ + # For the OS-native venv scheme, we essentially provide an alias: +-if os.name == 'nt': ++if os.name == 'nt' and not _POSIX_BUILD: + _INSTALL_SCHEMES['venv'] = _INSTALL_SCHEMES['nt_venv'] + else: + _INSTALL_SCHEMES['venv'] = _INSTALL_SCHEMES['posix_venv'] + + ++ + # NOTE: site.py has copy of this function. + # Sync it when modify this function. + def _getuserbase(): +@@ -120,7 +125,7 @@ def _getuserbase(): + 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") + +@@ -283,7 +288,7 @@ def _expand_vars(scheme, vars): + + + def _get_preferred_schemes(): +- if os.name == 'nt': ++ if os.name == 'nt' and not _POSIX_BUILD: + return { + 'prefix': 'nt', + 'home': 'posix_home', +@@ -617,7 +622,7 @@ def parse_config_h(fp, vars=None): + 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(_PROJECT_BASE, "PC") + else: + inc_dir = _PROJECT_BASE +@@ -683,10 +688,10 @@ def _init_config_vars(): + except AttributeError: + _CONFIG_VARS['py_version_nodot_plat'] = '' + +- if os.name == 'nt': ++ if os.name == 'nt' and not _POSIX_BUILD: + _init_non_posix(_CONFIG_VARS) + _CONFIG_VARS['VPATH'] = sys._vpath +- if os.name == 'posix': ++ if _POSIX_BUILD: + _init_posix(_CONFIG_VARS) + if _HAS_USER_BASE: + # Setting 'userbase' is done below the call to the +@@ -696,7 +701,7 @@ def _init_config_vars(): + + # 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.12/0018-Add-support-for-stdcall-without-underscore.patch b/mingw-w64-python3.12/0018-Add-support-for-stdcall-without-underscore.patch new file mode 100644 index 0000000000..3f86577027 --- /dev/null +++ b/mingw-w64-python3.12/0018-Add-support-for-stdcall-without-underscore.patch @@ -0,0 +1,53 @@ +From c7c28e844ca553ab0724e344440fb90b7e851b90 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?= + +Date: Thu, 17 Jun 2021 18:51:39 +0530 +Subject: [PATCH 018/N] Add support for stdcall without underscore +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This is the case used in MINGW + +Co-authored-by: Алексей +--- + Modules/_ctypes/_ctypes.c | 19 +++++++++++++++++++ + 1 file changed, 19 insertions(+) + +diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c +index 534ef8c..28f921c 100644 +--- a/Modules/_ctypes/_ctypes.c ++++ b/Modules/_ctypes/_ctypes.c +@@ -3378,6 +3378,18 @@ static PPROC FindAddress(void *handle, const char *name, PyObject *type) + 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 +@@ -3385,6 +3397,13 @@ static PPROC FindAddress(void *handle, const char *name, PyObject *type) + 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; + } + return NULL; + #endif diff --git a/mingw-w64-python3.12/0019-Customize-site-for-MINGW.patch b/mingw-w64-python3.12/0019-Customize-site-for-MINGW.patch new file mode 100644 index 0000000000..4139cc9656 --- /dev/null +++ b/mingw-w64-python3.12/0019-Customize-site-for-MINGW.patch @@ -0,0 +1,59 @@ +From 206bdd2be7d602d9651aeaddefb523ad6c59e1cf Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?= + +Date: Thu, 17 Jun 2021 18:51:42 +0530 +Subject: [PATCH 019/N] Customize site for MINGW +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Co-authored-by: Алексей +Co-authored-by: Christoph Reiter +--- + Lib/site.py | 12 +++++++++--- + 1 file changed, 9 insertions(+), 3 deletions(-) + +diff --git a/Lib/site.py b/Lib/site.py +index 672fa7b..4cbb55c 100644 +--- a/Lib/site.py ++++ b/Lib/site.py +@@ -88,6 +88,12 @@ + USER_BASE = None + + ++# Same as defined in Lib/sysconfig.py ++# redeclared since sysconfig is large for site. ++# GCC[mingw*] use posix build system ++_POSIX_BUILD = os.name == 'posix' or \ ++ (os.name == "nt" and 'GCC' in sys.version) ++ + def _trace(message): + if sys.flags.verbose: + print(message, file=sys.stderr) +@@ -273,7 +279,7 @@ def _getuserbase(): + 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") + +@@ -288,7 +294,7 @@ def joinuser(*args): + def _get_path(userbase): + version = sys.version_info + +- if os.name == 'nt': ++ if os.name == 'nt' and not _POSIX_BUILD: + ver_nodot = sys.winver.replace('.', '') + return f'{userbase}\\Python{ver_nodot}\\site-packages' + +@@ -361,7 +367,7 @@ def getsitepackages(prefixes=None): + continue + seen.add(prefix) + +- if os.sep == '/': ++ if _POSIX_BUILD: + libdirs = [sys.platlibdir] + if sys.platlibdir != "lib": + libdirs.append("lib") diff --git a/mingw-w64-python3.12/0020-add-python-config-sh.patch b/mingw-w64-python3.12/0020-add-python-config-sh.patch new file mode 100644 index 0000000000..108b83a1c2 --- /dev/null +++ b/mingw-w64-python3.12/0020-add-python-config-sh.patch @@ -0,0 +1,159 @@ +From be03be6923079d83a11c2c2580c3d3ec4295cb88 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?= + +Date: Thu, 17 Jun 2021 18:51:43 +0530 +Subject: [PATCH 020/N] add python config sh +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Co-authored-by: Алексей +Co-authored-by: Christoph Reiter +--- + Misc/python-config.sh.in | 62 +++++++++++++++++++++++++--------------- + 1 file changed, 39 insertions(+), 23 deletions(-) + +diff --git a/Misc/python-config.sh.in b/Misc/python-config.sh.in +index 2602fe2..e0e048a 100644 +--- a/Misc/python-config.sh.in ++++ b/Misc/python-config.sh.in +@@ -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 @@ LIBM="@LIBM@" + 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 @@ for ARG in $* + do + case $ARG in + --help) +- exit_with_usage 0 ++ exit_with_usage + ;; + --embed) + PY_EMBED=1 +@@ -69,7 +85,7 @@ do + --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--abiflags|--configdir) + ;; + *) +- exit_with_usage 1 ++ exit_with_usage + ;; + esac + done +@@ -80,37 +96,37 @@ fi + + 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.12/0021-mingw-prefer-unix-sep-if-MSYSTEM-environment-variabl.patch b/mingw-w64-python3.12/0021-mingw-prefer-unix-sep-if-MSYSTEM-environment-variabl.patch new file mode 100644 index 0000000000..77e28a2612 --- /dev/null +++ b/mingw-w64-python3.12/0021-mingw-prefer-unix-sep-if-MSYSTEM-environment-variabl.patch @@ -0,0 +1,459 @@ +From 216a7fef504bb563903b7426977e519d9dc63c22 Mon Sep 17 00:00:00 2001 +From: Ray Donnelly +Date: Thu, 17 Jun 2021 18:51:46 +0530 +Subject: [PATCH 021/N] mingw: prefer unix sep if MSYSTEM environment + variable +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Co-authored-by: Алексей +Co-authored-by: Christoph Reiter +Co-authored-by: cat +Co-authored-by: Naveen M K +--- + Include/pylifecycle.h | 6 ++ + Lib/ntpath.py | 106 ++++++++++++++++++--------------- + Modules/posixmodule.c | 2 + + Python/initconfig.c | 2 +- + Python/pathconfig.c | 135 ++++++++++++++++++++++++++++++++++++++++++ + Python/traceback.c | 2 +- + 6 files changed, 203 insertions(+), 50 deletions(-) + +diff --git a/Include/pylifecycle.h b/Include/pylifecycle.h +index e4c3b09..50d8b76 100644 +--- a/Include/pylifecycle.h ++++ b/Include/pylifecycle.h +@@ -21,6 +21,12 @@ PyAPI_FUNC(int) Py_IsInitialized(void); + 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 --git a/Lib/ntpath.py b/Lib/ntpath.py +index df3402d..ce683b1 100644 +--- a/Lib/ntpath.py ++++ b/Lib/ntpath.py +@@ -11,9 +11,7 @@ + curdir = '.' + pardir = '..' + extsep = '.' +-sep = '\\' + pathsep = ';' +-altsep = '/' + defpath = '.;C:\\bin' + devnull = 'nul' + +@@ -23,6 +21,14 @@ + 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","splitroot","split","splitext", + "basename","dirname","commonprefix","getsize","getmtime", +@@ -34,9 +40,33 @@ + + 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 '\\/' ++ 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 ':' ++ ++def _get_unc_prefix(path): ++ if isinstance(path, bytes): ++ return b'\\\\?\\UNC\\' ++ else: ++ return '\\\\?\\UNC\\' + + # Normalize the case of a pathname and map slashes to backslashes. + # Other normalizations (such as optimizing '../' away) are not done +@@ -58,14 +88,14 @@ def normcase(s): + return s + if isinstance(s, bytes): + encoding = sys.getfilesystemencoding() +- s = s.decode(encoding, 'surrogateescape').replace('/', '\\') ++ s = s.decode(encoding, 'surrogateescape').replace(altsep, sep) + s = _LCMapStringEx(_LOCALE_NAME_INVARIANT, + _LCMAP_LOWERCASE, s) + return s.encode(encoding, 'surrogateescape') + else: + return _LCMapStringEx(_LOCALE_NAME_INVARIANT, + _LCMAP_LOWERCASE, +- s.replace('/', '\\')) ++ s.replace(altsep, sep)) + except ImportError: + def normcase(s): + """Normalize case of pathname. +@@ -74,8 +104,8 @@ def normcase(s): + """ + s = os.fspath(s) + if isinstance(s, bytes): +- return os.fsencode(os.fsdecode(s).replace('/', '\\').lower()) +- return s.replace('/', '\\').lower() ++ return os.fsencode(os.fsdecode(s).replace(altsep, sep).lower()) ++ return s.replace(altsep, sep).lower() + + + # Return whether a path is absolute. +@@ -87,14 +117,9 @@ def normcase(s): + def isabs(s): + """Test whether a path is absolute""" + s = os.fspath(s) +- if isinstance(s, bytes): +- sep = b'\\' +- altsep = b'/' +- colon_sep = b':\\' +- else: +- sep = '\\' +- altsep = '/' +- colon_sep = ':\\' ++ sep = _get_sep(s) ++ altsep = _get_altsep(s) ++ colon_sep = _get_colon(s) + sep + s = s[:3].replace(altsep, sep) + # Absolute: UNC, device, and paths with a drive and root. + # LEGACY BUG: isabs("/x") should be false since the path has no drive. +@@ -106,14 +131,9 @@ def isabs(s): + # 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. +@@ -188,18 +208,12 @@ def splitroot(p): + splitroot('Windows/notepad') == ('', '', 'Windows/notepad') + """ + p = os.fspath(p) +- if isinstance(p, bytes): +- sep = b'\\' +- altsep = b'/' +- colon = b':' +- unc_prefix = b'\\\\?\\UNC\\' +- empty = b'' +- else: +- sep = '\\' +- altsep = '/' +- colon = ':' +- unc_prefix = '\\\\?\\UNC\\' +- empty = '' ++ sep = _get_sep(p) ++ altsep = _get_altsep(p) ++ colon = _get_colon(p) ++ unc_prefix = _get_unc_prefix(p) ++ empty = b'' if isinstance(p, bytes) else '' ++ + normp = p.replace(altsep, sep) + if normp[:1] == sep: + if normp[1:2] == sep: +@@ -257,9 +271,9 @@ def split(p): + 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__ + + +@@ -527,14 +541,12 @@ def expandvars(path): + 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'..' + else: +- sep = '\\' +- altsep = '/' + curdir = '.' + pardir = '..' + path = path.replace(altsep, sep) +@@ -757,6 +769,7 @@ def realpath(path, *, strict=False): + # strip the prefix anyway. + if ex.winerror == initial_winerror: + path = spath ++ path = normpath(path) + return path + + +@@ -766,12 +779,11 @@ def realpath(path, *, strict=False): + 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 = '..' + +@@ -826,13 +838,11 @@ def commonpath(paths): + 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 --git a/Modules/posixmodule.c b/Modules/posixmodule.c +index 0d6bb01..6cde737 100644 +--- a/Modules/posixmodule.c ++++ b/Modules/posixmodule.c +@@ -3926,6 +3926,7 @@ posix_getcwd(int use_bytes) + return NULL; + } + ++ Py_NormalizeSepsW(wbuf2); + PyObject *resobj = PyUnicode_FromWideChar(wbuf2, len); + if (wbuf2 != wbuf) { + PyMem_RawFree(wbuf2); +@@ -4810,6 +4811,7 @@ os__getfinalpathname_impl(PyObject *module, path_t *path) + 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 --git a/Python/initconfig.c b/Python/initconfig.c +index 4e5d4bb..a52d11e 100644 +--- a/Python/initconfig.c ++++ b/Python/initconfig.c +@@ -188,7 +188,7 @@ static const char usage_envvars[] = + "PYTHONVERBOSE : trace import statements (-v)\n" + "PYTHONWARNINGS=arg : warning control (-W arg)\n"; + +-#if defined(MS_WINDOWS) ++#if defined(_MSC_VER) + # define PYTHONHOMEHELP "\\python{major}{minor}" + #else + # define PYTHONHOMEHELP "/lib/pythonX.X" +diff --git a/Python/pathconfig.c b/Python/pathconfig.c +index be0f97c..3d684d6 100644 +--- a/Python/pathconfig.c ++++ b/Python/pathconfig.c +@@ -18,6 +18,140 @@ + extern "C" { + #endif + ++#ifdef __MINGW32__ ++#define wcstok wcstok_s ++#include ++#endif ++ ++static int ++Py_StartsWithA(const char * str, const char * prefix) ++{ ++ while(*prefix) ++ { ++ if(*prefix++ != *str++) ++ return 0; ++ } ++ ++ return 1; ++} ++ ++static int ++Py_StartsWithW(const wchar_t * str, const wchar_t * prefix) ++{ ++ while(*prefix) ++ { ++ if(*prefix++ != *str++) ++ return 0; ++ } ++ ++ return 1; ++} ++ ++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 && Py_StartsWithA(name, "\\\\?\\") != 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) ++{ ++ assert(name != NULL); ++ char sep = Py_GetSepA(name); ++ char altsep = Py_GetAltSepA(name); ++ char* seps; ++ if (name[0] != '\0' && 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 && Py_StartsWithW(name, L"\\\\?\\") != 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) ++{ ++ assert(name != NULL); ++ wchar_t sep = Py_GetSepW(name); ++ wchar_t altsep = Py_GetAltSepW(name); ++ wchar_t* seps; ++ if (name[0] != L'\0' && name[1] == L':') { ++ name[0] = towupper(name[0]); ++ } ++ seps = wcschr(name, altsep); ++ while(seps) { ++ *seps = sep; ++ seps = wcschr(seps, altsep); ++ } ++} + + /* External interface */ + +@@ -317,6 +451,7 @@ _Py_SetProgramFullPath(const wchar_t *program_full_path) + if (has_value && _Py_path_config.program_full_path == NULL) { + path_out_of_memory(__func__); + } ++ Py_NormalizeSepsW(_Py_path_config.program_name); + } + + +diff --git a/Python/traceback.c b/Python/traceback.c +index fdaf19d..74c9c45 100644 +--- a/Python/traceback.c ++++ b/Python/traceback.c +@@ -341,7 +341,7 @@ _Py_FindSourceFile(PyObject *filename, char* namebuf, size_t namelen, PyObject * + 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.12/0022-msys-cygwin-semi-native-build-sysconfig.patch b/mingw-w64-python3.12/0022-msys-cygwin-semi-native-build-sysconfig.patch new file mode 100644 index 0000000000..6a5ccbf921 --- /dev/null +++ b/mingw-w64-python3.12/0022-msys-cygwin-semi-native-build-sysconfig.patch @@ -0,0 +1,123 @@ +From 894a6d30cbddb7de34b72d6427269ec01280a688 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?= + +Date: Thu, 17 Jun 2021 18:51:50 +0530 +Subject: [PATCH 022/N] msys cygwin semi native build sysconfig +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Co-authored-by: Алексей +--- + Lib/sysconfig.py | 8 +++++++ + Makefile.pre.in | 7 ++++++ + configure.ac | 59 ++++++++++++++++++++++++++++++++++++++++++++++++ + 3 files changed, 74 insertions(+) + +diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py +index ce900b3..19fa25a 100644 +--- a/Lib/sysconfig.py ++++ b/Lib/sysconfig.py +@@ -446,6 +446,14 @@ def _parse_makefile(filename, vars=None, keep_unresolved=True): + 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 --git a/Makefile.pre.in b/Makefile.pre.in +index d16afef..b5c0c41 100644 +--- a/Makefile.pre.in ++++ b/Makefile.pre.in +@@ -142,6 +142,13 @@ exec_prefix= @exec_prefix@ + # 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/configure.ac b/configure.ac +index f1bcf82..ceab383 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -755,6 +755,65 @@ then + [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 --git a/mingw-w64-python3.12/0023-sysconfig-mingw-sysconfig-like-posix.patch b/mingw-w64-python3.12/0023-sysconfig-mingw-sysconfig-like-posix.patch new file mode 100644 index 0000000000..01e63bce11 --- /dev/null +++ b/mingw-w64-python3.12/0023-sysconfig-mingw-sysconfig-like-posix.patch @@ -0,0 +1,62 @@ +From f932c3d21ae13bd00139d0579eed9149e2fdf763 Mon Sep 17 00:00:00 2001 +From: Christoph Reiter +Date: Tue, 21 Sep 2021 20:53:59 +0200 +Subject: [PATCH 023/N] sysconfig: mingw sysconfig like posix + +--- + Lib/sysconfig.py | 28 ++++++++++++++-------------- + 1 file changed, 14 insertions(+), 14 deletions(-) + +diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py +index 19fa25a..08efb9b 100644 +--- a/Lib/sysconfig.py ++++ b/Lib/sysconfig.py +@@ -49,13 +49,13 @@ + '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}/site-packages', ++ 'platlib': '{base}/lib/python{py_version_short}/site-packages', ++ 'include': '{installed_base}/include/python{py_version_short}', ++ 'platinclude': '{installed_base}/include/python{py_version_short}', ++ 'scripts': '{base}/bin', + 'data': '{base}', + }, + # Downstream distributors can overwrite the default install scheme. +@@ -141,12 +141,12 @@ def joinuser(*args): + _INSTALL_SCHEMES |= { + # NOTE: When modifying "purelib" scheme, update site._get_path() too. + 'nt_user': { +- 'stdlib': '{userbase}/Python{py_version_nodot_plat}', +- 'platstdlib': '{userbase}/Python{py_version_nodot_plat}', +- 'purelib': '{userbase}/Python{py_version_nodot_plat}/site-packages', +- 'platlib': '{userbase}/Python{py_version_nodot_plat}/site-packages', +- 'include': '{userbase}/Python{py_version_nodot_plat}/Include', +- 'scripts': '{userbase}/Python{py_version_nodot_plat}/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': { +@@ -584,7 +584,7 @@ def _init_non_posix(vars): + except IndexError: + pass + vars['EXE'] = '.exe' +- vars['VERSION'] = _PY_VERSION_SHORT_NO_DOT ++ vars['VERSION'] = _PY_VERSION_SHORT + vars['BINDIR'] = os.path.dirname(_safe_realpath(sys.executable)) + vars['TZPATH'] = '' + diff --git a/mingw-w64-python3.12/0024-mingw-use-backslashes-in-compileall-py.patch b/mingw-w64-python3.12/0024-mingw-use-backslashes-in-compileall-py.patch new file mode 100644 index 0000000000..77534510b0 --- /dev/null +++ b/mingw-w64-python3.12/0024-mingw-use-backslashes-in-compileall-py.patch @@ -0,0 +1,27 @@ +From f6b5ccaebb9a7008218165db5f2b8e05f97ed432 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?= + +Date: Thu, 17 Jun 2021 18:51:53 +0530 +Subject: [PATCH 024/N] mingw use backslashes in compileall py +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Co-authored-by: Алексей +--- + Lib/compileall.py | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/Lib/compileall.py b/Lib/compileall.py +index d394156..ef3633e 100644 +--- a/Lib/compileall.py ++++ b/Lib/compileall.py +@@ -38,6 +38,8 @@ def _walk_dir(dir, maxlevels, quiet=0): + 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.12/0025-mingw-pdcurses_ISPAD.patch b/mingw-w64-python3.12/0025-mingw-pdcurses_ISPAD.patch new file mode 100644 index 0000000000..55c809358c --- /dev/null +++ b/mingw-w64-python3.12/0025-mingw-pdcurses_ISPAD.patch @@ -0,0 +1,32 @@ +From 39dc626fa370443de87a52a4f4c20c07688be64b Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?= + +Date: Thu, 17 Jun 2021 18:51:55 +0530 +Subject: [PATCH 025/N] mingw pdcurses_ISPAD +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Co-authored-by: Алексей +--- + Include/py_curses.h | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/Include/py_curses.h b/Include/py_curses.h +index e46b08e..34228fb 100644 +--- a/Include/py_curses.h ++++ b/Include/py_curses.h +@@ -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.12/0026-remove_path_max.default.patch b/mingw-w64-python3.12/0026-remove_path_max.default.patch new file mode 100644 index 0000000000..71026eb289 --- /dev/null +++ b/mingw-w64-python3.12/0026-remove_path_max.default.patch @@ -0,0 +1,26 @@ +From b6618fd164ce8bfc3e93ead5d8f2cbdb7db1ac9b Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?= + +Date: Thu, 17 Jun 2021 18:51:59 +0530 +Subject: [PATCH 026/N] remove_path_max.default +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Co-authored-by: Алексей +--- + Include/osdefs.h | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/Include/osdefs.h b/Include/osdefs.h +index 3243944..99d4977 100644 +--- a/Include/osdefs.h ++++ b/Include/osdefs.h +@@ -10,7 +10,6 @@ extern "C" { + #ifdef MS_WINDOWS + #define SEP L'\\' + #define ALTSEP L'/' +-#define MAXPATHLEN 256 + #define DELIM L';' + #endif + diff --git a/mingw-w64-python3.12/0027-dont-link-with-gettext.patch b/mingw-w64-python3.12/0027-dont-link-with-gettext.patch new file mode 100644 index 0000000000..5d19659dfb --- /dev/null +++ b/mingw-w64-python3.12/0027-dont-link-with-gettext.patch @@ -0,0 +1,57 @@ +From 4a9078f3f394c66eb4c224c1e67ed0fc5756c526 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?= + +Date: Thu, 17 Jun 2021 18:52:00 +0530 +Subject: [PATCH 027/N] dont link with gettext +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Co-authored-by: Алексей +--- + Modules/_localemodule.c | 7 +++++++ + configure.ac | 9 +++++++++ + 2 files changed, 16 insertions(+) + +diff --git a/Modules/_localemodule.c b/Modules/_localemodule.c +index cbd036f..9d71bb3 100644 +--- a/Modules/_localemodule.c ++++ b/Modules/_localemodule.c +@@ -12,6 +12,13 @@ This software comes with no warranty. Use at your own risk. + #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/configure.ac b/configure.ac +index ceab383..7a34f86 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -3828,10 +3828,19 @@ AC_SEARCH_LIBS([sem_init], [pthread rt posix4]) + 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 --git a/mingw-w64-python3.12/0028-ctypes-python-dll.patch b/mingw-w64-python3.12/0028-ctypes-python-dll.patch new file mode 100644 index 0000000000..a6098caf73 --- /dev/null +++ b/mingw-w64-python3.12/0028-ctypes-python-dll.patch @@ -0,0 +1,30 @@ +From 774710a21540f1aeccee20cd320f3c818e7ebb26 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?= + +Date: Thu, 17 Jun 2021 18:52:01 +0530 +Subject: [PATCH 028/N] ctypes python dll +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Co-authored-by: Алексей +Co-authored-by: Christoph Reiter +--- + Lib/ctypes/__init__.py | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/Lib/ctypes/__init__.py b/Lib/ctypes/__init__.py +index 95353ba..2b06fba 100644 +--- a/Lib/ctypes/__init__.py ++++ b/Lib/ctypes/__init__.py +@@ -464,7 +464,9 @@ def LoadLibrary(self, name): + 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.12/0029-gdbm-module-includes.patch b/mingw-w64-python3.12/0029-gdbm-module-includes.patch new file mode 100644 index 0000000000..a42c8be7e9 --- /dev/null +++ b/mingw-w64-python3.12/0029-gdbm-module-includes.patch @@ -0,0 +1,27 @@ +From 8e4d2ab38090e420066be303c315387106edd8b0 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?= + +Date: Thu, 17 Jun 2021 18:52:02 +0530 +Subject: [PATCH 029/N] gdbm module includes +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Co-authored-by: Алексей +--- + Modules/_gdbmmodule.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Modules/_gdbmmodule.c b/Modules/_gdbmmodule.c +index 4dbb574..f8701cb 100644 +--- a/Modules/_gdbmmodule.c ++++ b/Modules/_gdbmmodule.c +@@ -12,7 +12,7 @@ + #include + #include + +-#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.12/0030-use-gnu_printf-in-format.patch b/mingw-w64-python3.12/0030-use-gnu_printf-in-format.patch new file mode 100644 index 0000000000..2ce7a1830a --- /dev/null +++ b/mingw-w64-python3.12/0030-use-gnu_printf-in-format.patch @@ -0,0 +1,82 @@ +From 6499cbfbfa97c2db6bd483a3033b0c57b1a85825 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?= + +Date: Thu, 17 Jun 2021 18:52:03 +0530 +Subject: [PATCH 030/N] use gnu_printf in format +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Co-authored-by: Алексей +--- + Include/bytesobject.h | 4 ++-- + Include/pyerrors.h | 4 ++-- + Include/pyport.h | 6 ++++++ + Include/sysmodule.h | 4 ++-- + 4 files changed, 12 insertions(+), 6 deletions(-) + +diff --git a/Include/bytesobject.h b/Include/bytesobject.h +index ee448cd..d10ec3f 100644 +--- a/Include/bytesobject.h ++++ b/Include/bytesobject.h +@@ -35,9 +35,9 @@ PyAPI_FUNC(PyObject *) PyBytes_FromStringAndSize(const char *, Py_ssize_t); + 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 --git a/Include/pyerrors.h b/Include/pyerrors.h +index d089fa7..f8e604e 100644 +--- a/Include/pyerrors.h ++++ b/Include/pyerrors.h +@@ -321,9 +321,9 @@ PyAPI_FUNC(int) PyUnicodeTranslateError_SetReason( + ); + + 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 --git a/Include/pyport.h b/Include/pyport.h +index b7f3e66..b8810c1 100644 +--- a/Include/pyport.h ++++ b/Include/pyport.h +@@ -666,6 +666,12 @@ extern char * _getpty(int *, int, mode_t, int); + + #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/Include/sysmodule.h b/Include/sysmodule.h +index 96f8838..55c558a 100644 +--- a/Include/sysmodule.h ++++ b/Include/sysmodule.h +@@ -15,9 +15,9 @@ Py_DEPRECATED(3.11) PyAPI_FUNC(void) PySys_SetArgvEx(int, wchar_t **, int); + Py_DEPRECATED(3.11) 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, ...); + diff --git a/mingw-w64-python3.12/0031-mingw-fix-ssl-dont-use-enum_certificates.patch b/mingw-w64-python3.12/0031-mingw-fix-ssl-dont-use-enum_certificates.patch new file mode 100644 index 0000000000..8aa8c2357d --- /dev/null +++ b/mingw-w64-python3.12/0031-mingw-fix-ssl-dont-use-enum_certificates.patch @@ -0,0 +1,36 @@ +From 81bfbaabab3a2847a9cf434e60bab959c9923db1 Mon Sep 17 00:00:00 2001 +From: Ray Donnelly +Date: Thu, 17 Jun 2021 18:52:03 +0530 +Subject: [PATCH 031/N] mingw fix ssl dont use enum_certificates +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Co-authored-by: Алексей +Co-authored-by: Christoph Reiter +--- + Lib/ssl.py | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/Lib/ssl.py b/Lib/ssl.py +index 3586d3a..58a92dc 100644 +--- a/Lib/ssl.py ++++ b/Lib/ssl.py +@@ -254,7 +254,7 @@ class _TLSMessageType: + 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, SOCK_STREAM, create_connection +@@ -529,7 +529,7 @@ def _load_windows_store_certs(self, storename, purpose): + 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.12/0032-fix-using-dllhandle-and-winver-mingw.patch b/mingw-w64-python3.12/0032-fix-using-dllhandle-and-winver-mingw.patch new file mode 100644 index 0000000000..86d54cf60d --- /dev/null +++ b/mingw-w64-python3.12/0032-fix-using-dllhandle-and-winver-mingw.patch @@ -0,0 +1,36 @@ +From 46c5de660b742c85dc5d941dbe9d063e920a3686 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?= + +Date: Thu, 17 Jun 2021 18:52:06 +0530 +Subject: [PATCH 032/N] fix using dllhandle and winver mingw +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Co-authored-by: Алексей +--- + Python/sysmodule.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/Python/sysmodule.c b/Python/sysmodule.c +index 14f4447..6c2405c 100644 +--- a/Python/sysmodule.c ++++ b/Python/sysmodule.c +@@ -42,7 +42,7 @@ Data members: + #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; +@@ -3291,7 +3291,7 @@ _PySys_InitCore(PyThreadState *tstate, PyObject *sysdict) + SET_SYS_FROM_STRING("byteorder", "little"); + #endif + +-#ifdef MS_COREDLL ++#if defined(MS_WINDOWS) && defined(Py_ENABLE_SHARED) + SET_SYS("dllhandle", PyLong_FromVoidPtr(PyWin_DLLhModule)); + SET_SYS_FROM_STRING("winver", PyWin_DLLVersionString); + #endif diff --git a/mingw-w64-python3.12/0033-Add-AMD64-to-sys-config-so-msvccompiler-get_build_ve.patch b/mingw-w64-python3.12/0033-Add-AMD64-to-sys-config-so-msvccompiler-get_build_ve.patch new file mode 100644 index 0000000000..520bfc5e29 --- /dev/null +++ b/mingw-w64-python3.12/0033-Add-AMD64-to-sys-config-so-msvccompiler-get_build_ve.patch @@ -0,0 +1,39 @@ +From 5e0a48384fb296afed84d2ab346c0d5120b8489e Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?= + +Date: Thu, 17 Jun 2021 18:52:07 +0530 +Subject: [PATCH 033/N] Add AMD64 to sys config so msvccompiler + get_build_version works + +--- + Python/getcompiler.c | 17 ++++++++++++++++- + 1 file changed, 16 insertions(+), 1 deletion(-) + +diff --git a/Python/getcompiler.c b/Python/getcompiler.c +index a5d2623..3e31c80 100644 +--- a/Python/getcompiler.c ++++ b/Python/getcompiler.c +@@ -10,7 +10,22 @@ + #if defined(__clang__) + #define COMPILER "[Clang " __clang_version__ "]" + #elif defined(__GNUC__) +-#define COMPILER "[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.12/0034-MINGW-link-with-additional-library.patch b/mingw-w64-python3.12/0034-MINGW-link-with-additional-library.patch new file mode 100644 index 0000000000..813f2bd16e --- /dev/null +++ b/mingw-w64-python3.12/0034-MINGW-link-with-additional-library.patch @@ -0,0 +1,30 @@ +From ec57238583ffa0470c12bc5bc27536f514e5a855 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?= + +Date: Thu, 17 Jun 2021 18:52:08 +0530 +Subject: [PATCH 034/N] MINGW link with additional library + +--- + configure.ac | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/configure.ac b/configure.ac +index 7a34f86..dde8937 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -7053,6 +7053,15 @@ for dir in $SRCDIRS; do + 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_CACHE_CHECK([for -O2], [ac_cv_compile_o2], [ + saved_cflags="$CFLAGS" diff --git a/mingw-w64-python3.12/0035-install-msilib.patch b/mingw-w64-python3.12/0035-install-msilib.patch new file mode 100644 index 0000000000..6032401102 --- /dev/null +++ b/mingw-w64-python3.12/0035-install-msilib.patch @@ -0,0 +1,27 @@ +From 32cf53fc0ff98c55ebe0871f4716e58878cda0fe Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= +Date: Thu, 17 Jun 2021 18:52:09 +0530 +Subject: [PATCH 035/N] install msilib +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Co-authored-by: Алексей +Co-authored-by: Christoph Reiter +Co-authored-by: Ray Donnelly +--- + Makefile.pre.in | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/Makefile.pre.in b/Makefile.pre.in +index b5c0c41..e400d56 100644 +--- a/Makefile.pre.in ++++ b/Makefile.pre.in +@@ -2118,6 +2118,7 @@ LIBSUBDIRS= asyncio \ + tkinter \ + tomllib \ + turtledemo \ ++ msilib \ + unittest \ + urllib \ + venv venv/scripts venv/scripts/common venv/scripts/posix \ diff --git a/mingw-w64-python3.12/0036-fix-signal-module-build.patch b/mingw-w64-python3.12/0036-fix-signal-module-build.patch new file mode 100644 index 0000000000..2646aaf0cb --- /dev/null +++ b/mingw-w64-python3.12/0036-fix-signal-module-build.patch @@ -0,0 +1,27 @@ +From 87bc3aedc10cb8c01c76f7a105aeb044f0cf93a1 Mon Sep 17 00:00:00 2001 +From: Christoph Reiter +Date: Thu, 17 Jun 2021 18:52:10 +0530 +Subject: [PATCH 036/N] fix signal module build +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Co-authored-by: Алексей +Co-authored-by: Naveen M K +--- + Modules/Setup.bootstrap.in | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Modules/Setup.bootstrap.in b/Modules/Setup.bootstrap.in +index d8b41ee..ec0f81e 100644 +--- a/Modules/Setup.bootstrap.in ++++ b/Modules/Setup.bootstrap.in +@@ -9,7 +9,7 @@ + atexit atexitmodule.c + faulthandler faulthandler.c + @INITSYS@ posixmodule.c +-_signal signalmodule.c ++_signal signalmodule.c -lws2_32 + _tracemalloc _tracemalloc.c + + # modules used by importlib, deepfreeze, freeze, runpy, and sysconfig diff --git a/mingw-w64-python3.12/0037-build-build-winconsoleio-and-_testconsole.patch b/mingw-w64-python3.12/0037-build-build-winconsoleio-and-_testconsole.patch new file mode 100644 index 0000000000..c48e1ab7cc --- /dev/null +++ b/mingw-w64-python3.12/0037-build-build-winconsoleio-and-_testconsole.patch @@ -0,0 +1,53 @@ +From 631c774c6b1483c0524769d15b45b0ab21a53769 Mon Sep 17 00:00:00 2001 +From: Christoph Reiter +Date: Thu, 17 Jun 2021 18:52:11 +0530 +Subject: [PATCH 037/N] build: build winconsoleio and _testconsole +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Co-authored-by: Алексей +Co-authored-by: Naveen M K +--- + Modules/Setup.bootstrap.in | 2 +- + Modules/Setup.stdlib.in | 1 + + configure.ac | 1 + + 3 files changed, 3 insertions(+), 1 deletion(-) + +diff --git a/Modules/Setup.bootstrap.in b/Modules/Setup.bootstrap.in +index ec0f81e..cec80f5 100644 +--- a/Modules/Setup.bootstrap.in ++++ b/Modules/Setup.bootstrap.in +@@ -16,7 +16,7 @@ _tracemalloc _tracemalloc.c + _codecs _codecsmodule.c + _collections _collectionsmodule.c + errno errnomodule.c +-_io _io/_iomodule.c _io/iobase.c _io/fileio.c _io/bytesio.c _io/bufferedio.c _io/textio.c _io/stringio.c ++_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 + itertools itertoolsmodule.c + _sre _sre/sre.c + _thread _threadmodule.c +diff --git a/Modules/Setup.stdlib.in b/Modules/Setup.stdlib.in +index 202a55e..3f4d7f6 100644 +--- a/Modules/Setup.stdlib.in ++++ b/Modules/Setup.stdlib.in +@@ -184,6 +184,7 @@ + @MODULE__TESTMULTIPHASE_TRUE@_testmultiphase _testmultiphase.c + @MODULE__TESTMULTIPHASE_TRUE@_testsinglephase _testsinglephase.c + @MODULE__CTYPES_TEST_TRUE@_ctypes_test _ctypes/_ctypes_test.c ++@MODULE__TESTCONSOLE_TRUE@_testconsole ../PC/_testconsole.c + + # Limited API template modules; must be built as shared modules. + @MODULE_XXLIMITED_TRUE@xxlimited xxlimited.c +diff --git a/configure.ac b/configure.ac +index dde8937..3b4745f 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -7823,6 +7823,7 @@ PY_STDLIB_MOD([_testimportmultiple], [test "$TEST_MODULES" = yes], [test "$ac_cv + PY_STDLIB_MOD([_testmultiphase], [test "$TEST_MODULES" = yes], [test "$ac_cv_func_dlopen" = yes]) + PY_STDLIB_MOD([xxsubtype], [test "$TEST_MODULES" = yes]) + PY_STDLIB_MOD([_xxtestfuzz], [test "$TEST_MODULES" = yes]) ++PY_STDLIB_MOD([_testconsole], [test "$TEST_MODULES" = yes -a "$MACHDEP" = "win32"]) + PY_STDLIB_MOD([_ctypes_test], + [test "$TEST_MODULES" = yes], [test "$have_libffi" = yes -a "$ac_cv_func_dlopen" = yes], + [], [$LIBM]) diff --git a/mingw-w64-python3.12/0038-expose-sem_unlink.patch b/mingw-w64-python3.12/0038-expose-sem_unlink.patch new file mode 100644 index 0000000000..736621700a --- /dev/null +++ b/mingw-w64-python3.12/0038-expose-sem_unlink.patch @@ -0,0 +1,26 @@ +From d3687f2585f3233cdeea3ffc53683d6ea4f655ca Mon Sep 17 00:00:00 2001 +From: Christoph Reiter +Date: Thu, 17 Jun 2021 18:52:12 +0530 +Subject: [PATCH 038/N] expose sem_unlink +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Co-authored-by: Алексей +--- + Modules/_multiprocessing/multiprocessing.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Modules/_multiprocessing/multiprocessing.c b/Modules/_multiprocessing/multiprocessing.c +index 8f9daa5..eb2cb5f 100644 +--- a/Modules/_multiprocessing/multiprocessing.c ++++ b/Modules/_multiprocessing/multiprocessing.c +@@ -180,7 +180,7 @@ static PyMethodDef module_methods[] = { + _MULTIPROCESSING_RECV_METHODDEF + _MULTIPROCESSING_SEND_METHODDEF + #endif +-#if !defined(POSIX_SEMAPHORES_NOT_ENABLED) && !defined(__ANDROID__) ++#if defined(MS_WINDOWS) || (!defined(POSIX_SEMAPHORES_NOT_ENABLED) && !defined(__ANDROID__)) + _MULTIPROCESSING_SEM_UNLINK_METHODDEF + #endif + {NULL} diff --git a/mingw-w64-python3.12/0039-Use-cygpty-while-using-isatty.patch b/mingw-w64-python3.12/0039-Use-cygpty-while-using-isatty.patch new file mode 100644 index 0000000000..581a8ff0e4 --- /dev/null +++ b/mingw-w64-python3.12/0039-Use-cygpty-while-using-isatty.patch @@ -0,0 +1,485 @@ +From 542a2d46be156bfcfc555eeb3704455027529c72 Mon Sep 17 00:00:00 2001 +From: Christoph Reiter +Date: Thu, 17 Jun 2021 18:52:14 +0530 +Subject: [PATCH 039/N] Use cygpty while using isatty +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +so that msys shells are detected as interactive ones + +Co-authored-by: Алексей +Co-authored-by: Naveen M K +--- + Include/iscygpty.h | 41 ++++++++++ + Makefile.pre.in | 2 + + Modules/_io/fileio.c | 3 +- + Modules/main.c | 3 +- + Modules/posixmodule.c | 3 +- + Objects/fileobject.c | 3 +- + Python/bltinmodule.c | 5 +- + Python/fileutils.c | 7 +- + Python/frozenmain.c | 3 +- + Python/iscygpty.c | 185 ++++++++++++++++++++++++++++++++++++++++++ + Python/pylifecycle.c | 5 +- + 11 files changed, 248 insertions(+), 12 deletions(-) + create mode 100644 Include/iscygpty.h + create mode 100644 Python/iscygpty.c + +diff --git a/Include/iscygpty.h b/Include/iscygpty.h +new file mode 100644 +index 0000000..82fd0af +--- /dev/null ++++ b/Include/iscygpty.h +@@ -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 --git a/Makefile.pre.in b/Makefile.pre.in +index e400d56..93e23f0 100644 +--- a/Makefile.pre.in ++++ b/Makefile.pre.in +@@ -406,6 +406,7 @@ PYTHON_OBJS= \ + Python/instrumentation.o \ + Python/intrinsics.o \ + Python/legacy_tracing.o \ ++ Python/iscygpty.o \ + Python/marshal.o \ + Python/modsupport.o \ + Python/mysnprintf.o \ +@@ -1632,6 +1633,7 @@ PYTHON_HEADERS= \ + $(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/longobject.h \ +diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c +index c8be998..c09410a 100644 +--- a/Modules/_io/fileio.c ++++ b/Modules/_io/fileio.c +@@ -20,6 +20,7 @@ + #endif + #include /* For offsetof */ + #include "_iomodule.h" ++#include "iscygpty.h" + + /* + * Known likely problems: +@@ -1143,7 +1144,7 @@ _io_FileIO_isatty_impl(fileio *self) + 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 --git a/Modules/main.c b/Modules/main.c +index 1b189b4..674b737 100644 +--- a/Modules/main.c ++++ b/Modules/main.c +@@ -7,6 +7,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() +@@ -92,7 +93,7 @@ static inline int config_run_code(const PyConfig *config) + 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 --git a/Modules/posixmodule.c b/Modules/posixmodule.c +index 6cde737..38687e0 100644 +--- a/Modules/posixmodule.c ++++ b/Modules/posixmodule.c +@@ -54,6 +54,7 @@ + #ifdef __ANDROID__ + # undef HAVE_FACCESSAT + #endif ++#include "iscygpty.h" + + #include // ctermid() + #include // system() +@@ -11180,7 +11181,7 @@ os_isatty_impl(PyObject *module, int fd) + int return_value; + Py_BEGIN_ALLOW_THREADS + _Py_BEGIN_SUPPRESS_IPH +- return_value = isatty(fd); ++ return_value = isatty(fd) || is_cygpty(fd); + _Py_END_SUPPRESS_IPH + Py_END_ALLOW_THREADS + return return_value; +diff --git a/Objects/fileobject.c b/Objects/fileobject.c +index e99e155..c74d2af 100644 +--- a/Objects/fileobject.c ++++ b/Objects/fileobject.c +@@ -3,6 +3,7 @@ + #define PY_SSIZE_T_CLEAN + #include "Python.h" + #include "pycore_call.h" // _PyObject_CallNoArgs() ++#include "iscygpty.h" + #include "pycore_runtime.h" // _PyRuntime + + #if defined(HAVE_GETC_UNLOCKED) && !defined(_Py_MEMORY_SANITIZER) +@@ -382,7 +383,7 @@ stdprinter_isatty(PyStdPrinter_Object *self, PyObject *Py_UNUSED(ignored)) + } + + 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 --git a/Python/bltinmodule.c b/Python/bltinmodule.c +index 84fbc33..ac9166c 100644 +--- a/Python/bltinmodule.c ++++ b/Python/bltinmodule.c +@@ -1,6 +1,7 @@ + /* Built-in functions */ + + #include "Python.h" ++#include "iscygpty.h" + #include + #include "pycore_ast.h" // _PyAST_Validate() + #include "pycore_call.h" // _PyObject_CallNoArgs() +@@ -2153,7 +2154,7 @@ builtin_input_impl(PyObject *module, PyObject *prompt) + 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_CallMethodNoArgs(fout, &_Py_ID(fileno)); +@@ -2166,7 +2167,7 @@ builtin_input_impl(PyObject *module, PyObject *prompt) + 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 --git a/Python/fileutils.c b/Python/fileutils.c +index c752175..6d3b04f 100644 +--- a/Python/fileutils.c ++++ b/Python/fileutils.c +@@ -1,4 +1,5 @@ + #include "Python.h" ++#include "iscygpty.h" + #include "pycore_fileutils.h" // fileutils definitions + #include "pycore_runtime.h" // _PyRuntime + #include "osdefs.h" // SEP +@@ -77,7 +78,7 @@ _Py_device_encoding(int fd) + int valid; + Py_BEGIN_ALLOW_THREADS + _Py_BEGIN_SUPPRESS_IPH +- valid = isatty(fd); ++ valid = isatty(fd) || is_cygpty(fd); + _Py_END_SUPPRESS_IPH + Py_END_ALLOW_THREADS + if (!valid) +@@ -1925,12 +1926,12 @@ _Py_write_impl(int fd, const void *buf, size_t count, int gil_held) + depending on heap usage). */ + if (gil_held) { + Py_BEGIN_ALLOW_THREADS +- if (isatty(fd)) { ++ if (isatty(fd) || is_cygpty(fd)) { + count = 32767; + } + Py_END_ALLOW_THREADS + } else { +- if (isatty(fd)) { ++ if (isatty(fd) || is_cygpty(fd)) { + count = 32767; + } + } +diff --git a/Python/frozenmain.c b/Python/frozenmain.c +index f8be165..d18c7b3 100644 +--- a/Python/frozenmain.c ++++ b/Python/frozenmain.c +@@ -3,6 +3,7 @@ + #include "Python.h" + #include "pycore_runtime.h" // _PyRuntime_Initialize() + #include ++#include "iscygpty.h" + + #ifdef MS_WINDOWS + extern void PyWinFreeze_ExeInit(void); +@@ -71,7 +72,7 @@ Py_FrozenMain(int argc, char **argv) + sts = 0; + } + +- if (inspect && isatty((int)fileno(stdin))) { ++ if (inspect && (isatty((int)fileno(stdin)) || is_cygpty((int)fileno(stdin)))) + sts = PyRun_AnyFile(stdin, "") != 0; + } + +diff --git a/Python/iscygpty.c b/Python/iscygpty.c +new file mode 100644 +index 0000000..722f88f +--- /dev/null ++++ b/Python/iscygpty.c +@@ -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 --git a/Python/pylifecycle.c b/Python/pylifecycle.c +index a0130fd..5ad77d6 100644 +--- a/Python/pylifecycle.c ++++ b/Python/pylifecycle.c +@@ -30,6 +30,7 @@ + #include "pycore_unicodeobject.h" // _PyUnicode_InitTypes() + #include "opcode.h" + ++#include "iscygpty.h" + #include // setlocale() + #include // getenv() + +@@ -3070,7 +3071,7 @@ Py_Exit(int sts) + int + Py_FdIsInteractive(FILE *fp, const char *filename) + { +- if (isatty(fileno(fp))) { ++ if (isatty(fileno(fp)) || is_cygpty(fileno(fp))) { + return 1; + } + if (!_Py_GetConfig()->interactive) { +@@ -3085,7 +3086,7 @@ Py_FdIsInteractive(FILE *fp, const char *filename) + int + _Py_FdIsInteractive(FILE *fp, PyObject *filename) + { +- if (isatty(fileno(fp))) { ++ if (isatty(fileno(fp)) || is_cygpty(fileno(fp))) { + return 1; + } + if (!_Py_GetConfig()->interactive) { diff --git a/mingw-w64-python3.12/0040-build-link-win-resource-files-and-build-pythonw.patch b/mingw-w64-python3.12/0040-build-link-win-resource-files-and-build-pythonw.patch new file mode 100644 index 0000000000..2ab0af4af4 --- /dev/null +++ b/mingw-w64-python3.12/0040-build-link-win-resource-files-and-build-pythonw.patch @@ -0,0 +1,145 @@ +From 52cab5ad7ba709042b0d25d8e30aa96b72b27dd6 Mon Sep 17 00:00:00 2001 +From: Christoph Reiter +Date: Thu, 17 Jun 2021 18:52:16 +0530 +Subject: [PATCH 040/N] build: link win resource files and build pythonw +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Co-authored-by: Алексей +--- + Makefile.pre.in | 26 +++++++++++++++++++++----- + configure.ac | 27 +++++++++++++++++++++++++++ + 2 files changed, 48 insertions(+), 5 deletions(-) + +diff --git a/Makefile.pre.in b/Makefile.pre.in +index 93e23f0..4064977 100644 +--- a/Makefile.pre.in ++++ b/Makefile.pre.in +@@ -38,6 +38,7 @@ CC= @CC@ + CXX= @CXX@ + LINKCC= @LINKCC@ + AR= @AR@ ++WINDRES= @WINDRES@ + READELF= @READELF@ + SOABI= @SOABI@ + LDVERSION= @LDVERSION@ +@@ -124,6 +125,7 @@ PY_CORE_CFLAGS= $(PY_STDMODULE_CFLAGS) -DPy_BUILD_CORE + 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 +@@ -286,6 +288,7 @@ LIBOBJS= @LIBOBJS@ + + PYTHON= python$(EXE) + BUILDPYTHON= python$(BUILDEXE) ++BUILDPYTHONW= pythonw$(BUILDEXE) + + HOSTRUNNER= @HOSTRUNNER@ + +@@ -620,7 +623,7 @@ all: @DEF_MAKE_ALL_RULE@ + .PHONY: all + + .PHONY: build_all +-build_all: check-clean-src $(BUILDPYTHON) platform sharedmods \ ++build_all: check-clean-src $(BUILDPYTHON) $(BUILDPYTHONW) platform sharedmods \ + gdbhooks Programs/_testembed scripts checksharedmods rundsymutil + + .PHONY: build_wasm +@@ -785,9 +788,21 @@ coverage-report: regen-token regen-frozen + clinic: check-clean-src $(srcdir)/Modules/_blake2/blake2s_impl.c + $(PYTHON_FOR_REGEN) $(srcdir)/Tools/clinic/clinic.py --make --srcdir $(srcdir) + ++python_exe.o: $(srcdir)/PC/python_exe.rc ++ $(WINDRES) $(RCFLAGS) -I$(srcdir)/Include -I$(srcdir)/PC -I. $(srcdir)/PC/python_exe.rc $@ ++ ++pythonw_exe.o: $(srcdir)/PC/pythonw_exe.rc ++ $(WINDRES) $(RCFLAGS) -I$(srcdir)/Include -I$(srcdir)/PC -I. $(srcdir)/PC/pythonw_exe.rc $@ ++ ++python_nt.o: $(srcdir)/PC/python_nt.rc ++ $(WINDRES) $(RCFLAGS) -DORIGINAL_FILENAME=\\\"$(DLLLIBRARY)\\\" -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 $(LINK_PYTHON_DEPS) +- $(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/python.o $(LINK_PYTHON_OBJS) $(LIBS) $(MODLIBS) $(SYSLIBS) ++$(BUILDPYTHON): Programs/python.o $(LINK_PYTHON_DEPS) python_exe.o ++ $(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -municode -o $@ Programs/python.o $(LINK_PYTHON_OBJS) $(LIBS) $(MODLIBS) $(SYSLIBS) python_exe.o + + platform: $(PYTHON_FOR_BUILD_DEPS) 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 +@@ -876,10 +891,10 @@ $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK): \ + + # 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 + +@@ -1975,6 +1990,7 @@ altbininstall: $(BUILDPYTHON) @FRAMEWORKPYTHONW@ + 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/configure.ac b/configure.ac +index 3b4745f..d690f92 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -1759,6 +1759,10 @@ AC_SUBST([LINK_PYTHON_OBJS]) + AC_SUBST([AR]) + AC_CHECK_TOOLS([AR], [ar aal], [ar]) + ++# windres program ++AC_SUBST(WINDRES) ++AC_CHECK_TOOL(WINDRES, windres) ++ + # tweak ARFLAGS only if the user didn't set it on the command line + AC_SUBST([ARFLAGS]) + if test -z "$ARFLAGS" +@@ -7057,10 +7061,33 @@ AC_MSG_RESULT([done]) + case $host in + *-*-mingw*) + LIBS="$LIBS -lversion -lshlwapi -lpathcch" ++ AC_PROG_AWK ++ if test "$AWK" = "gawk"; then ++ awk_extra_flag="--non-decimal-data" ++ fi ++ AC_MSG_CHECKING([FIELD3]) ++ FIELD3=$($AWK $awk_extra_flag '\ ++ /^#define PY_RELEASE_LEVEL_/ {levels[$2]=$3} \ ++ /^#define PY_MICRO_VERSION[[:space:]]+/ {micro=$3} \ ++ /^#define PY_RELEASE_LEVEL[[:space:]]+/ {level=levels[$3]} \ ++ /^#define PY_RELEASE_SERIAL[[:space:]]+/ {serial=$3} \ ++ END {print micro * 1000 + level * 10 + serial}' \ ++ $srcdir/Include/patchlevel.h ++ ) ++ ++ AC_MSG_RESULT([${FIELD3}]) ++ RCFLAGS="$RCFLAGS -DFIELD3=$FIELD3 -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_CACHE_CHECK([for -O2], [ac_cv_compile_o2], [ diff --git a/mingw-w64-python3.12/0041-fix-isselectable.patch b/mingw-w64-python3.12/0041-fix-isselectable.patch new file mode 100644 index 0000000000..3e97eb9a15 --- /dev/null +++ b/mingw-w64-python3.12/0041-fix-isselectable.patch @@ -0,0 +1,26 @@ +From 2ce010ce13a1b5cff820c53de40cfd25e15f5183 Mon Sep 17 00:00:00 2001 +From: Christoph Reiter +Date: Thu, 17 Jun 2021 18:52:18 +0530 +Subject: [PATCH 041/N] fix isselectable +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Co-authored-by: Алексей +--- + Include/fileobject.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Include/fileobject.h b/Include/fileobject.h +index 2deef54..ae4bdac 100644 +--- a/Include/fileobject.h ++++ b/Include/fileobject.h +@@ -30,7 +30,7 @@ Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_UTF8Mode; + #endif + + /* 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.12/0042-configure.ac-fix-inet_pton-check.patch b/mingw-w64-python3.12/0042-configure.ac-fix-inet_pton-check.patch new file mode 100644 index 0000000000..b3edb32def --- /dev/null +++ b/mingw-w64-python3.12/0042-configure.ac-fix-inet_pton-check.patch @@ -0,0 +1,32 @@ +From 2b67fbdb9fdd6588ff43a9738d199eec52e16f5f Mon Sep 17 00:00:00 2001 +From: Christoph Reiter +Date: Thu, 17 Jun 2021 18:52:23 +0530 +Subject: [PATCH 042/N] configure.ac: fix inet_pton check +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Co-authored-by: Алексей +--- + configure.ac | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/configure.ac b/configure.ac +index d690f92..0fd77b9 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -5353,10 +5353,14 @@ PY_CHECK_NETDB_FUNC([getprotobyname]) + + dnl PY_CHECK_SOCKET_FUNC(FUNCTION) + AC_DEFUN([PY_CHECK_SOCKET_FUNC], [PY_CHECK_FUNC([$1], [ ++#ifdef _WIN32 ++#include ++#else + #include + #include + #include + #include ++#endif + ])]) + + PY_CHECK_SOCKET_FUNC([inet_aton]) diff --git a/mingw-w64-python3.12/0043-pass-gen-profile-ldflags.patch b/mingw-w64-python3.12/0043-pass-gen-profile-ldflags.patch new file mode 100644 index 0000000000..368cacb340 --- /dev/null +++ b/mingw-w64-python3.12/0043-pass-gen-profile-ldflags.patch @@ -0,0 +1,26 @@ +From 942ce0ac16624b91e753ab21eae6d75f343be536 Mon Sep 17 00:00:00 2001 +From: Christoph Reiter +Date: Thu, 17 Jun 2021 18:52:27 +0530 +Subject: [PATCH 043/N] pass gen profile ldflags +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Co-authored-by: Алексей +--- + Makefile.pre.in | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Makefile.pre.in b/Makefile.pre.in +index 4064977..03fa15e 100644 +--- a/Makefile.pre.in ++++ b/Makefile.pre.in +@@ -894,7 +894,7 @@ $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK): \ + $(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.12/0044-pkg-config-windows-must-link-ext-with-python-lib.patch b/mingw-w64-python3.12/0044-pkg-config-windows-must-link-ext-with-python-lib.patch new file mode 100644 index 0000000000..7cb567adaa --- /dev/null +++ b/mingw-w64-python3.12/0044-pkg-config-windows-must-link-ext-with-python-lib.patch @@ -0,0 +1,23 @@ +From 4f5ce776066be9e6c3ef959dfd204c1ce6cc2b10 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?= + +Date: Thu, 17 Jun 2021 18:52:29 +0530 +Subject: [PATCH 044/N] pkg config windows must link ext with python lib + +--- + configure.ac | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/configure.ac b/configure.ac +index 0fd77b9..0e15ece 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -6233,7 +6233,7 @@ AC_MSG_RESULT([$LDVERSION]) + + # On Android and Cygwin the shared libraries must be linked with libpython. + AC_SUBST([LIBPYTHON]) +-if test "$PY_ENABLE_SHARED" = "1" && ( test -n "$ANDROID_API_LEVEL" || test "$MACHDEP" = "cygwin"); then ++if test "$PY_ENABLE_SHARED" = "1" && ( test -n "$ANDROID_API_LEVEL" || test "$MACHDEP" = "cygwin" || test "$MACHDEP" = "win32"); then + LIBPYTHON="-lpython${VERSION}${ABIFLAGS}" + else + LIBPYTHON='' diff --git a/mingw-w64-python3.12/0045-importlib-bootstrap-path-sep.patch b/mingw-w64-python3.12/0045-importlib-bootstrap-path-sep.patch new file mode 100644 index 0000000000..0ec82dc6be --- /dev/null +++ b/mingw-w64-python3.12/0045-importlib-bootstrap-path-sep.patch @@ -0,0 +1,29 @@ +From 2209bcf1e009fc08bf11a8cfc18274c875bf7d11 Mon Sep 17 00:00:00 2001 +From: Christoph Reiter +Date: Thu, 17 Jun 2021 18:52:30 +0530 +Subject: [PATCH 045/N] importlib bootstrap path sep +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Co-authored-by: Алексей +Co-authored-by: Naveen M K +--- + Lib/importlib/_bootstrap_external.py | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py +index 73ac440..42d987d 100644 +--- a/Lib/importlib/_bootstrap_external.py ++++ b/Lib/importlib/_bootstrap_external.py +@@ -42,6 +42,10 @@ + path_separators = ['\\', '/'] + else: + path_separators = ['/'] ++ ++if 'MSYSTEM' in _os.environ: ++ path_separators = path_separators[::-1] ++ + # Assumption made in _path_join() + assert all(len(sep) == 1 for sep in path_separators) + path_sep = path_separators[0] diff --git a/mingw-w64-python3.12/0046-warnings-fixes.patch b/mingw-w64-python3.12/0046-warnings-fixes.patch new file mode 100644 index 0000000000..ebe13e0deb --- /dev/null +++ b/mingw-w64-python3.12/0046-warnings-fixes.patch @@ -0,0 +1,94 @@ +From a236eba8384c4f6bc6681520c4d829686eadcd8e Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?= + +Date: Thu, 17 Jun 2021 18:52:33 +0530 +Subject: [PATCH 046/N] warnings fixes + +--- + Modules/_winapi.c | 2 +- + Modules/posixmodule.c | 2 +- + Modules/socketmodule.h | 2 ++ + PC/python_exe.rc | 2 +- + PC/pythonw_exe.rc | 2 +- + PC/winreg.c | 1 + + 6 files changed, 7 insertions(+), 4 deletions(-) + +diff --git a/Modules/_winapi.c b/Modules/_winapi.c +index fda1171..d25f244 100644 +--- a/Modules/_winapi.c ++++ b/Modules/_winapi.c +@@ -962,7 +962,7 @@ getattributelist(PyObject *obj, const char *name, AttributeList *attribute_list) + 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 --git a/Modules/posixmodule.c b/Modules/posixmodule.c +index 38687e0..0cff7d6 100644 +--- a/Modules/posixmodule.c ++++ b/Modules/posixmodule.c +@@ -6241,7 +6241,7 @@ os_utime_impl(PyObject *module, path_t *path, PyObject *times, PyObject *ns, + /*[clinic end generated code: output=cfcac69d027b82cf input=2fbd62a2f228f8f4]*/ + { + #ifdef MS_WINDOWS +- HANDLE hFile; ++ HANDLE hFile = 0; + FILETIME atime, mtime; + #else + int result; +diff --git a/Modules/socketmodule.h b/Modules/socketmodule.h +index f5ca004..1e92327 100644 +--- a/Modules/socketmodule.h ++++ b/Modules/socketmodule.h +@@ -68,8 +68,10 @@ struct SOCKADDR_BTH_REDEF { + */ + # 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 --git a/PC/python_exe.rc b/PC/python_exe.rc +index c3d3bff..dde0e53 100644 +--- a/PC/python_exe.rc ++++ b/PC/python_exe.rc +@@ -12,7 +12,7 @@ + // current versions of Windows. + 1 RT_MANIFEST "python.manifest" + +-1 ICON DISCARDABLE "icons\python.ico" ++1 ICON DISCARDABLE "icons/python.ico" + + + ///////////////////////////////////////////////////////////////////////////// +diff --git a/PC/pythonw_exe.rc b/PC/pythonw_exe.rc +index 38570b7..7ce1043 100644 +--- a/PC/pythonw_exe.rc ++++ b/PC/pythonw_exe.rc +@@ -12,7 +12,7 @@ + // current versions of Windows. + 1 RT_MANIFEST "python.manifest" + +-1 ICON DISCARDABLE "icons\pythonw.ico" ++1 ICON DISCARDABLE "icons/pythonw.ico" + + + ///////////////////////////////////////////////////////////////////////////// +diff --git a/PC/winreg.c b/PC/winreg.c +index 368291d..33ec8ff 100644 +--- a/PC/winreg.c ++++ b/PC/winreg.c +@@ -831,6 +831,7 @@ Reg2Py(BYTE *retDataBuf, DWORD retDataSize, DWORD typ) + 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) { + obData = Py_NewRef(Py_None); diff --git a/mingw-w64-python3.12/0047-fix-build-testinternalcapi.patch b/mingw-w64-python3.12/0047-fix-build-testinternalcapi.patch new file mode 100644 index 0000000000..7384af8f95 --- /dev/null +++ b/mingw-w64-python3.12/0047-fix-build-testinternalcapi.patch @@ -0,0 +1,22 @@ +From 6d9f3fe8ccd271283b7f42beb6f77047cc5892f0 Mon Sep 17 00:00:00 2001 +From: Naveen M K +Date: Sat, 17 Jun 2023 00:21:25 +0530 +Subject: [PATCH 047/N] fix build testinternalcapi + +--- + configure.ac | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/configure.ac b/configure.ac +index 0e15ece..9fec1f9 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -7848,7 +7848,7 @@ PY_STDLIB_MOD([_overlapped], [test "$MACHDEP" = "win32"], [], [], + dnl test modules + PY_STDLIB_MOD([_testcapi], [test "$TEST_MODULES" = yes]) + PY_STDLIB_MOD([_testclinic], [test "$TEST_MODULES" = yes]) +-PY_STDLIB_MOD([_testinternalcapi], [test "$TEST_MODULES" = yes]) ++PY_STDLIB_MOD([_testinternalcapi], [test "$TEST_MODULES" = yes], [], [-DPY3_DLLNAME="\"$DLLLIBRARY\""], []) + PY_STDLIB_MOD([_testbuffer], [test "$TEST_MODULES" = yes]) + PY_STDLIB_MOD([_testimportmultiple], [test "$TEST_MODULES" = yes], [test "$ac_cv_func_dlopen" = yes]) + PY_STDLIB_MOD([_testmultiphase], [test "$TEST_MODULES" = yes], [test "$ac_cv_func_dlopen" = yes]) diff --git a/mingw-w64-python3.12/0048-clang-arm64.patch b/mingw-w64-python3.12/0048-clang-arm64.patch new file mode 100644 index 0000000000..a2a7e23d8d --- /dev/null +++ b/mingw-w64-python3.12/0048-clang-arm64.patch @@ -0,0 +1,47 @@ +From da616a0b3495114d4eadf7f05f0ef9fa3afce904 Mon Sep 17 00:00:00 2001 +From: jeremyd2019 <4524874+jeremyd2019@users.noreply.github.com> +Date: Thu, 17 Jun 2021 18:52:36 +0530 +Subject: [PATCH 048/N] clang arm64 + +Co-authored-by: Naveen M K +--- + Python/getcompiler.c | 11 ++++++++++- + 1 file changed, 10 insertions(+), 1 deletion(-) + +diff --git a/Python/getcompiler.c b/Python/getcompiler.c +index 3e31c80..7e7be71 100644 +--- a/Python/getcompiler.c ++++ b/Python/getcompiler.c +@@ -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 "[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++]" diff --git a/mingw-w64-python3.12/0049-configure.ac-set-MINGW-stack-reserve.patch b/mingw-w64-python3.12/0049-configure.ac-set-MINGW-stack-reserve.patch new file mode 100644 index 0000000000..c07915853d --- /dev/null +++ b/mingw-w64-python3.12/0049-configure.ac-set-MINGW-stack-reserve.patch @@ -0,0 +1,25 @@ +From 43f2ea75ddebca53bd0959da3bd3e3356004f304 Mon Sep 17 00:00:00 2001 +From: jeremyd2019 <4524874+jeremyd2019@users.noreply.github.com> +Date: Thu, 17 Jun 2021 18:52:37 +0530 +Subject: [PATCH 049/N] configure.ac: set MINGW stack reserve + +--- + configure.ac | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/configure.ac b/configure.ac +index 9fec1f9..4851088 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -3696,6 +3696,11 @@ then + VxWorks*) + LINKFORSHARED='-Wl,-export-dynamic';; + esac ++ case $host in ++ *-*-mingw*) ++ # for https://bugs.python.org/issue40458 on MINGW ++ LINKFORSHARED="-Wl,--stack,2000000";; ++ esac + fi + AC_MSG_RESULT([$LINKFORSHARED]) + diff --git a/mingw-w64-python3.12/0050-Don-t-use-os.pathsep-to-find-EOF.patch b/mingw-w64-python3.12/0050-Don-t-use-os.pathsep-to-find-EOF.patch new file mode 100644 index 0000000000..d02f99b1ea --- /dev/null +++ b/mingw-w64-python3.12/0050-Don-t-use-os.pathsep-to-find-EOF.patch @@ -0,0 +1,24 @@ +From 1860e5a5ee72f8ca60e5e5c549e8d1964bf1cfb2 Mon Sep 17 00:00:00 2001 +From: Naveen M K +Date: Fri, 18 Jun 2021 12:38:11 +0530 +Subject: [PATCH 050/N] Don't use os.pathsep to find EOF not all + distributions in win32 have them as \ instead check using sys.platform + +Signed-off-by: Naveen M K +--- + Lib/site.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Lib/site.py b/Lib/site.py +index 4cbb55c..7c89370 100644 +--- a/Lib/site.py ++++ b/Lib/site.py +@@ -398,7 +398,7 @@ def setquit(): + The repr of each object contains a hint at how it works. + + """ +- if os.sep == '\\': ++ if sys.platform == 'win32': + eof = 'Ctrl-Z plus Return' + else: + eof = 'Ctrl-D (i.e. EOF)' diff --git a/mingw-w64-python3.12/0051-Fix-extension-suffix-for-c-extensions-on-mingw.patch b/mingw-w64-python3.12/0051-Fix-extension-suffix-for-c-extensions-on-mingw.patch new file mode 100644 index 0000000000..02d1f57e22 --- /dev/null +++ b/mingw-w64-python3.12/0051-Fix-extension-suffix-for-c-extensions-on-mingw.patch @@ -0,0 +1,179 @@ +From efa19dfbf3d56c42a0a33aa77a2eec9466f4f434 Mon Sep 17 00:00:00 2001 +From: Naveen M K +Date: Wed, 23 Jun 2021 18:12:12 +0530 +Subject: [PATCH 051/N] Fix extension suffix for c-extensions on mingw + +Python is compiled with various compilers which previously +had same platform tags or extension suffix. This can be error +prone while loading c-extensions, so now each compiler or +runtime has a different extension suffix. + +Also, changed all extension to end with .pyd rather than +.dll file. + +Fixes https://github.com/msys2/MINGW-packages/issues/8843 + +Signed-off-by: Naveen M K +--- + Makefile.pre.in | 6 ++-- + Python/dynload_win.c | 6 ---- + configure.ac | 77 +++++++++++++++++++++++++++++++++++++++----- + 3 files changed, 72 insertions(+), 17 deletions(-) + +diff --git a/Makefile.pre.in b/Makefile.pre.in +index 03fa15e..7ca010b 100644 +--- a/Makefile.pre.in ++++ b/Makefile.pre.in +@@ -174,6 +174,7 @@ CONFINCLUDEPY= $(CONFINCLUDEDIR)/python$(LDVERSION) + # Symbols used for using shared libraries + SHLIB_SUFFIX= @SHLIB_SUFFIX@ + EXT_SUFFIX= @EXT_SUFFIX@ ++PYD_PLATFORM_TAG = @PYD_PLATFORM_TAG@ + LDSHARED= @LDSHARED@ $(PY_LDFLAGS) + BLDSHARED= @BLDSHARED@ $(PY_CORE_LDFLAGS) + LDCXXSHARED= @LDCXXSHARED@ +@@ -1399,8 +1400,7 @@ Python/dynload_hpux.o: $(srcdir)/Python/dynload_hpux.c Makefile + + Python/dynload_win.o: $(srcdir)/Python/dynload_win.c Makefile + $(CC) -c $(PY_CORE_CFLAGS) \ +- -DSHLIB_SUFFIX='"$(SHLIB_SUFFIX)"' \ +- -DEXT_SUFFIX='"$(EXT_SUFFIX)"' \ ++ -DPYD_PLATFORM_TAG='"$(PYD_PLATFORM_TAG)"' \ + -o $@ $(srcdir)/Python/dynload_win.c + + Python/sysmodule.o: $(srcdir)/Python/sysmodule.c Makefile $(srcdir)/Include/pydtrace.h +@@ -2462,7 +2462,7 @@ libainstall: all scripts + @if test "$(STATIC_LIBPYTHON)" = 1; then \ + if test -d $(LIBRARY); then :; else \ + if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \ +- if test "$(SHLIB_SUFFIX)" = .dll; then \ ++ if test "$(SHLIB_SUFFIX)" = .dll -o "$(SHLIB_SUFFIX)" = .pyd; then \ + $(INSTALL_DATA) $(LDLIBRARY) $(DESTDIR)$(LIBPL) ; \ + else \ + $(INSTALL_DATA) $(LIBRARY) $(DESTDIR)$(LIBPL)/$(LIBRARY) ; \ +diff --git a/Python/dynload_win.c b/Python/dynload_win.c +index 4bb90ba..26d6036 100644 +--- a/Python/dynload_win.c ++++ b/Python/dynload_win.c +@@ -29,12 +29,6 @@ + #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 +diff --git a/configure.ac b/configure.ac +index 4851088..6700d52 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -3438,7 +3438,7 @@ if test -z "$SHLIB_SUFFIX"; then + *) SHLIB_SUFFIX=.so;; + esac + case $host_os in +- mingw*) SHLIB_SUFFIX=.dll;; ++ mingw*) SHLIB_SUFFIX=.pyd;; + esac + fi + AC_MSG_RESULT([$SHLIB_SUFFIX]) +@@ -6198,6 +6198,68 @@ esac + # check for endianness + AC_C_BIGENDIAN + ++AC_SUBST(PYD_PLATFORM_TAG) ++# Special case of PYD_PLATFORM_TAG with python build with mingw. ++# Python can with compiled with clang or gcc and linked ++# to msvcrt or ucrt. To avoid conflicts between them ++# we are selecting the extension as based on the compiler ++# and the runtime they link to ++# gcc + x86_64 + msvcrt = cp{version number}-x86_64 ++# gcc + i686 + msvcrt = cp{version number}-i686 ++# gcc + x86_64 + ucrt = cp{version number}-x86_64-ucrt ++# clang + x86_64 + ucrt = cp{version number}-x86_64-clang ++# clang + i686 + ucrt = cp{version number}-i686-clang ++ ++PYD_PLATFORM_TAG="" ++case $host in ++ *-*-mingw*) ++ # check if we are linking to ucrt ++ AC_MSG_CHECKING(whether linking to ucrt) ++ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ ++ #include ++ #ifndef _UCRT ++ #error no ucrt ++ #endif ++ int main(){ return 0; } ++ ]])],[linking_to_ucrt=yes],[linking_to_ucrt=no]) ++ AC_MSG_RESULT($linking_to_ucrt) ++ ;; ++esac ++case $host_os in ++ mingw*) ++ AC_MSG_CHECKING(PYD_PLATFORM_TAG) ++ case $host in ++ i686-*-mingw*) ++ if test -n "${cc_is_clang}"; then ++ # it is CLANG32 ++ PYD_PLATFORM_TAG="mingw_i686_clang" ++ else ++ if test $linking_to_ucrt = no; then ++ PYD_PLATFORM_TAG="mingw_i686" ++ else ++ PYD_PLATFORM_TAG="mingw_i686_ucrt" ++ fi ++ fi ++ ;; ++ x86_64-*-mingw*) ++ if test -n "${cc_is_clang}"; then ++ # it is CLANG64 ++ PYD_PLATFORM_TAG="mingw_x86_64_clang" ++ else ++ if test $linking_to_ucrt = no; then ++ PYD_PLATFORM_TAG="mingw_x86_64" ++ else ++ PYD_PLATFORM_TAG="mingw_x86_64_ucrt" ++ fi ++ fi ++ ;; ++ aarch64-*-mingw*) ++ PYD_PLATFORM_TAG+="mingw_aarch64" ++ ;; ++ esac ++ AC_MSG_RESULT($PYD_PLATFORM_TAG) ++esac ++ + # ABI version string for Python extension modules. This appears between the + # periods in shared library file names, e.g. foo..so. It is calculated + # from the following attributes which affect the ABI of this Python build (in +@@ -6230,7 +6292,12 @@ if test "$Py_DEBUG" = 'true' -a "$with_trace_refs" != "yes"; then + fi + + AC_SUBST([EXT_SUFFIX]) +-EXT_SUFFIX=.${SOABI}${SHLIB_SUFFIX} ++VERSION_NO_DOTS=$(echo $LDVERSION | tr -d .) ++if test -n "${PYD_PLATFORM_TAG}"; then ++ EXT_SUFFIX=".cp${VERSION_NO_DOTS}-${PYD_PLATFORM_TAG}${SHLIB_SUFFIX}" ++else ++ EXT_SUFFIX=.${SOABI}${SHLIB_SUFFIX} ++fi + + AC_MSG_CHECKING([LDVERSION]) + LDVERSION='$(VERSION)$(ABIFLAGS)' +@@ -6989,12 +7056,6 @@ case "$ac_cv_computed_gotos" in yes*) + AC_DEFINE([HAVE_COMPUTED_GOTOS], [1], + [Define if the C compiler supports computed gotos.]) + 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 + + case $ac_sys_system in + AIX*) diff --git a/mingw-w64-python3.12/0052-Change-the-get_platform-method-in-sysconfig.patch b/mingw-w64-python3.12/0052-Change-the-get_platform-method-in-sysconfig.patch new file mode 100644 index 0000000000..6fcf88d460 --- /dev/null +++ b/mingw-w64-python3.12/0052-Change-the-get_platform-method-in-sysconfig.patch @@ -0,0 +1,61 @@ +From 3a72056f0b45a37febb548801e9d45c55cc06889 Mon Sep 17 00:00:00 2001 +From: Naveen M K +Date: Tue, 21 Sep 2021 21:36:58 +0200 +Subject: [PATCH 052/N] Change the `get_platform()` method in sysconfig + +This would possibly fix building wheels when mingw python +is used and would be unique to each python same as EXT_SUFFIX. + +Also, this modifies the `sys.version` argument to include UCRT +in it. + +Signed-off-by: Naveen M K +--- + Lib/sysconfig.py | 16 ++++++++++++++-- + Python/getcompiler.c | 4 ++++ + 2 files changed, 18 insertions(+), 2 deletions(-) + +diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py +index 08efb9b..44c0ff0 100644 +--- a/Lib/sysconfig.py ++++ b/Lib/sysconfig.py +@@ -795,8 +795,20 @@ def get_platform(): + + """ + if os.name == 'nt': +- if 'GCC' in sys.version: +- return 'mingw' ++ if 'gcc' in sys.version.lower(): ++ if 'ucrt' in sys.version.lower(): ++ if 'amd64' in sys.version.lower(): ++ return 'mingw_x86_64_ucrt' ++ return 'mingw_i686_ucrt' ++ if 'clang' in sys.version.lower(): ++ if 'amd64' in sys.version.lower(): ++ return 'mingw_x86_64_clang' ++ if 'arm64' in sys.version.lower(): ++ return 'mingw_aarch64' ++ return 'mingw_i686_clang' ++ if 'amd64' in sys.version.lower(): ++ return 'mingw_x86_64' ++ return 'mingw_i686' + if 'amd64' in sys.version.lower(): + return 'win-amd64' + if '(arm)' in sys.version.lower(): +diff --git a/Python/getcompiler.c b/Python/getcompiler.c +index 7e7be71..275f799 100644 +--- a/Python/getcompiler.c ++++ b/Python/getcompiler.c +@@ -33,8 +33,12 @@ + #define COMPILER COMP_SEP "[GCC Clang " xstr(__clang_major__) "." \ + xstr(__clang_minor__) "." xstr(__clang_patchlevel__) ARCH_SUFFIX "]" + #else ++#if defined(_UCRT) ++#define COMPILER COMP_SEP "[GCC UCRT " __VERSION__ ARCH_SUFFIX "]" ++#else + #define COMPILER COMP_SEP "[GCC " __VERSION__ ARCH_SUFFIX "]" + #endif ++#endif + // Generic fallbacks. + #elif defined(__cplusplus) + #define COMPILER "[C++]" diff --git a/mingw-w64-python3.12/0053-build-Fix-ncursesw-include-lookup.patch b/mingw-w64-python3.12/0053-build-Fix-ncursesw-include-lookup.patch new file mode 100644 index 0000000000..e5a7f5a28c --- /dev/null +++ b/mingw-w64-python3.12/0053-build-Fix-ncursesw-include-lookup.patch @@ -0,0 +1,51 @@ +From 441d13f416a1b0b4e68fef763a2d798408f40259 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?= + +Date: Thu, 17 Jun 2021 18:52:09 +0530 +Subject: [PATCH 053/N] build: Fix ncursesw include lookup + +Mirror what is already done for libffi; Look it up via +pkg-config and use the exported path via sysconfig in setup.py +--- + Makefile.pre.in | 4 ++++ + configure.ac | 9 ++++++++- + 2 files changed, 12 insertions(+), 1 deletion(-) + +diff --git a/Makefile.pre.in b/Makefile.pre.in +index 7ca010b..769fabc 100644 +--- a/Makefile.pre.in ++++ b/Makefile.pre.in +@@ -347,6 +347,10 @@ IO_OBJS= \ + Modules/_io/bytesio.o \ + Modules/_io/stringio.o + ++########################################################################## ++ ++NCURSESW_INCLUDEDIR= @NCURSESW_INCLUDEDIR@ ++ + ########################################################################## + # Parser + +diff --git a/configure.ac b/configure.ac +index 6700d52..4f71199 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -6849,10 +6849,17 @@ AS_VAR_IF([have_panel], [no], [ + AC_MSG_RESULT([$have_panel (CFLAGS: $PANEL_CFLAGS, LIBS: $PANEL_LIBS)]) + ]) + ++if test -n "$PKG_CONFIG"; then ++ NCURSESW_INCLUDEDIR="`"$PKG_CONFIG" ncursesw --cflags-only-I 2>/dev/null | sed -e 's/^-I//;s/ *$//'`" ++else ++ NCURSESW_INCLUDEDIR="" ++fi ++AC_SUBST(NCURSESW_INCLUDEDIR) ++ + # first curses header check + ac_save_cppflags="$CPPFLAGS" + if test "$cross_compiling" = no; then +- CPPFLAGS="$CPPFLAGS -I/usr/include/ncursesw" ++ CPPFLAGS="$CPPFLAGS -I$NCURSESW_INCLUDEDIR" + fi + + # On Solaris, term.h requires curses.h diff --git a/mingw-w64-python3.12/0054-tests-fix-test_bytes.patch b/mingw-w64-python3.12/0054-tests-fix-test_bytes.patch new file mode 100644 index 0000000000..26f589dcbd --- /dev/null +++ b/mingw-w64-python3.12/0054-tests-fix-test_bytes.patch @@ -0,0 +1,24 @@ +From 2a749b397722a1a87534eb64f000d19f4f993956 Mon Sep 17 00:00:00 2001 +From: Christoph Reiter +Date: Fri, 23 Jul 2021 08:51:32 +0200 +Subject: [PATCH 054/N] tests: fix test_bytes + +%p has different casing with mingw-w64, but it's implementation defined. +Change the test to the mingw-w64 variant. +--- + Lib/test/test_bytes.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py +index a3804a9..4997534 100644 +--- a/Lib/test/test_bytes.py ++++ b/Lib/test/test_bytes.py +@@ -1136,7 +1136,7 @@ def test_from_format(self): + + if os.name == 'nt': + # Windows (MSCRT) +- ptr_format = '0x%0{}X'.format(2 * sizeof_ptr) ++ ptr_format = '0x%0{}x'.format(2 * sizeof_ptr) + def ptr_formatter(ptr): + return (ptr_format % ptr) + else: diff --git a/mingw-w64-python3.12/0055-time-fix-strftime-not-raising-for-invalid-year-value.patch b/mingw-w64-python3.12/0055-time-fix-strftime-not-raising-for-invalid-year-value.patch new file mode 100644 index 0000000000..80139312ad --- /dev/null +++ b/mingw-w64-python3.12/0055-time-fix-strftime-not-raising-for-invalid-year-value.patch @@ -0,0 +1,25 @@ +From 490320311882e23c1afc259695f788f74e310945 Mon Sep 17 00:00:00 2001 +From: Christoph Reiter +Date: Fri, 23 Jul 2021 08:52:50 +0200 +Subject: [PATCH 055/N] time: fix strftime not raising for invalid year + values + +It's crt specific and not compiler specific. +This fixes a test case in test_time +--- + Modules/timemodule.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Modules/timemodule.c b/Modules/timemodule.c +index 3b46dea..aea6097 100644 +--- a/Modules/timemodule.c ++++ b/Modules/timemodule.c +@@ -825,7 +825,7 @@ time_strftime(PyObject *module, PyObject *args) + return NULL; + } + +-#if defined(_MSC_VER) || (defined(__sun) && defined(__SVR4)) || defined(_AIX) || defined(__VXWORKS__) ++#if defined(MS_WINDOWS) || (defined(__sun) && defined(__SVR4)) || defined(_AIX) || defined(__VXWORKS__) + if (buf.tm_year + 1900 < 1 || 9999 < buf.tm_year + 1900) { + PyErr_SetString(PyExc_ValueError, + "strftime() requires year in [1; 9999]"); diff --git a/mingw-w64-python3.12/0056-ctypes-find_library-c-should-return-None-with-ucrt.patch b/mingw-w64-python3.12/0056-ctypes-find_library-c-should-return-None-with-ucrt.patch new file mode 100644 index 0000000000..a7fa56b1b5 --- /dev/null +++ b/mingw-w64-python3.12/0056-ctypes-find_library-c-should-return-None-with-ucrt.patch @@ -0,0 +1,38 @@ +From 4e38eab6ba68953f78ca95f6e133f2de1cac6db3 Mon Sep 17 00:00:00 2001 +From: Christoph Reiter +Date: Fri, 23 Jul 2021 18:23:58 +0200 +Subject: [PATCH 056/N] ctypes: find_library('c') should return None with + ucrt + +Just like with MSVC. This fixes a test in test_ctypes. +--- + Lib/ctypes/util.py | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py +index 0c2510e..48ddb3b 100644 +--- a/Lib/ctypes/util.py ++++ b/Lib/ctypes/util.py +@@ -31,6 +31,12 @@ def _get_build_version(): + # else we don't know what version of the compiler this is + return None + ++ def find_msvcrt_mingw(): ++ is_ucrt = 'clang' in sys.version.lower() or 'ucrt' in sys.version.lower() ++ if is_ucrt: ++ return None ++ return 'msvcrt.dll' ++ + def find_msvcrt(): + """Return the name of the VC runtime dll""" + version = _get_build_version() +@@ -54,6 +60,9 @@ def find_msvcrt(): + + def find_library(name): + if name in ('c', 'm'): ++ import sysconfig ++ if sysconfig.get_platform().startswith('mingw'): ++ return find_msvcrt_mingw() + return find_msvcrt() + # See MSDN for the REAL search order. + for directory in os.environ['PATH'].split(os.pathsep): diff --git a/mingw-w64-python3.12/0057-build-Disable-checks-for-dlopen-dlfcn.patch b/mingw-w64-python3.12/0057-build-Disable-checks-for-dlopen-dlfcn.patch new file mode 100644 index 0000000000..7a958ad177 --- /dev/null +++ b/mingw-w64-python3.12/0057-build-Disable-checks-for-dlopen-dlfcn.patch @@ -0,0 +1,64 @@ +From cd274c6a6ba955931e0d794c2037470e0918bd24 Mon Sep 17 00:00:00 2001 +From: Christoph Reiter +Date: Sun, 25 Jul 2021 13:54:12 +0200 +Subject: [PATCH 057/N] build: Disable checks for dlopen/dlfcn + +While it is (potentially) available with mingw we don't want to use it, so skip any +checks for it. +--- + configure.ac | 21 ++++++++++++++++++--- + 1 file changed, 18 insertions(+), 3 deletions(-) + +diff --git a/configure.ac b/configure.ac +index 4f71199..4b0cd79 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -3026,7 +3026,7 @@ AC_DEFINE([STDC_HEADERS], [1], + + # checks for header files + AC_CHECK_HEADERS([ \ +- alloca.h asm/types.h bluetooth.h conio.h crypt.h direct.h dlfcn.h endian.h errno.h fcntl.h grp.h \ ++ alloca.h asm/types.h bluetooth.h conio.h crypt.h direct.h endian.h errno.h fcntl.h grp.h \ + ieeefp.h io.h langinfo.h libintl.h libutil.h linux/auxvec.h sys/auxv.h linux/fs.h linux/limits.h linux/memfd.h \ + linux/random.h linux/soundcard.h \ + linux/tipc.h linux/wait.h netdb.h net/ethernet.h netinet/in.h netpacket/packet.h poll.h process.h pty.h \ +@@ -3038,6 +3038,13 @@ AC_CHECK_HEADERS([ \ + sys/types.h sys/uio.h sys/un.h sys/utsname.h sys/wait.h sys/xattr.h sysexits.h syslog.h \ + termios.h util.h utime.h utmp.h \ + ]) ++ ++case $host in ++ *-*-mingw*) ;; ++ *) AC_CHECK_HEADERS([dlfcn.h]);; ++esac ++ ++ + AC_HEADER_DIRENT + AC_HEADER_MAJOR + +@@ -3765,7 +3772,12 @@ AC_SUBST([PERF_TRAMPOLINE_OBJ]) + + # checks for libraries + AC_CHECK_LIB([sendfile], [sendfile]) +-AC_CHECK_LIB([dl], [dlopen]) # Dynamic linking for SunOS/Solaris and SYSV ++ ++case $host in ++ *-*-mingw*) ;; ++ *) AC_CHECK_LIB([dl], [dlopen]) ;; # Dynamic linking for SunOS/Solaris and SYSV ++esac ++ + AC_CHECK_LIB([dld], [shl_load]) # Dynamic linking for HP-UX + + +@@ -6108,7 +6120,10 @@ AS_VAR_IF([ac_cv_broken_sem_getvalue], [yes], [ + ) + ]) + +-AC_CHECK_DECLS([RTLD_LAZY, RTLD_NOW, RTLD_GLOBAL, RTLD_LOCAL, RTLD_NODELETE, RTLD_NOLOAD, RTLD_DEEPBIND, RTLD_MEMBER], [], [], [[@%:@include ]]) ++case $host in ++ *-*-mingw*) ;; ++ *) AC_CHECK_DECLS([RTLD_LAZY, RTLD_NOW, RTLD_GLOBAL, RTLD_LOCAL, RTLD_NODELETE, RTLD_NOLOAD, RTLD_DEEPBIND, RTLD_MEMBER], [], [], [[@%:@include ]]) ++esac + + # determine what size digit to use for Python's longs + AC_MSG_CHECKING([digit size for Python's longs]) diff --git a/mingw-w64-python3.12/0058-Fix-install-location-of-the-import-library.patch b/mingw-w64-python3.12/0058-Fix-install-location-of-the-import-library.patch new file mode 100644 index 0000000000..89f363b6a6 --- /dev/null +++ b/mingw-w64-python3.12/0058-Fix-install-location-of-the-import-library.patch @@ -0,0 +1,22 @@ +From 3002b516f9a4a13744b94f51259b6db15576def7 Mon Sep 17 00:00:00 2001 +From: Christoph Reiter +Date: Sun, 25 Jul 2021 15:46:01 +0200 +Subject: [PATCH 058/N] Fix install location of the import library + +--- + Makefile.pre.in | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Makefile.pre.in b/Makefile.pre.in +index 769fabc..84fc56c 100644 +--- a/Makefile.pre.in ++++ b/Makefile.pre.in +@@ -2467,7 +2467,7 @@ libainstall: all scripts + if test -d $(LIBRARY); then :; else \ + if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \ + if test "$(SHLIB_SUFFIX)" = .dll -o "$(SHLIB_SUFFIX)" = .pyd; then \ +- $(INSTALL_DATA) $(LDLIBRARY) $(DESTDIR)$(LIBPL) ; \ ++ $(INSTALL_DATA) $(LDLIBRARY) $(DESTDIR)$(LIBDIR) ; \ + else \ + $(INSTALL_DATA) $(LIBRARY) $(DESTDIR)$(LIBPL)/$(LIBRARY) ; \ + fi; \ diff --git a/mingw-w64-python3.12/0059-build-Integrate-venvlauncher-build-installation-into.patch b/mingw-w64-python3.12/0059-build-Integrate-venvlauncher-build-installation-into.patch new file mode 100644 index 0000000000..93d95adb75 --- /dev/null +++ b/mingw-w64-python3.12/0059-build-Integrate-venvlauncher-build-installation-into.patch @@ -0,0 +1,76 @@ +From 6d8ce76ab34dd2571362037b4eaf0088b1c58641 Mon Sep 17 00:00:00 2001 +From: Christoph Reiter +Date: Sun, 25 Jul 2021 16:53:35 +0200 +Subject: [PATCH 059/N] build: Integrate venvlauncher build/installation into + the Makefile + +This is required for venv creation on Windows. +Ideally this would use the venv specific launcher (PC/launcher.c), +but a copy of main binary seems to work as well for now. +--- + Makefile.pre.in | 17 +++++++++++++++-- + 1 file changed, 15 insertions(+), 2 deletions(-) + +diff --git a/Makefile.pre.in b/Makefile.pre.in +index 84fc56c..4a6e692 100644 +--- a/Makefile.pre.in ++++ b/Makefile.pre.in +@@ -170,6 +170,7 @@ BINLIBDEST= @BINLIBDEST@ + LIBDEST= $(SCRIPTDIR)/python$(VERSION) + INCLUDEPY= $(INCLUDEDIR)/python$(LDVERSION) + CONFINCLUDEPY= $(CONFINCLUDEDIR)/python$(LDVERSION) ++VENVLAUNCHERDIR= $(BINLIBDEST)/venv/scripts/nt + + # Symbols used for using shared libraries + SHLIB_SUFFIX= @SHLIB_SUFFIX@ +@@ -290,6 +291,8 @@ LIBOBJS= @LIBOBJS@ + PYTHON= python$(EXE) + BUILDPYTHON= python$(BUILDEXE) + BUILDPYTHONW= pythonw$(BUILDEXE) ++BUILDVENVLAUNCHER= venvlauncher$(BUILDEXE) ++BUILDVENVWLAUNCHER= venvwlauncher$(BUILDEXE) + + HOSTRUNNER= @HOSTRUNNER@ + +@@ -628,7 +631,7 @@ all: @DEF_MAKE_ALL_RULE@ + .PHONY: all + + .PHONY: build_all +-build_all: check-clean-src $(BUILDPYTHON) $(BUILDPYTHONW) platform sharedmods \ ++build_all: check-clean-src $(BUILDPYTHON) $(BUILDPYTHONW) $(BUILDVENVLAUNCHER) $(BUILDVENVWLAUNCHER) platform sharedmods \ + gdbhooks Programs/_testembed scripts checksharedmods rundsymutil + + .PHONY: build_wasm +@@ -809,6 +812,14 @@ $(BUILDPYTHONW): Programs/python.o $(LIBRARY) $(LDLIBRARY) $(PY3LIBRARY) pythonw + $(BUILDPYTHON): Programs/python.o $(LINK_PYTHON_DEPS) python_exe.o + $(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -municode -o $@ Programs/python.o $(LINK_PYTHON_OBJS) $(LIBS) $(MODLIBS) $(SYSLIBS) python_exe.o + ++# FIXME: build these from PC/launcher.c instead ++$(BUILDVENVLAUNCHER): $(BUILDPYTHON) ++ cp $(BUILDPYTHON) $(BUILDVENVLAUNCHER) ++ ++# FIXME: build these from PC/launcher.c instead ++$(BUILDVENVWLAUNCHER): $(BUILDPYTHONW) ++ cp $(BUILDPYTHONW) $(BUILDVENVWLAUNCHER) ++ + platform: $(PYTHON_FOR_BUILD_DEPS) 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 + +@@ -1984,7 +1995,7 @@ sharedinstall: all + # This goes into $(exec_prefix) + .PHONY: altbininstall + altbininstall: $(BUILDPYTHON) @FRAMEWORKPYTHONW@ +- @for i in $(BINDIR) $(LIBDIR); \ ++ @for i in $(BINDIR) $(LIBDIR) $(VENVLAUNCHERDIR); \ + do \ + if test ! -d $(DESTDIR)$$i; then \ + echo "Creating directory $$i"; \ +@@ -1995,6 +2006,8 @@ altbininstall: $(BUILDPYTHON) @FRAMEWORKPYTHONW@ + if test "$(PYTHONFRAMEWORKDIR)" = "no-framework" ; then \ + $(INSTALL_PROGRAM) $(BUILDPYTHON) $(DESTDIR)$(BINDIR)/python$(LDVERSION)$(EXE); \ + $(INSTALL_PROGRAM) $(BUILDPYTHONW) $(DESTDIR)$(BINDIR)/python3w$(EXE); \ ++ $(INSTALL_PROGRAM) $(BUILDPYTHON) $(DESTDIR)$(VENVLAUNCHERDIR)/python$(EXE); \ ++ $(INSTALL_PROGRAM) $(BUILDPYTHONW) $(DESTDIR)$(VENVLAUNCHERDIR)/pythonw$(EXE); \ + else \ + $(INSTALL_PROGRAM) $(STRIPFLAG) Mac/pythonw $(DESTDIR)$(BINDIR)/python$(LDVERSION)$(EXE); \ + fi diff --git a/mingw-w64-python3.12/0060-configure.ac-set-_WIN32_WINNT-version.patch b/mingw-w64-python3.12/0060-configure.ac-set-_WIN32_WINNT-version.patch new file mode 100644 index 0000000000..89f35a9bb4 --- /dev/null +++ b/mingw-w64-python3.12/0060-configure.ac-set-_WIN32_WINNT-version.patch @@ -0,0 +1,25 @@ +From cdf16e5cb3f6b36a4406b41bd7339986ae2fc4e9 Mon Sep 17 00:00:00 2001 +From: Christoph Reiter +Date: Sun, 1 Aug 2021 15:18:50 +0200 +Subject: [PATCH 060/N] configure.ac: set _WIN32_WINNT version + +--- + configure.ac | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/configure.ac b/configure.ac +index 4b0cd79..f14e51a 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -4547,6 +4547,11 @@ done + IFS=$as_save_IFS + AC_MSG_RESULT([$DBM_CFLAGS $DBM_LIBS]) + ++case $host in ++ *-*-mingw*) ++ CFLAGS_NODIST="$CFLAGS_NODIST -D_WIN32_WINNT=0x0602";; ++esac ++ + # Determine if windows modules should be used. + AC_SUBST(USE_WIN32_MODULE) + USE_WIN32_MODULE='#' diff --git a/mingw-w64-python3.12/0061-configure.ac-don-t-check-for-clock_-functions.patch b/mingw-w64-python3.12/0061-configure.ac-don-t-check-for-clock_-functions.patch new file mode 100644 index 0000000000..ac612f7bbb --- /dev/null +++ b/mingw-w64-python3.12/0061-configure.ac-don-t-check-for-clock_-functions.patch @@ -0,0 +1,33 @@ +From aa626c00d72c0dd5a258f39673bf54bbe8b56fd2 Mon Sep 17 00:00:00 2001 +From: Christoph Reiter +Date: Sun, 1 Aug 2021 18:35:17 +0200 +Subject: [PATCH 061/N] configure.ac: don't check for clock_ functions + +They shouldn't be exposed on Windows and lead to winpthread being linked in +--- + configure.ac | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/configure.ac b/configure.ac +index f14e51a..fc1f083 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -5488,6 +5488,9 @@ WITH_SAVE_ENV([ + ]) + ]) + ++case $host in ++ *-*-mingw*) ;; ++ *) + AC_CHECK_FUNCS([clock_gettime], [], [ + AC_CHECK_LIB([rt], [clock_gettime], [ + LIBS="$LIBS -lrt" +@@ -5508,6 +5511,8 @@ AC_CHECK_FUNCS([clock_settime], [], [ + AC_DEFINE([HAVE_CLOCK_SETTIME], [1]) + ]) + ]) ++ ;; ++esac + + AC_CHECK_FUNCS([clock_nanosleep], [], [ + AC_CHECK_LIB([rt], [clock_nanosleep], [ diff --git a/mingw-w64-python3.12/0062-expanduser-normpath-paths-coming-from-env-vars.patch b/mingw-w64-python3.12/0062-expanduser-normpath-paths-coming-from-env-vars.patch new file mode 100644 index 0000000000..3707937d7a --- /dev/null +++ b/mingw-w64-python3.12/0062-expanduser-normpath-paths-coming-from-env-vars.patch @@ -0,0 +1,32 @@ +From bc61e3a11754715d70914052e159ee0e6f0046bc Mon Sep 17 00:00:00 2001 +From: Christoph Reiter +Date: Sun, 8 Aug 2021 10:17:35 +0200 +Subject: [PATCH 062/N] expanduser: normpath paths coming from env vars + +This makes sure we get the same paths as with related functions in pathlib. +--- + Lib/ntpath.py | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/Lib/ntpath.py b/Lib/ntpath.py +index ce683b1..309235b 100644 +--- a/Lib/ntpath.py ++++ b/Lib/ntpath.py +@@ -379,7 +379,7 @@ def expanduser(path): + if 'USERPROFILE' in os.environ: + userhome = os.environ['USERPROFILE'] + elif not 'HOMEPATH' in os.environ: +- return path ++ return os.path.normpath(path) + else: + try: + drive = os.environ['HOMEDRIVE'] +@@ -406,7 +406,7 @@ def expanduser(path): + if isinstance(path, bytes): + userhome = os.fsencode(userhome) + +- return userhome + path[i:] ++ return os.path.normpath(userhome) + path[i:] + + + # Expand paths containing shell variable substitutions. diff --git a/mingw-w64-python3.12/0063-CI-test-the-build-and-add-some-mingw-specific-tests.patch b/mingw-w64-python3.12/0063-CI-test-the-build-and-add-some-mingw-specific-tests.patch new file mode 100644 index 0000000000..82ba6cf330 --- /dev/null +++ b/mingw-w64-python3.12/0063-CI-test-the-build-and-add-some-mingw-specific-tests.patch @@ -0,0 +1,680 @@ +From 4c1a33f26848d4e2a3107d910101edebf558a905 Mon Sep 17 00:00:00 2001 +From: Naveen M K +Date: Fri, 18 Jun 2021 17:51:59 +0530 +Subject: [PATCH 063/N] CI: test the build and add some mingw specific tests + +- Use actions/setup-python for setting up correct version in cross build +- CI: add cross llvm-mingw jobs +- CI: fix sed pattern for python-config.py shebang + The shebang (`#!`) does not include `${pkgdir}` so this sed did nothing +- CI: remove --without-c-locale-coercion + No longer needed since the default now works on Windows +- Make sure we always use the stdlib distutils +- CI: update actions and images + ubuntu-18.04 is gone now +- CI: updates for mstorsjo/llvm-mingw moving to 20.04 +- CI: 3.10 -> 3.11 +--- + .github/workflows/mingw.yml | 289 +++++++++++++++++++++++++++++++++ + mingw_ignorefile.txt | 34 ++++ + mingw_smoketests.py | 313 ++++++++++++++++++++++++++++++++++++ + 3 files changed, 636 insertions(+) + create mode 100644 .github/workflows/mingw.yml + create mode 100644 mingw_ignorefile.txt + create mode 100644 mingw_smoketests.py + +diff --git a/.github/workflows/mingw.yml b/.github/workflows/mingw.yml +new file mode 100644 +index 0000000..6445b6b +--- /dev/null ++++ b/.github/workflows/mingw.yml +@@ -0,0 +1,289 @@ ++name: Build ++on: [push, pull_request, workflow_dispatch] ++ ++jobs: ++ build: ++ runs-on: windows-2022 ++ strategy: ++ fail-fast: false ++ matrix: ++ msystem: ['MINGW64','MINGW32','UCRT64','CLANG64','CLANG32'] ++ include: ++ - msystem: MINGW64 ++ prefix: mingw-w64-x86_64 ++ - msystem: MINGW32 ++ prefix: mingw-w64-i686 ++ - msystem: UCRT64 ++ prefix: mingw-w64-ucrt-x86_64 ++ - msystem: CLANG64 ++ prefix: mingw-w64-clang-x86_64 ++ - msystem: CLANG32 ++ prefix: mingw-w64-clang-i686 ++ steps: ++ - name: Setup git ++ run: | ++ git config --global core.autocrlf false ++ git config --global core.eol lf ++ - uses: actions/checkout@v3 ++ - uses: msys2/setup-msys2@v2 ++ with: ++ msystem: ${{ matrix.msystem }} ++ release: false ++ update: true ++ install: >- ++ make ++ binutils ++ autoconf ++ autoconf-archive ++ automake-wrapper ++ tar ++ gzip ++ ${{ matrix.prefix }}-toolchain ++ ${{ matrix.prefix }}-expat ++ ${{ matrix.prefix }}-bzip2 ++ ${{ matrix.prefix }}-libffi ++ ${{ matrix.prefix }}-mpdecimal ++ ${{ matrix.prefix }}-ncurses ++ ${{ matrix.prefix }}-openssl ++ ${{ matrix.prefix }}-sqlite3 ++ ${{ matrix.prefix }}-tcl ++ ${{ matrix.prefix }}-tk ++ ${{ matrix.prefix }}-zlib ++ ${{ matrix.prefix }}-xz ++ ${{ matrix.prefix }}-tzdata ++ ++ - name: Build Python ++ shell: msys2 {0} ++ run: | ++ set -ex ++ ++ if [[ "${{ matrix.msystem }}" == "CLANG64" ]] || [[ "${{ matrix.msystem }}" == "CLANG32" ]]; then ++ export CC=clang ++ export CXX=clang++ ++ fi ++ autoreconf -vfi ++ ++ rm -Rf _build && mkdir _build && cd _build ++ ++ ../configure \ ++ --prefix=${MINGW_PREFIX} \ ++ --host=${MINGW_CHOST} \ ++ --build=${MINGW_CHOST} \ ++ --enable-shared \ ++ --with-system-expat \ ++ --with-system-libmpdec \ ++ --without-ensurepip \ ++ --enable-loadable-sqlite-extensions \ ++ --with-tzpath=${MINGW_PREFIX}/share/zoneinfo \ ++ --enable-optimizations ++ ++ make -j8 ++ ++ - name: Run Smoke Test (build) ++ shell: msys2 {0} ++ run: | ++ SMOKETESTS="$(pwd)/mingw_smoketests.py" ++ cd _build ++ ./python.exe "$SMOKETESTS" ++ MSYSTEM= ./python.exe "$SMOKETESTS" ++ ++ - name: Run tests ++ shell: msys2 {0} ++ run: | ++ IGNOREFILE="$(pwd)/mingw_ignorefile.txt" ++ cd _build ++ MSYSTEM= ./python.exe -m test -j8 --ignorefile "$IGNOREFILE" -W ++ ++ - name: Run broken tests ++ continue-on-error: true ++ shell: msys2 {0} ++ run: | ++ IGNOREFILE="$(pwd)/mingw_ignorefile.txt" ++ cd _build ++ MSYSTEM= ./python.exe -m test -j8 --matchfile "$IGNOREFILE" -W ++ ++ - name: Install ++ shell: msys2 {0} ++ run: | ++ set -ex ++ cd _build ++ ++ pkgdir=python_pkgdir ++ ++ make -j1 install DESTDIR="${pkgdir}" ++ ++ # Fix shebangs ++ _pybasever=$(./python.exe -c "import sys; print(f'{sys.version_info[0]}.{sys.version_info[1]}');") ++ 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 ++ sed -i "s|#!${MINGW_PREFIX}/bin/python${_pybasever}.exe|#!/usr/bin/env python${_pybasever}.exe|" "${pkgdir}${MINGW_PREFIX}"/lib/python${_pybasever}/config-${_pybasever}/python-config.py ++ ++ # Create version-less aliases ++ 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 ++ ++ - name: Run Smoke Test (installed) ++ shell: msys2 {0} ++ run: | ++ export PYTHONTZPATH="${MINGW_PREFIX}/share/zoneinfo" ++ SMOKETESTS="$(pwd)/mingw_smoketests.py" ++ cd _build ++ cd python_pkgdir/${MINGW_PREFIX}/bin ++ ./python.exe "$SMOKETESTS" ++ MSYSTEM= ./python.exe "$SMOKETESTS" ++ ++ - name: Compress ++ if: always() ++ shell: msys2 {0} ++ run: | ++ cd _build ++ tar -zcf python.tar.gz python_pkgdir/ ++ ++ - name: Upload ++ uses: actions/upload-artifact@v3 ++ if: always() ++ with: ++ name: build-${{ matrix.msystem }} ++ path: _build/python.tar.gz ++ ++ cross-gcc-x86_64: ++ runs-on: ubuntu-latest ++ container: ++ image: archlinux:base-devel ++ steps: ++ - uses: actions/checkout@v3 ++ - name: Install deps ++ run: | ++ pacman --noconfirm -Suuy ++ pacman --needed --noconfirm -S mingw-w64-gcc autoconf-archive autoconf automake zip ++ ++ - uses: actions/setup-python@v4 ++ with: ++ python-version: '3.12' ++ ++ - name: Check Python Version ++ run: | ++ which python ++ python --version ++ ++ - name: Build ++ run: | ++ autoreconf -vfi ++ ++ mkdir _build && cd _build ++ ++ ../configure \ ++ --host=x86_64-w64-mingw32 \ ++ --build=x86_64-pc-linux-gnu \ ++ --enable-shared \ ++ --with-system-expat \ ++ --with-system-ffi \ ++ --with-system-libmpdec \ ++ --without-ensurepip \ ++ --enable-loadable-sqlite-extensions \ ++ --with-build-python=yes ++ ++ make -j8 ++ ++ make install DESTDIR="$(pwd)/install" ++ ++ - name: 'Zip files' ++ run: | ++ zip -r install.zip _build/install ++ ++ - name: Upload ++ uses: actions/upload-artifact@v3 ++ with: ++ name: build-cross-gcc-x86_64 ++ path: install.zip ++ ++ cross-gcc-x86_64-test: ++ needs: [cross-gcc-x86_64] ++ runs-on: windows-latest ++ steps: ++ - uses: actions/download-artifact@v3 ++ with: ++ name: build-cross-gcc-x86_64 ++ ++ - name: 'Run tests' ++ run: | ++ 7z x install.zip ++ ./_build/install/usr/local/bin/python3.exe -c "import sysconfig, pprint; pprint.pprint(sysconfig.get_config_vars())" ++ ++ ++ cross-llvm-mingw: ++ runs-on: ubuntu-latest ++ container: ++ image: mstorsjo/llvm-mingw:latest ++ strategy: ++ fail-fast: false ++ matrix: ++ arch: ['x86_64', 'i686', 'aarch64', 'armv7'] ++ steps: ++ - uses: actions/checkout@v3 ++ ++ - name: Install deps ++ run: | ++ export DEBIAN_FRONTEND=noninteractive ++ apt-get update -qq ++ apt-get install -qqy software-properties-common ++ add-apt-repository --yes ppa:deadsnakes/ppa ++ apt-get update -qq ++ apt-get install -qqy autoconf-archive python3.12-dev python3.12 ++ ++ - name: Build ++ run: | ++ autoreconf -vfi ++ ++ mkdir _build && cd _build ++ ++ export CC=${{ matrix.arch }}-w64-mingw32-clang ++ export CXX=${CC}++ ++ ../configure \ ++ --host=${{ matrix.arch }}-w64-mingw32 \ ++ --build=x86_64-pc-linux-gnu \ ++ --enable-shared \ ++ --with-system-expat \ ++ --with-system-ffi \ ++ --with-system-libmpdec \ ++ --without-ensurepip \ ++ --without-c-locale-coercion \ ++ --enable-loadable-sqlite-extensions \ ++ --with-build-python=yes ++ ++ make -j8 ++ ++ make install DESTDIR="$(pwd)/install" ++ ++ - name: 'Zip files' ++ run: | ++ zip -r install.zip _build/install ++ ++ - name: Upload ++ uses: actions/upload-artifact@v3 ++ with: ++ name: build-cross-llvm-mingw-${{ matrix.arch }} ++ path: install.zip ++ ++ cross-llvm-mingw-test: ++ needs: [cross-llvm-mingw] ++ runs-on: windows-latest ++ strategy: ++ fail-fast: false ++ matrix: ++ arch: ['x86_64', 'i686'] ++ steps: ++ - uses: actions/download-artifact@v3 ++ with: ++ name: build-cross-llvm-mingw-${{ matrix.arch }} ++ ++ - name: 'Run tests' ++ run: | ++ 7z x install.zip ++ ./_build/install/usr/local/bin/python3.exe -c "import sysconfig, pprint; pprint.pprint(sysconfig.get_config_vars())" ++ ++ +diff --git a/mingw_ignorefile.txt b/mingw_ignorefile.txt +new file mode 100644 +index 0000000..dc3802e +--- /dev/null ++++ b/mingw_ignorefile.txt +@@ -0,0 +1,34 @@ ++ctypes.test.test_loading.LoaderTest.test_load_dll_with_flags ++distutils.tests.test_bdist_dumb.BuildDumbTestCase.test_simple_built ++distutils.tests.test_cygwinccompiler.CygwinCCompilerTestCase.test_get_versions ++distutils.tests.test_util.UtilTestCase.test_change_root ++test.datetimetester.TestLocalTimeDisambiguation_Fast.* ++test.datetimetester.TestLocalTimeDisambiguation_Pure.* ++test.test_cmath.CMathTests.test_specific_values ++test.test_cmd_line_script.CmdLineTest.test_consistent_sys_path_for_direct_execution ++test.test_compileall.CommandLineTestsNoSourceEpoch.* ++test.test_compileall.CommandLineTestsWithSourceEpoch.* ++test.test_compileall.CompileallTestsWithoutSourceEpoch.* ++test.test_compileall.CompileallTestsWithSourceEpoch.* ++test.test_import.ImportTests.test_dll_dependency_import ++test.test_math.MathTests.* ++test.test_ntpath.NtCommonTest.test_import ++test.test_os.StatAttributeTests.test_stat_block_device ++test.test_os.TestScandir.test_attributes ++test.test_os.UtimeTests.test_large_time ++test.test_platform.PlatformTest.test_architecture_via_symlink ++test.test_regrtest.ProgramsTestCase.test_pcbuild_rt ++test.test_regrtest.ProgramsTestCase.test_tools_buildbot_test ++test.test_site._pthFileTests.* ++test.test_site.HelperFunctionsTests.* ++test.test_site.StartupImportTests.* ++test.test_ssl.* ++test.test_strptime.CalculationTests.* ++test.test_strptime.StrptimeTests.test_weekday ++test.test_strptime.TimeRETests.test_compile ++test.test_tools.test_i18n.Test_pygettext.test_POT_Creation_Date ++test.test_venv.BasicTest.* ++test.test_venv.EnsurePipTest.* ++# flaky ++test.test__xxsubinterpreters.* ++test.test_asyncio.test_subprocess.SubprocessProactorTests.test_stdin_broken_pipe +\ No newline at end of file +diff --git a/mingw_smoketests.py b/mingw_smoketests.py +new file mode 100644 +index 0000000..d92c74a +--- /dev/null ++++ b/mingw_smoketests.py +@@ -0,0 +1,313 @@ ++#!/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 ++import sysconfig ++ ++if "MSYSTEM" in os.environ: ++ SEP = "/" ++else: ++ SEP = "\\" ++ ++_UCRT = "clang" in sysconfig.get_platform() or "ucrt" in sysconfig.get_platform() ++ ++ ++class Tests(unittest.TestCase): ++ ++ def test_zoneinfo(self): ++ # https://github.com/msys2-contrib/cpython-mingw/issues/32 ++ import zoneinfo ++ self.assertTrue(any(os.path.exists(p) for p in zoneinfo.TZPATH)) ++ zoneinfo.ZoneInfo("America/Sao_Paulo") ++ ++ def test_userdir_path_sep(self): ++ # Make sure os.path and pathlib use the same path separators ++ from unittest import mock ++ from os.path import expanduser ++ from pathlib import Path ++ ++ profiles = ["C:\\foo", "C:/foo"] ++ for profile in profiles: ++ with mock.patch.dict(os.environ, {"USERPROFILE": profile}): ++ self.assertEqual(expanduser("~"), os.path.normpath(expanduser("~"))) ++ self.assertEqual(str(Path("~").expanduser()), expanduser("~")) ++ self.assertEqual(str(Path.home()), expanduser("~")) ++ ++ def test_sysconfig_schemes(self): ++ # https://github.com/msys2/MINGW-packages/issues/9319 ++ import sysconfig ++ from distutils.dist import Distribution ++ from distutils.command.install import install ++ ++ names = ['scripts', 'purelib', 'platlib', 'data', 'include'] ++ for scheme in ["nt", "nt_user"]: ++ for name in names: ++ c = install(Distribution({"name": "foobar"})) ++ c.user = (scheme == "nt_user") ++ c.finalize_options() ++ if name == "include": ++ dist_path = os.path.dirname(getattr(c, "install_" + "headers")) ++ else: ++ dist_path = getattr(c, "install_" + name) ++ sys_path = sysconfig.get_path(name, scheme) ++ self.assertEqual(dist_path, sys_path, (scheme, name)) ++ ++ def test_ctypes_find_library(self): ++ from ctypes.util import find_library ++ from ctypes import cdll ++ self.assertTrue(cdll.msvcrt) ++ if _UCRT: ++ self.assertIsNone(find_library('c')) ++ else: ++ self.assertEqual(find_library('c'), 'msvcrt.dll') ++ ++ def test_ctypes_dlopen(self): ++ import ctypes ++ import sys ++ self.assertEqual(ctypes.RTLD_GLOBAL, 0) ++ self.assertEqual(ctypes.RTLD_GLOBAL, ctypes.RTLD_LOCAL) ++ self.assertFalse(hasattr(sys, 'setdlopenflags')) ++ self.assertFalse(hasattr(sys, 'getdlopenflags')) ++ self.assertFalse([n for n in dir(os) if n.startswith("RTLD_")]) ++ ++ def test_time_no_unix_stuff(self): ++ import time ++ self.assertFalse([n for n in dir(time) if n.startswith("clock_")]) ++ self.assertFalse([n for n in dir(time) if n.startswith("CLOCK_")]) ++ self.assertFalse([n for n in dir(time) if n.startswith("pthread_")]) ++ self.assertFalse(hasattr(time, 'tzset')) ++ ++ def test_strftime(self): ++ import time ++ with self.assertRaises(ValueError): ++ time.strftime('%Y', (12345,) + (0,) * 8) ++ ++ 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 ++ import curses ++ ++ def test_c_modules_import(self): ++ import _decimal ++ ++ 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 test_platform_things(self): ++ import sys ++ import sysconfig ++ import platform ++ import importlib.machinery ++ self.assertEqual(sys.implementation.name, "cpython") ++ self.assertEqual(sys.platform, "win32") ++ self.assertTrue(sysconfig.get_platform().startswith("mingw")) ++ self.assertTrue(sysconfig.get_config_var('SOABI').startswith("cpython-")) ++ ext_suffix = sysconfig.get_config_var('EXT_SUFFIX') ++ self.assertTrue(ext_suffix.endswith(".pyd")) ++ self.assertTrue("mingw" in ext_suffix) ++ self.assertEqual(sysconfig.get_config_var('SHLIB_SUFFIX'), ".pyd") ++ ext_suffixes = importlib.machinery.EXTENSION_SUFFIXES ++ self.assertTrue(ext_suffix in ext_suffixes) ++ self.assertTrue(".pyd" in ext_suffixes) ++ self.assertEqual(sys.winver, ".".join(map(str, sys.version_info[:2]))) ++ self.assertEqual(platform.python_implementation(), "CPython") ++ self.assertEqual(platform.system(), "Windows") ++ self.assertTrue(isinstance(sys.api_version, int) and sys.api_version > 0) ++ ++ def test_c_ext_build(self): ++ import tempfile ++ import sys ++ import subprocess ++ import textwrap ++ from pathlib import Path ++ ++ with tempfile.TemporaryDirectory() as tmppro: ++ subprocess.check_call([sys.executable, "-m", "ensurepip", "--user"]) ++ with Path(tmppro, "setup.py").open("w") as f: ++ f.write( ++ textwrap.dedent( ++ """\ ++ from setuptools import setup, Extension ++ ++ setup( ++ name='cwrapper', ++ version='1.0', ++ ext_modules=[ ++ Extension( ++ 'cwrapper', ++ sources=['cwrapper.c']), ++ ], ++ ) ++ """ ++ ) ++ ) ++ with Path(tmppro, "cwrapper.c").open("w") as f: ++ f.write( ++ textwrap.dedent( ++ """\ ++ #include ++ static PyObject * ++ helloworld(PyObject *self, PyObject *args) ++ { ++ printf("Hello World\\n"); ++ Py_RETURN_NONE; ++ } ++ static PyMethodDef ++ myMethods[] = { ++ { "helloworld", helloworld, METH_NOARGS, "Prints Hello World" }, ++ { NULL, NULL, 0, NULL } ++ }; ++ static struct PyModuleDef cwrapper = { ++ PyModuleDef_HEAD_INIT, ++ "cwrapper", ++ "Test Module", ++ -1, ++ myMethods ++ }; ++ ++ PyMODINIT_FUNC ++ PyInit_cwrapper(void) ++ { ++ return PyModule_Create(&cwrapper); ++ } ++ """ ++ ) ++ ) ++ subprocess.check_call( ++ [sys.executable, "-c", "import struct"], ++ ) ++ subprocess.check_call( ++ [ ++ sys.executable, ++ "-m", ++ "pip", ++ "install", ++ "wheel", ++ ], ++ ) ++ subprocess.check_call( ++ [ ++ sys.executable, ++ "-m", ++ "pip", ++ "install", ++ tmppro, ++ ], ++ ) ++ subprocess.check_call( ++ [sys.executable, "-c", "import cwrapper"], ++ ) ++ ++ ++ ++def suite(): ++ return unittest.TestLoader().loadTestsFromName(__name__) ++ ++ ++if __name__ == '__main__': ++ unittest.main(defaultTest='suite') diff --git a/mingw-w64-python3.12/0064-Define-PY3_DLLNAME-to-fix-build.patch b/mingw-w64-python3.12/0064-Define-PY3_DLLNAME-to-fix-build.patch new file mode 100644 index 0000000000..f836e2b937 --- /dev/null +++ b/mingw-w64-python3.12/0064-Define-PY3_DLLNAME-to-fix-build.patch @@ -0,0 +1,26 @@ +From 731fa5ca973d4ceca4f8679e17a176051314bb2c Mon Sep 17 00:00:00 2001 +From: Naveen M K +Date: Tue, 12 Oct 2021 18:35:21 +0530 +Subject: [PATCH 064/N] Define PY3_DLLNAME to fix build + +PY3_DLLNAME is used in Python/pathconfig.c but isn't +defined. I guess it is useless but it will fix the build. + +Co-authored-by: jeremyd2019 +--- + configure.ac | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/configure.ac b/configure.ac +index fc1f083..2d3c574 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -5093,7 +5093,7 @@ then + *-*-mingw*) + DYNLOADFILE="dynload_win.o" + extra_machdep_objs="$extra_machdep_objs PC/dl_nt.o" +- CFLAGS_NODIST="$CFLAGS_NODIST -DMS_DLL_ID='\"$VERSION\"'" ++ CFLAGS_NODIST="$CFLAGS_NODIST -DMS_DLL_ID='\"$VERSION\"' -DPY3_DLLNAME='L\"$DLLLIBRARY\"'" + ;; + esac + fi diff --git a/mingw-w64-python3.12/0065-_testconsole.c-Fix-casing-path-sep.patch b/mingw-w64-python3.12/0065-_testconsole.c-Fix-casing-path-sep.patch new file mode 100644 index 0000000000..c8ace8582a --- /dev/null +++ b/mingw-w64-python3.12/0065-_testconsole.c-Fix-casing-path-sep.patch @@ -0,0 +1,22 @@ +From 453ebc55f3cc7a69f946f6ba43c89afe455cd052 Mon Sep 17 00:00:00 2001 +From: Long Nguyen +Date: Sun, 14 Nov 2021 14:55:35 +0700 +Subject: [PATCH 065/N] _testconsole.c: Fix casing & path sep + +--- + PC/_testconsole.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/PC/_testconsole.c b/PC/_testconsole.c +index 3221b98..47fbe6f 100644 +--- a/PC/_testconsole.c ++++ b/PC/_testconsole.c +@@ -116,7 +116,7 @@ _testconsole_read_output_impl(PyObject *module, PyObject *file) + Py_RETURN_NONE; + } + +-#include "clinic\_testconsole.c.h" ++#include "clinic/_testconsole.c.h" + + PyMethodDef testconsole_methods[] = { + _TESTCONSOLE_WRITE_INPUT_METHODDEF diff --git a/mingw-w64-python3.12/0066-Return-consistent-architecture-markers-for-python-on.patch b/mingw-w64-python3.12/0066-Return-consistent-architecture-markers-for-python-on.patch new file mode 100644 index 0000000000..ee4791d423 --- /dev/null +++ b/mingw-w64-python3.12/0066-Return-consistent-architecture-markers-for-python-on.patch @@ -0,0 +1,52 @@ +From 52eb9560ea54ecf155b91c01fa1c305367f0c19d Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Martin=20Storsj=C3=B6?= +Date: Fri, 19 Nov 2021 12:18:06 +0200 +Subject: [PATCH 066/N] Return consistent architecture markers for python on + mingw/armv7 + +--- + Lib/sysconfig.py | 2 ++ + Python/getcompiler.c | 2 ++ + configure.ac | 3 +++ + 3 files changed, 7 insertions(+) + +diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py +index 44c0ff0..33f8cd8 100644 +--- a/Lib/sysconfig.py ++++ b/Lib/sysconfig.py +@@ -805,6 +805,8 @@ def get_platform(): + return 'mingw_x86_64_clang' + if 'arm64' in sys.version.lower(): + return 'mingw_aarch64' ++ if 'arm' in sys.version.lower(): ++ return 'mingw_armv7' + return 'mingw_i686_clang' + if 'amd64' in sys.version.lower(): + return 'mingw_x86_64' +diff --git a/Python/getcompiler.c b/Python/getcompiler.c +index 275f799..4b0b9b3 100644 +--- a/Python/getcompiler.c ++++ b/Python/getcompiler.c +@@ -20,6 +20,8 @@ + #define ARCH_SUFFIX " 64 bit (AMD64)" + #elif defined(__aarch64__) + #define ARCH_SUFFIX " 64 bit (ARM64)" ++#elif defined(__arm__) ++#define ARCH_SUFFIX " 32 bit (ARM)" + #else + #define ARCH_SUFFIX " 32 bit" + #endif +diff --git a/configure.ac b/configure.ac +index 2d3c574..ecab56d 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -6281,6 +6281,9 @@ case $host_os in + aarch64-*-mingw*) + PYD_PLATFORM_TAG+="mingw_aarch64" + ;; ++ armv7-*-mingw*) ++ PYD_PLATFORM_TAG+="mingw_armv7" ++ ;; + esac + AC_MSG_RESULT($PYD_PLATFORM_TAG) + esac diff --git a/mingw-w64-python3.12/0067-handle-ncursesw-pkg-config-when-cross-compiling.patch b/mingw-w64-python3.12/0067-handle-ncursesw-pkg-config-when-cross-compiling.patch new file mode 100644 index 0000000000..8935f84990 --- /dev/null +++ b/mingw-w64-python3.12/0067-handle-ncursesw-pkg-config-when-cross-compiling.patch @@ -0,0 +1,36 @@ +From 0ade53e4e7d444daa47672893ce07167cec84162 Mon Sep 17 00:00:00 2001 +From: jeremyd2019 +Date: Mon, 22 Nov 2021 16:04:41 -0800 +Subject: [PATCH 067/N] handle ncursesw pkg-config when cross-compiling + +strip extra args from pkg-config --cflags-only-I, setup.py is only expecting a single path. + +Use pkg-config ncursesw include dir even if cross-compiling (PKG_CONFIG_PATH should be set in that case). +--- + configure.ac | 6 ++---- + 1 file changed, 2 insertions(+), 4 deletions(-) + +diff --git a/configure.ac b/configure.ac +index ecab56d..f07fce5 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -6878,7 +6878,7 @@ AS_VAR_IF([have_panel], [no], [ + ]) + + if test -n "$PKG_CONFIG"; then +- NCURSESW_INCLUDEDIR="`"$PKG_CONFIG" ncursesw --cflags-only-I 2>/dev/null | sed -e 's/^-I//;s/ *$//'`" ++ NCURSESW_INCLUDEDIR="`"$PKG_CONFIG" ncursesw --cflags-only-I 2>/dev/null | sed -e 's/^-I//;s/ .*$//'`" + else + NCURSESW_INCLUDEDIR="" + fi +@@ -6886,9 +6886,7 @@ AC_SUBST(NCURSESW_INCLUDEDIR) + + # first curses header check + ac_save_cppflags="$CPPFLAGS" +-if test "$cross_compiling" = no; then +- CPPFLAGS="$CPPFLAGS -I$NCURSESW_INCLUDEDIR" +-fi ++CPPFLAGS="$CPPFLAGS -I$NCURSESW_INCLUDEDIR" + + # On Solaris, term.h requires curses.h + AC_CHECK_HEADERS([term.h], [], [], [ diff --git a/mingw-w64-python3.12/0068-mingw_smoketests-fix-_UCRT-condition.patch b/mingw-w64-python3.12/0068-mingw_smoketests-fix-_UCRT-condition.patch new file mode 100644 index 0000000000..52f46cbbc6 --- /dev/null +++ b/mingw-w64-python3.12/0068-mingw_smoketests-fix-_UCRT-condition.patch @@ -0,0 +1,23 @@ +From 29d1642bfc256e8fc7cedfdf48604975cf99b6f7 Mon Sep 17 00:00:00 2001 +From: jeremyd2019 +Date: Sat, 22 Jan 2022 11:33:00 -0800 +Subject: [PATCH 068/N] mingw_smoketests: fix _UCRT condition + +The prior detection missed ARM (32 and 64) being UCRT. Since there are fewer non-UCRT platforms, list those two instead of trying to extend the list of UCRT. +--- + mingw_smoketests.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/mingw_smoketests.py b/mingw_smoketests.py +index d92c74a..ce95846 100644 +--- a/mingw_smoketests.py ++++ b/mingw_smoketests.py +@@ -34,7 +34,7 @@ + else: + SEP = "\\" + +-_UCRT = "clang" in sysconfig.get_platform() or "ucrt" in sysconfig.get_platform() ++_UCRT = sysconfig.get_platform() not in ('mingw_x86_64', 'mingw_i686') + + + class Tests(unittest.TestCase): diff --git a/mingw-w64-python3.12/0069-Modify-sys.winver-to-match-upstream.patch b/mingw-w64-python3.12/0069-Modify-sys.winver-to-match-upstream.patch new file mode 100644 index 0000000000..84915b2455 --- /dev/null +++ b/mingw-w64-python3.12/0069-Modify-sys.winver-to-match-upstream.patch @@ -0,0 +1,69 @@ +From 66065e2d38e9b1c23e23f1ebf22b29c7fb37f926 Mon Sep 17 00:00:00 2001 +From: Naveen M K +Date: Wed, 19 Jan 2022 19:39:20 +0530 +Subject: [PATCH 069/N] Modify `sys.winver` to match upstream + +With this change `sys.winver` will add the Arch for which +python was compiled on, for example in 32-bits, `sys.winver` +will be `3.10-32`, for arm32 it would be `3.10-arm32` and +so on. + +See https://github.com/msys2-contrib/cpython-mingw/issues/40 +--- + configure.ac | 22 ++++++++++++++++++---- + mingw_smoketests.py | 9 ++++++++- + 2 files changed, 26 insertions(+), 5 deletions(-) + +diff --git a/configure.ac b/configure.ac +index f07fce5..3d8a63c 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -5091,10 +5091,24 @@ then + esac + case $host in + *-*-mingw*) +- DYNLOADFILE="dynload_win.o" +- extra_machdep_objs="$extra_machdep_objs PC/dl_nt.o" +- CFLAGS_NODIST="$CFLAGS_NODIST -DMS_DLL_ID='\"$VERSION\"' -DPY3_DLLNAME='L\"$DLLLIBRARY\"'" +- ;; ++ DYNLOADFILE="dynload_win.o" ++ extra_machdep_objs="$extra_machdep_objs PC/dl_nt.o" ++ CFLAGS_NODIST="$CFLAGS_NODIST -DPY3_DLLNAME='L\"$DLLLIBRARY\"'" ++ case $host in ++ i686*) ++ CFLAGS_NODIST="$CFLAGS_NODIST -DMS_DLL_ID='\"${VERSION}-32\"'" ++ ;; ++ armv7*) ++ CFLAGS_NODIST="$CFLAGS_NODIST -DMS_DLL_ID='\"${VERSION}-arm32\"'" ++ ;; ++ aarch64*) ++ CFLAGS_NODIST="$CFLAGS_NODIST -DMS_DLL_ID='\"${VERSION}-arm64\"'" ++ ;; ++ *) ++ CFLAGS_NODIST="$CFLAGS_NODIST -DMS_DLL_ID='\"$VERSION\"'" ++ ;; ++ esac ++ ;; + esac + fi + AC_MSG_RESULT([$DYNLOADFILE]) +diff --git a/mingw_smoketests.py b/mingw_smoketests.py +index ce95846..aa76659 100644 +--- a/mingw_smoketests.py ++++ b/mingw_smoketests.py +@@ -214,7 +214,14 @@ def test_platform_things(self): + ext_suffixes = importlib.machinery.EXTENSION_SUFFIXES + self.assertTrue(ext_suffix in ext_suffixes) + self.assertTrue(".pyd" in ext_suffixes) +- self.assertEqual(sys.winver, ".".join(map(str, sys.version_info[:2]))) ++ if sysconfig.get_platform().startswith('mingw_i686'): ++ self.assertEqual(sys.winver, ".".join(map(str, sys.version_info[:2])) + '-32') ++ elif sysconfig.get_platform().startswith('mingw_aarch64'): ++ self.assertEqual(sys.winver, ".".join(map(str, sys.version_info[:2])) + '-arm64') ++ elif sysconfig.get_platform().startswith('mingw_armv7'): ++ self.assertEqual(sys.winver, ".".join(map(str, sys.version_info[:2])) + '-arm32') ++ else: ++ self.assertEqual(sys.winver, ".".join(map(str, sys.version_info[:2]))) + self.assertEqual(platform.python_implementation(), "CPython") + self.assertEqual(platform.system(), "Windows") + self.assertTrue(isinstance(sys.api_version, int) and sys.api_version > 0) diff --git a/mingw-w64-python3.12/0070-Change-user-site-packages-path-to-include-the-enviro.patch b/mingw-w64-python3.12/0070-Change-user-site-packages-path-to-include-the-enviro.patch new file mode 100644 index 0000000000..6eac1e9291 --- /dev/null +++ b/mingw-w64-python3.12/0070-Change-user-site-packages-path-to-include-the-enviro.patch @@ -0,0 +1,119 @@ +From 83258d903c0b8f3614feadbf78fb813d02d116a9 Mon Sep 17 00:00:00 2001 +From: Naveen M K +Date: Wed, 19 Jan 2022 20:01:45 +0530 +Subject: [PATCH 070/N] Change user site-packages path to include the + environment info + +This should avoid mixing of user site-packages between python +from various environments. Previously, the user site-packages +should be located at `~/.local/lib/python3.10` for all environment +including 32-bits variants which caused problems with 64-bit trying to +load 32-bit extensions. Now this path will be changed to +`~/.local/lib/python3.10-`, for example, in +CLANG64 this would be `~/.local/lib/python3.10-mingw_x86_64_clang`. + +Fixes https://github.com/msys2-contrib/cpython-mingw/issues/40 +--- + Lib/site.py | 28 +++++++++++++++++++++++++--- + Lib/sysconfig.py | 26 +++++++++++++++----------- + 2 files changed, 40 insertions(+), 14 deletions(-) + +diff --git a/Lib/site.py b/Lib/site.py +index 7c89370..0cca82f 100644 +--- a/Lib/site.py ++++ b/Lib/site.py +@@ -289,14 +289,36 @@ def joinuser(*args): + + return joinuser("~", ".local") + ++# Copy of sysconfig.get_platform() but only for MinGW ++def _get_platform(): ++ if os.name == 'nt': ++ if 'gcc' in sys.version.lower(): ++ if 'ucrt' in sys.version.lower(): ++ if 'amd64' in sys.version.lower(): ++ return 'mingw_x86_64_ucrt' ++ return 'mingw_i686_ucrt' ++ if 'clang' in sys.version.lower(): ++ if 'amd64' in sys.version.lower(): ++ return 'mingw_x86_64_clang' ++ if 'arm64' in sys.version.lower(): ++ return 'mingw_aarch64' ++ if 'arm' in sys.version.lower(): ++ return 'mingw_armv7' ++ return 'mingw_i686_clang' ++ if 'amd64' in sys.version.lower(): ++ return 'mingw_x86_64' ++ return 'mingw_i686' ++ return sys.platform + + # Same to sysconfig.get_path('purelib', os.name+'_user') + def _get_path(userbase): + version = sys.version_info + +- if os.name == 'nt' and not _POSIX_BUILD: +- ver_nodot = sys.winver.replace('.', '') +- return f'{userbase}\\Python{ver_nodot}\\site-packages' ++ if os.name == 'nt': ++ if not _POSIX_BUILD: ++ ver_nodot = sys.winver.replace('.', '') ++ return f'{userbase}\\Python{ver_nodot}\\site-packages' ++ return f'{userbase}/lib/python{version[0]}.{version[1]}-{_get_platform()}/site-packages' + + if sys.platform == 'darwin' and sys._framework: + return f'{userbase}/lib/python/site-packages' +diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py +index 33f8cd8..cbe060f 100644 +--- a/Lib/sysconfig.py ++++ b/Lib/sysconfig.py +@@ -141,20 +141,20 @@ def joinuser(*args): + _INSTALL_SCHEMES |= { + # NOTE: When modifying "purelib" scheme, update site._get_path() too. + 'nt_user': { +- '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}', ++ 'stdlib': '{userbase}/lib/python{py_version_short_plat}', ++ 'platstdlib': '{userbase}/lib/python{py_version_short_plat}', ++ 'purelib': '{userbase}/lib/python{py_version_short_plat}/site-packages', ++ 'platlib': '{userbase}/lib/python{py_version_short_plat}/site-packages', ++ 'include': '{userbase}/include/python{py_version_short_plat}', + 'scripts': '{userbase}/bin', + 'data': '{userbase}', + }, + 'posix_user': { +- 'stdlib': '{userbase}/{platlibdir}/python{py_version_short}', +- 'platstdlib': '{userbase}/{platlibdir}/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}', ++ 'stdlib': '{userbase}/{platlibdir}/python{py_version_short_plat}', ++ 'platstdlib': '{userbase}/{platlibdir}/python{py_version_short_plat}', ++ 'purelib': '{userbase}/lib/python{py_version_short_plat}/site-packages', ++ 'platlib': '{userbase}/lib/python{py_version_short_plat}/site-packages', ++ 'include': '{userbase}/include/python{py_version_short_plat}', + 'scripts': '{userbase}/bin', + 'data': '{userbase}', + }, +@@ -695,6 +695,10 @@ def _init_config_vars(): + _CONFIG_VARS['py_version_nodot_plat'] = sys.winver.replace('.', '') + except AttributeError: + _CONFIG_VARS['py_version_nodot_plat'] = '' ++ if os.name == 'nt' and _POSIX_BUILD: ++ _CONFIG_VARS['py_version_short_plat'] = f'{_PY_VERSION_SHORT}-{get_platform()}' ++ else: ++ _CONFIG_VARS['py_version_short_plat'] = _PY_VERSION_SHORT + + if os.name == 'nt' and not _POSIX_BUILD: + _init_non_posix(_CONFIG_VARS) +@@ -772,7 +776,7 @@ def get_config_var(name): + """ + return get_config_vars().get(name) + +- ++# make sure to change site._get_platform() while changing this function + def get_platform(): + """Return a string that identifies the current platform. + diff --git a/mingw-w64-python3.12/0071-configure-Include-a-header-in-the-check-for-_beginth.patch b/mingw-w64-python3.12/0071-configure-Include-a-header-in-the-check-for-_beginth.patch new file mode 100644 index 0000000000..7ac6a4b33e --- /dev/null +++ b/mingw-w64-python3.12/0071-configure-Include-a-header-in-the-check-for-_beginth.patch @@ -0,0 +1,33 @@ +From fd99658f3ebe275329b506b9f4f4f0d2418a190d Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Martin=20Storsj=C3=B6?= +Date: Thu, 21 Apr 2022 14:25:51 +0300 +Subject: [PATCH 071/N] configure: Include a header in the check for + _beginthread + +Previously, the test tried compiling a call to the +_beginthread function without either declaring the function +(and its parameters) or including the corresponding header. + +Since Clang 15 (which still is under development, so this may +still change before it's released) [1], implicit function +declarations are a hard error by default, when building code +in C99 mode (or newer). + +[1] https://github.com/llvm/llvm-project/commit/7d644e1215b376ec5e915df9ea2eeb56e2d94626 +--- + configure.ac | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/configure.ac b/configure.ac +index 3d8a63c..1bca34c 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -2838,7 +2838,7 @@ AC_MSG_RESULT([$with_nt_threads]) + if test $with_nt_threads = yes ; then + AC_MSG_CHECKING([whether linking with nt-threads work]) + AC_LINK_IFELSE([ +- AC_LANG_PROGRAM([[]],[[_beginthread(0, 0, 0);]]) ++ AC_LANG_PROGRAM([[#include ]],[[_beginthread(0, 0, 0);]]) + ], + [AC_MSG_RESULT([yes])], + [AC_MSG_ERROR([failed to link with nt-threads])]) diff --git a/mingw-w64-python3.12/0072-configure.ac-Default-to-without-c-locale-coercion-on.patch b/mingw-w64-python3.12/0072-configure.ac-Default-to-without-c-locale-coercion-on.patch new file mode 100644 index 0000000000..7c1db652df --- /dev/null +++ b/mingw-w64-python3.12/0072-configure.ac-Default-to-without-c-locale-coercion-on.patch @@ -0,0 +1,37 @@ +From a98d668d5be7b5e17d1c5e5f0a0af53c1b405282 Mon Sep 17 00:00:00 2001 +From: Christoph Reiter +Date: Fri, 22 Apr 2022 17:31:19 +0200 +Subject: [PATCH 072/N] configure.ac: Default to --without-c-locale-coercion + on Windows + +--with-c-locale-coercion otherwise defaults to yes and enables code +that isn't compatible on Windows, mainly because the feature is Unix related. + +Default to "no" on Windows instead. + +Fixes #36 +--- + configure.ac | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +diff --git a/configure.ac b/configure.ac +index 1bca34c..a0b2aba 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -4980,11 +4980,14 @@ AC_MSG_RESULT([$with_freelists]) + AC_MSG_CHECKING([for --with-c-locale-coercion]) + AC_ARG_WITH( + [c-locale-coercion], +- [AS_HELP_STRING([--with-c-locale-coercion], [enable C locale coercion to a UTF-8 based locale (default is yes)])]) ++ [AS_HELP_STRING([--with-c-locale-coercion], [enable C locale coercion to a UTF-8 based locale (default is yes on Unix, no on Windows)])]) + + if test -z "$with_c_locale_coercion" + then +- with_c_locale_coercion="yes" ++ case $host in ++ *-*-mingw*) with_c_locale_coercion="no";; ++ *) with_c_locale_coercion="yes";; ++ esac + fi + if test "$with_c_locale_coercion" != "no" + then diff --git a/mingw-w64-python3.12/0073-Fix-failing-tests.patch b/mingw-w64-python3.12/0073-Fix-failing-tests.patch new file mode 100644 index 0000000000..6564d66e2d --- /dev/null +++ b/mingw-w64-python3.12/0073-Fix-failing-tests.patch @@ -0,0 +1,136 @@ +From 3a8acec4421fb0f4c4fcdbe7e5f420d6201e0e97 Mon Sep 17 00:00:00 2001 +From: Naveen M K +Date: Sun, 5 Jun 2022 20:28:53 +0530 +Subject: [PATCH 073/N] Fix failing tests + +- In `test_sysconfig`, ignore `test_sysconfig.TestSysConfig.test_user_similar` test failure. +- Copy `get_platform()` from from distutils.utils to test_importlib/test_windows.py. +- In `test_tcl`, ignore `test_tcl.TclTest.testLoadWithUNC` test failure. +- Disable `test.test_asynchat.TestAsynchat.test_line_terminator2`, seems flaky. +- skip some more flaky tests +- some basic fixes for test_getpath +- test_sysconfig.py: fix tests related to mingw +--- + Lib/test/test_getpath.py | 3 +++ + Lib/test/test_importlib/test_windows.py | 17 +++++++++++++++++ + Lib/test/test_sysconfig.py | 8 ++++++-- + mingw_ignorefile.txt | 13 +++++++++++-- + 4 files changed, 37 insertions(+), 4 deletions(-) + +diff --git a/Lib/test/test_getpath.py b/Lib/test/test_getpath.py +index b9cbe1d..ee4ab99 100644 +--- a/Lib/test/test_getpath.py ++++ b/Lib/test/test_getpath.py +@@ -837,6 +837,7 @@ def test_symlink_buildpath_macos(self): + ENV_PYTHONHOME="", + ENV_PYTHONEXECUTABLE="", + ENV___PYVENV_LAUNCHER__="", ++ ENV_MSYSTEM="", + argv0="", + py_setpath="", + real_executable="", +@@ -876,6 +877,7 @@ def __init__(self, *a, argv0=None, config=None, **kw): + self.update(DEFAULT_NAMESPACE) + self["config"] = DEFAULT_CONFIG.copy() + self["os_name"] = "nt" ++ self["is_mingw"] = 0 + self["PLATLIBDIR"] = "DLLs" + self["PYWINVER"] = "9.8-XY" + self["VPATH"] = r"..\.." +@@ -1052,6 +1054,7 @@ def __init__(self, *a, argv0=None, config=None, **kw): + self.update(DEFAULT_NAMESPACE) + self["config"] = DEFAULT_CONFIG.copy() + self["os_name"] = "posix" ++ self["is_mingw"] = 0 + self["PLATLIBDIR"] = "lib" + self["WITH_NEXT_FRAMEWORK"] = 0 + super().__init__(*a, **kw) +diff --git a/Lib/test/test_importlib/test_windows.py b/Lib/test/test_importlib/test_windows.py +index 40b8aa1..03b5a98 100644 +--- a/Lib/test/test_importlib/test_windows.py ++++ b/Lib/test/test_importlib/test_windows.py +@@ -24,6 +24,23 @@ def get_platform(): + 'x64' : 'win-amd64', + 'arm' : 'win-arm32', + } ++ if os.name == 'nt': ++ if 'gcc' in sys.version.lower(): ++ if 'ucrt' in sys.version.lower(): ++ if 'amd64' in sys.version.lower(): ++ return 'mingw_x86_64_ucrt' ++ return 'mingw_i686_ucrt' ++ if 'clang' in sys.version.lower(): ++ if 'amd64' in sys.version.lower(): ++ return 'mingw_x86_64_clang' ++ if 'arm64' in sys.version.lower(): ++ return 'mingw_aarch64' ++ if 'arm' in sys.version.lower(): ++ return 'mingw_armv7' ++ return 'mingw_i686_clang' ++ if 'amd64' in sys.version.lower(): ++ return 'mingw_x86_64' ++ return 'mingw_i686' + if ('VSCMD_ARG_TGT_ARCH' in os.environ and + os.environ['VSCMD_ARG_TGT_ARCH'] in TARGET_TO_PLAT): + return TARGET_TO_PLAT[os.environ['VSCMD_ARG_TGT_ARCH']] +diff --git a/Lib/test/test_sysconfig.py b/Lib/test/test_sysconfig.py +index b6dbf3d..42a81c4 100644 +--- a/Lib/test/test_sysconfig.py ++++ b/Lib/test/test_sysconfig.py +@@ -16,7 +16,7 @@ + from sysconfig import (get_paths, get_platform, get_config_vars, + get_path, get_path_names, _INSTALL_SCHEMES, + get_default_scheme, get_scheme_names, get_config_var, +- _expand_vars, _get_preferred_schemes, _main) ++ _expand_vars, _get_preferred_schemes, _main, _POSIX_BUILD) + import _osx_support + + +@@ -179,7 +179,7 @@ def test_nt_venv_scheme(self): + self.assertEqual(libpath, sysconfig.get_path('purelib', scheme='nt_venv')) + + def test_venv_scheme(self): +- if sys.platform == 'win32': ++ if not _POSIX_BUILD and sys.platform == 'win32': + self.assertEqual( + sysconfig.get_path('scripts', scheme='venv'), + sysconfig.get_path('scripts', scheme='nt_venv') +@@ -370,6 +370,10 @@ def test_user_similar(self): + if HAS_USER_BASE: + user_path = get_path(name, 'posix_user') + expected = os.path.normpath(global_path.replace(base, user, 1)) ++ if os.name == 'nt' and _POSIX_BUILD: ++ expected = expected.replace( ++ f'python{sysconfig.get_python_version()}', ++ f'python{sysconfig.get_python_version()}-{get_platform()}') + # bpo-44860: platlib of posix_user doesn't use sys.platlibdir, + # whereas posix_prefix does. + if name == 'platlib': +diff --git a/mingw_ignorefile.txt b/mingw_ignorefile.txt +index dc3802e..e692d7f 100644 +--- a/mingw_ignorefile.txt ++++ b/mingw_ignorefile.txt +@@ -1,4 +1,4 @@ +-ctypes.test.test_loading.LoaderTest.test_load_dll_with_flags ++test.test_ctypes.test_loading.LoaderTest.test_load_dll_with_flags + distutils.tests.test_bdist_dumb.BuildDumbTestCase.test_simple_built + distutils.tests.test_cygwinccompiler.CygwinCCompilerTestCase.test_get_versions + distutils.tests.test_util.UtilTestCase.test_change_root +@@ -29,6 +29,15 @@ test.test_strptime.TimeRETests.test_compile + test.test_tools.test_i18n.Test_pygettext.test_POT_Creation_Date + test.test_venv.BasicTest.* + test.test_venv.EnsurePipTest.* ++test.test_sysconfig.TestSysConfig.test_user_similar ++test.test_tcl.TclTest.testLoadWithUNC ++test.test_wmi + # flaky + test.test__xxsubinterpreters.* +-test.test_asyncio.test_subprocess.SubprocessProactorTests.test_stdin_broken_pipe +\ No newline at end of file ++test.test_asyncio.test_subprocess.SubprocessProactorTests.test_stdin_broken_pipe ++test.test_asynchat.TestAsynchat.test_line_terminator2 ++test.test_asyncgen.AsyncGenAsyncioTest.test_async_gen_asyncio_gc_aclose_09 ++test.test_concurrent_futures.ThreadPoolShutdownTest.test_interpreter_shutdown ++test.test_asynchat.TestNotConnected.test_disallow_negative_terminator ++test.test_logging.SysLogHandlerTest.* ++test.test_logging.IPv6SysLogHandlerTest.* diff --git a/mingw-w64-python3.12/0074-Don-t-change-os.sep-with-an-empty-MSYSTEM-env-var-no.patch b/mingw-w64-python3.12/0074-Don-t-change-os.sep-with-an-empty-MSYSTEM-env-var-no.patch new file mode 100644 index 0000000000..eec57f16de --- /dev/null +++ b/mingw-w64-python3.12/0074-Don-t-change-os.sep-with-an-empty-MSYSTEM-env-var-no.patch @@ -0,0 +1,132 @@ +From 078fffbb89900c5ab1df3c4a9848515a1732ebce Mon Sep 17 00:00:00 2001 +From: Christoph Reiter +Date: Thu, 22 Sep 2022 17:51:33 +0200 +Subject: [PATCH 074/N] Don't change os.sep with an empty MSYSTEM env var, + not just a missing one + +Up until now this didn't really happen when calling from cygwin +because empty env vars were removed before Python would run. + +But https://github.com/msys2/msys2-runtime/pull/101 changed that. + +To avoid breaking users that did something like + +MSYSTEM= python ... + +not only check that MSYSTEM isn't set but also that it isn't empty +when deciding if os.sep/os.altsep should be switched. + +Also, guard the msystem env check to execute only on MINGW + +Co-authored-by: Naveen M K +--- + Lib/importlib/_bootstrap_external.py | 2 +- + Lib/ntpath.py | 2 +- + Python/pathconfig.c | 20 +++++++++++--------- + mingw_smoketests.py | 2 +- + 4 files changed, 14 insertions(+), 12 deletions(-) + +diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py +index 42d987d..92ba611 100644 +--- a/Lib/importlib/_bootstrap_external.py ++++ b/Lib/importlib/_bootstrap_external.py +@@ -43,7 +43,7 @@ + else: + path_separators = ['/'] + +-if 'MSYSTEM' in _os.environ: ++if _os.environ.get('MSYSTEM', ''): + path_separators = path_separators[::-1] + + # Assumption made in _path_join() +diff --git a/Lib/ntpath.py b/Lib/ntpath.py +index 309235b..0eb4aa0 100644 +--- a/Lib/ntpath.py ++++ b/Lib/ntpath.py +@@ -21,7 +21,7 @@ + import genericpath + from genericpath import * + +-if sys.platform == "win32" and "MSYSTEM" in os.environ: ++if sys.platform == "win32" and os.environ.get("MSYSTEM", ""): + sep = '/' + altsep = '\\' + else: +diff --git a/Python/pathconfig.c b/Python/pathconfig.c +index 3d684d6..1195a04 100644 +--- a/Python/pathconfig.c ++++ b/Python/pathconfig.c +@@ -2,7 +2,7 @@ + + #include "Python.h" + #include "marshal.h" // PyMarshal_ReadObjectFromString +-#include "osdefs.h" // DELIM ++#include "osdefs.h" // DELIM, SEP + #include "pycore_initconfig.h" + #include "pycore_fileutils.h" + #include "pycore_pathconfig.h" +@@ -50,7 +50,6 @@ Py_StartsWithW(const wchar_t * str, const wchar_t * prefix) + 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 +@@ -65,12 +64,14 @@ Py_GetSepA(const char *name) + if (sep != '\0') + return sep; + #if defined(__MINGW32__) +- msystem = Py_GETENV("MSYSTEM"); +-#endif +- if (msystem != NULL) ++ char* msystem = getenv("MSYSTEM"); ++ if (msystem != NULL && strcmp(msystem, "") != 0) + sep = '/'; + else + sep = '\\'; ++#else ++ sep = SEP; ++#endif + return sep; + } + +@@ -103,7 +104,6 @@ Py_NormalizeSepsA(char *name) + 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 +@@ -118,12 +118,14 @@ Py_GetSepW(const wchar_t *name) + if (sep != L'\0') + return sep; + #if defined(__MINGW32__) +- msystem = Py_GETENV("MSYSTEM"); +-#endif +- if (msystem != NULL) ++ char* msystem = getenv("MSYSTEM"); ++ if (msystem != NULL && strcmp(msystem, "") != 0) + sep = L'/'; + else + sep = L'\\'; ++#else ++ sep = SEP; ++#endif + return sep; + } + +diff --git a/mingw_smoketests.py b/mingw_smoketests.py +index aa76659..2a8bd16 100644 +--- a/mingw_smoketests.py ++++ b/mingw_smoketests.py +@@ -29,7 +29,7 @@ + import unittest + import sysconfig + +-if "MSYSTEM" in os.environ: ++if os.environ.get("MSYSTEM", ""): + SEP = "/" + else: + SEP = "\\" diff --git a/mingw-w64-python3.12/0075-def-VPATH-when-compiling-Python-sysmodule.c.patch b/mingw-w64-python3.12/0075-def-VPATH-when-compiling-Python-sysmodule.c.patch new file mode 100644 index 0000000000..e6d4e936ca --- /dev/null +++ b/mingw-w64-python3.12/0075-def-VPATH-when-compiling-Python-sysmodule.c.patch @@ -0,0 +1,21 @@ +From 87662963e70b97cba57a7ccee9a633de2657805c Mon Sep 17 00:00:00 2001 +From: Naveen M K +Date: Sun, 18 Jun 2023 13:12:56 +0530 +Subject: [PATCH 075/N] def VPATH when compiling `Python/sysmodule.c` + +--- + Makefile.pre.in | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/Makefile.pre.in b/Makefile.pre.in +index 4a6e692..7037c3d 100644 +--- a/Makefile.pre.in ++++ b/Makefile.pre.in +@@ -1421,6 +1421,7 @@ Python/dynload_win.o: $(srcdir)/Python/dynload_win.c Makefile + Python/sysmodule.o: $(srcdir)/Python/sysmodule.c Makefile $(srcdir)/Include/pydtrace.h + $(CC) -c $(PY_CORE_CFLAGS) \ + -DABIFLAGS='"$(ABIFLAGS)"' \ ++ -DVPATH='"$(VPATH)"' \ + $(MULTIARCH_CPPFLAGS) \ + -o $@ $(srcdir)/Python/sysmodule.c + diff --git a/mingw-w64-python3.12/0076-Make-_Py_CheckPython3-extern.patch b/mingw-w64-python3.12/0076-Make-_Py_CheckPython3-extern.patch new file mode 100644 index 0000000000..e83b08708a --- /dev/null +++ b/mingw-w64-python3.12/0076-Make-_Py_CheckPython3-extern.patch @@ -0,0 +1,38 @@ +From d556fd3784168da06aab0bd310c10a10e971cd2b Mon Sep 17 00:00:00 2001 +From: Naveen M K +Date: Sun, 18 Jun 2023 13:17:48 +0530 +Subject: [PATCH 076/N] Make `_Py_CheckPython3` extern + +it's declared in headers but defined as static here, remove it +also run `_Py_CheckPython3` only when using MSVC +--- + Python/dynload_win.c | 9 ++++----- + 1 file changed, 4 insertions(+), 5 deletions(-) + +diff --git a/Python/dynload_win.c b/Python/dynload_win.c +index 26d6036..1f90e21 100644 +--- a/Python/dynload_win.c ++++ b/Python/dynload_win.c +@@ -171,8 +171,7 @@ static char *GetPythonImport (HINSTANCE hModule) + Return whether the DLL was found. + */ + extern HMODULE PyWin_DLLhModule; +-static int +-_Py_CheckPython3(void) ++int _Py_CheckPython3(void) + { + static int python3_checked = 0; + static HANDLE hPython3; +@@ -226,9 +225,9 @@ dl_funcptr _PyImport_FindSharedFuncptrWindows(const char *prefix, + dl_funcptr p; + char funcname[258], *import_python; + +-#ifdef Py_ENABLE_SHARED +- _Py_CheckPython3(); +-#endif /* Py_ENABLE_SHARED */ ++#ifdef _MSC_VER ++ _Py_CheckPython3(); ++#endif /* _MSC_VER */ + + wchar_t *wpathname = PyUnicode_AsWideCharString(pathname, NULL); + if (wpathname == NULL) diff --git a/mingw-w64-python3.12/0077-link-with-bcrypt.patch b/mingw-w64-python3.12/0077-link-with-bcrypt.patch new file mode 100644 index 0000000000..05dfca7c70 --- /dev/null +++ b/mingw-w64-python3.12/0077-link-with-bcrypt.patch @@ -0,0 +1,22 @@ +From 59989dddda6f207a2689564a63f5b16d3c6dcef5 Mon Sep 17 00:00:00 2001 +From: Naveen M K +Date: Sun, 18 Jun 2023 14:20:44 +0530 +Subject: [PATCH 077/N] link with bcrypt + +--- + configure.ac | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/configure.ac b/configure.ac +index a0b2aba..84192b9 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -7180,7 +7180,7 @@ AC_MSG_RESULT([done]) + # For mingw build need additional library for linking + case $host in + *-*-mingw*) +- LIBS="$LIBS -lversion -lshlwapi -lpathcch" ++ LIBS="$LIBS -lversion -lshlwapi -lpathcch -lbcrypt" + AC_PROG_AWK + if test "$AWK" = "gawk"; then + awk_extra_flag="--non-decimal-data" diff --git a/mingw-w64-python3.12/0078-correctly-find-native-python.patch b/mingw-w64-python3.12/0078-correctly-find-native-python.patch new file mode 100644 index 0000000000..8ca27a0efc --- /dev/null +++ b/mingw-w64-python3.12/0078-correctly-find-native-python.patch @@ -0,0 +1,27 @@ +From 742c6c9041d42767b8ec30e3d76af29f1c76ff8d Mon Sep 17 00:00:00 2001 +From: Naveen M K +Date: Sun, 18 Jun 2023 14:29:50 +0530 +Subject: [PATCH 078/N] correctly find native python + +it's required for regen-modules +--- + configure.ac | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/configure.ac b/configure.ac +index 84192b9..05c4dd5 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -204,9 +204,11 @@ AC_SUBST([FREEZE_MODULE]) + AC_SUBST([FREEZE_MODULE_DEPS]) + AC_SUBST([PYTHON_FOR_BUILD_DEPS]) + ++NATIVE_PYTHON_SEARCH_PATH_MINGW=`echo $host | grep -Eq 'mingw*' && echo "$MINGW_PREFIX/bin" || echo $PATH` + AC_CHECK_PROGS([PYTHON_FOR_REGEN], + [python$PACKAGE_VERSION python3.12 python3.11 python3.10 python3 python], +- [python3]) ++ [python3], ++ [$NATIVE_PYTHON_SEARCH_PATH_MINGW]) + AC_SUBST([PYTHON_FOR_REGEN]) + + AC_MSG_CHECKING([Python for regen version]) diff --git a/mingw-w64-python3.12/0079-Add-extra-flags-for-_bootstrap_python.patch b/mingw-w64-python3.12/0079-Add-extra-flags-for-_bootstrap_python.patch new file mode 100644 index 0000000000..16e3d953ee --- /dev/null +++ b/mingw-w64-python3.12/0079-Add-extra-flags-for-_bootstrap_python.patch @@ -0,0 +1,22 @@ +From d161651cab4115d627094dd1bed1b58841f75af4 Mon Sep 17 00:00:00 2001 +From: Naveen M K +Date: Sun, 18 Jun 2023 14:30:09 +0530 +Subject: [PATCH 079/N] Add extra flags for `_bootstrap_python` + +--- + Makefile.pre.in | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Makefile.pre.in b/Makefile.pre.in +index 7037c3d..486076d 100644 +--- a/Makefile.pre.in ++++ b/Makefile.pre.in +@@ -1107,7 +1107,7 @@ BOOTSTRAP_HEADERS = \ + Programs/_bootstrap_python.o: Programs/_bootstrap_python.c $(BOOTSTRAP_HEADERS) $(PYTHON_HEADERS) + + _bootstrap_python: $(LIBRARY_OBJS_OMIT_FROZEN) Programs/_bootstrap_python.o Modules/getpath.o Modules/Setup.local +- $(LINKCC) $(PY_LDFLAGS_NOLTO) -o $@ $(LIBRARY_OBJS_OMIT_FROZEN) \ ++ $(LINKCC) $(PY_LDFLAGS_NOLTO) -o $@ -municode -mwindows $(LIBRARY_OBJS_OMIT_FROZEN) \ + Programs/_bootstrap_python.o Modules/getpath.o $(LIBS) $(MODLIBS) $(SYSLIBS) + + diff --git a/mingw-w64-python3.12/0080-posixmodule-undefine-HAVE_OPENDIR.patch b/mingw-w64-python3.12/0080-posixmodule-undefine-HAVE_OPENDIR.patch new file mode 100644 index 0000000000..4c28b7551d --- /dev/null +++ b/mingw-w64-python3.12/0080-posixmodule-undefine-HAVE_OPENDIR.patch @@ -0,0 +1,31 @@ +From 955c80002f562265983ad6011b8afc4c582a9826 Mon Sep 17 00:00:00 2001 +From: Naveen M K +Date: Tue, 20 Jun 2023 18:32:58 +0530 +Subject: [PATCH 080/N] posixmodule: undefine `HAVE_OPENDIR` + +opendir is detected by configure on mingw-w64, and for some reason +things don't work as expected. For example, os.listdir always returns +the cwd's directory listing instead of the one specified. By +un-defining, this, os.listdir will use the one which uses native +windows API. +--- + Modules/posixmodule.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c +index 0cff7d6..53ee3b7 100644 +--- a/Modules/posixmodule.c ++++ b/Modules/posixmodule.c +@@ -365,6 +365,12 @@ corresponding Unix manual entries for more information on calls."); + #elif defined(__MINGW32__) /* GCC for windows hosts */ + /* getlogin is detected by configure on mingw-w64 */ + # undef HAVE_GETLOGIN ++/* opendir is detected by configure on mingw-w64, and for some reason ++things don't work as expected. For example, os.listdir always returns ++the cwd's directory listing instead of the one specified. By ++un-defining, this, os.listdir will use the one which uses native ++windows API. */ ++# undef HAVE_OPENDIR + /*# define HAVE_GETCWD 1 - detected by configure*/ + # define HAVE_GETPPID 1 + # define HAVE_GETLOGIN 1 diff --git a/mingw-w64-python3.12/0081-getpath.py-add-support-for-mingw.patch b/mingw-w64-python3.12/0081-getpath.py-add-support-for-mingw.patch new file mode 100644 index 0000000000..34daff559b --- /dev/null +++ b/mingw-w64-python3.12/0081-getpath.py-add-support-for-mingw.patch @@ -0,0 +1,341 @@ +From 4b36c1161c374dbc3081b13b0ddaa5bb8490c48d Mon Sep 17 00:00:00 2001 +From: Naveen M K +Date: Tue, 20 Jun 2023 18:43:59 +0530 +Subject: [PATCH 081/N] getpath.py: add support for mingw + +- always normalize the PREFIX to an absolute path +- use `/` when MSYSTEM is defined +--- + Include/pylifecycle.h | 1 + + Modules/getpath.c | 9 ++++++++ + Modules/getpath.py | 48 +++++++++++++++++++++++++++++++------------ + Python/fileutils.c | 41 +++++++++++++++++++++--------------- + Python/pathconfig.c | 2 +- + 5 files changed, 71 insertions(+), 30 deletions(-) + +diff --git a/Include/pylifecycle.h b/Include/pylifecycle.h +index 50d8b76..5d29201 100644 +--- a/Include/pylifecycle.h ++++ b/Include/pylifecycle.h +@@ -21,6 +21,7 @@ PyAPI_FUNC(int) Py_IsInitialized(void); + PyAPI_FUNC(PyThreadState *) Py_NewInterpreter(void); + PyAPI_FUNC(void) Py_EndInterpreter(PyThreadState *); + ++PyAPI_FUNC(wchar_t) Py_GetAltSepW(const wchar_t *); + PyAPI_FUNC(wchar_t) Py_GetSepW(const wchar_t *); + PyAPI_FUNC(char) Py_GetSepA(const char *); + +diff --git a/Modules/getpath.c b/Modules/getpath.c +index b9914a0..bd80221 100644 +--- a/Modules/getpath.c ++++ b/Modules/getpath.c +@@ -68,6 +68,7 @@ getpath_abspath(PyObject *Py_UNUSED(self), PyObject *args) + if (path) { + wchar_t *abs; + if (_Py_abspath((const wchar_t *)_Py_normpath(path, -1), &abs) == 0 && abs) { ++ abs = _Py_normpath(abs, -1); + r = PyUnicode_FromWideChar(abs, -1); + PyMem_RawFree((void *)abs); + } else { +@@ -877,6 +878,11 @@ _PyConfig_InitPathConfig(PyConfig *config, int compute_path_config) + #else + !decode_to_dict(dict, "os_name", "posix") || + #endif ++#ifdef __MINGW32__ ++ !int_to_dict(dict, "is_mingw", 1) || ++#else ++ !int_to_dict(dict, "is_mingw", 0) || ++#endif + #ifdef WITH_NEXT_FRAMEWORK + !int_to_dict(dict, "WITH_NEXT_FRAMEWORK", 1) || + #else +@@ -903,6 +909,9 @@ _PyConfig_InitPathConfig(PyConfig *config, int compute_path_config) + !funcs_to_dict(dict, config->pathconfig_warnings) || + #ifndef MS_WINDOWS + PyDict_SetItemString(dict, "winreg", Py_None) < 0 || ++#endif ++#ifdef __MINGW32__ ++ !env_to_dict(dict, "ENV_MSYSTEM", 0) || + #endif + PyDict_SetItemString(dict, "__builtins__", PyEval_GetBuiltins()) < 0 + ) { +diff --git a/Modules/getpath.py b/Modules/getpath.py +index 9913fcb..6867e98 100644 +--- a/Modules/getpath.py ++++ b/Modules/getpath.py +@@ -30,6 +30,7 @@ + + # ** Values known at compile time ** + # os_name -- [in] one of 'nt', 'posix', 'darwin' ++# is_mingw -- [in] True if targeting MinGW + # PREFIX -- [in] sysconfig.get_config_var(...) + # EXEC_PREFIX -- [in] sysconfig.get_config_var(...) + # PYTHONPATH -- [in] sysconfig.get_config_var(...) +@@ -51,6 +52,7 @@ + # ENV_PYTHONHOME -- [in] getenv(...) + # ENV_PYTHONEXECUTABLE -- [in] getenv(...) + # ENV___PYVENV_LAUNCHER__ -- [in] getenv(...) ++# ENV_MSYSTEM -- [in] getenv(...) + + # ** Values calculated at runtime ** + # config -- [in/out] dict of the PyConfig structure +@@ -185,8 +187,27 @@ + ZIP_LANDMARK = f'{platlibdir}/python{VERSION_MAJOR}{VERSION_MINOR}.zip' + DELIM = ':' + SEP = '/' ++ ALTSEP = None + +-elif os_name == 'nt': ++elif os_name == 'nt' and is_mingw: ++ BUILDDIR_TXT = 'pybuilddir.txt' ++ BUILD_LANDMARK = 'Modules/Setup.local' ++ DEFAULT_PROGRAM_NAME = f'python{VERSION_MAJOR}' ++ STDLIB_SUBDIR = f'{platlibdir}/python{VERSION_MAJOR}.{VERSION_MINOR}' ++ STDLIB_LANDMARKS = [f'{STDLIB_SUBDIR}/os.py', f'{STDLIB_SUBDIR}/os.pyc'] ++ PLATSTDLIB_LANDMARK = f'{platlibdir}/python{VERSION_MAJOR}.{VERSION_MINOR}/lib-dynload' ++ BUILDSTDLIB_LANDMARKS = ['Lib/os.py'] ++ VENV_LANDMARK = 'pyvenv.cfg' ++ ZIP_LANDMARK = f'{platlibdir}/python{VERSION_MAJOR}{VERSION_MINOR}.zip' ++ DELIM = ';' ++ if ENV_MSYSTEM: ++ SEP = '/' ++ ALTSEP = '\\' ++ else: ++ SEP = '\\' ++ ALTSEP = '/' ++ ++elif os_name == 'nt': # MSVC + BUILDDIR_TXT = 'pybuilddir.txt' + BUILD_LANDMARK = f'{VPATH}\\Modules\\Setup.local' + DEFAULT_PROGRAM_NAME = f'python' +@@ -199,6 +220,7 @@ + WINREG_KEY = f'SOFTWARE\\Python\\PythonCore\\{PYWINVER}\\PythonPath' + DELIM = ';' + SEP = '\\' ++ ALTSEP = '/' + + + # ****************************************************************************** +@@ -263,10 +285,10 @@ def search_up(prefix, *landmarks, test=isfile): + if not executable: + executable = real_executable + +-if not executable and SEP in program_name: ++if not executable and (SEP in program_name or ++ (ALTSEP and ALTSEP in program_name)): + # Resolve partial path program_name against current directory + executable = abspath(program_name) +- + if not executable: + # All platforms default to real_executable if known at this + # stage. POSIX does not set this value. +@@ -497,15 +519,15 @@ def search_up(prefix, *landmarks, test=isfile): + except (FileNotFoundError, PermissionError): + if isfile(joinpath(real_executable_dir, BUILD_LANDMARK)): + build_prefix = joinpath(real_executable_dir, VPATH) +- if os_name == 'nt': ++ if os_name == 'nt' and not is_mingw: + # QUIRK: Windows builds need platstdlib_dir to be the executable + # dir. Normally the builddir marker handles this, but in this + # case we need to correct manually. + platstdlib_dir = real_executable_dir + + if build_prefix: +- if os_name == 'nt': +- # QUIRK: No searching for more landmarks on Windows ++ if os_name == 'nt' and not is_mingw: ++ # QUIRK: No searching for more landmarks on MSVC + build_stdlib_prefix = build_prefix + else: + build_stdlib_prefix = search_up(build_prefix, *BUILDSTDLIB_LANDMARKS) +@@ -597,7 +619,7 @@ def search_up(prefix, *landmarks, test=isfile): + + # Detect exec_prefix by searching from executable for the platstdlib_dir + if PLATSTDLIB_LANDMARK and not exec_prefix: +- if os_name == 'nt': ++ if os_name == 'nt' and (not is_mingw): + # QUIRK: Windows always assumed these were the same + # gh-100320: Our PYDs are assumed to be relative to the Lib directory + # (that is, prefix) rather than the executable (that is, executable_dir) +@@ -607,7 +629,7 @@ def search_up(prefix, *landmarks, test=isfile): + if not exec_prefix and EXEC_PREFIX: + exec_prefix = EXEC_PREFIX + if not exec_prefix or not isdir(joinpath(exec_prefix, PLATSTDLIB_LANDMARK)): +- if os_name == 'nt': ++ if os_name == 'nt' and (not is_mingw): + # QUIRK: If DLLs is missing on Windows, don't warn, just assume + # that they're in exec_prefix + if not platstdlib_dir: +@@ -660,7 +682,7 @@ def search_up(prefix, *landmarks, test=isfile): + pythonpath.append(abspath(p)) + + # Then add the default zip file +- if os_name == 'nt': ++ if os_name == 'nt' and (not is_mingw): + # QUIRK: Windows uses the library directory rather than the prefix + if library: + library_dir = dirname(library) +@@ -673,7 +695,7 @@ def search_up(prefix, *landmarks, test=isfile): + else: + pythonpath.append(joinpath(prefix, ZIP_LANDMARK)) + +- if os_name == 'nt' and use_environment and winreg: ++ if (not is_mingw) and os_name == 'nt' and use_environment and winreg: + # QUIRK: Windows also lists paths in the registry. Paths are stored + # as the default value of each subkey of + # {HKCU,HKLM}\Software\Python\PythonCore\{winver}\PythonPath +@@ -714,7 +736,7 @@ def search_up(prefix, *landmarks, test=isfile): + if not platstdlib_dir and exec_prefix: + platstdlib_dir = joinpath(exec_prefix, PLATSTDLIB_LANDMARK) + +- if os_name == 'nt': ++ if os_name == 'nt' and (not is_mingw): + # QUIRK: Windows generates paths differently + if platstdlib_dir: + pythonpath.append(platstdlib_dir) +@@ -742,8 +764,8 @@ def search_up(prefix, *landmarks, test=isfile): + + # QUIRK: Non-Windows replaces prefix/exec_prefix with defaults when running + # in build directory. This happens after pythonpath calculation. +-if os_name != 'nt' and build_prefix: +- prefix = config.get('prefix') or PREFIX ++if (os_name != 'nt' or is_mingw) and build_prefix: ++ prefix = config.get('prefix') or abspath(PREFIX) + exec_prefix = config.get('exec_prefix') or EXEC_PREFIX or prefix + + +diff --git a/Python/fileutils.c b/Python/fileutils.c +index 6d3b04f..50c78f1 100644 +--- a/Python/fileutils.c ++++ b/Python/fileutils.c +@@ -2189,7 +2189,11 @@ _Py_abspath(const wchar_t *path, wchar_t **abspath_p) + } + + #ifdef MS_WINDOWS +- return _PyOS_getfullpathname(path, abspath_p); ++ if (_PyOS_getfullpathname(path, abspath_p) < 0){ ++ return -1; ++ } ++ *abspath_p = _Py_normpath(*abspath_p, -1); ++ return 0; + #else + wchar_t cwd[MAXPATHLEN + 1]; + cwd[Py_ARRAY_LENGTH(cwd) - 1] = 0; +@@ -2401,11 +2405,16 @@ _Py_normpath_and_size(wchar_t *path, Py_ssize_t size, Py_ssize_t *normsize) + wchar_t *minP2 = path; // the beginning of the destination range + wchar_t lastC = L'\0'; // the last ljusted character, p2[-1] in most cases + ++ const wchar_t sep = Py_GetSepW(NULL); ++#ifdef ALTSEP ++ const wchar_t altsep = Py_GetAltSepW(NULL); ++#endif ++ + #define IS_END(x) (pEnd ? (x) == pEnd : !*(x)) + #ifdef ALTSEP +-#define IS_SEP(x) (*(x) == SEP || *(x) == ALTSEP) ++#define IS_SEP(x) (*(x) == sep || *(x) == altsep) + #else +-#define IS_SEP(x) (*(x) == SEP) ++#define IS_SEP(x) (*(x) == sep) + #endif + #define SEP_OR_END(x) (IS_SEP(x) || IS_END(x)) + +@@ -2416,7 +2425,7 @@ _Py_normpath_and_size(wchar_t *path, Py_ssize_t size, Py_ssize_t *normsize) + path++; + } + p1 = p2 = minP2 = path; +- lastC = SEP; ++ lastC = sep; + } + #ifdef MS_WINDOWS + // Skip past drive segment and update minP2 +@@ -2430,13 +2439,13 @@ _Py_normpath_and_size(wchar_t *path, Py_ssize_t size, Py_ssize_t *normsize) + // and network paths, including the first segment. + else if (IS_SEP(&p1[0]) && IS_SEP(&p1[1])) { + int sepCount = 2; +- *p2++ = SEP; +- *p2++ = SEP; ++ *p2++ = sep; ++ *p2++ = sep; + p1 += 2; + for (; !IS_END(p1) && sepCount; ++p1) { + if (IS_SEP(p1)) { + --sepCount; +- *p2++ = lastC = SEP; ++ *p2++ = lastC = sep; + } else { + *p2++ = lastC = *p1; + } +@@ -2449,7 +2458,7 @@ _Py_normpath_and_size(wchar_t *path, Py_ssize_t size, Py_ssize_t *normsize) + *p2++ = *p1++; + *p2++ = *p1++; + minP2 = p2 - 1; // Absolute path has SEP at minP2 +- lastC = SEP; ++ lastC = sep; + } + #endif /* MS_WINDOWS */ + +@@ -2457,18 +2466,18 @@ _Py_normpath_and_size(wchar_t *path, Py_ssize_t size, Py_ssize_t *normsize) + for (; !IS_END(p1); ++p1) { + wchar_t c = *p1; + #ifdef ALTSEP +- if (c == ALTSEP) { +- c = SEP; ++ if (c == altsep) { ++ c = sep; + } + #endif +- if (lastC == SEP) { ++ if (lastC == sep) { + if (c == L'.') { + int sep_at_1 = SEP_OR_END(&p1[1]); + int sep_at_2 = !sep_at_1 && SEP_OR_END(&p1[2]); + if (sep_at_2 && p1[1] == L'.') { + wchar_t *p3 = p2; +- while (p3 != minP2 && *--p3 == SEP) { } +- while (p3 != minP2 && *(p3 - 1) != SEP) { --p3; } ++ while (p3 != minP2 && *--p3 == sep) { } ++ while (p3 != minP2 && *(p3 - 1) != sep) { --p3; } + if (p2 == minP2 + || (p3[0] == L'.' && p3[1] == L'.' && IS_SEP(&p3[2]))) + { +@@ -2477,7 +2486,7 @@ _Py_normpath_and_size(wchar_t *path, Py_ssize_t size, Py_ssize_t *normsize) + *p2++ = L'.'; + *p2++ = L'.'; + lastC = L'.'; +- } else if (p3[0] == SEP) { ++ } else if (p3[0] == sep) { + // Absolute path, so absorb segment + p2 = p3 + 1; + } else { +@@ -2488,7 +2497,7 @@ _Py_normpath_and_size(wchar_t *path, Py_ssize_t size, Py_ssize_t *normsize) + } else { + *p2++ = lastC = c; + } +- } else if (c == SEP) { ++ } else if (c == sep) { + } else { + *p2++ = lastC = c; + } +@@ -2498,7 +2507,7 @@ _Py_normpath_and_size(wchar_t *path, Py_ssize_t size, Py_ssize_t *normsize) + } + *p2 = L'\0'; + if (p2 != minP2) { +- while (--p2 != minP2 && *p2 == SEP) { ++ while (--p2 != minP2 && *p2 == sep) { + *p2 = L'\0'; + } + } else { +diff --git a/Python/pathconfig.c b/Python/pathconfig.c +index 1195a04..08a4a37 100644 +--- a/Python/pathconfig.c ++++ b/Python/pathconfig.c +@@ -129,7 +129,7 @@ Py_GetSepW(const wchar_t *name) + return sep; + } + +-static wchar_t ++wchar_t + Py_GetAltSepW(const wchar_t *name) + { + char sep = Py_GetSepW(name); diff --git a/mingw-w64-python3.12/0082-Don-t-build-_posixsubprocess-on-Windows.patch b/mingw-w64-python3.12/0082-Don-t-build-_posixsubprocess-on-Windows.patch new file mode 100644 index 0000000000..00bae0495e --- /dev/null +++ b/mingw-w64-python3.12/0082-Don-t-build-_posixsubprocess-on-Windows.patch @@ -0,0 +1,29 @@ +From cbaff611ec2c073f6f963aad3f7862f0158b1037 Mon Sep 17 00:00:00 2001 +From: Naveen M K +Date: Tue, 20 Jun 2023 20:17:23 +0530 +Subject: [PATCH 082/N] Don't build _posixsubprocess on Windows. + +--- + configure.ac | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/configure.ac b/configure.ac +index 05c4dd5..f8043cd 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -7815,7 +7815,6 @@ PY_STDLIB_MOD_SIMPLE([_json]) + PY_STDLIB_MOD_SIMPLE([_lsprof]) + PY_STDLIB_MOD_SIMPLE([_opcode]) + PY_STDLIB_MOD_SIMPLE([_pickle]) +-PY_STDLIB_MOD_SIMPLE([_posixsubprocess]) + PY_STDLIB_MOD_SIMPLE([_queue]) + PY_STDLIB_MOD_SIMPLE([_random]) + PY_STDLIB_MOD_SIMPLE([select]) +@@ -7868,6 +7867,7 @@ PY_STDLIB_MOD([_scproxy], + PY_STDLIB_MOD([spwd], [], [test "$ac_cv_func_getspent" = yes -o "$ac_cv_func_getspnam" = yes]) + PY_STDLIB_MOD([syslog], [], [test "$ac_cv_header_syslog_h" = yes]) + PY_STDLIB_MOD([termios], [], [test "$ac_cv_header_termios_h" = yes]) ++PY_STDLIB_MOD([_posixsubprocess], [], [test "$MACHDEP" != "win32"]) + + dnl _elementtree loads libexpat via CAPI hook in pyexpat + PY_STDLIB_MOD([pyexpat], diff --git a/mingw-w64-python3.12/0083-_ssl-link-with-ws2_32.patch b/mingw-w64-python3.12/0083-_ssl-link-with-ws2_32.patch new file mode 100644 index 0000000000..4011574cdd --- /dev/null +++ b/mingw-w64-python3.12/0083-_ssl-link-with-ws2_32.patch @@ -0,0 +1,22 @@ +From 62d0b819f5cf6a12c325cf56ef61617cfbf2719c Mon Sep 17 00:00:00 2001 +From: Naveen M K +Date: Tue, 20 Jun 2023 20:35:27 +0530 +Subject: [PATCH 083/N] `_ssl`: link with `ws2_32` + +--- + configure.ac | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/configure.ac b/configure.ac +index f8043cd..e76c845 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -7949,7 +7949,7 @@ PY_STDLIB_MOD([_lzma], [], [test "$have_liblzma" = yes], + + dnl OpenSSL bindings + PY_STDLIB_MOD([_ssl], [], [test "$ac_cv_working_openssl_ssl" = yes], +- [$OPENSSL_INCLUDES], [$OPENSSL_LDFLAGS $OPENSSL_LDFLAGS_RPATH $OPENSSL_LIBS]) ++ [$OPENSSL_INCLUDES], [$OPENSSL_LDFLAGS $OPENSSL_LDFLAGS_RPATH $OPENSSL_LIBS -lws2_32]) + PY_STDLIB_MOD([_hashlib], [], [test "$ac_cv_working_openssl_hashlib" = yes], + [$OPENSSL_INCLUDES], [$OPENSSL_LDFLAGS $OPENSSL_LDFLAGS_RPATH $LIBCRYPTO_LIBS]) + diff --git a/mingw-w64-python3.12/0084-Always-normalize-path-in-abspath.patch b/mingw-w64-python3.12/0084-Always-normalize-path-in-abspath.patch new file mode 100644 index 0000000000..3434a9f707 --- /dev/null +++ b/mingw-w64-python3.12/0084-Always-normalize-path-in-abspath.patch @@ -0,0 +1,22 @@ +From 062c8ba1084f97d249a68ce602c25d16b8a94dac Mon Sep 17 00:00:00 2001 +From: Naveen M K +Date: Tue, 20 Jun 2023 23:00:43 +0530 +Subject: [PATCH 084/N] Always normalize path in abspath + +--- + Lib/ntpath.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Lib/ntpath.py b/Lib/ntpath.py +index 0eb4aa0..6b9074f 100644 +--- a/Lib/ntpath.py ++++ b/Lib/ntpath.py +@@ -608,7 +608,7 @@ def _abspath_fallback(path): + def abspath(path): + """Return the absolute version of a path.""" + try: +- return _getfullpathname(normpath(path)) ++ return normpath(_getfullpathname(normpath(path))) + except (OSError, ValueError): + return _abspath_fallback(path) + diff --git a/mingw-w64-python3.12/0085-Include-winsock.h-when-checking-for-netdb-function.patch b/mingw-w64-python3.12/0085-Include-winsock.h-when-checking-for-netdb-function.patch new file mode 100644 index 0000000000..48a8c07e01 --- /dev/null +++ b/mingw-w64-python3.12/0085-Include-winsock.h-when-checking-for-netdb-function.patch @@ -0,0 +1,46 @@ +From 4be4188154fe4f9f7ee01111efb4b7208d5ff4fb Mon Sep 17 00:00:00 2001 +From: Naveen M K +Date: Wed, 21 Jun 2023 15:42:39 +0530 +Subject: [PATCH 085/N] Include `winsock.h` when checking for netdb function + +also move `gethostname` to that check +--- + configure.ac | 11 +++++++++-- + 1 file changed, 9 insertions(+), 2 deletions(-) + +diff --git a/configure.ac b/configure.ac +index e76c845..34e58fa 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -5155,7 +5155,7 @@ AC_CHECK_FUNCS([ \ + faccessat fchmod fchmodat fchown fchownat fdopendir fdwalk fexecve \ + fork fork1 fpathconf fstatat ftime ftruncate futimens futimes futimesat \ + gai_strerror getegid getentropy geteuid getgid getgrgid getgrgid_r \ +- getgrnam_r getgrouplist getgroups gethostname getitimer getloadavg getlogin \ ++ getgrnam_r getgrouplist getgroups getitimer getloadavg getlogin \ + getpeername getpgid getpid getppid getpriority _getpty \ + getpwent getpwnam_r getpwuid getpwuid_r getresgid getresuid getrusage getsid getspent \ + getspnam getuid getwd if_nameindex initgroups kill killpg lchown linkat \ +@@ -5382,7 +5382,13 @@ PKG_CHECK_MODULES([LIBLZMA], [liblzma], [have_liblzma=yes], [ + ]) + + dnl PY_CHECK_NETDB_FUNC(FUNCTION) +-AC_DEFUN([PY_CHECK_NETDB_FUNC], [PY_CHECK_FUNC([$1], [@%:@include ])]) ++AC_DEFUN([PY_CHECK_NETDB_FUNC], [PY_CHECK_FUNC([$1], [ ++#ifdef _WIN32 ++ #include ++#else ++ #include ++#endif ++])]) + + PY_CHECK_NETDB_FUNC([hstrerror]) + dnl not available in WASI yet +@@ -5391,6 +5397,7 @@ PY_CHECK_NETDB_FUNC([getservbyport]) + PY_CHECK_NETDB_FUNC([gethostbyname]) + PY_CHECK_NETDB_FUNC([gethostbyaddr]) + PY_CHECK_NETDB_FUNC([getprotobyname]) ++PY_CHECK_NETDB_FUNC([gethostname]) + + dnl PY_CHECK_SOCKET_FUNC(FUNCTION) + AC_DEFUN([PY_CHECK_SOCKET_FUNC], [PY_CHECK_FUNC([$1], [ diff --git a/mingw-w64-python3.12/0086-include-_multiprocessing-semaphore.c-on-win32.patch b/mingw-w64-python3.12/0086-include-_multiprocessing-semaphore.c-on-win32.patch new file mode 100644 index 0000000000..c509a3c3a5 --- /dev/null +++ b/mingw-w64-python3.12/0086-include-_multiprocessing-semaphore.c-on-win32.patch @@ -0,0 +1,24 @@ +From 31037b3ba9a98e9ed450bd181ad304d1f870c6a2 Mon Sep 17 00:00:00 2001 +From: Naveen M K +Date: Fri, 23 Jun 2023 20:13:23 +0530 +Subject: [PATCH 086/N] include `_multiprocessing/semaphore.c` on win32 + +while building `_multiprocessing` extension +also, always build that module on win32 +--- + configure.ac | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/configure.ac b/configure.ac +index 34e58fa..1e4fc2c 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -7833,7 +7833,7 @@ PY_STDLIB_MOD_SIMPLE([_zoneinfo]) + + dnl multiprocessing modules + PY_STDLIB_MOD([_multiprocessing], +- [], [test "$ac_cv_func_sem_unlink" = "yes"], ++ [], [test "$ac_cv_func_sem_unlink" = "yes" -o "$MACHDEP" = "win32"], + [-I\$(srcdir)/Modules/_multiprocessing]) + PY_STDLIB_MOD([_posixshmem], + [], [test "$have_posix_shmem" = "yes"], diff --git a/mingw-w64-python3.12/0087-configure-build-mmap-module-on-win32.patch b/mingw-w64-python3.12/0087-configure-build-mmap-module-on-win32.patch new file mode 100644 index 0000000000..8a23e99ac1 --- /dev/null +++ b/mingw-w64-python3.12/0087-configure-build-mmap-module-on-win32.patch @@ -0,0 +1,24 @@ +From 8b688d3c23389f7f86097f8a0222ae0a13d17ded Mon Sep 17 00:00:00 2001 +From: Naveen M K +Date: Fri, 23 Jun 2023 20:15:38 +0530 +Subject: [PATCH 087/N] configure: build `mmap` module on win32 + +--- + configure.ac | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/configure.ac b/configure.ac +index 1e4fc2c..cba1434 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -7853,7 +7853,9 @@ PY_STDLIB_MOD([fcntl], + [], [test "$ac_cv_header_sys_ioctl_h" = "yes" -a "$ac_cv_header_fcntl_h" = "yes"], + [], [$FCNTL_LIBS]) + PY_STDLIB_MOD([mmap], +- [], [test "$ac_cv_header_sys_mman_h" = "yes" -a "$ac_cv_header_sys_stat_h" = "yes"]) ++ [], m4_flatten([test "$ac_cv_header_sys_mman_h" = "yes" ++ -a "$ac_cv_header_sys_stat_h" = "yes" ++ -o "$MACHDEP" = "win32"])) + PY_STDLIB_MOD([_socket], + [], m4_flatten([test "$ac_cv_header_sys_socket_h" = "yes" + -a "$ac_cv_header_sys_types_h" = "yes" diff --git a/mingw-w64-python3.12/0088-venv-creation-fixes.patch b/mingw-w64-python3.12/0088-venv-creation-fixes.patch new file mode 100644 index 0000000000..5490b53579 --- /dev/null +++ b/mingw-w64-python3.12/0088-venv-creation-fixes.patch @@ -0,0 +1,52 @@ +From 29cd24b1d69cbc5ef8047ff92cbafb7bde0c9352 Mon Sep 17 00:00:00 2001 +From: Naveen M K +Date: Fri, 23 Jun 2023 20:49:15 +0530 +Subject: [PATCH 088/N] venv creation fixes + +--- + Lib/venv/__init__.py | 11 +++++++++-- + 1 file changed, 9 insertions(+), 2 deletions(-) + +diff --git a/Lib/venv/__init__.py b/Lib/venv/__init__.py +index 2173c9b..22e8adf 100644 +--- a/Lib/venv/__init__.py ++++ b/Lib/venv/__init__.py +@@ -11,7 +11,7 @@ + import sys + import sysconfig + import types +- ++from sysconfig import _POSIX_BUILD + + CORE_VENV_DEPS = ('pip',) + logger = logging.getLogger(__name__) +@@ -302,7 +302,7 @@ def setup_python(self, context): + 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 +@@ -326,6 +326,12 @@ def setup_python(self, context): + if os.path.lexists(src): + copier(src, os.path.join(binpath, suffix)) + ++ 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(): + # copy init.tcl + for root, dirs, files in os.walk(context.python_dir): +@@ -350,6 +356,7 @@ def _call_new_python(self, context, *py_args, **kwargs): + env['VIRTUAL_ENV'] = context.env_dir + env.pop('PYTHONHOME', None) + env.pop('PYTHONPATH', None) ++ env.pop("MSYSTEM", None) + kwargs['cwd'] = context.env_dir + kwargs['executable'] = context.env_exec_cmd + subprocess.check_output(args, **kwargs) diff --git a/mingw-w64-python3.12/0089-move-the-shutdown-function-where-winsock.h-is-includ.patch b/mingw-w64-python3.12/0089-move-the-shutdown-function-where-winsock.h-is-includ.patch new file mode 100644 index 0000000000..6169f67ceb --- /dev/null +++ b/mingw-w64-python3.12/0089-move-the-shutdown-function-where-winsock.h-is-includ.patch @@ -0,0 +1,31 @@ +From 4b83207f4c821f1da5ec939edf4e28bb8c609774 Mon Sep 17 00:00:00 2001 +From: Naveen M K +Date: Fri, 23 Jun 2023 23:34:01 +0530 +Subject: [PATCH 089/N] move the `shutdown` function where `winsock.h` is + included + +--- + configure.ac | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/configure.ac b/configure.ac +index cba1434..e407e1d 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -5168,7 +5168,7 @@ AC_CHECK_FUNCS([ \ + sched_setparam sched_setscheduler sem_clockwait sem_getvalue sem_open \ + sem_timedwait sem_unlink sendfile setegid seteuid setgid sethostname \ + setitimer setlocale setpgid setpgrp setpriority setregid setresgid \ +- setresuid setreuid setsid setuid setvbuf shutdown sigaction sigaltstack \ ++ setresuid setreuid setsid setuid setvbuf sigaction sigaltstack \ + sigfillset siginterrupt sigpending sigrelse sigtimedwait sigwait \ + sigwaitinfo snprintf splice strftime strlcpy strsignal symlinkat sync \ + sysconf system tcgetpgrp tcsetpgrp tempnam timegm times tmpfile \ +@@ -5398,6 +5398,7 @@ PY_CHECK_NETDB_FUNC([gethostbyname]) + PY_CHECK_NETDB_FUNC([gethostbyaddr]) + PY_CHECK_NETDB_FUNC([getprotobyname]) + PY_CHECK_NETDB_FUNC([gethostname]) ++PY_CHECK_NETDB_FUNC([shutdown]) + + dnl PY_CHECK_SOCKET_FUNC(FUNCTION) + AC_DEFUN([PY_CHECK_SOCKET_FUNC], [PY_CHECK_FUNC([$1], [ diff --git a/mingw-w64-python3.12/0090-configure.ac-set-BUILDEXEEXT-and-EXEEXT.patch b/mingw-w64-python3.12/0090-configure.ac-set-BUILDEXEEXT-and-EXEEXT.patch new file mode 100644 index 0000000000..1bda3d01b6 --- /dev/null +++ b/mingw-w64-python3.12/0090-configure.ac-set-BUILDEXEEXT-and-EXEEXT.patch @@ -0,0 +1,32 @@ +From 7e1ed60a3558f74c3d27e1fb65214bf74803456d Mon Sep 17 00:00:00 2001 +From: Christoph Reiter +Date: Fri, 23 Jun 2023 21:47:32 +0200 +Subject: [PATCH 090/N] configure.ac: set BUILDEXEEXT and EXEEXT + +--- + configure.ac | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/configure.ac b/configure.ac +index e407e1d..3337b12 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -1409,6 +1409,7 @@ AC_ARG_WITH([suffix], + [Emscripten/browser*], [EXEEXT=.js], + [Emscripten/node*], [EXEEXT=.js], + [WASI/*], [EXEEXT=.wasm], ++ [MINGW*], [EXEEXT=.exe], + [EXEEXT=] + ) + ]) +@@ -1432,6 +1433,10 @@ else + fi + rmdir CaseSensitiveTestDir + ++AS_CASE([$ac_sys_system], ++ [MINGW], [BUILDEXEEXT=".exe"] ++) ++ + case $ac_sys_system in + hp*|HP*) + case $CC in diff --git a/mingw-w64-python3.12/0091-configure.ac-fix-building-some-test-modules.patch b/mingw-w64-python3.12/0091-configure.ac-fix-building-some-test-modules.patch new file mode 100644 index 0000000000..0ae4d71978 --- /dev/null +++ b/mingw-w64-python3.12/0091-configure.ac-fix-building-some-test-modules.patch @@ -0,0 +1,53 @@ +From 7219ae643fe9e2bd67667c45201baeb1fee88af5 Mon Sep 17 00:00:00 2001 +From: Christoph Reiter +Date: Fri, 23 Jun 2023 23:42:39 +0200 +Subject: [PATCH 091/N] configure.ac: fix building some test modules + +they are guarded by dlopen being present, but if module loading is enabled +is more correct. +--- + configure.ac | 13 ++++++++----- + 1 file changed, 8 insertions(+), 5 deletions(-) + +diff --git a/configure.ac b/configure.ac +index 3337b12..c1875f8 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -5124,8 +5124,11 @@ fi + AC_MSG_RESULT([$DYNLOADFILE]) + if test "$DYNLOADFILE" != "dynload_stub.o" + then ++ have_dynamic_loading=yes + AC_DEFINE([HAVE_DYNAMIC_LOADING], [1], + [Defined when any dynamic module loading is enabled.]) ++else ++ have_dynamic_loading=no + fi + + # MACHDEP_OBJS can be set to platform-specific object files needed by Python +@@ -7983,20 +7986,20 @@ PY_STDLIB_MOD([_testcapi], [test "$TEST_MODULES" = yes]) + PY_STDLIB_MOD([_testclinic], [test "$TEST_MODULES" = yes]) + PY_STDLIB_MOD([_testinternalcapi], [test "$TEST_MODULES" = yes], [], [-DPY3_DLLNAME="\"$DLLLIBRARY\""], []) + PY_STDLIB_MOD([_testbuffer], [test "$TEST_MODULES" = yes]) +-PY_STDLIB_MOD([_testimportmultiple], [test "$TEST_MODULES" = yes], [test "$ac_cv_func_dlopen" = yes]) +-PY_STDLIB_MOD([_testmultiphase], [test "$TEST_MODULES" = yes], [test "$ac_cv_func_dlopen" = yes]) ++PY_STDLIB_MOD([_testimportmultiple], [test "$TEST_MODULES" = yes], [test "$have_dynamic_loading" = yes]) ++PY_STDLIB_MOD([_testmultiphase], [test "$TEST_MODULES" = yes], [test "$have_dynamic_loading" = yes]) + PY_STDLIB_MOD([xxsubtype], [test "$TEST_MODULES" = yes]) + PY_STDLIB_MOD([_xxtestfuzz], [test "$TEST_MODULES" = yes]) + PY_STDLIB_MOD([_testconsole], [test "$TEST_MODULES" = yes -a "$MACHDEP" = "win32"]) + PY_STDLIB_MOD([_ctypes_test], +- [test "$TEST_MODULES" = yes], [test "$have_libffi" = yes -a "$ac_cv_func_dlopen" = yes], ++ [test "$TEST_MODULES" = yes], [test "$have_libffi" = yes -a "$have_dynamic_loading" = yes], + [], [$LIBM]) + + dnl Limited API template modules. + dnl The limited C API is not compatible with the Py_TRACE_REFS macro. + dnl Emscripten does not support shared libraries yet. +-PY_STDLIB_MOD([xxlimited], [test "$with_trace_refs" = "no"], [test "$ac_cv_func_dlopen" = yes]) +-PY_STDLIB_MOD([xxlimited_35], [test "$with_trace_refs" = "no"], [test "$ac_cv_func_dlopen" = yes]) ++PY_STDLIB_MOD([xxlimited], [test "$with_trace_refs" = "no"], [test "$have_dynamic_loading" = yes]) ++PY_STDLIB_MOD([xxlimited_35], [test "$with_trace_refs" = "no"], [test "$have_dynamic_loading" = yes]) + + # substitute multiline block, must come after last PY_STDLIB_MOD() + AC_SUBST([MODULE_BLOCK]) diff --git a/mingw-w64-python3.12/0092-Don-t-convert-sysconfig.get_config_var-VPATH-to-an-a.patch b/mingw-w64-python3.12/0092-Don-t-convert-sysconfig.get_config_var-VPATH-to-an-a.patch new file mode 100644 index 0000000000..abd1d21d99 --- /dev/null +++ b/mingw-w64-python3.12/0092-Don-t-convert-sysconfig.get_config_var-VPATH-to-an-a.patch @@ -0,0 +1,53 @@ +From 4492bf83d5e82dc5983fa379badbe60e5de9fd1f Mon Sep 17 00:00:00 2001 +From: Naveen M K +Date: Sun, 25 Jun 2023 17:20:52 +0530 +Subject: [PATCH 092/N] Don't convert `sysconfig.get_config_var('VPATH')` to + an absolute path + +this is required for venv to work properly +--- + Makefile.pre.in | 1 - + configure.ac | 10 +--------- + 2 files changed, 1 insertion(+), 10 deletions(-) + +diff --git a/Makefile.pre.in b/Makefile.pre.in +index 486076d..03c6087 100644 +--- a/Makefile.pre.in ++++ b/Makefile.pre.in +@@ -146,7 +146,6 @@ 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@ +diff --git a/configure.ac b/configure.ac +index c1875f8..5eff281 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -763,12 +763,8 @@ fi + # 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 ++# 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. +@@ -795,10 +791,6 @@ AC_DEFUN([ABS_PATH_HOST], + 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]) diff --git a/mingw-w64-python3.12/0093-Always-convert-to-before-passing-though-pathcch-func.patch b/mingw-w64-python3.12/0093-Always-convert-to-before-passing-though-pathcch-func.patch new file mode 100644 index 0000000000..2ba81a3be3 --- /dev/null +++ b/mingw-w64-python3.12/0093-Always-convert-to-before-passing-though-pathcch-func.patch @@ -0,0 +1,102 @@ +From ab3ef7381c0eb8518d0a6ea63cf675b3f6cf8204 Mon Sep 17 00:00:00 2001 +From: Naveen M K +Date: Sun, 25 Jun 2023 17:24:11 +0530 +Subject: [PATCH 093/N] Always convert `/` to `\\` before passing though + pathcch functions + +they don't seems to handle `/` as path separator correctly +--- + Include/pylifecycle.h | 2 ++ + Python/fileutils.c | 22 ++++++++++++++++++---- + Python/pathconfig.c | 16 ++++++++++++++++ + 3 files changed, 36 insertions(+), 4 deletions(-) + +diff --git a/Include/pylifecycle.h b/Include/pylifecycle.h +index 5d29201..21346ba 100644 +--- a/Include/pylifecycle.h ++++ b/Include/pylifecycle.h +@@ -28,6 +28,8 @@ PyAPI_FUNC(char) Py_GetSepA(const char *); + PyAPI_FUNC(void) Py_NormalizeSepsW(wchar_t *); + PyAPI_FUNC(void) Py_NormalizeSepsA(char *); + ++PyAPI_FUNC(void) Py_NormalizeSepsPathcchW(wchar_t *); ++ + + /* Py_PyAtExit is for the atexit module, Py_AtExit is for low-level + * exit functions. +diff --git a/Python/fileutils.c b/Python/fileutils.c +index 50c78f1..aae4143 100644 +--- a/Python/fileutils.c ++++ b/Python/fileutils.c +@@ -2144,19 +2144,31 @@ int + _Py_isabs(const wchar_t *path) + { + #ifdef MS_WINDOWS ++ // create a copy of path and replace all forward slashes with backslashes ++ // pathccskiproot does not handle forward slashes ++ wchar_t *path_copy = _wcsdup(path); ++ if (path_copy == NULL) { ++ return 0; ++ } ++ Py_NormalizeSepsPathcchW(path_copy); ++ + const wchar_t *tail; +- HRESULT hr = PathCchSkipRoot(path, &tail); +- if (FAILED(hr) || path == tail) { ++ HRESULT hr = PathCchSkipRoot(path_copy, &tail); ++ if (FAILED(hr) || path_copy == tail) { ++ free(path_copy); + return 0; + } +- if (tail == &path[1] && (path[0] == SEP || path[0] == ALTSEP)) { ++ if (tail == &path_copy[1] && (path_copy[0] == SEP || path_copy[0] == ALTSEP)) { + // Exclude paths with leading SEP ++ free(path_copy); + return 0; + } +- if (tail == &path[2] && path[1] == L':') { ++ if (tail == &path_copy[2] && path_copy[1] == L':') { + // Exclude drive-relative paths (e.g. C:filename.ext) ++ free(path_copy); + return 0; + } ++ free(path_copy); + return 1; + #else + return (path[0] == SEP); +@@ -2303,6 +2315,8 @@ join_relfile(wchar_t *buffer, size_t bufsize, + const wchar_t *dirname, const wchar_t *relfile) + { + #ifdef MS_WINDOWS ++ Py_NormalizeSepsPathcchW(dirname); ++ Py_NormalizeSepsPathcchW(relfile); + if (FAILED(PathCchCombineEx(buffer, bufsize, dirname, relfile, + PATHCCH_ALLOW_LONG_PATHS))) { + return -1; +diff --git a/Python/pathconfig.c b/Python/pathconfig.c +index 08a4a37..8053b91 100644 +--- a/Python/pathconfig.c ++++ b/Python/pathconfig.c +@@ -155,6 +155,22 @@ Py_NormalizeSepsW(wchar_t *name) + } + } + ++void ++Py_NormalizeSepsPathcchW(wchar_t *name) ++{ ++#ifdef MS_WINDOWS ++ assert(name != NULL); ++ wchar_t sep = '\\'; ++ wchar_t altsep = '/'; ++ wchar_t* seps; ++ seps = wcschr(name, altsep); ++ while(seps) { ++ *seps = sep; ++ seps = wcschr(seps, altsep); ++ } ++#endif ++} ++ + /* External interface */ + + /* Stored values set by C API functions */ diff --git a/mingw-w64-python3.12/0094-Build-venvlauncher.exe-from-PC-launcher.c.patch b/mingw-w64-python3.12/0094-Build-venvlauncher.exe-from-PC-launcher.c.patch new file mode 100644 index 0000000000..7e7a52ad22 --- /dev/null +++ b/mingw-w64-python3.12/0094-Build-venvlauncher.exe-from-PC-launcher.c.patch @@ -0,0 +1,194 @@ +From 4a4b65385946815cd4c843c151c9b3052bafd957 Mon Sep 17 00:00:00 2001 +From: Naveen M K +Date: Sun, 25 Jun 2023 17:26:55 +0530 +Subject: [PATCH 094/N] Build venvlauncher.exe from PC/launcher.c + +- Use function available in original msvcrt.dll + _wdupenv_s -> _wgetenv_s + fread_s -> fread +- Add a test for checking the new launchers +--- + Makefile.pre.in | 20 ++++++++++++-------- + PC/launcher.c | 33 +++++++++++++++++++-------------- + PC/pylauncher.rc | 20 ++++++++++---------- + mingw_smoketests.py | 12 ++++++++++++ + 4 files changed, 53 insertions(+), 32 deletions(-) + +diff --git a/Makefile.pre.in b/Makefile.pre.in +index 03c6087..4b8f513 100644 +--- a/Makefile.pre.in ++++ b/Makefile.pre.in +@@ -804,6 +804,12 @@ pythonw_exe.o: $(srcdir)/PC/pythonw_exe.rc + python_nt.o: $(srcdir)/PC/python_nt.rc + $(WINDRES) $(RCFLAGS) -DORIGINAL_FILENAME=\\\"$(DLLLIBRARY)\\\" -I$(srcdir)/Include -I$(srcdir)/PC -I. $(srcdir)/PC/python_nt.rc $@ + ++venvlauncher.o: $(srcdir)/PC/pylauncher.rc ++ $(WINDRES) $(RCFLAGS) -DPY_ICON -I$(srcdir)/Include -I$(srcdir)/PC -I. $(srcdir)/PC/pylauncher.rc $@ ++ ++venvwlauncher.o: $(srcdir)/PC/pylauncher.rc ++ $(WINDRES) $(RCFLAGS) -DPYW_ICON -I$(srcdir)/Include -I$(srcdir)/PC -I. $(srcdir)/PC/pylauncher.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 + +@@ -811,13 +817,11 @@ $(BUILDPYTHONW): Programs/python.o $(LIBRARY) $(LDLIBRARY) $(PY3LIBRARY) pythonw + $(BUILDPYTHON): Programs/python.o $(LINK_PYTHON_DEPS) python_exe.o + $(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -municode -o $@ Programs/python.o $(LINK_PYTHON_OBJS) $(LIBS) $(MODLIBS) $(SYSLIBS) python_exe.o + +-# FIXME: build these from PC/launcher.c instead +-$(BUILDVENVLAUNCHER): $(BUILDPYTHON) +- cp $(BUILDPYTHON) $(BUILDVENVLAUNCHER) ++$(BUILDVENVLAUNCHER): $(BUILDPYTHON) venvlauncher.o $(srcdir)/PC/launcher.c ++ $(LINKCC) -D_CONSOLE -DVENV_REDIRECT -DPYTHON_EXECUTABLE_WITH_VERSION="L\"python$(LDVERSION)$(EXE)\"" -municode -static -static-libgcc -static-libstdc++ venvlauncher.o $(srcdir)/PC/launcher.c -o $@ -lversion + +-# FIXME: build these from PC/launcher.c instead +-$(BUILDVENVWLAUNCHER): $(BUILDPYTHONW) +- cp $(BUILDPYTHONW) $(BUILDVENVWLAUNCHER) ++$(BUILDVENVWLAUNCHER): $(BUILDPYTHONW) venvwlauncher.o $(srcdir)/PC/launcher.c ++ $(LINKCC) -D_WINDOWS -DVENV_REDIRECT -DPYTHON_EXECUTABLE_WITH_VERSION="L\"pythonw$(LDVERSION)$(EXE)\"" -mwindows -municode -static -static-libgcc -static-libstdc++ venvwlauncher.o $(srcdir)/PC/launcher.c -o $@ -lversion + + platform: $(PYTHON_FOR_BUILD_DEPS) 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 +@@ -2006,8 +2010,8 @@ altbininstall: $(BUILDPYTHON) @FRAMEWORKPYTHONW@ + if test "$(PYTHONFRAMEWORKDIR)" = "no-framework" ; then \ + $(INSTALL_PROGRAM) $(BUILDPYTHON) $(DESTDIR)$(BINDIR)/python$(LDVERSION)$(EXE); \ + $(INSTALL_PROGRAM) $(BUILDPYTHONW) $(DESTDIR)$(BINDIR)/python3w$(EXE); \ +- $(INSTALL_PROGRAM) $(BUILDPYTHON) $(DESTDIR)$(VENVLAUNCHERDIR)/python$(EXE); \ +- $(INSTALL_PROGRAM) $(BUILDPYTHONW) $(DESTDIR)$(VENVLAUNCHERDIR)/pythonw$(EXE); \ ++ $(INSTALL_PROGRAM) $(BUILDVENVLAUNCHER) $(DESTDIR)$(VENVLAUNCHERDIR)/python$(EXE); \ ++ $(INSTALL_PROGRAM) $(BUILDVENVWLAUNCHER) $(DESTDIR)$(VENVLAUNCHERDIR)/pythonw$(EXE); \ + else \ + $(INSTALL_PROGRAM) $(STRIPFLAG) Mac/pythonw $(DESTDIR)$(BINDIR)/python$(LDVERSION)$(EXE); \ + fi +diff --git a/PC/launcher.c b/PC/launcher.c +index dc26553..118e963 100644 +--- a/PC/launcher.c ++++ b/PC/launcher.c +@@ -155,12 +155,12 @@ static wchar_t * get_env(wchar_t * key) + #else + #if defined(_WINDOWS) + +-#define PYTHON_EXECUTABLE L"pythonw.exe" ++#define PYTHON_EXECUTABLE PYTHON_EXECUTABLE_WITH_VERSION + #define EXECUTABLEPATH_VALUE L"WindowedExecutablePath" + + #else + +-#define PYTHON_EXECUTABLE L"python.exe" ++#define PYTHON_EXECUTABLE PYTHON_EXECUTABLE_WITH_VERSION + #define EXECUTABLEPATH_VALUE L"ExecutablePath" + + #endif +@@ -924,7 +924,7 @@ static COMMAND path_command; + static COMMAND * find_on_path(wchar_t * name) + { + wchar_t * pathext; +- size_t varsize; ++ size_t requiredSize; + wchar_t * context = NULL; + wchar_t * extension; + COMMAND * result = NULL; +@@ -941,18 +941,23 @@ static COMMAND * find_on_path(wchar_t * name) + } + else { + /* No extension - search using registered extensions. */ +- rc = _wdupenv_s(&pathext, &varsize, L"PATHEXT"); +- if (rc == 0) { +- extension = wcstok_s(pathext, L";", &context); +- while (extension) { +- len = SearchPathW(NULL, name, extension, MSGSIZE, path_command.value, NULL); +- if (len) { +- result = &path_command; +- break; ++ _wgetenv_s(&requiredSize, NULL, 0, L"PATHEXT"); ++ if (requiredSize > 0) { ++ pathext = (wchar_t *)malloc(requiredSize * sizeof(wchar_t)); ++ /* No extension - search using registered extensions. */ ++ rc = _wgetenv_s(&requiredSize, pathext, requiredSize, L"PATHEXT"); ++ if (rc == 0) { ++ extension = wcstok_s(pathext, L";", &context); ++ while (extension) { ++ len = SearchPathW(NULL, name, extension, MSGSIZE, path_command.value, NULL); ++ if (len) { ++ result = &path_command; ++ break; ++ } ++ extension = wcstok_s(NULL, L";", &context); + } +- extension = wcstok_s(NULL, L";", &context); ++ free(pathext); + } +- free(pathext); + } + } + return result; +@@ -1912,7 +1917,7 @@ process(int argc, wchar_t ** argv) + if (_wfopen_s(&f, venv_cfg_path, L"r")) { + error(RC_BAD_VENV_CFG, L"Cannot read '%ls'", venv_cfg_path); + } +- cb = fread_s(buffer, sizeof(buffer), sizeof(buffer[0]), ++ cb = fread(buffer, sizeof(buffer[0]), + sizeof(buffer) / sizeof(buffer[0]), f); + fclose(f); + +diff --git a/PC/pylauncher.rc b/PC/pylauncher.rc +index 1186264..84b2917 100644 +--- a/PC/pylauncher.rc ++++ b/PC/pylauncher.rc +@@ -12,17 +12,17 @@ + 1 RT_MANIFEST "python.manifest" + + #if defined(PY_ICON) +-1 ICON DISCARDABLE "icons\python.ico" ++1 ICON DISCARDABLE "icons/python.ico" + #elif defined(PYW_ICON) +-1 ICON DISCARDABLE "icons\pythonw.ico" ++1 ICON DISCARDABLE "icons/pythonw.ico" + #else +-1 ICON DISCARDABLE "icons\launcher.ico" +-2 ICON DISCARDABLE "icons\py.ico" +-3 ICON DISCARDABLE "icons\pyc.ico" +-4 ICON DISCARDABLE "icons\pyd.ico" +-5 ICON DISCARDABLE "icons\python.ico" +-6 ICON DISCARDABLE "icons\pythonw.ico" +-7 ICON DISCARDABLE "icons\setup.ico" ++1 ICON DISCARDABLE "icons/launcher.ico" ++2 ICON DISCARDABLE "icons/py.ico" ++3 ICON DISCARDABLE "icons/pyc.ico" ++4 ICON DISCARDABLE "icons/pyd.ico" ++5 ICON DISCARDABLE "icons/python.ico" ++6 ICON DISCARDABLE "icons/pythonw.ico" ++7 ICON DISCARDABLE "icons/setup.ico" + #endif + + 1 USAGE "launcher-usage.txt" +@@ -64,4 +64,4 @@ BEGIN + BEGIN + VALUE "Translation", 0x0, 1200 + END +-END +\ No newline at end of file ++END +diff --git a/mingw_smoketests.py b/mingw_smoketests.py +index 2a8bd16..00601f9 100644 +--- a/mingw_smoketests.py ++++ b/mingw_smoketests.py +@@ -194,6 +194,18 @@ def test_venv_creation(self): + assert os.path.exists(os.path.join(tmp, "bin", "python3.exe")) + subprocess.check_call([shutil.which("bash.exe"), os.path.join(tmp, "bin", "activate")]) + ++ # This will not work in in-tree build ++ if not sysconfig.is_python_build(): ++ op = subprocess.check_output( ++ [ ++ os.path.join(tmp, "bin", "python.exe"), ++ "-c", ++ "print('Hello World')" ++ ], ++ cwd=tmp, ++ ) ++ assert op.decode().strip() == "Hello World" ++ + def test_has_mktime(self): + from time import mktime, gmtime + mktime(gmtime()) diff --git a/mingw-w64-python3.12/0095-getpath.py-fix-dirname.patch b/mingw-w64-python3.12/0095-getpath.py-fix-dirname.patch new file mode 100644 index 0000000000..adb88b9de3 --- /dev/null +++ b/mingw-w64-python3.12/0095-getpath.py-fix-dirname.patch @@ -0,0 +1,55 @@ +From c4d0bdb74deb03161bbb583bf3bf356fffee2eb6 Mon Sep 17 00:00:00 2001 +From: Naveen M K +Date: Sun, 25 Jun 2023 19:39:30 +0530 +Subject: [PATCH 095/N] getpath.py: fix `dirname` + +also, fix finding prefix when in a venv +--- + Modules/getpath.c | 12 ++++++++++++ + Modules/getpath.py | 3 +++ + 2 files changed, 15 insertions(+) + +diff --git a/Modules/getpath.c b/Modules/getpath.c +index bd80221..16d18b3 100644 +--- a/Modules/getpath.c ++++ b/Modules/getpath.c +@@ -89,6 +89,12 @@ getpath_basename(PyObject *Py_UNUSED(self), PyObject *args) + } + Py_ssize_t end = PyUnicode_GET_LENGTH(path); + Py_ssize_t pos = PyUnicode_FindChar(path, SEP, 0, end, -1); ++#ifdef ALTSEP ++ if (pos < 0) { ++ // try using altsep ++ pos = PyUnicode_FindChar(path, ALTSEP, 0, end, -1); ++ } ++#endif + if (pos < 0) { + return Py_NewRef(path); + } +@@ -105,6 +111,12 @@ getpath_dirname(PyObject *Py_UNUSED(self), PyObject *args) + } + Py_ssize_t end = PyUnicode_GET_LENGTH(path); + Py_ssize_t pos = PyUnicode_FindChar(path, SEP, 0, end, -1); ++#ifdef ALTSEP ++ if (pos < 0) { ++ // try using altsep ++ pos = PyUnicode_FindChar(path, ALTSEP, 0, end, -1); ++ } ++#endif + if (pos < 0) { + return PyUnicode_FromStringAndSize(NULL, 0); + } +diff --git a/Modules/getpath.py b/Modules/getpath.py +index 6867e98..5687e4f 100644 +--- a/Modules/getpath.py ++++ b/Modules/getpath.py +@@ -574,6 +574,9 @@ def search_up(prefix, *landmarks, test=isfile): + # First try to detect prefix by looking alongside our runtime library, if known + if library and not prefix: + library_dir = dirname(library) ++ if os_name == 'nt' and is_mingw: ++ # QUIRK: On Windows, mingw Python DLLs are in the bin directory ++ library_dir = joinpath(library_dir, '..') + if ZIP_LANDMARK: + if os_name == 'nt': + # QUIRK: Windows does not search up for ZIP file diff --git a/mingw-w64-python3.12/0096-getpath-use-normpath-on-all-generated-paths.patch b/mingw-w64-python3.12/0096-getpath-use-normpath-on-all-generated-paths.patch new file mode 100644 index 0000000000..911654dccc --- /dev/null +++ b/mingw-w64-python3.12/0096-getpath-use-normpath-on-all-generated-paths.patch @@ -0,0 +1,154 @@ +From 51fa807b6357e1f2ed85018233f44d117e71f017 Mon Sep 17 00:00:00 2001 +From: Christoph Reiter +Date: Fri, 28 Jul 2023 20:13:58 +0200 +Subject: [PATCH 096/N] getpath: use normpath on all generated paths + +Instead of just calling normpath in abspath just call normpath +on all the config results. This makes sure we don't change getpath.py +too much and still cover all outputs. + +This fixes sys.exec_prefix not matching sys.prefix, see +https://github.com/msys2-contrib/cpython-mingw/issues/142 +--- + Lib/test/test_getpath.py | 6 ++++++ + Modules/getpath.c | 21 ++++++++++++++++++++- + Modules/getpath.py | 30 ++++++++++++++++-------------- + 3 files changed, 42 insertions(+), 15 deletions(-) + +diff --git a/Lib/test/test_getpath.py b/Lib/test/test_getpath.py +index ee4ab99..47ca302 100644 +--- a/Lib/test/test_getpath.py ++++ b/Lib/test/test_getpath.py +@@ -913,6 +913,9 @@ def __missing__(self, key): + except AttributeError: + raise KeyError(key) from None + ++ def normpath(self, path): ++ return ntpath.normpath(path) ++ + def abspath(self, path): + if self.isabs(path): + return path +@@ -1091,6 +1094,9 @@ def __missing__(self, key): + except AttributeError: + raise KeyError(key) from None + ++ def normpath(self, path): ++ return path ++ + def abspath(self, path): + if self.isabs(path): + return path +diff --git a/Modules/getpath.c b/Modules/getpath.c +index 16d18b3..4753022 100644 +--- a/Modules/getpath.c ++++ b/Modules/getpath.c +@@ -54,6 +54,25 @@ + + /* HELPER FUNCTIONS for getpath.py */ + ++static PyObject * ++getpath_normpath(PyObject *Py_UNUSED(self), PyObject *args) ++{ ++ PyObject *r = NULL; ++ PyObject *pathobj; ++ wchar_t *path; ++ if (!PyArg_ParseTuple(args, "U", &pathobj)) { ++ return NULL; ++ } ++ Py_ssize_t len; ++ wchar_t *buffer = PyUnicode_AsWideCharString(pathobj, &len); ++ if (!buffer) { ++ return NULL; ++ } ++ r = PyUnicode_FromWideChar(_Py_normpath(buffer, len), -1); ++ PyMem_Free(buffer); ++ return r; ++} ++ + static PyObject * + getpath_abspath(PyObject *Py_UNUSED(self), PyObject *args) + { +@@ -68,7 +87,6 @@ getpath_abspath(PyObject *Py_UNUSED(self), PyObject *args) + if (path) { + wchar_t *abs; + if (_Py_abspath((const wchar_t *)_Py_normpath(path, -1), &abs) == 0 && abs) { +- abs = _Py_normpath(abs, -1); + r = PyUnicode_FromWideChar(abs, -1); + PyMem_RawFree((void *)abs); + } else { +@@ -519,6 +537,7 @@ getpath_realpath(PyObject *Py_UNUSED(self) , PyObject *args) + + + static PyMethodDef getpath_methods[] = { ++ {"normpath", getpath_normpath, METH_VARARGS, NULL}, + {"abspath", getpath_abspath, METH_VARARGS, NULL}, + {"basename", getpath_basename, METH_VARARGS, NULL}, + {"dirname", getpath_dirname, METH_VARARGS, NULL}, +diff --git a/Modules/getpath.py b/Modules/getpath.py +index 5687e4f..d143f97 100644 +--- a/Modules/getpath.py ++++ b/Modules/getpath.py +@@ -233,6 +233,8 @@ def search_up(prefix, *landmarks, test=isfile): + return prefix + prefix = dirname(prefix) + ++def _normpath(p): ++ return normpath(p) if p is not None else None + + # ****************************************************************************** + # READ VARIABLES FROM config +@@ -670,7 +672,7 @@ def search_up(prefix, *landmarks, test=isfile): + + if py_setpath: + # If Py_SetPath was called then it overrides any existing search path +- config['module_search_paths'] = py_setpath.split(DELIM) ++ config['module_search_paths'] = [_normpath(p) for p in py_setpath.split(DELIM)] + config['module_search_paths_set'] = 1 + + elif not pythonpath_was_set: +@@ -757,7 +759,7 @@ def search_up(prefix, *landmarks, test=isfile): + if platstdlib_dir: + pythonpath.append(platstdlib_dir) + +- config['module_search_paths'] = pythonpath ++ config['module_search_paths'] = [_normpath(p) for p in pythonpath] + config['module_search_paths_set'] = 1 + + +@@ -792,23 +794,23 @@ def search_up(prefix, *landmarks, test=isfile): + warn("unsupported 'import' line in ._pth file") + else: + pythonpath.append(joinpath(pth_dir, line)) +- config['module_search_paths'] = pythonpath ++ config['module_search_paths'] = [_normpath(p) for p in pythonpath] + config['module_search_paths_set'] = 1 + + # ****************************************************************************** + # UPDATE config FROM CALCULATED VALUES + # ****************************************************************************** + +-config['program_name'] = program_name +-config['home'] = home +-config['executable'] = executable +-config['base_executable'] = base_executable +-config['prefix'] = prefix +-config['exec_prefix'] = exec_prefix +-config['base_prefix'] = base_prefix or prefix +-config['base_exec_prefix'] = base_exec_prefix or exec_prefix ++config['program_name'] = _normpath(program_name) ++config['home'] = _normpath(home) ++config['executable'] = _normpath(executable) ++config['base_executable'] = _normpath(base_executable) ++config['prefix'] = _normpath(prefix) ++config['exec_prefix'] = _normpath(exec_prefix) ++config['base_prefix'] = _normpath(base_prefix or prefix) ++config['base_exec_prefix'] = _normpath(base_exec_prefix or exec_prefix) + +-config['platlibdir'] = platlibdir ++config['platlibdir'] = _normpath(platlibdir) + # test_embed expects empty strings, not None +-config['stdlib_dir'] = stdlib_dir or '' +-config['platstdlib_dir'] = platstdlib_dir or '' ++config['stdlib_dir'] = _normpath(stdlib_dir or '') ++config['platstdlib_dir'] = _normpath(platstdlib_dir or '') diff --git a/mingw-w64-python3.12/0097-pathconfig-normpath-sys.path-0.patch b/mingw-w64-python3.12/0097-pathconfig-normpath-sys.path-0.patch new file mode 100644 index 0000000000..05b9bd40b8 --- /dev/null +++ b/mingw-w64-python3.12/0097-pathconfig-normpath-sys.path-0.patch @@ -0,0 +1,24 @@ +From e23c9747e36b67afeb8e7d4fbb7ebbe5ed1d4990 Mon Sep 17 00:00:00 2001 +From: Christoph Reiter +Date: Fri, 28 Jul 2023 20:14:38 +0200 +Subject: [PATCH 097/N] pathconfig: normpath sys.path[0] + +this gets added as first element in sys.path. +use normpath to make sure it uses the right path separator +--- + Python/pathconfig.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Python/pathconfig.c b/Python/pathconfig.c +index 8053b91..7eb9006 100644 +--- a/Python/pathconfig.c ++++ b/Python/pathconfig.c +@@ -662,7 +662,7 @@ _PyPathConfig_ComputeSysPath0(const PyWideStringList *argv, PyObject **path0_p) + } + #endif /* All others */ + +- PyObject *path0_obj = PyUnicode_FromWideChar(path0, n); ++ PyObject *path0_obj = PyUnicode_FromWideChar(_Py_normpath(path0, -1), n); + if (path0_obj == NULL) { + return -1; + } diff --git a/mingw-w64-python3.12/0098-smoketests-add-some-tests-for-sys-site-paths.patch b/mingw-w64-python3.12/0098-smoketests-add-some-tests-for-sys-site-paths.patch new file mode 100644 index 0000000000..453f4e1e1f --- /dev/null +++ b/mingw-w64-python3.12/0098-smoketests-add-some-tests-for-sys-site-paths.patch @@ -0,0 +1,43 @@ +From f2d1898d485f41180c6d99474f6fd48ff2509a48 Mon Sep 17 00:00:00 2001 +From: Christoph Reiter +Date: Fri, 28 Jul 2023 20:15:01 +0200 +Subject: [PATCH 098/N] smoketests: add some tests for sys/site paths + +--- + mingw_smoketests.py | 23 +++++++++++++++++++++++ + 1 file changed, 23 insertions(+) + +diff --git a/mingw_smoketests.py b/mingw_smoketests.py +index 00601f9..516005c 100644 +--- a/mingw_smoketests.py ++++ b/mingw_smoketests.py +@@ -238,6 +238,29 @@ def test_platform_things(self): + self.assertEqual(platform.system(), "Windows") + self.assertTrue(isinstance(sys.api_version, int) and sys.api_version > 0) + ++ def test_sys_getpath(self): ++ # everything sourced from getpath.py ++ import sys ++ ++ def assertNormpath(path): ++ self.assertEqual(path, os.path.normpath(path)) ++ ++ assertNormpath(sys.executable) ++ assertNormpath(sys._base_executable) ++ assertNormpath(sys.prefix) ++ assertNormpath(sys.base_prefix) ++ assertNormpath(sys.exec_prefix) ++ assertNormpath(sys.base_exec_prefix) ++ assertNormpath(sys.platlibdir) ++ assertNormpath(sys._stdlib_dir) ++ for p in sys.path: ++ assertNormpath(p) ++ ++ def test_site(self): ++ import site ++ ++ self.assertEqual(len(site.getsitepackages()), 1) ++ + def test_c_ext_build(self): + import tempfile + import sys diff --git a/mingw-w64-python3.12/0099-Search-DLLs-only-on-paths-added-using-add_dll_direct.patch b/mingw-w64-python3.12/0099-Search-DLLs-only-on-paths-added-using-add_dll_direct.patch new file mode 100644 index 0000000000..30fcbe863f --- /dev/null +++ b/mingw-w64-python3.12/0099-Search-DLLs-only-on-paths-added-using-add_dll_direct.patch @@ -0,0 +1,134 @@ +From cd2927084b47627236aad65067d72d8596e2c74d Mon Sep 17 00:00:00 2001 +From: Naveen M K +Date: Sat, 5 Aug 2023 14:10:27 +0530 +Subject: [PATCH 099/N] Search DLLs only on paths added using + `add_dll_directory()`. + +This is the default behavior on upstream Python. We previously +reverted this behavior because it broke some use cases. + +The old behavior can be restored by setting the environment variable +PYTHONLEGACYWINDOWSDLLLOADING to 1. + +Fixes https://github.com/msys2-contrib/cpython-mingw/issues/48 +Also fixes https://github.com/msys2-contrib/cpython-mingw/issues/141 + +Signed-off-by: Naveen M K +--- + .github/workflows/mingw.yml | 10 +++++----- + Lib/test/__main__.py | 8 ++++++++ + Python/dynload_win.c | 16 ++++++++++++++-- + Tools/build/check_extension_modules.py | 4 ++++ + mingw_smoketests.py | 3 +++ + 5 files changed, 34 insertions(+), 7 deletions(-) + +diff --git a/.github/workflows/mingw.yml b/.github/workflows/mingw.yml +index 6445b6b..f0a0d92 100644 +--- a/.github/workflows/mingw.yml ++++ b/.github/workflows/mingw.yml +@@ -126,15 +126,15 @@ jobs: + cp "${pkgdir}${MINGW_PREFIX}"/bin/idle3 "${pkgdir}${MINGW_PREFIX}"/bin/idle + cp "${pkgdir}${MINGW_PREFIX}"/bin/pydoc3 "${pkgdir}${MINGW_PREFIX}"/bin/pydoc + ++ # copy to / ++ cp -rf "${pkgdir}"/* / ++ + - name: Run Smoke Test (installed) + shell: msys2 {0} + run: | +- export PYTHONTZPATH="${MINGW_PREFIX}/share/zoneinfo" + SMOKETESTS="$(pwd)/mingw_smoketests.py" +- cd _build +- cd python_pkgdir/${MINGW_PREFIX}/bin +- ./python.exe "$SMOKETESTS" +- MSYSTEM= ./python.exe "$SMOKETESTS" ++ ${MINGW_PREFIX}/bin/python.exe "$SMOKETESTS" ++ MSYSTEM= ${MINGW_PREFIX}/bin/python.exe "$SMOKETESTS" + + - name: Compress + if: always() +diff --git a/Lib/test/__main__.py b/Lib/test/__main__.py +index 82b50ad..25bac39 100644 +--- a/Lib/test/__main__.py ++++ b/Lib/test/__main__.py +@@ -1,2 +1,10 @@ ++import os ++import sys ++ + from test.libregrtest.main import main ++ ++if sys.platform == "win32": ++ # Enable DLL loading from PATH. ++ os.environ["PYTHONLEGACYWINDOWSDLLLOADING"] = "1" ++ + main(_add_python_opts=True) +diff --git a/Python/dynload_win.c b/Python/dynload_win.c +index 1f90e21..db79687 100644 +--- a/Python/dynload_win.c ++++ b/Python/dynload_win.c +@@ -4,6 +4,7 @@ + #include "Python.h" + #include "pycore_fileutils.h" // _Py_add_relfile() + #include "pycore_pystate.h" // _PyInterpreterState_GET() ++#include "pycore_initconfig.h" + + #ifdef HAVE_DIRECT_H + #include +@@ -225,6 +226,18 @@ dl_funcptr _PyImport_FindSharedFuncptrWindows(const char *prefix, + dl_funcptr p; + char funcname[258], *import_python; + ++ int use_legacy = 0; ++ DWORD load_library_flags = 0; ++ ++ _Py_get_env_flag(1, &use_legacy, "PYTHONLEGACYWINDOWSDLLLOADING"); ++ ++ if (use_legacy) { ++ load_library_flags = LOAD_WITH_ALTERED_SEARCH_PATH; ++ } else { ++ load_library_flags = LOAD_LIBRARY_SEARCH_DEFAULT_DIRS | ++ LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR; ++ } ++ + #ifdef _MSC_VER + _Py_CheckPython3(); + #endif /* _MSC_VER */ +@@ -249,8 +262,7 @@ dl_funcptr _PyImport_FindSharedFuncptrWindows(const char *prefix, + AddDllDirectory function. We add SEARCH_DLL_LOAD_DIR to + ensure DLLs adjacent to the PYD are preferred. */ + Py_BEGIN_ALLOW_THREADS +- hDLL = LoadLibraryExW(wpathname, NULL, +- LOAD_WITH_ALTERED_SEARCH_PATH); ++ hDLL = LoadLibraryExW(wpathname, NULL, load_library_flags); + Py_END_ALLOW_THREADS + PyMem_Free(wpathname); + +diff --git a/Tools/build/check_extension_modules.py b/Tools/build/check_extension_modules.py +index 59239c6..6810b3b 100644 +--- a/Tools/build/check_extension_modules.py ++++ b/Tools/build/check_extension_modules.py +@@ -60,6 +60,10 @@ + "winsound", + } + ++if sys.platform == "win32": ++ # Enable DLL loading from PATH. ++ os.environ["PYTHONLEGACYWINDOWSDLLLOADING"] = "1" ++ + + logger = logging.getLogger(__name__) + +diff --git a/mingw_smoketests.py b/mingw_smoketests.py +index 516005c..ca1f652 100644 +--- a/mingw_smoketests.py ++++ b/mingw_smoketests.py +@@ -34,6 +34,9 @@ + else: + SEP = "\\" + ++if sysconfig.is_python_build(): ++ os.environ["PYTHONLEGACYWINDOWSDLLLOADING"] = "1" ++ + _UCRT = sysconfig.get_platform() not in ('mingw_x86_64', 'mingw_i686') + + diff --git a/mingw-w64-python3.12/0100-Build-and-install-libpython3.dll.patch b/mingw-w64-python3.12/0100-Build-and-install-libpython3.dll.patch new file mode 100644 index 0000000000..c03548082a --- /dev/null +++ b/mingw-w64-python3.12/0100-Build-and-install-libpython3.dll.patch @@ -0,0 +1,108 @@ +From 4c28b3108f89f35bb093873843777eb10d8d6d7f Mon Sep 17 00:00:00 2001 +From: Christoph Reiter +Date: Mon, 21 Aug 2023 08:19:28 +0200 +Subject: [PATCH 100/N] Build and install libpython3.dll + +This provides the limited ABI as a separate DLL, forwarding to the +real one. This makes linking with "-lpython3" work. + +Fixes #147 +--- + Makefile.pre.in | 15 +++++++++++++-- + PC/python3dll.c | 8 ++++++++ + 2 files changed, 21 insertions(+), 2 deletions(-) + +diff --git a/Makefile.pre.in b/Makefile.pre.in +index 4b8f513..9717caf 100644 +--- a/Makefile.pre.in ++++ b/Makefile.pre.in +@@ -273,6 +273,8 @@ LIBRARY_DEPS= @LIBRARY_DEPS@ + LINK_PYTHON_DEPS=@LINK_PYTHON_DEPS@ + PY_ENABLE_SHARED= @PY_ENABLE_SHARED@ + STATIC_LIBPYTHON= @STATIC_LIBPYTHON@ ++ABI3DLLLIBRARY= libpython3.dll ++ABI3LDLIBRARY= libpython3.dll.a + + + LIBS= @LIBS@ +@@ -631,7 +633,7 @@ all: @DEF_MAKE_ALL_RULE@ + + .PHONY: build_all + build_all: check-clean-src $(BUILDPYTHON) $(BUILDPYTHONW) $(BUILDVENVLAUNCHER) $(BUILDVENVWLAUNCHER) platform sharedmods \ +- gdbhooks Programs/_testembed scripts checksharedmods rundsymutil ++ gdbhooks Programs/_testembed scripts checksharedmods rundsymutil $(ABI3DLLLIBRARY) $(ABI3LDLIBRARY) + + .PHONY: build_wasm + build_wasm: check-clean-src $(BUILDPYTHON) platform sharedmods \ +@@ -804,6 +806,9 @@ pythonw_exe.o: $(srcdir)/PC/pythonw_exe.rc + python_nt.o: $(srcdir)/PC/python_nt.rc + $(WINDRES) $(RCFLAGS) -DORIGINAL_FILENAME=\\\"$(DLLLIBRARY)\\\" -I$(srcdir)/Include -I$(srcdir)/PC -I. $(srcdir)/PC/python_nt.rc $@ + ++python3dll_nt.o: $(srcdir)/PC/python_nt.rc ++ $(WINDRES) $(RCFLAGS) -DORIGINAL_FILENAME=\\\"$(ABI3DLLLIBRARY)\\\" -I$(srcdir)/Include -I$(srcdir)/PC -I. $(srcdir)/PC/python_nt.rc $@ ++ + venvlauncher.o: $(srcdir)/PC/pylauncher.rc + $(WINDRES) $(RCFLAGS) -DPY_ICON -I$(srcdir)/Include -I$(srcdir)/PC -I. $(srcdir)/PC/pylauncher.rc $@ + +@@ -917,6 +922,10 @@ $(DLLLIBRARY) libpython$(LDVERSION).dll.a: $(LIBRARY_OBJS) python_nt.o + else true; \ + fi + ++$(ABI3DLLLIBRARY) $(ABI3LDLIBRARY): python3dll_nt.o $(srcdir)/PC/launcher.c ++ $(LDSHARED) -DPYTHON_DLL_NAME=\"$(DLLLIBRARY)\" $(srcdir)/PC/python3dll.c -Wl,--out-implib=$(ABI3LDLIBRARY) -o $(ABI3DLLLIBRARY) python3dll_nt.o \ ++ $(LDFLAGS_NODIST); ++ + # wasm32-emscripten browser build + # wasm assets directory is relative to current build dir, e.g. "./usr/local". + # --preload-file turns a relative asset path into an absolute path. +@@ -2025,6 +2034,7 @@ altbininstall: $(BUILDPYTHON) @FRAMEWORKPYTHONW@ + if test -f $(LDLIBRARY) && test "$(PYTHONFRAMEWORKDIR)" = "no-framework" ; then \ + if test -n "$(DLLLIBRARY)" ; then \ + $(INSTALL_SHARED) $(DLLLIBRARY) $(DESTDIR)$(BINDIR); \ ++ $(INSTALL_SHARED) $(ABI3DLLLIBRARY) $(DESTDIR)$(BINDIR); \ + else \ + $(INSTALL_SHARED) $(LDLIBRARY) $(DESTDIR)$(LIBDIR)/$(INSTSONAME); \ + if test $(LDLIBRARY) != $(INSTSONAME); then \ +@@ -2485,6 +2495,7 @@ libainstall: all scripts + if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \ + if test "$(SHLIB_SUFFIX)" = .dll -o "$(SHLIB_SUFFIX)" = .pyd; then \ + $(INSTALL_DATA) $(LDLIBRARY) $(DESTDIR)$(LIBDIR) ; \ ++ $(INSTALL_DATA) $(ABI3LDLIBRARY) $(DESTDIR)$(LIBDIR) ; \ + else \ + $(INSTALL_DATA) $(LIBRARY) $(DESTDIR)$(LIBPL)/$(LIBRARY) ; \ + fi; \ +@@ -2734,7 +2745,7 @@ clean: clean-retain-profile clean-bolt + + .PHONY: clobber + clobber: clean +- -rm -f $(BUILDPYTHON) $(LIBRARY) $(LDLIBRARY) $(DLLLIBRARY) \ ++ -rm -f $(BUILDPYTHON) $(LIBRARY) $(LDLIBRARY) $(DLLLIBRARY)$(ABI3LDLIBRARY) $(ABI3DLLLIBRARY) \ + tags TAGS \ + config.cache config.log pyconfig.h Modules/config.c + -rm -rf build platform +diff --git a/PC/python3dll.c b/PC/python3dll.c +index 505feef..ee9380c 100755 +--- a/PC/python3dll.c ++++ b/PC/python3dll.c +@@ -2,6 +2,7 @@ + + /* Generated by Tools/build/stable_abi.py */ + ++#ifdef _MSC_VER + #ifdef _M_IX86 + #define DECORATE "_" + #else +@@ -12,6 +13,13 @@ + __pragma(comment(linker, "/EXPORT:" DECORATE #name "=" PYTHON_DLL_NAME "." #name)) + #define EXPORT_DATA(name) \ + __pragma(comment(linker, "/EXPORT:" DECORATE #name "=" PYTHON_DLL_NAME "." #name ",DATA")) ++#else ++// XXX: Why do we need the .dll extension and no DECORATE compared to the MSVC case? ++#define EXPORT_FUNC(name) \ ++ asm(".section .drectve\n\t.ascii \" -export:" #name "=\\\"" PYTHON_DLL_NAME "." #name "\\\" \""); ++#define EXPORT_DATA(name) \ ++ asm(".section .drectve\n\t.ascii \" -export:" #name "=\\\"" PYTHON_DLL_NAME "." #name "\\\",DATA \""); ++#endif + + EXPORT_FUNC(_Py_BuildValue_SizeT) + EXPORT_FUNC(_Py_CheckRecursiveCall) diff --git a/mingw-w64-python3.12/0101-Port-GetPythonImport-to-mingw.patch b/mingw-w64-python3.12/0101-Port-GetPythonImport-to-mingw.patch new file mode 100644 index 0000000000..aa989308f7 --- /dev/null +++ b/mingw-w64-python3.12/0101-Port-GetPythonImport-to-mingw.patch @@ -0,0 +1,74 @@ +From a6e3077cf648f9085d1d00903b68a3870be291c2 Mon Sep 17 00:00:00 2001 +From: Christoph Reiter +Date: Sun, 27 Aug 2023 15:00:32 +0200 +Subject: [PATCH 101/N] Port GetPythonImport() to mingw + +This looks for DLL names in the import table but while with MSVC the DLL +is named python311.dll in our case it is named libpython3.11.dll. +Adjust the strings and lengths accordingly. +--- + Python/dynload_win.c | 24 +++++++++++++++++------- + 1 file changed, 17 insertions(+), 7 deletions(-) + +diff --git a/Python/dynload_win.c b/Python/dynload_win.c +index db79687..36d1c7a 100644 +--- a/Python/dynload_win.c ++++ b/Python/dynload_win.c +@@ -56,6 +56,16 @@ const char *_PyImport_DynLoadFiletab[] = { + #define DWORD_AT(mem) (*(DWORD *)(mem)) + #define WORD_AT(mem) (*(WORD *)(mem)) + ++#ifdef __MINGW32__ ++#define DLL_PREFIX "libpython" ++#define DLL_PREFIX_LEN 9 ++#define DLL_NAME_FORMAT "libpython%d.%d" ++#else ++#define DLL_PREFIX "python" ++#define DLL_PREFIX_LEN 6 ++#define DLL_NAME_FORMAT "python%d%d" ++#endif ++ + static char *GetPythonImport (HINSTANCE hModule) + { + unsigned char *dllbase, *import_data, *import_name; +@@ -122,15 +132,15 @@ static char *GetPythonImport (HINSTANCE hModule) + import_off); + while (DWORD_AT(import_data)) { + import_name = dllbase + DWORD_AT(import_data+12); +- if (strlen(import_name) >= 6 && +- !strncmp(import_name,"python",6)) { ++ if (strlen(import_name) >= DLL_PREFIX_LEN && ++ !strncmp(import_name, DLL_PREFIX, DLL_PREFIX_LEN)) { + char *pch; + + /* Don't claim that python3.dll is a Python DLL. */ + #ifdef _DEBUG +- if (strcmp(import_name, "python3_d.dll") == 0) { ++ if (strcmp(import_name, DLL_PREFIX "3_d.dll") == 0) { + #else +- if (strcmp(import_name, "python3.dll") == 0) { ++ if (strcmp(import_name, DLL_PREFIX "3.dll") == 0) { + #endif + import_data += 20; + continue; +@@ -138,7 +148,7 @@ static char *GetPythonImport (HINSTANCE hModule) + + /* Ensure python prefix is followed only + by numbers to the end of the basename */ +- pch = import_name + 6; ++ pch = import_name + DLL_PREFIX_LEN; + #ifdef _DEBUG + while (*pch && pch[0] != '_' && pch[1] != 'd' && pch[2] != '.') { + #else +@@ -329,9 +339,9 @@ dl_funcptr _PyImport_FindSharedFuncptrWindows(const char *prefix, + + PyOS_snprintf(buffer, sizeof(buffer), + #ifdef _DEBUG +- "python%d%d_d.dll", ++ DLL_NAME_FORMAT "_d.dll", + #else +- "python%d%d.dll", ++ DLL_NAME_FORMAT ".dll", + #endif + PY_MAJOR_VERSION,PY_MINOR_VERSION); + import_python = GetPythonImport(hDLL); diff --git a/mingw-w64-python3.12/0102-LoadLibraryExW-make-sure-to-only-use-backslashes-for.patch b/mingw-w64-python3.12/0102-LoadLibraryExW-make-sure-to-only-use-backslashes-for.patch new file mode 100644 index 0000000000..43eab176eb --- /dev/null +++ b/mingw-w64-python3.12/0102-LoadLibraryExW-make-sure-to-only-use-backslashes-for.patch @@ -0,0 +1,47 @@ +From 788013a59ef6ddfdcbef1d97917aa224281a0d98 Mon Sep 17 00:00:00 2001 +From: Christoph Reiter +Date: Sun, 27 Aug 2023 16:04:50 +0200 +Subject: [PATCH 102/N] LoadLibraryExW: make sure to only use backslashes for + paths + +It seems like in case the path passed to it is absolute, but contains +forward slashes then LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR does not work +and DLLs in the same directory as the extension are not considered. + +This occurs in our fork because in MSYS2-mode the extension loader will +normalize to forward slashes before. + +Normalize everything to backslashes again before passing it to LoadLibraryExW. + +Fixes #151 +--- + Python/dynload_win.c | 12 ++++++++++++ + 1 file changed, 12 insertions(+) + +diff --git a/Python/dynload_win.c b/Python/dynload_win.c +index 36d1c7a..caa4968 100644 +--- a/Python/dynload_win.c ++++ b/Python/dynload_win.c +@@ -252,10 +252,22 @@ dl_funcptr _PyImport_FindSharedFuncptrWindows(const char *prefix, + _Py_CheckPython3(); + #endif /* _MSC_VER */ + ++// So we can adjust the separators in the path below ++#define USE_UNICODE_WCHAR_CACHE 0 ++ + wchar_t *wpathname = PyUnicode_AsWideCharString(pathname, NULL); + if (wpathname == NULL) + return NULL; + ++ // LoadLibraryExW only considers paths using backslashes as "fully qualified", ++ // and for example LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR doesn't work with forward slashes. ++ // https://github.com/msys2-contrib/cpython-mingw/issues/151 ++ for (size_t i = 0; wpathname[i] != L'\0'; ++i) { ++ if (wpathname[i] == L'/') { ++ wpathname[i] = L'\\'; ++ } ++ } ++ + PyOS_snprintf(funcname, sizeof(funcname), "%.20s_%.200s", prefix, shortname); + + { diff --git a/mingw-w64-python3.12/0103-mingw_smoketests-add-a-test-to-check-if-sysconfig-re.patch b/mingw-w64-python3.12/0103-mingw_smoketests-add-a-test-to-check-if-sysconfig-re.patch new file mode 100644 index 0000000000..1b8b44ae80 --- /dev/null +++ b/mingw-w64-python3.12/0103-mingw_smoketests-add-a-test-to-check-if-sysconfig-re.patch @@ -0,0 +1,46 @@ +From 6a326b63d5894e4cb1bd0ac71bc4b83ffc1b04e3 Mon Sep 17 00:00:00 2001 +From: Naveen M K +Date: Wed, 8 Nov 2023 19:44:22 +0530 +Subject: [PATCH 103/N] mingw_smoketests: add a test to check if sysconfig + returns correct values for `LIBDIR` + +--- + mingw_smoketests.py | 18 ++++++++++++++++++ + 1 file changed, 18 insertions(+) + +diff --git a/mingw_smoketests.py b/mingw_smoketests.py +index ca1f652..4f81c68 100644 +--- a/mingw_smoketests.py ++++ b/mingw_smoketests.py +@@ -218,6 +218,9 @@ def test_platform_things(self): + import sysconfig + import platform + import importlib.machinery ++ import tempfile ++ import venv ++ import subprocess + self.assertEqual(sys.implementation.name, "cpython") + self.assertEqual(sys.platform, "win32") + self.assertTrue(sysconfig.get_platform().startswith("mingw")) +@@ -241,6 +244,21 @@ def test_platform_things(self): + self.assertEqual(platform.system(), "Windows") + self.assertTrue(isinstance(sys.api_version, int) and sys.api_version > 0) + ++ with tempfile.TemporaryDirectory() as tmp: ++ builder = venv.EnvBuilder() ++ builder.create(tmp) ++ # This will not work in in-tree build ++ if not sysconfig.is_python_build(): ++ op = subprocess.check_output( ++ [ ++ os.path.join(tmp, "bin", "python.exe"), ++ "-c", ++ "import sysconfig; print(sysconfig.get_config_var('LIBDIR'))" ++ ], ++ cwd=tmp, ++ ) ++ self.assertTrue(op.decode().strip().startswith(sys.base_prefix)) ++ + def test_sys_getpath(self): + # everything sourced from getpath.py + import sys diff --git a/mingw-w64-python3.12/0104-Add-missing-library-for-multiprocessing-module.patch b/mingw-w64-python3.12/0104-Add-missing-library-for-multiprocessing-module.patch new file mode 100644 index 0000000000..175aec6d0a --- /dev/null +++ b/mingw-w64-python3.12/0104-Add-missing-library-for-multiprocessing-module.patch @@ -0,0 +1,37 @@ +From bd51677657509f4a418b69e063486559290af8b5 Mon Sep 17 00:00:00 2001 +From: Naveen M K +Date: Mon, 1 Jan 2024 13:42:01 +0530 +Subject: [PATCH 104/N] Add missing library for multiprocessing module + +`ws2_32` is required when building that module +--- + configure.ac | 9 ++++++++- + 1 file changed, 8 insertions(+), 1 deletion(-) + +diff --git a/configure.ac b/configure.ac +index 5eff281..4a7b66c 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -4232,6 +4232,13 @@ AS_CASE([$MACHDEP], + [SOCKET_LIBS=""] + ) + ++dnl On MINGW, you need to link againt ws2_32 for _multiprocessing ++AS_CASE([$MACHDEP], ++ [win32], [MULTIPROCESSING_LIBS="-lws2_32"], ++ [MULTIPROCESSING_LIBS=""] ++) ++ ++ + dnl detect sqlite3 from Emscripten emport + PY_CHECK_EMSCRIPTEN_PORT([LIBSQLITE3], [-sUSE_SQLITE3]) + +@@ -7835,7 +7842,7 @@ PY_STDLIB_MOD_SIMPLE([_zoneinfo]) + dnl multiprocessing modules + PY_STDLIB_MOD([_multiprocessing], + [], [test "$ac_cv_func_sem_unlink" = "yes" -o "$MACHDEP" = "win32"], +- [-I\$(srcdir)/Modules/_multiprocessing]) ++ [-I\$(srcdir)/Modules/_multiprocessing], [$MULTIPROCESSING_LIBS]) + PY_STDLIB_MOD([_posixshmem], + [], [test "$have_posix_shmem" = "yes"], + [$POSIXSHMEM_CFLAGS], [$POSIXSHMEM_LIBS]) diff --git a/mingw-w64-python3.12/0105-selectmodule-add-support-for-MINGW.patch b/mingw-w64-python3.12/0105-selectmodule-add-support-for-MINGW.patch new file mode 100644 index 0000000000..442a7d3b36 --- /dev/null +++ b/mingw-w64-python3.12/0105-selectmodule-add-support-for-MINGW.patch @@ -0,0 +1,60 @@ +From 561fc7c0f4e80bfdca3badec47ff254cedb6f2be Mon Sep 17 00:00:00 2001 +From: Naveen M K +Date: Mon, 1 Jan 2024 14:14:45 +0530 +Subject: [PATCH 105/N] selectmodule: add support for MINGW + +--- + Modules/selectmodule.c | 6 +++--- + configure.ac | 7 ++++++- + 2 files changed, 9 insertions(+), 4 deletions(-) + +diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c +index b7c6b1b..de47121 100644 +--- a/Modules/selectmodule.c ++++ b/Modules/selectmodule.c +@@ -169,9 +169,9 @@ seq2set(PyObject *seq, fd_set *set, pylist fd2obj[FD_SETSIZE + 1]) + 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()"); +@@ -179,7 +179,7 @@ seq2set(PyObject *seq, fd_set *set, pylist fd2obj[FD_SETSIZE + 1]) + } + 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 --git a/configure.ac b/configure.ac +index 4a7b66c..57b2df1 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -4238,6 +4238,11 @@ AS_CASE([$MACHDEP], + [MULTIPROCESSING_LIBS=""] + ) + ++dnl On MINGW, you need to link againt ws2_32 for selectmodule ++AS_CASE([$MACHDEP], ++ [win32], [SELECTMODULE_LIBS="-lws2_32"], ++ [SELECTMODULE_LIBS=""] ++) + + dnl detect sqlite3 from Emscripten emport + PY_CHECK_EMSCRIPTEN_PORT([LIBSQLITE3], [-sUSE_SQLITE3]) +@@ -7832,7 +7837,7 @@ PY_STDLIB_MOD_SIMPLE([_opcode]) + PY_STDLIB_MOD_SIMPLE([_pickle]) + PY_STDLIB_MOD_SIMPLE([_queue]) + PY_STDLIB_MOD_SIMPLE([_random]) +-PY_STDLIB_MOD_SIMPLE([select]) ++PY_STDLIB_MOD_SIMPLE([select], [], [$SELECTMODULE_LIBS]) + PY_STDLIB_MOD_SIMPLE([_struct]) + PY_STDLIB_MOD_SIMPLE([_typing]) + PY_STDLIB_MOD_SIMPLE([_xxsubinterpreters]) diff --git a/mingw-w64-python3.12/0106-readline-disable-on-MINGW.patch b/mingw-w64-python3.12/0106-readline-disable-on-MINGW.patch new file mode 100644 index 0000000000..9e2cec7020 --- /dev/null +++ b/mingw-w64-python3.12/0106-readline-disable-on-MINGW.patch @@ -0,0 +1,21 @@ +From cc5ceaf8377bb0588a2f09029c147d25b9a3c43f Mon Sep 17 00:00:00 2001 +From: Naveen M K +Date: Mon, 1 Jan 2024 14:19:41 +0530 +Subject: [PATCH 106/N] readline: disable on MINGW + +--- + configure.ac | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/configure.ac b/configure.ac +index 57b2df1..aa52c11 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -7704,6 +7704,7 @@ AS_CASE([$ac_sys_system], + [VxWorks*], [PY_STDLIB_MOD_SET_NA([_scproxy], [_crypt], [termios], [grp])], + [Darwin], [PY_STDLIB_MOD_SET_NA([ossaudiodev], [spwd])], + [CYGWIN*], [PY_STDLIB_MOD_SET_NA([_scproxy], [nis])], ++ [MINGW*], [PY_STDLIB_MOD_SET_NA([readline])], + [QNX*], [PY_STDLIB_MOD_SET_NA([_scproxy], [nis])], + [FreeBSD*], [PY_STDLIB_MOD_SET_NA([_scproxy], [spwd])], + [Emscripten|WASI], [ diff --git a/mingw-w64-python3.12/0107-Add-libraries-to-fix-compile-of-ctypes-on-MINGW.patch b/mingw-w64-python3.12/0107-Add-libraries-to-fix-compile-of-ctypes-on-MINGW.patch new file mode 100644 index 0000000000..ec93df08f0 --- /dev/null +++ b/mingw-w64-python3.12/0107-Add-libraries-to-fix-compile-of-ctypes-on-MINGW.patch @@ -0,0 +1,44 @@ +From 3bb9185ebf5df474783e376c820b59cef15b4a23 Mon Sep 17 00:00:00 2001 +From: Naveen M K +Date: Mon, 1 Jan 2024 14:25:11 +0530 +Subject: [PATCH 107/N] Add libraries to fix compile of ctypes on MINGW + +--- + configure.ac | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +diff --git a/configure.ac b/configure.ac +index aa52c11..894a543 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -4244,6 +4244,12 @@ AS_CASE([$MACHDEP], + [SELECTMODULE_LIBS=""] + ) + ++dnl On MINGW, you need to link againt ole32, oleaut32 and uuid for ctypes ++AS_CASE([$MACHDEP], ++ [win32], [CTYPES_LIBS="-lole32 -loleaut32 -luuid"], ++ [CTYPES_LIBS=""] ++) ++ + dnl detect sqlite3 from Emscripten emport + PY_CHECK_EMSCRIPTEN_PORT([LIBSQLITE3], [-sUSE_SQLITE3]) + +@@ -7927,7 +7933,7 @@ PY_STDLIB_MOD([_crypt], + [$LIBCRYPT_CFLAGS], [$LIBCRYPT_LIBS]) + PY_STDLIB_MOD([_ctypes], + [], [test "$have_libffi" = yes], +- [$NO_STRICT_OVERFLOW_CFLAGS $LIBFFI_CFLAGS], [$LIBFFI_LIBS]) ++ [$NO_STRICT_OVERFLOW_CFLAGS $LIBFFI_CFLAGS], [$LIBFFI_LIBS $CTYPES_LIBS]) + PY_STDLIB_MOD([_curses], + [], [test "$have_curses" != "no"], + [$CURSES_CFLAGS], [$CURSES_LIBS] +@@ -7998,7 +8004,7 @@ PY_STDLIB_MOD([_xxtestfuzz], [test "$TEST_MODULES" = yes]) + PY_STDLIB_MOD([_testconsole], [test "$TEST_MODULES" = yes -a "$MACHDEP" = "win32"]) + PY_STDLIB_MOD([_ctypes_test], + [test "$TEST_MODULES" = yes], [test "$have_libffi" = yes -a "$have_dynamic_loading" = yes], +- [], [$LIBM]) ++ [], [$LIBM $CTYPES_LIBS]) + + dnl Limited API template modules. + dnl The limited C API is not compatible with the Py_TRACE_REFS macro. diff --git a/mingw-w64-python3.12/0108-Add-lpython-version-while-linking-stdlib.patch b/mingw-w64-python3.12/0108-Add-lpython-version-while-linking-stdlib.patch new file mode 100644 index 0000000000..fbf15c55c1 --- /dev/null +++ b/mingw-w64-python3.12/0108-Add-lpython-version-while-linking-stdlib.patch @@ -0,0 +1,41 @@ +From 9448873e84b2b24bf5e1b3ebe8266fcceb4d0177 Mon Sep 17 00:00:00 2001 +From: Naveen M K +Date: Mon, 1 Jan 2024 14:48:28 +0530 +Subject: [PATCH 108/N] Add `-lpython` while linking stdlib + +--- + Modules/makesetup | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +diff --git a/Modules/makesetup b/Modules/makesetup +index f000c9c..13e4149 100755 +--- a/Modules/makesetup ++++ b/Modules/makesetup +@@ -88,7 +88,7 @@ NL='\ + ' + + # Setup to link with extra libraries when making shared extensions. +-# Currently, only Cygwin needs this baggage. ++# Currently, only Cygwin and MINGW needs this baggage. + case `uname -s` in + CYGWIN*) if test $libdir = . + then +@@ -97,6 +97,9 @@ CYGWIN*) if test $libdir = . + ExtraLibDir='$(LIBPL)' + fi + ExtraLibs="-L$ExtraLibDir -lpython\$(LDVERSION)";; ++MINGW*) ++ ExtraLibs='$(BLDLIBRARY)' ++ ExtraLibDepends='$(LIBRARY_DEPS)';; + esac + + # Main loop +@@ -285,7 +288,7 @@ sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' | + BUILT_SHARED="$BUILT_SHARED $mod" + ;; + esac +- rule="$file: $objs" ++ rule="$file: $objs $ExtraLibDepends" + rule="$rule; \$(BLDSHARED) $objs $libs $ExtraLibs -o $file" + echo "$rule" >>$rulesf + done diff --git a/mingw-w64-python3.12/0109-Enable-_uuid-on-MINGW.patch b/mingw-w64-python3.12/0109-Enable-_uuid-on-MINGW.patch new file mode 100644 index 0000000000..718e51949d --- /dev/null +++ b/mingw-w64-python3.12/0109-Enable-_uuid-on-MINGW.patch @@ -0,0 +1,37 @@ +From 7df6f8165a141f4e87e4639e318b6b5563ce3c32 Mon Sep 17 00:00:00 2001 +From: Naveen M K +Date: Mon, 1 Jan 2024 15:04:43 +0530 +Subject: [PATCH 109/N] Enable `_uuid` on MINGW + +--- + configure.ac | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +diff --git a/configure.ac b/configure.ac +index 894a543..d840b0a 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -4250,6 +4250,12 @@ AS_CASE([$MACHDEP], + [CTYPES_LIBS=""] + ) + ++dnl On MINGW, you need to link againt rpcrt4 for _uuid ++AS_CASE([$MACHDEP], ++ [win32], [UUID_LIBS="-lrpcrt4"], ++ [UUID_LIBS=""] ++) ++ + dnl detect sqlite3 from Emscripten emport + PY_CHECK_EMSCRIPTEN_PORT([LIBSQLITE3], [-sUSE_SQLITE3]) + +@@ -7963,8 +7969,8 @@ PY_STDLIB_MOD([_tkinter], + [], [test "$have_tcltk" = "yes"], + [$TCLTK_CFLAGS], [$TCLTK_LIBS]) + PY_STDLIB_MOD([_uuid], +- [], [test "$have_uuid" = "yes"], +- [$LIBUUID_CFLAGS], [$LIBUUID_LIBS]) ++ [], [test "$have_uuid" = "yes" -o "$MACHDEP" = "win32"], ++ [$LIBUUID_CFLAGS], [$LIBUUID_LIBS $UUID_LIBS]) + + dnl compression libs + PY_STDLIB_MOD([zlib], [], [test "$have_zlib" = yes], diff --git a/mingw-w64-python3.12/0110-Enable-curses-library-on-MINGW.patch b/mingw-w64-python3.12/0110-Enable-curses-library-on-MINGW.patch new file mode 100644 index 0000000000..0eb378738e --- /dev/null +++ b/mingw-w64-python3.12/0110-Enable-curses-library-on-MINGW.patch @@ -0,0 +1,28 @@ +From 8530c9cb494caacdb9004fa213999419dfcd40de Mon Sep 17 00:00:00 2001 +From: Naveen M K +Date: Mon, 1 Jan 2024 16:43:41 +0530 +Subject: [PATCH 110/N] Enable curses library on MINGW + +--- + configure.ac | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/configure.ac b/configure.ac +index d840b0a..444773e 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -6817,6 +6817,14 @@ dnl have_panel=[no, panelw, panel] + have_curses=no + have_panel=no + ++case "$host_os" in ++ mingw*) ++ # On Mingw, include directory is different, so just assume ++ # it's there. ++ ac_cv_header_ncurses_h=yes ++ ;; ++esac ++ + AH_TEMPLATE([HAVE_NCURSESW], [Define to 1 if you have the `ncursesw' library.]) + AC_CHECK_HEADERS([curses.h ncurses.h]) + diff --git a/mingw-w64-python3.12/0111-mingw_smoketests-disable-distutils-related-tests.patch b/mingw-w64-python3.12/0111-mingw_smoketests-disable-distutils-related-tests.patch new file mode 100644 index 0000000000..882f7177e9 --- /dev/null +++ b/mingw-w64-python3.12/0111-mingw_smoketests-disable-distutils-related-tests.patch @@ -0,0 +1,56 @@ +From 9c61a4117b25364b378076bbac8c7e8674991ba3 Mon Sep 17 00:00:00 2001 +From: Naveen M K +Date: Fri, 2 Feb 2024 14:43:29 +0530 +Subject: [PATCH 111/N] mingw_smoketests: disable distutils related tests + +--- + mingw_smoketests.py | 36 ++++++++++++++++++------------------ + 1 file changed, 18 insertions(+), 18 deletions(-) + +diff --git a/mingw_smoketests.py b/mingw_smoketests.py +index 4f81c68..0ab5d3b 100644 +--- a/mingw_smoketests.py ++++ b/mingw_smoketests.py +@@ -61,24 +61,24 @@ def test_userdir_path_sep(self): + self.assertEqual(str(Path("~").expanduser()), expanduser("~")) + self.assertEqual(str(Path.home()), expanduser("~")) + +- def test_sysconfig_schemes(self): +- # https://github.com/msys2/MINGW-packages/issues/9319 +- import sysconfig +- from distutils.dist import Distribution +- from distutils.command.install import install +- +- names = ['scripts', 'purelib', 'platlib', 'data', 'include'] +- for scheme in ["nt", "nt_user"]: +- for name in names: +- c = install(Distribution({"name": "foobar"})) +- c.user = (scheme == "nt_user") +- c.finalize_options() +- if name == "include": +- dist_path = os.path.dirname(getattr(c, "install_" + "headers")) +- else: +- dist_path = getattr(c, "install_" + name) +- sys_path = sysconfig.get_path(name, scheme) +- self.assertEqual(dist_path, sys_path, (scheme, name)) ++ # def test_sysconfig_schemes(self): ++ # # https://github.com/msys2/MINGW-packages/issues/9319 ++ # import sysconfig ++ # from distutils.dist import Distribution ++ # from distutils.command.install import install ++ ++ # names = ['scripts', 'purelib', 'platlib', 'data', 'include'] ++ # for scheme in ["nt", "nt_user"]: ++ # for name in names: ++ # c = install(Distribution({"name": "foobar"})) ++ # c.user = (scheme == "nt_user") ++ # c.finalize_options() ++ # if name == "include": ++ # dist_path = os.path.dirname(getattr(c, "install_" + "headers")) ++ # else: ++ # dist_path = getattr(c, "install_" + name) ++ # sys_path = sysconfig.get_path(name, scheme) ++ # self.assertEqual(dist_path, sys_path, (scheme, name)) + + def test_ctypes_find_library(self): + from ctypes.util import find_library diff --git a/mingw-w64-python3.12/0112-mingw_smoketests-skip-test_c_ext_build-for-in-tree-b.patch b/mingw-w64-python3.12/0112-mingw_smoketests-skip-test_c_ext_build-for-in-tree-b.patch new file mode 100644 index 0000000000..7466d713a1 --- /dev/null +++ b/mingw-w64-python3.12/0112-mingw_smoketests-skip-test_c_ext_build-for-in-tree-b.patch @@ -0,0 +1,25 @@ +From 64f2dfd43a63b6f241a72a633aa1afafe7be45e6 Mon Sep 17 00:00:00 2001 +From: Naveen M K +Date: Mon, 19 Feb 2024 19:55:55 +0530 +Subject: [PATCH 112/N] mingw_smoketests: skip test_c_ext_build for in-tree + builds + +--- + mingw_smoketests.py | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/mingw_smoketests.py b/mingw_smoketests.py +index 0ab5d3b..dc31423 100644 +--- a/mingw_smoketests.py ++++ b/mingw_smoketests.py +@@ -283,6 +283,10 @@ def test_site(self): + self.assertEqual(len(site.getsitepackages()), 1) + + def test_c_ext_build(self): ++ # This will not work in in-tree build ++ if sysconfig.is_python_build(): ++ raise unittest.SkipTest("in-tree build") ++ + import tempfile + import sys + import subprocess diff --git a/mingw-w64-python3.12/0113-configure.ac-use-autoconf-2.69.patch b/mingw-w64-python3.12/0113-configure.ac-use-autoconf-2.69.patch new file mode 100644 index 0000000000..0a41c41ee6 --- /dev/null +++ b/mingw-w64-python3.12/0113-configure.ac-use-autoconf-2.69.patch @@ -0,0 +1,23 @@ +From ec4403d01449c3be7a8f41cb3f3c9ee4cee48eff Mon Sep 17 00:00:00 2001 +From: Naveen M K +Date: Mon, 19 Feb 2024 22:09:25 +0530 +Subject: [PATCH 113/N] configure.ac: use autoconf 2.69 + +llvm-mingw only has autoconf 2.69 +--- + configure.ac | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/configure.ac b/configure.ac +index 444773e..edebb03 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -12,7 +12,7 @@ dnl + # Set VERSION so we only need to edit in one place (i.e., here) + m4_define([PYTHON_VERSION], [3.12]) + +-AC_PREREQ([2.71]) ++AC_PREREQ([2.69]) + + AC_INIT([python],[PYTHON_VERSION],[https://github.com/python/cpython/issues/]) + diff --git a/mingw-w64-python3.12/0114-3.12-gh-114440-Close-writer-pipe-in-multiprocessing..patch b/mingw-w64-python3.12/0114-3.12-gh-114440-Close-writer-pipe-in-multiprocessing..patch new file mode 100644 index 0000000000..d72433baba --- /dev/null +++ b/mingw-w64-python3.12/0114-3.12-gh-114440-Close-writer-pipe-in-multiprocessing..patch @@ -0,0 +1,67 @@ +From 2ce1791f6bef296a36196ab70c6f7a31a3dc0286 Mon Sep 17 00:00:00 2001 +From: Petr Viktorin +Date: Wed, 24 Jan 2024 13:21:10 +0100 +Subject: [PATCH 114/N] [3.12] gh-114440: Close writer pipe in + multiprocessing.Queue, not concurrent.futures (GH-114489) + +This was left out of the 3.12 backport for three related issues: +- gh-107219 (which adds `self.call_queue._writer.close()` to `_ExecutorManagerThread` in `concurrent.futures`) +- gh-109370 (which changes this to be only called on Windows) +- gh-109047 (which moves the call to `multiprocessing.Queue`'s `_terminate_broken`) + +Without this change, ProcessPoolExecutor sometimes hangs on Windows +when a worker process is terminated. + +Co-authored-by: Victor Stinner +Co-authored-by: Serhiy Storchaka +--- + Lib/concurrent/futures/process.py | 5 ----- + Lib/multiprocessing/queues.py | 5 +++++ + .../Library/2023-09-25-02-11-14.gh-issue-114440.b2TrqG.rst | 6 ++++++ + 3 files changed, 11 insertions(+), 5 deletions(-) + create mode 100644 Misc/NEWS.d/next/Library/2023-09-25-02-11-14.gh-issue-114440.b2TrqG.rst + +diff --git a/Lib/concurrent/futures/process.py b/Lib/concurrent/futures/process.py +index 33e62fe..0e45288 100644 +--- a/Lib/concurrent/futures/process.py ++++ b/Lib/concurrent/futures/process.py +@@ -524,11 +524,6 @@ def _terminate_broken(self, cause): + + self.call_queue._terminate_broken() + +- # gh-107219: Close the connection writer which can unblock +- # Queue._feed() if it was stuck in send_bytes(). +- if sys.platform == 'win32': +- self.call_queue._writer.close() +- + # clean up resources + self._join_executor_internals(broken=True) + +diff --git a/Lib/multiprocessing/queues.py b/Lib/multiprocessing/queues.py +index d36de75..852ae87 100644 +--- a/Lib/multiprocessing/queues.py ++++ b/Lib/multiprocessing/queues.py +@@ -164,6 +164,11 @@ def _terminate_broken(self): + # gh-94777: Prevent queue writing to a pipe which is no longer read. + self._reader.close() + ++ # gh-107219: Close the connection writer which can unblock ++ # Queue._feed() if it was stuck in send_bytes(). ++ if sys.platform == 'win32': ++ self._writer.close() ++ + self.close() + self.join_thread() + +diff --git a/Misc/NEWS.d/next/Library/2023-09-25-02-11-14.gh-issue-114440.b2TrqG.rst b/Misc/NEWS.d/next/Library/2023-09-25-02-11-14.gh-issue-114440.b2TrqG.rst +new file mode 100644 +index 0000000..7231a3c +--- /dev/null ++++ b/Misc/NEWS.d/next/Library/2023-09-25-02-11-14.gh-issue-114440.b2TrqG.rst +@@ -0,0 +1,6 @@ ++On Windows, closing the connection writer when cleaning up a broken ++:class:`multiprocessing.Queue` queue is now done for all queues, rather than ++only in :mod:`concurrent.futures` manager thread. ++This can prevent a deadlock when a ``multiprocessing`` worker process terminates ++without cleaning up. ++This completes the backport of patches by Victor Stinner and Serhiy Storchaka. diff --git a/mingw-w64-python3.12/0115-3.12-gh-115133-Fix-tests-for-XMLPullParser-with-Expa.patch b/mingw-w64-python3.12/0115-3.12-gh-115133-Fix-tests-for-XMLPullParser-with-Expa.patch new file mode 100644 index 0000000000..c8995a8354 --- /dev/null +++ b/mingw-w64-python3.12/0115-3.12-gh-115133-Fix-tests-for-XMLPullParser-with-Expa.patch @@ -0,0 +1,109 @@ +From ad679e523044da983f8feeeb5de35472f48a1df9 Mon Sep 17 00:00:00 2001 +From: "Miss Islington (bot)" + <31488909+miss-islington@users.noreply.github.com> +Date: Sun, 11 Feb 2024 11:34:04 +0100 +Subject: [PATCH 115/N] [3.12] gh-115133: Fix tests for XMLPullParser with + Expat 2.6.0 (GH-115164) (GH-115288) + +Feeding the parser by too small chunks defers parsing to prevent +CVE-2023-52425. Future versions of Expat may be more reactive. +(cherry picked from commit 4a08e7b3431cd32a0daf22a33421cd3035343dc4) + +Co-authored-by: Serhiy Storchaka +--- + Lib/test/test_xml_etree.py | 58 ++++++++++++------- + ...-02-08-14-21-28.gh-issue-115133.ycl4ko.rst | 2 + + 2 files changed, 38 insertions(+), 22 deletions(-) + create mode 100644 Misc/NEWS.d/next/Library/2024-02-08-14-21-28.gh-issue-115133.ycl4ko.rst + +diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py +index 53a4e9f..1cf6ce8 100644 +--- a/Lib/test/test_xml_etree.py ++++ b/Lib/test/test_xml_etree.py +@@ -13,6 +13,7 @@ + import operator + import os + import pickle ++import pyexpat + import sys + import textwrap + import types +@@ -120,6 +121,10 @@ + + """ + ++fails_with_expat_2_6_0 = (unittest.expectedFailure ++ if pyexpat.version_info >= (2, 6, 0) else ++ lambda test: test) ++ + def checkwarnings(*filters, quiet=False): + def decorator(test): + def newtest(*args, **kwargs): +@@ -1398,28 +1403,37 @@ def assert_event_tags(self, parser, expected, max_events=None): + self.assertEqual([(action, elem.tag) for action, elem in events], + expected) + +- def test_simple_xml(self): +- for chunk_size in (None, 1, 5): +- with self.subTest(chunk_size=chunk_size): +- parser = ET.XMLPullParser() +- self.assert_event_tags(parser, []) +- self._feed(parser, "\n", chunk_size) +- self.assert_event_tags(parser, []) +- self._feed(parser, +- "\n text\n", chunk_size) +- self.assert_event_tags(parser, [('end', 'element')]) +- self._feed(parser, "texttail\n", chunk_size) +- self._feed(parser, "\n", chunk_size) +- self.assert_event_tags(parser, [ +- ('end', 'element'), +- ('end', 'empty-element'), +- ]) +- self._feed(parser, "\n", chunk_size) +- self.assert_event_tags(parser, [('end', 'root')]) +- self.assertIsNone(parser.close()) ++ def test_simple_xml(self, chunk_size=None): ++ parser = ET.XMLPullParser() ++ self.assert_event_tags(parser, []) ++ self._feed(parser, "\n", chunk_size) ++ self.assert_event_tags(parser, []) ++ self._feed(parser, ++ "\n text\n", chunk_size) ++ self.assert_event_tags(parser, [('end', 'element')]) ++ self._feed(parser, "texttail\n", chunk_size) ++ self._feed(parser, "\n", chunk_size) ++ self.assert_event_tags(parser, [ ++ ('end', 'element'), ++ ('end', 'empty-element'), ++ ]) ++ self._feed(parser, "\n", chunk_size) ++ self.assert_event_tags(parser, [('end', 'root')]) ++ self.assertIsNone(parser.close()) ++ ++ @fails_with_expat_2_6_0 ++ def test_simple_xml_chunk_1(self): ++ self.test_simple_xml(chunk_size=1) ++ ++ @fails_with_expat_2_6_0 ++ def test_simple_xml_chunk_5(self): ++ self.test_simple_xml(chunk_size=5) ++ ++ def test_simple_xml_chunk_22(self): ++ self.test_simple_xml(chunk_size=22) + + def test_feed_while_iterating(self): + parser = ET.XMLPullParser() +diff --git a/Misc/NEWS.d/next/Library/2024-02-08-14-21-28.gh-issue-115133.ycl4ko.rst b/Misc/NEWS.d/next/Library/2024-02-08-14-21-28.gh-issue-115133.ycl4ko.rst +new file mode 100644 +index 0000000..6f10152 +--- /dev/null ++++ b/Misc/NEWS.d/next/Library/2024-02-08-14-21-28.gh-issue-115133.ycl4ko.rst +@@ -0,0 +1,2 @@ ++Fix tests for :class:`~xml.etree.ElementTree.XMLPullParser` with Expat ++2.6.0. diff --git a/mingw-w64-python3.12/0116-CI-clean-up-ignored-tests.patch b/mingw-w64-python3.12/0116-CI-clean-up-ignored-tests.patch new file mode 100644 index 0000000000..daf38d40f8 --- /dev/null +++ b/mingw-w64-python3.12/0116-CI-clean-up-ignored-tests.patch @@ -0,0 +1,258 @@ +From 4d9ee66b36192b8ba489110f781e44428f0c9afd Mon Sep 17 00:00:00 2001 +From: Naveen M K +Date: Tue, 20 Feb 2024 11:04:39 +0530 +Subject: [PATCH 116/N] CI: clean up ignored tests + +Remove tests which are passing now, or no longer exist, and +move tests which only fail with msvcrt into a separate file. +--- + .github/workflows/mingw.yml | 12 ++- + Lib/test/test_wmi.py | 148 ++++++++++++++++++------------------ + mingw_ignorefile.txt | 23 +----- + mingw_ignorefile_msvcrt.txt | 8 ++ + 4 files changed, 94 insertions(+), 97 deletions(-) + create mode 100644 mingw_ignorefile_msvcrt.txt + +diff --git a/.github/workflows/mingw.yml b/.github/workflows/mingw.yml +index f0a0d92..c3001cd 100644 +--- a/.github/workflows/mingw.yml ++++ b/.github/workflows/mingw.yml +@@ -91,16 +91,24 @@ jobs: + shell: msys2 {0} + run: | + IGNOREFILE="$(pwd)/mingw_ignorefile.txt" ++ IGNOREFILE_EXTRA="$IGNOREFILE" ++ if [[ "${{ matrix.msystem }}" == "MINGW32" ]] || [[ "${{ matrix.msystem }}" == "MINGW64" ]]; then ++ IGNOREFILE_EXTRA="$(pwd)/mingw_ignorefile_msvcrt.txt" ++ fi + cd _build +- MSYSTEM= ./python.exe -m test -j8 --ignorefile "$IGNOREFILE" -W ++ MSYSTEM= ./python.exe -m test -j8 --ignorefile "$IGNOREFILE" --ignorefile "$IGNOREFILE_EXTRA" -W + + - name: Run broken tests + continue-on-error: true + shell: msys2 {0} + run: | + IGNOREFILE="$(pwd)/mingw_ignorefile.txt" ++ IGNOREFILE_EXTRA="$IGNOREFILE" ++ if [[ "${{ matrix.msystem }}" == "MINGW32" ]] || [[ "${{ matrix.msystem }}" == "MINGW64" ]]; then ++ IGNOREFILE_EXTRA="$(pwd)/mingw_ignorefile_msvcrt.txt" ++ fi + cd _build +- MSYSTEM= ./python.exe -m test -j8 --matchfile "$IGNOREFILE" -W ++ MSYSTEM= ./python.exe -m test -j8 --matchfile "$IGNOREFILE" --matchfile "$IGNOREFILE_EXTRA" -W + + - name: Install + shell: msys2 {0} +diff --git a/Lib/test/test_wmi.py b/Lib/test/test_wmi.py +index 3445702..542dbc1 100644 +--- a/Lib/test/test_wmi.py ++++ b/Lib/test/test_wmi.py +@@ -1,74 +1,74 @@ +-# Test the internal _wmi module on Windows +-# This is used by the platform module, and potentially others +- +-import unittest +-from test.support import import_helper, requires_resource +- +- +-# Do this first so test will be skipped if module doesn't exist +-_wmi = import_helper.import_module('_wmi', required_on=['win']) +- +- +-class WmiTests(unittest.TestCase): +- def test_wmi_query_os_version(self): +- r = _wmi.exec_query("SELECT Version FROM Win32_OperatingSystem").split("\0") +- self.assertEqual(1, len(r)) +- k, eq, v = r[0].partition("=") +- self.assertEqual("=", eq, r[0]) +- self.assertEqual("Version", k, r[0]) +- # Best we can check for the version is that it's digits, dot, digits, anything +- # Otherwise, we are likely checking the result of the query against itself +- self.assertRegex(v, r"\d+\.\d+.+$", r[0]) +- +- def test_wmi_query_repeated(self): +- # Repeated queries should not break +- for _ in range(10): +- self.test_wmi_query_os_version() +- +- def test_wmi_query_error(self): +- # Invalid queries fail with OSError +- try: +- _wmi.exec_query("SELECT InvalidColumnName FROM InvalidTableName") +- except OSError as ex: +- if ex.winerror & 0xFFFFFFFF == 0x80041010: +- # This is the expected error code. All others should fail the test +- return +- self.fail("Expected OSError") +- +- def test_wmi_query_repeated_error(self): +- for _ in range(10): +- self.test_wmi_query_error() +- +- def test_wmi_query_not_select(self): +- # Queries other than SELECT are blocked to avoid potential exploits +- with self.assertRaises(ValueError): +- _wmi.exec_query("not select, just in case someone tries something") +- +- @requires_resource('cpu') +- def test_wmi_query_overflow(self): +- # Ensure very big queries fail +- # Test multiple times to ensure consistency +- for _ in range(2): +- with self.assertRaises(OSError): +- _wmi.exec_query("SELECT * FROM CIM_DataFile") +- +- def test_wmi_query_multiple_rows(self): +- # Multiple instances should have an extra null separator +- r = _wmi.exec_query("SELECT ProcessId FROM Win32_Process WHERE ProcessId < 1000") +- self.assertFalse(r.startswith("\0"), r) +- self.assertFalse(r.endswith("\0"), r) +- it = iter(r.split("\0")) +- try: +- while True: +- self.assertRegex(next(it), r"ProcessId=\d+") +- self.assertEqual("", next(it)) +- except StopIteration: +- pass +- +- def test_wmi_query_threads(self): +- from concurrent.futures import ThreadPoolExecutor +- query = "SELECT ProcessId FROM Win32_Process WHERE ProcessId < 1000" +- with ThreadPoolExecutor(4) as pool: +- task = [pool.submit(_wmi.exec_query, query) for _ in range(32)] +- for t in task: +- self.assertRegex(t.result(), "ProcessId=") ++# Test the internal _wmi module on Windows ++# This is used by the platform module, and potentially others ++ ++import unittest ++from test.support import import_helper, requires_resource ++ ++ ++# Do this first so test will be skipped if module doesn't exist ++_wmi = import_helper.import_module('_wmi') ++ ++ ++class WmiTests(unittest.TestCase): ++ def test_wmi_query_os_version(self): ++ r = _wmi.exec_query("SELECT Version FROM Win32_OperatingSystem").split("\0") ++ self.assertEqual(1, len(r)) ++ k, eq, v = r[0].partition("=") ++ self.assertEqual("=", eq, r[0]) ++ self.assertEqual("Version", k, r[0]) ++ # Best we can check for the version is that it's digits, dot, digits, anything ++ # Otherwise, we are likely checking the result of the query against itself ++ self.assertRegex(v, r"\d+\.\d+.+$", r[0]) ++ ++ def test_wmi_query_repeated(self): ++ # Repeated queries should not break ++ for _ in range(10): ++ self.test_wmi_query_os_version() ++ ++ def test_wmi_query_error(self): ++ # Invalid queries fail with OSError ++ try: ++ _wmi.exec_query("SELECT InvalidColumnName FROM InvalidTableName") ++ except OSError as ex: ++ if ex.winerror & 0xFFFFFFFF == 0x80041010: ++ # This is the expected error code. All others should fail the test ++ return ++ self.fail("Expected OSError") ++ ++ def test_wmi_query_repeated_error(self): ++ for _ in range(10): ++ self.test_wmi_query_error() ++ ++ def test_wmi_query_not_select(self): ++ # Queries other than SELECT are blocked to avoid potential exploits ++ with self.assertRaises(ValueError): ++ _wmi.exec_query("not select, just in case someone tries something") ++ ++ @requires_resource('cpu') ++ def test_wmi_query_overflow(self): ++ # Ensure very big queries fail ++ # Test multiple times to ensure consistency ++ for _ in range(2): ++ with self.assertRaises(OSError): ++ _wmi.exec_query("SELECT * FROM CIM_DataFile") ++ ++ def test_wmi_query_multiple_rows(self): ++ # Multiple instances should have an extra null separator ++ r = _wmi.exec_query("SELECT ProcessId FROM Win32_Process WHERE ProcessId < 1000") ++ self.assertFalse(r.startswith("\0"), r) ++ self.assertFalse(r.endswith("\0"), r) ++ it = iter(r.split("\0")) ++ try: ++ while True: ++ self.assertRegex(next(it), r"ProcessId=\d+") ++ self.assertEqual("", next(it)) ++ except StopIteration: ++ pass ++ ++ def test_wmi_query_threads(self): ++ from concurrent.futures import ThreadPoolExecutor ++ query = "SELECT ProcessId FROM Win32_Process WHERE ProcessId < 1000" ++ with ThreadPoolExecutor(4) as pool: ++ task = [pool.submit(_wmi.exec_query, query) for _ in range(32)] ++ for t in task: ++ self.assertRegex(t.result(), "ProcessId=") +diff --git a/mingw_ignorefile.txt b/mingw_ignorefile.txt +index e692d7f..ec94c35 100644 +--- a/mingw_ignorefile.txt ++++ b/mingw_ignorefile.txt +@@ -2,16 +2,11 @@ test.test_ctypes.test_loading.LoaderTest.test_load_dll_with_flags + distutils.tests.test_bdist_dumb.BuildDumbTestCase.test_simple_built + distutils.tests.test_cygwinccompiler.CygwinCCompilerTestCase.test_get_versions + distutils.tests.test_util.UtilTestCase.test_change_root +-test.datetimetester.TestLocalTimeDisambiguation_Fast.* +-test.datetimetester.TestLocalTimeDisambiguation_Pure.* +-test.test_cmath.CMathTests.test_specific_values +-test.test_cmd_line_script.CmdLineTest.test_consistent_sys_path_for_direct_execution + test.test_compileall.CommandLineTestsNoSourceEpoch.* + test.test_compileall.CommandLineTestsWithSourceEpoch.* + test.test_compileall.CompileallTestsWithoutSourceEpoch.* + test.test_compileall.CompileallTestsWithSourceEpoch.* + test.test_import.ImportTests.test_dll_dependency_import +-test.test_math.MathTests.* + test.test_ntpath.NtCommonTest.test_import + test.test_os.StatAttributeTests.test_stat_block_device + test.test_os.TestScandir.test_attributes +@@ -23,21 +18,7 @@ test.test_site._pthFileTests.* + test.test_site.HelperFunctionsTests.* + test.test_site.StartupImportTests.* + test.test_ssl.* +-test.test_strptime.CalculationTests.* +-test.test_strptime.StrptimeTests.test_weekday +-test.test_strptime.TimeRETests.test_compile +-test.test_tools.test_i18n.Test_pygettext.test_POT_Creation_Date + test.test_venv.BasicTest.* + test.test_venv.EnsurePipTest.* +-test.test_sysconfig.TestSysConfig.test_user_similar +-test.test_tcl.TclTest.testLoadWithUNC +-test.test_wmi +-# flaky +-test.test__xxsubinterpreters.* +-test.test_asyncio.test_subprocess.SubprocessProactorTests.test_stdin_broken_pipe +-test.test_asynchat.TestAsynchat.test_line_terminator2 +-test.test_asyncgen.AsyncGenAsyncioTest.test_async_gen_asyncio_gc_aclose_09 +-test.test_concurrent_futures.ThreadPoolShutdownTest.test_interpreter_shutdown +-test.test_asynchat.TestNotConnected.test_disallow_negative_terminator +-test.test_logging.SysLogHandlerTest.* +-test.test_logging.IPv6SysLogHandlerTest.* ++ ++test.test_dict.DictTest.test_splittable_to_generic_combinedtable +diff --git a/mingw_ignorefile_msvcrt.txt b/mingw_ignorefile_msvcrt.txt +new file mode 100644 +index 0000000..be363bd +--- /dev/null ++++ b/mingw_ignorefile_msvcrt.txt +@@ -0,0 +1,8 @@ ++test.datetimetester.TestLocalTimeDisambiguation_Fast.* ++test.datetimetester.TestLocalTimeDisambiguation_Pure.* ++test.test_cmath.CMathTests.test_specific_values ++test.test_math.MathTests.* ++test.test_strptime.CalculationTests.* ++test.test_strptime.StrptimeTests.test_weekday ++test.test_strptime.TimeRETests.test_compile ++test.test_tools.test_i18n.Test_pygettext.test_POT_Creation_Date diff --git a/mingw-w64-python3.12/0117-gcc-make-incompatible-pointer-types-as-warning.patch b/mingw-w64-python3.12/0117-gcc-make-incompatible-pointer-types-as-warning.patch new file mode 100644 index 0000000000..e8b68bb5a9 --- /dev/null +++ b/mingw-w64-python3.12/0117-gcc-make-incompatible-pointer-types-as-warning.patch @@ -0,0 +1,48 @@ +From 1e278fca29ca3bbae3f28dc359e9eb4b710b763d Mon Sep 17 00:00:00 2001 +From: Naveen M K +Date: Thu, 11 Jul 2024 13:58:20 +0530 +Subject: [PATCH 117/N] gcc: make `incompatible-pointer-types` as warning + +gcc 14 changed `incompatible-pointer-types` from warning to error +for now, make it as warning to avoid build failure +--- + Makefile.pre.in | 4 ++-- + configure.ac | 8 ++++++++ + 2 files changed, 10 insertions(+), 2 deletions(-) + +diff --git a/Makefile.pre.in b/Makefile.pre.in +index 9717caf..ac6388d 100644 +--- a/Makefile.pre.in ++++ b/Makefile.pre.in +@@ -823,10 +823,10 @@ $(BUILDPYTHON): Programs/python.o $(LINK_PYTHON_DEPS) python_exe.o + $(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -municode -o $@ Programs/python.o $(LINK_PYTHON_OBJS) $(LIBS) $(MODLIBS) $(SYSLIBS) python_exe.o + + $(BUILDVENVLAUNCHER): $(BUILDPYTHON) venvlauncher.o $(srcdir)/PC/launcher.c +- $(LINKCC) -D_CONSOLE -DVENV_REDIRECT -DPYTHON_EXECUTABLE_WITH_VERSION="L\"python$(LDVERSION)$(EXE)\"" -municode -static -static-libgcc -static-libstdc++ venvlauncher.o $(srcdir)/PC/launcher.c -o $@ -lversion ++ $(LINKCC) -D_CONSOLE -DVENV_REDIRECT -DPYTHON_EXECUTABLE_WITH_VERSION="L\"python$(LDVERSION)$(EXE)\"" -Wno-error=incompatible-pointer-types -municode -static -static-libgcc -static-libstdc++ venvlauncher.o $(srcdir)/PC/launcher.c -o $@ -lversion + + $(BUILDVENVWLAUNCHER): $(BUILDPYTHONW) venvwlauncher.o $(srcdir)/PC/launcher.c +- $(LINKCC) -D_WINDOWS -DVENV_REDIRECT -DPYTHON_EXECUTABLE_WITH_VERSION="L\"pythonw$(LDVERSION)$(EXE)\"" -mwindows -municode -static -static-libgcc -static-libstdc++ venvwlauncher.o $(srcdir)/PC/launcher.c -o $@ -lversion ++ $(LINKCC) -D_WINDOWS -DVENV_REDIRECT -DPYTHON_EXECUTABLE_WITH_VERSION="L\"pythonw$(LDVERSION)$(EXE)\"" -Wno-error=incompatible-pointer-types -mwindows -municode -static -static-libgcc -static-libstdc++ venvwlauncher.o $(srcdir)/PC/launcher.c -o $@ -lversion + + platform: $(PYTHON_FOR_BUILD_DEPS) 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 +diff --git a/configure.ac b/configure.ac +index edebb03..c663c7c 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -2496,6 +2496,14 @@ case $GCC in + yes) + CFLAGS_NODIST="$CFLAGS_NODIST -std=c11" + ++ # GCC 14 and later error out with incompatible-pointer-types ++ # this only occues on mingw ++ case $host in ++ *-*-mingw*) ++ CFLAGS_NODIST="$CFLAGS_NODIST -Wno-error=incompatible-pointer-types" ++ ;; ++ esac ++ + PY_CHECK_CC_WARNING([enable], [extra], [if we can add -Wextra]) + AS_VAR_IF([ac_cv_enable_extra_warning], [yes], + [CFLAGS_NODIST="$CFLAGS_NODIST -Wextra"]) diff --git a/mingw-w64-python3.12/PKGBUILD b/mingw-w64-python3.12/PKGBUILD new file mode 100644 index 0000000000..165a809002 --- /dev/null +++ b/mingw-w64-python3.12/PKGBUILD @@ -0,0 +1,522 @@ +# Maintainer: Alexey Pavlov +# Maintainer: Ray Donnelly +# Maintainer: Naveen M K +# Contributor: Saul Ibarra Corretge +# Contributor: Frode Solheim + +_primary_python="no" +_pybasever=3.12 +_realname=python + +if [[ "${_primary_python}" == "yes" ]]; then + pkgbase="mingw-w64-${_realname}" + pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}") + provides=("${MINGW_PACKAGE_PREFIX}-python3" + "${MINGW_PACKAGE_PREFIX}-python${_pybasever}") + conflicts=("${MINGW_PACKAGE_PREFIX}-python3" + "${MINGW_PACKAGE_PREFIX}-python${_pybasever}" + "${MINGW_PACKAGE_PREFIX}-python2<2.7.16-7") + replaces=("${MINGW_PACKAGE_PREFIX}-python3" + "${MINGW_PACKAGE_PREFIX}-python${_pybasever}") +else + pkgbase="mingw-w64-${_realname}${_pybasever}" + pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}${_pybasever}") +fi +pkgver=${_pybasever}.1 +pkgrel=2 +pkgdesc="A high-level scripting language (mingw-w64)" +arch=('any') +mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64') +license=('spdx:PSF-2.0') +url="https://www.python.org/" +msys2_references=( + "cpe: cpe:/a:python:python" + "cpe: cpe:/a:python_software_foundation:python" +) +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" + "${MINGW_PACKAGE_PREFIX}-tzdata") +makedepends=( + "${MINGW_PACKAGE_PREFIX}-cc" + "${MINGW_PACKAGE_PREFIX}-autotools" + "autoconf-archive" +) +#options=('debug' '!strip') +source=("https://www.python.org/ftp/python/${pkgver%rc?}/Python-${pkgver}.tar.xz" + 0001-sysconfig-make-_sysconfigdata.py-relocatable.patch + 0002-build-add-with-nt-threads-and-make-it-default-on-min.patch + 0003-Define-MS_WINDOWS-and-others-when-compiling-with-MIN.patch + 0004-configure-add-MACHDEP-and-platform-on-MINGW.patch + 0005-Add-default-configuration-for-MINGW.patch + 0006-configure-enable-largefile-support-by-default-for-Mi.patch + 0007-Add-PC-to-CPPFLAGS-and-to-SRCDIRS-on-Mingw.patch + 0008-posixmodule.c-Define-necessary-headers-for-compiling.patch + 0009-Build-winreg-by-default-when-compiling-for-MINGW.patch + 0010-pyport.h-Add-support-for-MINGW.patch + 0011-configure-add-options-so-that-shared-build-is-possib.patch + 0012-Add-dynamic-loading-support-for-MINGW.patch + 0013-Ignore-main-program-for-frozen-scripts-on-MINGW.patch + 0014-Detect-winsock2-and-setup-_socket-module-on-MINGW.patch + 0015-Enable-some-windows-specific-modules.patch + 0016-sysconfig-MINGW-build-extensions-with-GCC.patch + 0017-sysconfig-treat-MINGW-builds-as-POSIX-builds.patch + 0018-Add-support-for-stdcall-without-underscore.patch + 0019-Customize-site-for-MINGW.patch + 0020-add-python-config-sh.patch + 0021-mingw-prefer-unix-sep-if-MSYSTEM-environment-variabl.patch + 0022-msys-cygwin-semi-native-build-sysconfig.patch + 0023-sysconfig-mingw-sysconfig-like-posix.patch + 0024-mingw-use-backslashes-in-compileall-py.patch + 0025-mingw-pdcurses_ISPAD.patch + 0026-remove_path_max.default.patch + 0027-dont-link-with-gettext.patch + 0028-ctypes-python-dll.patch + 0029-gdbm-module-includes.patch + 0030-use-gnu_printf-in-format.patch + 0031-mingw-fix-ssl-dont-use-enum_certificates.patch + 0032-fix-using-dllhandle-and-winver-mingw.patch + 0033-Add-AMD64-to-sys-config-so-msvccompiler-get_build_ve.patch + 0034-MINGW-link-with-additional-library.patch + 0035-install-msilib.patch + 0036-fix-signal-module-build.patch + 0037-build-build-winconsoleio-and-_testconsole.patch + 0038-expose-sem_unlink.patch + 0039-Use-cygpty-while-using-isatty.patch + 0040-build-link-win-resource-files-and-build-pythonw.patch + 0041-fix-isselectable.patch + 0042-configure.ac-fix-inet_pton-check.patch + 0043-pass-gen-profile-ldflags.patch + 0044-pkg-config-windows-must-link-ext-with-python-lib.patch + 0045-importlib-bootstrap-path-sep.patch + 0046-warnings-fixes.patch + 0047-fix-build-testinternalcapi.patch + 0048-clang-arm64.patch + 0049-configure.ac-set-MINGW-stack-reserve.patch + 0050-Don-t-use-os.pathsep-to-find-EOF.patch + 0051-Fix-extension-suffix-for-c-extensions-on-mingw.patch + 0052-Change-the-get_platform-method-in-sysconfig.patch + 0053-build-Fix-ncursesw-include-lookup.patch + 0054-tests-fix-test_bytes.patch + 0055-time-fix-strftime-not-raising-for-invalid-year-value.patch + 0056-ctypes-find_library-c-should-return-None-with-ucrt.patch + 0057-build-Disable-checks-for-dlopen-dlfcn.patch + 0058-Fix-install-location-of-the-import-library.patch + 0059-build-Integrate-venvlauncher-build-installation-into.patch + 0060-configure.ac-set-_WIN32_WINNT-version.patch + 0061-configure.ac-don-t-check-for-clock_-functions.patch + 0062-expanduser-normpath-paths-coming-from-env-vars.patch + 0063-CI-test-the-build-and-add-some-mingw-specific-tests.patch + 0064-Define-PY3_DLLNAME-to-fix-build.patch + 0065-_testconsole.c-Fix-casing-path-sep.patch + 0066-Return-consistent-architecture-markers-for-python-on.patch + 0067-handle-ncursesw-pkg-config-when-cross-compiling.patch + 0068-mingw_smoketests-fix-_UCRT-condition.patch + 0069-Modify-sys.winver-to-match-upstream.patch + 0070-Change-user-site-packages-path-to-include-the-enviro.patch + 0071-configure-Include-a-header-in-the-check-for-_beginth.patch + 0072-configure.ac-Default-to-without-c-locale-coercion-on.patch + 0073-Fix-failing-tests.patch + 0074-Don-t-change-os.sep-with-an-empty-MSYSTEM-env-var-no.patch + 0075-def-VPATH-when-compiling-Python-sysmodule.c.patch + 0076-Make-_Py_CheckPython3-extern.patch + 0077-link-with-bcrypt.patch + 0078-correctly-find-native-python.patch + 0079-Add-extra-flags-for-_bootstrap_python.patch + 0080-posixmodule-undefine-HAVE_OPENDIR.patch + 0081-getpath.py-add-support-for-mingw.patch + 0082-Don-t-build-_posixsubprocess-on-Windows.patch + 0083-_ssl-link-with-ws2_32.patch + 0084-Always-normalize-path-in-abspath.patch + 0085-Include-winsock.h-when-checking-for-netdb-function.patch + 0086-include-_multiprocessing-semaphore.c-on-win32.patch + 0087-configure-build-mmap-module-on-win32.patch + 0088-venv-creation-fixes.patch + 0089-move-the-shutdown-function-where-winsock.h-is-includ.patch + 0090-configure.ac-set-BUILDEXEEXT-and-EXEEXT.patch + 0091-configure.ac-fix-building-some-test-modules.patch + 0092-Don-t-convert-sysconfig.get_config_var-VPATH-to-an-a.patch + 0093-Always-convert-to-before-passing-though-pathcch-func.patch + 0094-Build-venvlauncher.exe-from-PC-launcher.c.patch + 0095-getpath.py-fix-dirname.patch + 0096-getpath-use-normpath-on-all-generated-paths.patch + 0097-pathconfig-normpath-sys.path-0.patch + 0098-smoketests-add-some-tests-for-sys-site-paths.patch + 0099-Search-DLLs-only-on-paths-added-using-add_dll_direct.patch + 0100-Build-and-install-libpython3.dll.patch + 0101-Port-GetPythonImport-to-mingw.patch + 0102-LoadLibraryExW-make-sure-to-only-use-backslashes-for.patch + 0103-mingw_smoketests-add-a-test-to-check-if-sysconfig-re.patch + 0104-Add-missing-library-for-multiprocessing-module.patch + 0105-selectmodule-add-support-for-MINGW.patch + 0106-readline-disable-on-MINGW.patch + 0107-Add-libraries-to-fix-compile-of-ctypes-on-MINGW.patch + 0108-Add-lpython-version-while-linking-stdlib.patch + 0109-Enable-_uuid-on-MINGW.patch + 0110-Enable-curses-library-on-MINGW.patch + 0111-mingw_smoketests-disable-distutils-related-tests.patch + 0112-mingw_smoketests-skip-test_c_ext_build-for-in-tree-b.patch + 0113-configure.ac-use-autoconf-2.69.patch + 0114-3.12-gh-114440-Close-writer-pipe-in-multiprocessing..patch + 0115-3.12-gh-115133-Fix-tests-for-XMLPullParser-with-Expa.patch + 0116-CI-clean-up-ignored-tests.patch + 0117-gcc-make-incompatible-pointer-types-as-warning.patch) + +# Helper macros to help make tasks easier # +apply_patch_with_msg() { + for _patch in "$@" + do + msg2 "Applying ${_patch}" + patch -Nbp1 -i "${srcdir}/${_patch}" + done +} + +prepare() { + cd "${srcdir}/Python-${pkgver}" + + apply_patch_with_msg 0001-sysconfig-make-_sysconfigdata.py-relocatable.patch \ + 0002-build-add-with-nt-threads-and-make-it-default-on-min.patch \ + 0003-Define-MS_WINDOWS-and-others-when-compiling-with-MIN.patch \ + 0004-configure-add-MACHDEP-and-platform-on-MINGW.patch \ + 0005-Add-default-configuration-for-MINGW.patch \ + 0006-configure-enable-largefile-support-by-default-for-Mi.patch \ + 0007-Add-PC-to-CPPFLAGS-and-to-SRCDIRS-on-Mingw.patch \ + 0008-posixmodule.c-Define-necessary-headers-for-compiling.patch \ + 0009-Build-winreg-by-default-when-compiling-for-MINGW.patch \ + 0010-pyport.h-Add-support-for-MINGW.patch \ + 0011-configure-add-options-so-that-shared-build-is-possib.patch \ + 0012-Add-dynamic-loading-support-for-MINGW.patch \ + 0013-Ignore-main-program-for-frozen-scripts-on-MINGW.patch \ + 0014-Detect-winsock2-and-setup-_socket-module-on-MINGW.patch \ + 0015-Enable-some-windows-specific-modules.patch \ + 0016-sysconfig-MINGW-build-extensions-with-GCC.patch \ + 0017-sysconfig-treat-MINGW-builds-as-POSIX-builds.patch \ + 0018-Add-support-for-stdcall-without-underscore.patch \ + 0019-Customize-site-for-MINGW.patch \ + 0020-add-python-config-sh.patch \ + 0021-mingw-prefer-unix-sep-if-MSYSTEM-environment-variabl.patch \ + 0022-msys-cygwin-semi-native-build-sysconfig.patch \ + 0023-sysconfig-mingw-sysconfig-like-posix.patch \ + 0024-mingw-use-backslashes-in-compileall-py.patch \ + 0025-mingw-pdcurses_ISPAD.patch \ + 0026-remove_path_max.default.patch \ + 0027-dont-link-with-gettext.patch \ + 0028-ctypes-python-dll.patch \ + 0029-gdbm-module-includes.patch \ + 0030-use-gnu_printf-in-format.patch \ + 0031-mingw-fix-ssl-dont-use-enum_certificates.patch \ + 0032-fix-using-dllhandle-and-winver-mingw.patch \ + 0033-Add-AMD64-to-sys-config-so-msvccompiler-get_build_ve.patch \ + 0034-MINGW-link-with-additional-library.patch \ + 0035-install-msilib.patch \ + 0036-fix-signal-module-build.patch \ + 0037-build-build-winconsoleio-and-_testconsole.patch \ + 0038-expose-sem_unlink.patch \ + 0039-Use-cygpty-while-using-isatty.patch \ + 0040-build-link-win-resource-files-and-build-pythonw.patch \ + 0041-fix-isselectable.patch \ + 0042-configure.ac-fix-inet_pton-check.patch \ + 0043-pass-gen-profile-ldflags.patch \ + 0044-pkg-config-windows-must-link-ext-with-python-lib.patch \ + 0045-importlib-bootstrap-path-sep.patch \ + 0046-warnings-fixes.patch \ + 0047-fix-build-testinternalcapi.patch \ + 0048-clang-arm64.patch \ + 0049-configure.ac-set-MINGW-stack-reserve.patch \ + 0050-Don-t-use-os.pathsep-to-find-EOF.patch \ + 0051-Fix-extension-suffix-for-c-extensions-on-mingw.patch \ + 0052-Change-the-get_platform-method-in-sysconfig.patch \ + 0053-build-Fix-ncursesw-include-lookup.patch \ + 0054-tests-fix-test_bytes.patch \ + 0055-time-fix-strftime-not-raising-for-invalid-year-value.patch \ + 0056-ctypes-find_library-c-should-return-None-with-ucrt.patch \ + 0057-build-Disable-checks-for-dlopen-dlfcn.patch \ + 0058-Fix-install-location-of-the-import-library.patch \ + 0059-build-Integrate-venvlauncher-build-installation-into.patch \ + 0060-configure.ac-set-_WIN32_WINNT-version.patch \ + 0061-configure.ac-don-t-check-for-clock_-functions.patch \ + 0062-expanduser-normpath-paths-coming-from-env-vars.patch \ + 0063-CI-test-the-build-and-add-some-mingw-specific-tests.patch \ + 0064-Define-PY3_DLLNAME-to-fix-build.patch \ + 0065-_testconsole.c-Fix-casing-path-sep.patch \ + 0066-Return-consistent-architecture-markers-for-python-on.patch \ + 0067-handle-ncursesw-pkg-config-when-cross-compiling.patch \ + 0068-mingw_smoketests-fix-_UCRT-condition.patch \ + 0069-Modify-sys.winver-to-match-upstream.patch \ + 0070-Change-user-site-packages-path-to-include-the-enviro.patch \ + 0071-configure-Include-a-header-in-the-check-for-_beginth.patch \ + 0072-configure.ac-Default-to-without-c-locale-coercion-on.patch \ + 0073-Fix-failing-tests.patch \ + 0074-Don-t-change-os.sep-with-an-empty-MSYSTEM-env-var-no.patch \ + 0075-def-VPATH-when-compiling-Python-sysmodule.c.patch \ + 0076-Make-_Py_CheckPython3-extern.patch \ + 0077-link-with-bcrypt.patch \ + 0078-correctly-find-native-python.patch \ + 0079-Add-extra-flags-for-_bootstrap_python.patch \ + 0080-posixmodule-undefine-HAVE_OPENDIR.patch \ + 0081-getpath.py-add-support-for-mingw.patch \ + 0082-Don-t-build-_posixsubprocess-on-Windows.patch \ + 0083-_ssl-link-with-ws2_32.patch \ + 0084-Always-normalize-path-in-abspath.patch \ + 0085-Include-winsock.h-when-checking-for-netdb-function.patch \ + 0086-include-_multiprocessing-semaphore.c-on-win32.patch \ + 0087-configure-build-mmap-module-on-win32.patch \ + 0088-venv-creation-fixes.patch \ + 0089-move-the-shutdown-function-where-winsock.h-is-includ.patch \ + 0090-configure.ac-set-BUILDEXEEXT-and-EXEEXT.patch \ + 0091-configure.ac-fix-building-some-test-modules.patch \ + 0092-Don-t-convert-sysconfig.get_config_var-VPATH-to-an-a.patch \ + 0093-Always-convert-to-before-passing-though-pathcch-func.patch \ + 0094-Build-venvlauncher.exe-from-PC-launcher.c.patch \ + 0095-getpath.py-fix-dirname.patch \ + 0096-getpath-use-normpath-on-all-generated-paths.patch \ + 0097-pathconfig-normpath-sys.path-0.patch \ + 0098-smoketests-add-some-tests-for-sys-site-paths.patch \ + 0099-Search-DLLs-only-on-paths-added-using-add_dll_direct.patch \ + 0100-Build-and-install-libpython3.dll.patch \ + 0101-Port-GetPythonImport-to-mingw.patch \ + 0102-LoadLibraryExW-make-sure-to-only-use-backslashes-for.patch \ + 0103-mingw_smoketests-add-a-test-to-check-if-sysconfig-re.patch \ + 0104-Add-missing-library-for-multiprocessing-module.patch \ + 0105-selectmodule-add-support-for-MINGW.patch \ + 0106-readline-disable-on-MINGW.patch \ + 0107-Add-libraries-to-fix-compile-of-ctypes-on-MINGW.patch \ + 0108-Add-lpython-version-while-linking-stdlib.patch \ + 0109-Enable-_uuid-on-MINGW.patch \ + 0110-Enable-curses-library-on-MINGW.patch \ + 0111-mingw_smoketests-disable-distutils-related-tests.patch \ + 0112-mingw_smoketests-skip-test_c_ext_build-for-in-tree-b.patch \ + 0113-configure.ac-use-autoconf-2.69.patch \ + 0114-3.12-gh-114440-Close-writer-pipe-in-multiprocessing..patch \ + 0115-3.12-gh-115133-Fix-tests-for-XMLPullParser-with-Expa.patch \ + 0116-CI-clean-up-ignored-tests.patch \ + 0117-gcc-make-incompatible-pointer-types-as-warning.patch + + autoreconf -vfi +} + +build() { + declare -a _extra_config + if check_option "debug" "n"; then + _extra_config+=("--enable-optimizations") + # Upstream defaults to -O3, so we can do too + CFLAGS+=" -O3" + # FIXME: https://github.com/msys2-contrib/cpython-mingw/issues/10 + # _extra_config+=("--with-lto") + else + CFLAGS+=" -O0 -ggdb" + CXXFLAGS+=" -O0 -ggdb" + _extra_config+=("--with-pydebug") + fi + + case "${CARCH}" in + i686) + LDFLAGS+=" -Wl,--large-address-aware" + ;; + esac + + mkdir -p "${srcdir}/build-${MSYSTEM}" && cd "${srcdir}/build-${MSYSTEM}" + + ../Python-${pkgver}/configure \ + --prefix=${MINGW_PREFIX} \ + --host=${MINGW_CHOST} \ + --build=${MINGW_CHOST} \ + --enable-shared \ + --with-system-expat \ + --with-system-ffi \ + --with-system-libmpdec \ + --without-ensurepip \ + --enable-loadable-sqlite-extensions \ + --with-tzpath=${MINGW_PREFIX}/share/zoneinfo \ + "${_extra_config[@]}" + + make +} + +check() { + cd "${srcdir}/build-${MSYSTEM}" + + # Some basic tests to ensure nothing major or MSYS2 specific features are broken + ./python.exe "../Python-${pkgver}/mingw_smoketests.py" + MSYSTEM= ./python.exe "../Python-${pkgver}/mingw_smoketests.py" +} + +package() { + cd "${srcdir}/build-${MSYSTEM}" + + make -j1 install DESTDIR="${pkgdir}" + + # 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 + + # 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/ + + # fixup shebangs + for fscripts in 2to3 2to3-${_pybasever} idle3 idle${_pybasever} pydoc3 pydoc${_pybasever}; do + sed -e '1 { s|^#!.*$|#!/usr/bin/env python'"${_pybasever}"'.exe| }' -i "${pkgdir}${MINGW_PREFIX}"/bin/${fscripts} + done + + # default aliases for all scripts/binaries + 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 + fi + + # delete anything that could conflict with the primary Python + if [[ "${_primary_python}" != "yes" ]]; then + 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}"/bin/libpython3.dll + rm "${pkgdir}${MINGW_PREFIX}"/lib/libpython3.dll.a + 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 +} + +sha256sums=('8dfb8f426fcd226657f9e2bd5f1e96e53264965176fa17d32658e873591aeb21' + '6c5823575f95eb6b90fc3af8e41a21a751a5eb468d577ffeb2cfa208f22eac21' + '974901e51bc56dc6c4491268b70097ad2da3cd143d3b901262244d6311be1647' + '8829bf445930c4a9d291e57f0c685d7b0eb5d55a4affd2f3f5fe379888b0021b' + 'b48031bff04737b328666576b0aa00317f4ab65461ada8f1287e7736b33e421b' + '85af01023d3f0d3031eccfe040ceda80a89db36e73834c1f6c6b79f5db63ecc9' + '0385461974ed561c829b07c5a03f7e8ababe61aec1752bf9815ada85c2266522' + 'b1df0b35c0ebe1f9c9af8b9869b3252b3dac3a29b4f969892bce40c54dbd54b3' + 'aabed2633fb1e16ce13bfb80a2b4c3dd092ad75a723d68f960a423e85f3597e0' + '9cb6958cad84f20b214f56d296bbd62ca4b471359506ed448029cd7d17fb6385' + '39698aeb0b7dde92d51d65376a2ea82da433e0dfde28b3ddddcfc8139c71e999' + '17b29ab32edbaab2d8f3f85789cdae0fb39f724ae8ee6cf74e9c25ab679e9b6b' + 'f73a3257ee245da2dab835eed109f5302c2d86e3c5f82f6ed59a61e5828ade4c' + '9fc2f9f6fda4c0a9109d0fb8c5cfb040d52c2320160d8c42ac33c46cd557ca0b' + '9efd32e2e4a1a2dc97982f9a4d3de058264d26d16f4c4fc7971f901b86ac7fce' + '4f7fc3b3cb9e79aa150e31dc45b7188a165d9f99718bc83923b8fa7284d1a2e8' + '55fcb105f3edc18a58500b456b93bf8f52e3bc4371a5f1ac9b71f5557b84e175' + 'c4cd31cff6d102b23b05cd307c3843a8084df8e7cbc6926bee869d227354139e' + 'b19e6969a854be6cb559a668e511f92f6e483e077ce76319823cc88c1bf137dd' + 'e3816a3e35da68331b5798971bff7b4fac8659bbe2fbe51ab42318892eac651c' + '4b38722139d674cd43769ee6a809a066dec29a5cad6f496271c7a3c5b286cdef' + '7ab904dc6f2dd20e4a37de41d2b068fd01a8b2bcaa8f26ab9de47bfcd0af29eb' + '5aa635ba408c3ae3ef99085931e68510737d42e14aa20a1aaa062e8bdd56e18e' + '6abd089d6e5765c1fb456cdc2a83d4cd109eb0218951746a42c6666de8833b13' + '7eb3a4f85d24f8fb3a19615943ac8bce5b22abb1a06e5ff1f3a814200f0b4b64' + '9896e323d525fa374e57743cd02518e0ab7088e98af8dead1fe6761c4afb85ab' + 'f77293ab63decb3c67aab838e8e6ef4ce5b8226cdf91f0951b1497a52720777d' + '995cda1be8d68cdaa2287388f7b053a5d36dd8e369a5d6ab87d499bc7c6d5f0e' + '7b33479166b802cf5d04306eca18405e15383a6da5b364a5e1dad255770192a3' + '2394beace7839129db69e5cf988e45eb32bed6795a68249a507f8d8793bfecc1' + 'eeb068fac16b6c83955331c174f5d4e12e6bc8d61ac08e07b112f6e7047f1879' + '901fcb3b71fef5df9eb8ccce84a819683d5c2ec5b6e9b827ca70355b13e1d8d8' + '406769f09a81860de41ae55497426f62d6291193efc9e166dda31360039aeb7f' + '841e265ce5276bf7cddddb988b3cc612c30874d0bc630fffe3a0ef895388784a' + '6529bd2bb410be421f20738006a060bd0a5efbe4a2bcfc3f1be2d36e3af434e8' + '0bfc586f4c2608875a9a9c080f2a2562954ec4f52793e2b591af0ee8e981af88' + 'bc46aee3fc5951b907ad70fc7d996af50caac04f955effdc2eb6520f4a06b795' + 'a7aff6d1611455462bee252f87b3c1311121c641013285ad9feff2a8c6bd4ec5' + '4c052cf9ebaf1e201a1df0f8f882488f353e3c7d9c85f13fca0e44e6d4f35e9a' + '5793ca15086e913810fb61c9d7ab54281d5e40c39e0abe940ab86518b5425c2d' + 'bdefd9f00bd72acd348e9e7ee7a6faa450648ca7e5199db72c150f695fa0b7c4' + 'd0a28482b42b057c0b0d536b76604d4c52dcfcd8bde97c7026d14742bf4cca0c' + 'a2d070fef8174fad9c23330f12b29687ec873a83ce75fc0d43b8616a92321b79' + '2c9e1ff6ca6936311732492a66445e1b9635ed5ab12fac3d55216b4972c49ee4' + 'ca95b16a0457fff45baebb3dff59c216e97d059cb3c13fc2c55268474225bc99' + '53f75c6b78091ae49c1e9c102eac4bd540593be5808a715e5848d281c466c93a' + '80e792e261fde2e44b7000bb0cacc7aff50e92de3d5cf81fc27bebb07de752e8' + '9b64fd7eb17d4dae659016afd56f9e4528957ddac16de70e89e7cc1b5f048146' + '64db622bf6b55360294f40dac787a3b790c3fe388222b6d9d3b5b14465ada35b' + '4b31f79cf49dfa993d7dc96950ceab8dc492e42b244b403856d2658ceacb66f7' + 'e555e05fa039d6d631e8cc6bc7b1f81b23c86d386cdd8054f2ea7ad2ac09bd9d' + 'db10596451811a2e809f766dd7c7a8bc20c2f6e7cc697ce99b37c91e2f21397d' + 'dd1d6604e7a044187952e4510c9ef522325887434d0083f34e36cf061493db26' + '9d199724bc9b2df5188d0511e629908ab1af74bbf6b83a43f956ea91eb1e61ca' + 'f50523ac8910e6bbcccd3fead5661336fadc081fb156e275ca32b5114c43f486' + '874fc8349df235cc0aac86573df342568f2a20d198076a2a57cad97d4b3a3e92' + 'a5f0a463be5f46e1c582d06cd43c288369a760e22cdf5a30558c20b472b7fb0b' + '4cf015d3f76d8156ba7298e651a8ad349145778e63e6bfceced6f5952b4bd9d3' + 'de7ab0b941c846cdf20354fc17fb9713b5e6b68af06f22ad12421c83a8756a4f' + '6a1fc29b6266e23012bbf9a6c47cd632721e7411e6ecb56a03665ed41b285dec' + '944205af4998130e70819ca9914576a74fbaf7c253a4d52dc437eacfaba6aed9' + 'ee4a089073fabd8c9bbfafa75a7979d08eaf375e673ba8e7a4e790980347c4ed' + '36b8c5a12f00434f399003f2075e4f1362b0d3208b6ddac584d96542c0dd63db' + '4817828133facc9fbe8da5b9e51d3679b73068f53e4ed1ec85de12a588f02110' + '31ab086b18bc84bd8aee7d9d9f10e3994f6a963743eeeeb1e7e60d23d11f5161' + '0562703c27272ad3590666b5f561ab1aa2e1fac5e17d54ee6ceb5f8c8457b781' + '2b54f9ecfa02745e2763f8c7e6be090348a7b31be2f3ea4ff155c7ca864cfa43' + '5194630766cc3317b627020de13cf3b316d2c98ab532567d7e7f52ad2ea21d8f' + 'a3cdd52975a4a08e37db8f64f167ffdd571c453c4e33980fa3e80d446b168b9f' + '7c549c11edb177dad4df5ae13c0471d209fca3228b53d2c4ef689749d9096a0e' + 'dc3d8f3d20964a3930baaa5ebf46917737b33abac2e8e298bf5b5aa052dc8179' + '5adb594d450e499d6d81cb029180627a58ed1be8750f9bbb41c1225227da16b9' + 'cb497acfca1400081e853f7747d3e0d83fa847d9258dc839070b6bbd386e699e' + '233041bfd389c7c1b59b76575de68d18b50210d804737b442bd96b007003449f' + 'dc86b127566c6da91bf5cbdebafb15fa9823c9e048592eaae65b967413ea3c65' + '9438225342a441557d5434d7c3d077dc20fcf1aeb6246c7deb86387d665628e9' + '1b2770cd03232ec8c74abc8997a8415451ae8858da51aec755e8b9670b899116' + '1672402e935fd1bab3c338b53bd2affa6c9b2faec807cb5579593d9272b82b2f' + '79891611c8a0877ad6e05bf1c0899ee8f86859db53801b85b9fdc91df7fea9c3' + 'f649d891f5e454a50bdbf14dff4afa76e33df93ffdb2c65b9e55766479ca0957' + '1aab6926fc625ab921d591c8018c40731722cbd9901e2c5dc2f903cb89a14331' + 'f71a61882d89447ced9928ace3c8458f8845485e66d198e344f3e1dbe97e4e6c' + 'd98bc94e23482472aeed37961545914e6cb197972999753f29d1f9894c876e01' + '9463f117d07a80c02f019e065e582a312efdf12e193cd7217e74e389a2f2fe3e' + '7821d6b2fb50da634e67ce2397538c0b2ab5438f03eebe6622d95c7f89a078c9' + 'd67b4e9185e539eaa0cf149c4f668c4251848cd608d6d80b12c88e8f6468f5f8' + '5de364962e82bca4cceffcabcba2617535f6004f92b57ed316d5cfa82421ecb2' + 'f2036c41acd1dae55ab80ca8fcc48c8c1127263a755736655baba3ab279182e6' + '65dd7bad62e60d321bd0bac9a200fb4ddebf75c05ec7ed2a9c4530a36a4c74eb' + 'b73e0fd84616466e13dc18711f76f1d02ec2b33fcb85479a5b55655116a11464' + '7a7a1206ea71ecdd18051679c3eb8c466c7d9f4e598e06fce84a625c40587ca6' + 'adcc06e1e2adfe34b4fa8bb6e5c41b97596afb373e65aa5f6fa03cfe78fb89e4' + 'dfbd82deaa19f2a9baafc5601ba4d6047c2bb5d4a4e956a7a082287ce486b1ec' + '219cfd1f6f35de824084ca5186becac10a32bc3d0c0178a49cd58859b7c065d5' + 'e4c0d521127b49fffef50da9320cff2dd762f148c1d1b2e204237450ba522065' + '962ee212b159dccc9e44aad6b565efca41c5d4dba3ecad83fb24009b263e796b' + '596c0684268adaf5cdf820f2c55b8b96d39c15c7707b0e443d5d14b4a883241d' + 'd77322b2e6bc5ce7ae36d710081edc933085e4010595b92f2fe5793e1c60ae75' + 'ba3cc1aafa3e046d856e13054cc8d9dd14ce98fc53d4f854a0788b81fbb2839c' + '94f1d0ac6c29059a3e21f7495d678bf71ca8fe53cc9eed0003cbfecab01a4806' + '329f83b7f7aac69f65124595e339cf908677075e56d6a3121b15039e159d1da5' + '58ad318f885a5fe76fcb9bbc5cd2c3e8b39ec4170348e8018b3259d6996c9f05' + '76e970d55dc3d61c203d05008d4771da2e9808548444e347d5e2c8b2d7654299' + 'b290144e98300fc88cf19e6c9bf33b4080f6dcc437f3f5323662c5ffb0b32045' + '59b155e6597e3be2b9188e7b7468381d7d65c6e4aee188cdacb5eebaa695f071' + '34caa4c8e68f970a031f65bef0c2e4e6dd97d6fb6e13da9121069840cfd6bafa' + '757c0a45fd77ddb74f91cd141304d5fb0530ff8c52809d133c679d32c9c8326d' + '922101eec57956f4c6a52522e87d3755c52cfe90e68186b1b480424455c8efef' + '54c1abee4b13278090fd26a7b725c10dbeee0d8deffc46843be031f9b824364b' + 'e745ad7e0b75a858d1b1755d845d20cf5d70d10309ea68c9067a287991866726' + '2ec6b6c7c64ae20b2e53a43cfba93eb03b8971dcb92bddddaf8d4c3df2e43520' + 'ccbdcf61a06f0a1a4fbdc78f03c4ecd449c3793c07e117e6d9c2f80b197f151c' + '72fd7b38599091fe73028cddcda1223d2359832145a7cd0b5a3f1e28de96ebf2' + '7a9a917e64d8e0b01b3be4fc1144268eb8bf55faf4cf69b59dc95483e6350231' + 'f2dab1281f7e64aba1eca657b7c1f87a5facbc52edd57bc00c4f3d81a2e1cbaa' + 'cb37d5377f0ca0411da99749dc2fee0c5edcb81bb8162fa43fca164590c84eaf' + 'a343e4063d59cbc7f4837dd0b6ca30b89c5887c33bb82acf05d3774e3553533b' + '67cbe0824f78a6c71bade9a79cbc4d96dfca4abafb6a38c621b18cabb91359ec') diff --git a/mingw-w64-python3.12/README.md b/mingw-w64-python3.12/README.md new file mode 100644 index 0000000000..858c558d9c --- /dev/null +++ b/mingw-w64-python3.12/README.md @@ -0,0 +1,4 @@ +The patches for this package are auto generated and managed in git: +https://github.com/msys2-contrib/cpython-mingw + +Run `./update-patches.sh` to re-create the patches. diff --git a/mingw-w64-python3.12/update-patches.sh b/mingw-w64-python3.12/update-patches.sh new file mode 100644 index 0000000000..1a813035c2 --- /dev/null +++ b/mingw-w64-python3.12/update-patches.sh @@ -0,0 +1,81 @@ +#!/bin/bash + +set -e + +die () { + echo "$*" >&2 + exit 1 +} + +cd "$(dirname "$0")" || +die "Could not cd to mingw-w64-python3.12/" + +git rev-parse --verify HEAD >/dev/null && +git update-index -q --ignore-submodules --refresh && +git diff-files --quiet --ignore-submodules && +git diff-index --cached --quiet --ignore-submodules HEAD -- || +die "Clean worktree required" + +git rm 0*.patch || +die "Could not remove previous patches" + +source PKGBUILD || die "Can't source PKGBUILD" + +base_tag=refs/tags/v$pkgver +msys2_branch=mingw-v$pkgver +url=https://github.com/msys2-contrib/cpython-mingw +upstream_url=https://github.com/python/cpython + +test -d cpython || +git clone --bare $url cpython --depth=1000 --branch=$msys2_branch || +die "Could not clone cpython" + +git -C cpython fetch --no-tags $url $msys2_branch:$msys2_branch --depth=1000 +git -C cpython fetch --no-tags $upstream_url $base_tag:$base_tag --depth=1000 + +git -c core.abbrev=7 \ + -c diff.renames=true \ + -c format.from=false \ + -c format.numbered=auto \ + -c format.useAutoBase=false \ + -C cpython \ + format-patch \ + --no-signature \ + --topo-order \ + --diff-algorithm=default \ + --no-attach \ + --no-add-header \ + --no-cover-letter \ + --no-thread \ + --suffix=.patch \ + --subject-prefix=PATCH \ + --output-directory .. \ + $base_tag..$msys2_branch || + -- ':(exclude).github/' || +die "Could not generate new patch set" + +patches="$(ls -1 0*.patch)" && +for p in $patches +do + sed -i 's/^\(Subject: \[PATCH [0-9]*\/\)[1-9][0-9]*/\1N/' $p || + die "Could not fix Subject: line in $p" +done && +patches="$(ls -1 0*.patch)" && +git add $patches || +die "Could not stage new patch set" + +in_sources="$(echo "$patches" | sed "{s/^/ /;:1;N;s/\\n/\\\\n /;b1}")" +in_prepare="$(echo "$patches" | tr '\n' '\\' | sed -e 's/\\$//' -e 's/\\/ &&&n /g')" +sed -i -e "/^ 0.*\.patch$/{:1;N;/[^)]$/b1;s|.*|$in_sources)|}" \ + -e "/^ *apply_patch_with_msg /{:2;N;/[^}]$/b2;s|.*| apply_patch_with_msg $in_prepare\\n\\ \n autoreconf -vfi\n}|}" \ + PKGBUILD || +die "Could not update the patch set in PKGBUILD" + +updpkgsums || +die "Could not update the patch set checksums in PKGBUILD" + +# bump pkgrel +sed "s/\(pkgrel\).*/pkgrel=$(($pkgrel + 1))/" -i PKGBUILD + +git add PKGBUILD || +die "Could not stage updates in PKGBUILD"