From 15dab6a7628cb11cc9bea72a5065eeb473099e7c Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Wed, 6 Oct 2021 15:53:06 -0400 Subject: [PATCH] [python3] Upgrade to Python 3.10.0 (#20519) * [python3] Update to Python 3.10.0rc2 (for testing). * [python3] Revert trivial patch changes. * [python3] Bump to 3.10.0 final. * x-add-version * update python tools to 3.10.0 * [ecm] Add patch from upstream for Python 3.10. Remove this on the next release. * x-add-version * [python3] Add patch to fix static interpreter. * x-add-version --- ports/ecm/fix_python_version.patch | 61 +++++++++++++++++++ ports/ecm/portfile.cmake | 1 + ports/ecm/vcpkg.json | 2 +- ports/python3/0001-static-library.patch | 14 +++++ .../python3/0006-fix-duplicate-symbols.patch | 39 ------------ ... 0006-restore-support-for-windows-7.patch} | 0 ...nd-windows-11-sdk-rc-compiler-error.patch} | 0 ports/python3/portfile.cmake | 11 ++-- ports/python3/vcpkg.json | 3 +- .../cmake/vcpkg_find_acquire_program.cmake | 8 +-- scripts/vcpkgTools.xml | 8 +-- versions/baseline.json | 6 +- versions/e-/ecm.json | 5 ++ versions/p-/python3.json | 5 ++ 14 files changed, 104 insertions(+), 59 deletions(-) create mode 100644 ports/ecm/fix_python_version.patch delete mode 100644 ports/python3/0006-fix-duplicate-symbols.patch rename ports/python3/{0007-restore-support-for-windows-7.patch => 0006-restore-support-for-windows-7.patch} (100%) rename ports/python3/{0008-workaround-windows-11-sdk-rc-compiler-error.patch => 0007-workaround-windows-11-sdk-rc-compiler-error.patch} (100%) diff --git a/ports/ecm/fix_python_version.patch b/ports/ecm/fix_python_version.patch new file mode 100644 index 00000000000..a443bb1a64f --- /dev/null +++ b/ports/ecm/fix_python_version.patch @@ -0,0 +1,61 @@ +From 12f4266eb71b30da1df92a5d628d402ea1a45b3b Mon Sep 17 00:00:00 2001 +From: Michael Pyne +Date: Sun, 4 Jul 2021 18:47:45 -0400 +Subject: [PATCH] python: Bump maximum version for Python 3 module generator + check. + +The proximate problem is that the Python Module generator cmake script +has started failing for people with Python 3.10, which a CMake backtrace +pointing into FindPythonModuleGeneration.cmake with an error of the form +"The max python version in PythonModuleGeneration must be updated." + +At least one distro has addressed this by simply patching out modules +that happen to use this CMake module [1]. + +From what I can tell and the testing I've done, the cause is pretty +simple: The CMake script attempts to find the best Python 3 version by +starting from an impossible version and working backwards until it finds +a version that is installed. + +As a sanity check, if the "impossible" version is actually present, it +aborts. But this appears to be just a sanity check, and not any sort of +guard against buggy version handling code later. + +While the best fix is probably to start from a known *good* version and +move up until we stop finding better versions, there's problems here +(e.g. a user with 3.6 and 3.8 installed would fail to see 3.7 and so be +left with 3.6 as the "best" match), so I opted just to increase the max +version significantly, and improve the documentation as to what's +happening and whether it is safe to repeat the step again later. + +[1]: https://bugs.gentoo.org/746866 +--- + find-modules/FindPythonModuleGeneration.cmake | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +diff --git a/find-modules/FindPythonModuleGeneration.cmake b/find-modules/FindPythonModuleGeneration.cmake +index 210ba662..6104c1f4 100644 +--- a/find-modules/FindPythonModuleGeneration.cmake ++++ b/find-modules/FindPythonModuleGeneration.cmake +@@ -162,14 +162,19 @@ endif() + + if (NOT GPB_PYTHON3_LIBRARY) + set(_PYTHON3_MIN_VERSION 4) +- set(_PYTHON3_MAX_VERSION 10) + +- _find_python(3 ${_PYTHON3_MAX_VERSION}) # Canary check ++ # This value is safe to increment over time, it is used only as a reasonable ++ # upper bound to start searching from ++ set(_PYTHON3_MAX_VERSION 50) ++ ++ _find_python(3 ${_PYTHON3_MAX_VERSION}) + + if (GPB_PYTHON3_LIBRARY) + message(FATAL_ERROR "The max python version in ${CMAKE_FIND_PACKAGE_NAME} must be updated.") + endif() + ++ # Look for the highest supported version of Python 3 by looking for a minor ++ # version that doesn't exist and decrementing until we find a match. + set(_PYTHON3_FIND_VERSION ${_PYTHON3_MAX_VERSION}) + + while(NOT GPB_PYTHON3_LIBRARY diff --git a/ports/ecm/portfile.cmake b/ports/ecm/portfile.cmake index 53acd4d8dd1..19105838303 100644 --- a/ports/ecm/portfile.cmake +++ b/ports/ecm/portfile.cmake @@ -6,6 +6,7 @@ vcpkg_from_github( HEAD_REF master PATCHES fix_canberra.patch + fix_python_version.patch # Remove on next release ) vcpkg_cmake_configure( diff --git a/ports/ecm/vcpkg.json b/ports/ecm/vcpkg.json index bc120806eed..11a544924b1 100644 --- a/ports/ecm/vcpkg.json +++ b/ports/ecm/vcpkg.json @@ -1,7 +1,7 @@ { "name": "ecm", "version": "5.84.0", - "port-version": 1, + "port-version": 2, "description": "Extra CMake Modules (ECM), extra modules and scripts for CMake", "homepage": "https://github.com/KDE/extra-cmake-modules", "dependencies": [ diff --git a/ports/python3/0001-static-library.patch b/ports/python3/0001-static-library.patch index 93a89a2e3c6..eef3875742f 100644 --- a/ports/python3/0001-static-library.patch +++ b/ports/python3/0001-static-library.patch @@ -58,6 +58,20 @@ index 2625d0293d..2f8bdaa931 100644 _Py_HAVE_ZLIB;%(PreprocessorDefinitions) +diff --git a/Python/sysmodule.c b/Python/sysmodule.c +index ac49f7867a..f3583345ff 100644 +--- a/Python/sysmodule.c ++++ b/Python/sysmodule.c +@@ -2804,6 +2804,9 @@ _PySys_InitCore(PyThreadState *tstate, PyObject *sysdict) + #ifdef MS_COREDLL + SET_SYS("dllhandle", PyLong_FromVoidPtr(PyWin_DLLhModule)); + SET_SYS_FROM_STRING("winver", PyWin_DLLVersionString); ++#elif defined(MS_WINDOWS) ++ SET_SYS("dllhandle", PyLong_FromVoidPtr(NULL)); ++ SET_SYS_FROM_STRING("winver", MS_DLL_ID); + #endif + #ifdef ABIFLAGS + SET_SYS_FROM_STRING("abiflags", ABIFLAGS); -- 2.28.0.windows.1 diff --git a/ports/python3/0006-fix-duplicate-symbols.patch b/ports/python3/0006-fix-duplicate-symbols.patch deleted file mode 100644 index 251c0186abf..00000000000 --- a/ports/python3/0006-fix-duplicate-symbols.patch +++ /dev/null @@ -1,39 +0,0 @@ -From 62e082c1eba79d46ba8ab4b7a556a57a2253d555 Mon Sep 17 00:00:00 2001 -From: Adam Johnson -Date: Fri, 11 Sep 2020 12:35:36 -0400 -Subject: [PATCH 6/6] fix duplicate symbols - ---- - Modules/_winapi.c | 2 +- - Modules/overlapped.c | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/Modules/_winapi.c b/Modules/_winapi.c -index e1672c4785..27148094d2 100644 ---- a/Modules/_winapi.c -+++ b/Modules/_winapi.c -@@ -304,7 +304,7 @@ static PyMemberDef overlapped_members[] = { - {NULL} - }; - --PyTypeObject OverlappedType = { -+static PyTypeObject OverlappedType = { - PyVarObject_HEAD_INIT(NULL, 0) - /* tp_name */ "_winapi.Overlapped", - /* tp_basicsize */ sizeof(OverlappedObject), -diff --git a/Modules/overlapped.c b/Modules/overlapped.c -index cd7869fa8a..319ea0a4b7 100644 ---- a/Modules/overlapped.c -+++ b/Modules/overlapped.c -@@ -1756,7 +1756,7 @@ static PyGetSetDef Overlapped_getsets[] = { - {NULL}, - }; - --PyTypeObject OverlappedType = { -+static PyTypeObject OverlappedType = { - PyVarObject_HEAD_INIT(NULL, 0) - /* tp_name */ "_overlapped.Overlapped", - /* tp_basicsize */ sizeof(OverlappedObject), --- -2.28.0.windows.1 - diff --git a/ports/python3/0007-restore-support-for-windows-7.patch b/ports/python3/0006-restore-support-for-windows-7.patch similarity index 100% rename from ports/python3/0007-restore-support-for-windows-7.patch rename to ports/python3/0006-restore-support-for-windows-7.patch diff --git a/ports/python3/0008-workaround-windows-11-sdk-rc-compiler-error.patch b/ports/python3/0007-workaround-windows-11-sdk-rc-compiler-error.patch similarity index 100% rename from ports/python3/0008-workaround-windows-11-sdk-rc-compiler-error.patch rename to ports/python3/0007-workaround-windows-11-sdk-rc-compiler-error.patch diff --git a/ports/python3/portfile.cmake b/ports/python3/portfile.cmake index 8967d5a3d75..b57de25bbbf 100644 --- a/ports/python3/portfile.cmake +++ b/ports/python3/portfile.cmake @@ -4,8 +4,8 @@ if (VCPKG_LIBRARY_LINKAGE STREQUAL dynamic AND VCPKG_CRT_LINKAGE STREQUAL static endif() set(PYTHON_VERSION_MAJOR 3) -set(PYTHON_VERSION_MINOR 9) -set(PYTHON_VERSION_PATCH 7) +set(PYTHON_VERSION_MINOR 10) +set(PYTHON_VERSION_PATCH 0) set(PYTHON_VERSION ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}.${PYTHON_VERSION_PATCH}) set(PATCHES @@ -13,7 +13,6 @@ set(PATCHES 0003-devendor-external-dependencies.patch 0004-dont-copy-vcruntime.patch 0005-only-build-required-projects.patch - 0006-fix-duplicate-symbols.patch ) if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") list(PREPEND PATCHES 0001-static-library.patch) @@ -22,7 +21,7 @@ endif() # Python 3.9 removed support for Windows 7. This patch re-adds support for Windows 7 and is therefore # required to build this port on Windows 7 itself due to Python using itself in its own build system. if("deprecated-win7-support" IN_LIST FEATURES) - list(APPEND PATCHES 0007-restore-support-for-windows-7.patch) + list(APPEND PATCHES 0006-restore-support-for-windows-7.patch) message(WARNING "Windows 7 support is deprecated and may be removed at any time.") elseif(VCPKG_TARGET_IS_WINDOWS AND CMAKE_SYSTEM_VERSION EQUAL 6.1) message(FATAL_ERROR "python3 requires the feature deprecated-win7-support when building on Windows 7.") @@ -32,7 +31,7 @@ endif() if(VCPKG_TARGET_IS_WINDOWS OR VCPKG_TARGET_IS_UWP) vcpkg_get_windows_sdk(WINSDK_VERSION) if("${WINSDK_VERSION}" VERSION_GREATER_EQUAL "10.0.22000") - list(APPEND PATCHES "0008-workaround-windows-11-sdk-rc-compiler-error.patch") + list(APPEND PATCHES "0007-workaround-windows-11-sdk-rc-compiler-error.patch") endif() endif() @@ -40,7 +39,7 @@ vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO python/cpython REF v${PYTHON_VERSION} - SHA512 05de4e485fb6f5f21e4e48fb4d7ec0e9a420fab243cba08663e52b8062f86df3e4f57b8afd49ad94d363ca0972ab85efe132b980a7f84188c82814b6df0ba191 + SHA512 d83e0685c274be09da7833a3c24b7379ae0e43b43c131f11bfaccd5902f6a1c510a3ae67c42471a4281922ead3bd34856608ec47be7dd76ddd734e59906ba03b HEAD_REF master PATCHES ${PATCHES} ) diff --git a/ports/python3/vcpkg.json b/ports/python3/vcpkg.json index c3bec2e6b80..22ec7166622 100644 --- a/ports/python3/vcpkg.json +++ b/ports/python3/vcpkg.json @@ -1,7 +1,6 @@ { "name": "python3", - "version-semver": "3.9.7", - "port-version": 2, + "version-semver": "3.10.0", "description": "The Python programming language", "homepage": "https://github.com/python/cpython", "supports": "!(arm | uwp)", diff --git a/scripts/cmake/vcpkg_find_acquire_program.cmake b/scripts/cmake/vcpkg_find_acquire_program.cmake index a75e3c6be81..d8b1de614b0 100644 --- a/scripts/cmake/vcpkg_find_acquire_program.cmake +++ b/scripts/cmake/vcpkg_find_acquire_program.cmake @@ -149,20 +149,20 @@ function(vcpkg_find_acquire_program VAR) elseif(VAR MATCHES "PYTHON3") if(CMAKE_HOST_WIN32) set(PROGNAME python) - set(PYTHON_VERSION 3.9.7) + set(PYTHON_VERSION 3.10.0) if (VCPKG_TARGET_ARCHITECTURE STREQUAL x86) set(SUBDIR "python-${PYTHON_VERSION}-x86") set(URL "https://www.python.org/ftp/python/${PYTHON_VERSION}/python-${PYTHON_VERSION}-embed-win32.zip") set(ARCHIVE "python-${PYTHON_VERSION}-embed-win32.zip") - set(HASH 5f12f693c6df68b75f96b797740a156f2dcd471e96e7980a6e297bbfd064467ba2b2cc9d2f450296388402a8a0b716fce1c4a25b94b50615503d528e33fea870) + set(HASH 0b007bfa02cdd48b3c260986493fa124a6b9d794da6eba2b4fad0d779fd655e9ae4e16daf5f02ff5b30a17abcfc1499bc6bee394c0f8abe933f2d4fe702af3cd) else() set(SUBDIR "python-${PYTHON_VERSION}-x64") set(URL "https://www.python.org/ftp/python/${PYTHON_VERSION}/python-${PYTHON_VERSION}-embed-amd64.zip") set(ARCHIVE "python-${PYTHON_VERSION}-embed-amd64.zip") - set(HASH 482765de165863f86637591d57141930e2c4ca6e210d0c2569bd0e5fe63157966fb44dea0d5adf249ff15ec9c50cb2dddb704c4ea79369d598f348ee5406f160) + set(HASH 23d81d007698383d8dc088da532dcb86c6ceca7eb78ba5688fc2e18ee7f33f53a5632282873762293b8164556dfb15870f8ffb7abd368faba0a3d8d5d5bc6297) endif() set(PATHS ${DOWNLOADS}/tools/python/${SUBDIR}) - set(POST_INSTALL_COMMAND ${CMAKE_COMMAND} -E rm python39._pth) + set(POST_INSTALL_COMMAND ${CMAKE_COMMAND} -E rm python310._pth) else() set(PROGNAME python3) set(BREW_PACKAGE_NAME "python") diff --git a/scripts/vcpkgTools.xml b/scripts/vcpkgTools.xml index fc07adeb512..ad691adbb9d 100644 --- a/scripts/vcpkgTools.xml +++ b/scripts/vcpkgTools.xml @@ -1,11 +1,11 @@ - 3.9.7 + 3.10.0 python.exe - https://www.python.org/ftp/python/3.9.7/python-3.9.7-embed-win32.zip - 5f12f693c6df68b75f96b797740a156f2dcd471e96e7980a6e297bbfd064467ba2b2cc9d2f450296388402a8a0b716fce1c4a25b94b50615503d528e33fea870 - python-3.9.7-embed-win32.zip + https://www.python.org/ftp/python/3.10.0/python-3.10.0-embed-win32.zip + 0b007bfa02cdd48b3c260986493fa124a6b9d794da6eba2b4fad0d779fd655e9ae4e16daf5f02ff5b30a17abcfc1499bc6bee394c0f8abe933f2d4fe702af3cd + python-3.10.0-embed-win32.zip 3.21.1 diff --git a/versions/baseline.json b/versions/baseline.json index 9049c7f5673..7864ae7b1eb 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -1930,7 +1930,7 @@ }, "ecm": { "baseline": "5.84.0", - "port-version": 1 + "port-version": 2 }, "ecos": { "baseline": "2.0.8", @@ -5337,8 +5337,8 @@ "port-version": 1 }, "python3": { - "baseline": "3.9.7", - "port-version": 2 + "baseline": "3.10.0", + "port-version": 0 }, "qca": { "baseline": "2.3.1", diff --git a/versions/e-/ecm.json b/versions/e-/ecm.json index 5ce5bb02b05..82859b55a4d 100644 --- a/versions/e-/ecm.json +++ b/versions/e-/ecm.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "e01bd7b91852c7fa2dffc588bad45167d8d45c6b", + "version": "5.84.0", + "port-version": 2 + }, { "git-tree": "5832b19b778f60eb0fb24654e0c8b665f0f8fb20", "version": "5.84.0", diff --git a/versions/p-/python3.json b/versions/p-/python3.json index 64e2590cd11..007cb9431c0 100644 --- a/versions/p-/python3.json +++ b/versions/p-/python3.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "08e4258968ff551133ae315eb8ed207f87f085b6", + "version-semver": "3.10.0", + "port-version": 0 + }, { "git-tree": "3975ee0659914edc75d63f914ac91bb3b7453f0c", "version-semver": "3.9.7",