From fa1ae6408d9b14f8434cbc4b06aab1ed2d9ec71f Mon Sep 17 00:00:00 2001 From: Funda Wang Date: Sat, 11 Feb 2023 20:16:28 +0800 Subject: [PATCH] Fix linkage of internal modules and external modules --- python3-3.10.10-fix-linkage.patch | 20 +++++++++++++++++++ ....10.10-link-C-modules-with-libpython.patch | 13 ++++++++++++ python3.spec | 13 ++++++++++-- 3 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 python3-3.10.10-fix-linkage.patch create mode 100644 python3-3.10.10-link-C-modules-with-libpython.patch diff --git a/python3-3.10.10-fix-linkage.patch b/python3-3.10.10-fix-linkage.patch new file mode 100644 index 0000000..953c076 --- /dev/null +++ b/python3-3.10.10-fix-linkage.patch @@ -0,0 +1,20 @@ +--- Python-3.10.10/Misc/python.pc.in.orig 2023-02-11 18:50:30.601282069 +0800 ++++ Python-3.10.10/Misc/python.pc.in 2023-02-11 18:50:51.021282069 +0800 +@@ -9,5 +9,5 @@ + Requires: + Version: @VERSION@ + Libs.private: @LIBS@ +-Libs: ++Libs: -lpython@VERSION@@ABIFLAGS@ + Cflags: -I${includedir}/python@VERSION@@ABIFLAGS@ +--- Python-3.10.10/Misc/python-config.sh.in.orig 2023-02-11 18:48:55.443282069 +0800 ++++ Python-3.10.10/Misc/python-config.sh.in 2023-02-11 18:49:43.850282069 +0800 +@@ -41,7 +41,7 @@ + LIBC="@LIBC@" + SYSLIBS="$LIBM $LIBC" + ABIFLAGS="@ABIFLAGS@" +-LIBS="@LIBPYTHON@ @LIBS@ $SYSLIBS" ++LIBS="-lpython${VERSION}${ABIFLAGS} @LIBS@ $SYSLIBS" + LIBS_EMBED="-lpython${VERSION}${ABIFLAGS} @LIBS@ $SYSLIBS" + BASECFLAGS="@BASECFLAGS@" + LDLIBRARY="@LDLIBRARY@" diff --git a/python3-3.10.10-link-C-modules-with-libpython.patch b/python3-3.10.10-link-C-modules-with-libpython.patch new file mode 100644 index 0000000..c685394 --- /dev/null +++ b/python3-3.10.10-link-C-modules-with-libpython.patch @@ -0,0 +1,13 @@ +diff --git a/Lib/distutils/command/build_ext.py b/Lib/distutils/command/build_ext.py +index 2d7cdf0..058809b 100644 +--- a/Lib/distutils/command/build_ext.py ++++ b/Lib/distutils/command/build_ext.py +@@ -724,7 +724,7 @@ class build_ext(Command): + # Windows like MinGW) it is simply necessary that all symbols in + # shared libraries are resolved at link time. + from distutils.sysconfig import get_config_var +- link_libpython = False ++ link_libpython = True + if get_config_var('Py_ENABLE_SHARED'): + # A native build on an Android device or on Cygwin + if hasattr(sys, 'getandroidapilevel'): diff --git a/python3.spec b/python3.spec index 8567c45..ef9fb0f 100644 --- a/python3.spec +++ b/python3.spec @@ -1,4 +1,4 @@ -%define anolis_release 1 +%define anolis_release 2 %global pybasever 3.10 # pybasever without the dot: @@ -227,6 +227,12 @@ BuildRequires: python3-rpm-generators Source0: %{url}ftp/python/%{general_version}/Python-%{upstream_version}.tar.xz +# Anolis patches (>1000) +# Fix linkage of extensions produced by external packages by linking against libpython +Patch1001: python3-3.10.10-fix-linkage.patch +# Force link C modules with libpython +Patch1002: python3-3.10.10-link-C-modules-with-libpython.patch + # ========================================== # Descriptions, and metadata for subpackages # ========================================== @@ -522,7 +528,7 @@ version once Python %{pybasever} is stable. # ====================================================== %prep -%autosetup -n Python-%{upstream_version} +%autosetup -p1 -n Python-%{upstream_version} %if %{with rpmwheels} rm Lib/ensurepip/_bundled/pip-%{pip_version}-py3-none-any.whl @@ -1434,6 +1440,9 @@ CheckPython optimized # ====================================================== %changelog +* Sat Feb 11 2023 Funda Wang - 3.10.10-2 +- Fix linkage of internal modules and external modules + * Wed Feb 8 2023 Funda Wang - 3.10.10-1 - New version 3.10.10 -- Gitee