python3: Restore platform triplet to paths
authorJeffery To <jeffery.to@gmail.com>
Thu, 29 Jun 2023 08:33:25 +0000 (16:33 +0800)
committerJeffery To <jeffery.to@gmail.com>
Thu, 24 Aug 2023 18:24:38 +0000 (02:24 +0800)
This removes 014-remove-platform-so-suffix.patch and
016-adjust-config-paths.patch, restoring the platform triplet to paths
for:

* C extensions (*.cpython-311-*.so)

* Build config data directory (/usr/lib/python3.11/config-3.11-*/)

* sysconfig data file (/usr/lib/python3.11/_sysconfigdata_*.py)

Setting `_PYTHON_SYSCONFIGDATA_NAME` during package builds ensures that
sysconfig data for target Python is loaded, in particular so that C
extensions built will have the correct extension / platform triplet.

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
lang/python/python3-package.mk
lang/python/python3/Makefile
lang/python/python3/files/python3-package-dev.mk
lang/python/python3/patches/014-remove-platform-so-suffix.patch [deleted file]
lang/python/python3/patches/016-adjust-config-paths.patch [deleted file]

index d07cec1744eb4398288a2e814c6e173ad607c8c4..268bca07f98dbf27ebf6868312ae274bcf6d21ff 100644 (file)
@@ -20,7 +20,7 @@ PYTHON3:=python$(PYTHON3_VERSION)
 
 PYTHON3PATH:=$(PYTHON3_LIB_DIR):$(STAGING_DIR)/$(PYTHON3_PKG_DIR):$(PKG_INSTALL_DIR)/$(PYTHON3_PKG_DIR)
 
--include $(PYTHON3_LIB_DIR)/config-$(PYTHON3_VERSION)/Makefile-vars
+-include $(PYTHON3_LIB_DIR)/openwrt/Makefile-vars
 
 # These configure args are needed in detection of path to Python header files
 # using autotools.
@@ -39,6 +39,7 @@ PYTHON3_VARS = \
        CPPFLAGS="$(TARGET_CPPFLAGS) -I$(PYTHON3_INC_DIR)" \
        LDFLAGS="$(TARGET_LDFLAGS) -lpython$(PYTHON3_VERSION)" \
        _PYTHON_HOST_PLATFORM="$(_PYTHON_HOST_PLATFORM)" \
+       _PYTHON_SYSCONFIGDATA_NAME="_sysconfigdata_$(ABIFLAGS)_$(MACHDEP)_$(MULTIARCH)" \
        PYTHONPATH="$(PYTHON3PATH)" \
        PYTHONDONTWRITEBYTECODE=1 \
        _python_sysroot="$(STAGING_DIR)" \
index f355567693b0fb6c508d35f9a4f453332bb972af..0b4eb31592798c4a313d6eb4cc92465cc734fb15 100644 (file)
@@ -11,7 +11,7 @@ include $(TOPDIR)/rules.mk
 include ../python3-version.mk
 
 PKG_NAME:=python3
-PKG_RELEASE:=2
+PKG_RELEASE:=3
 PKG_VERSION:=$(PYTHON3_VERSION).$(PYTHON3_VERSION_MICRO)
 
 PKG_SOURCE:=Python-$(PKG_VERSION).tar.xz
@@ -112,7 +112,7 @@ endef
 
 PYTHON3_LIB_FILES_DEL:=
 PYTHON3_PACKAGES:=
-PYTHON3_SO_SUFFIX:=cpython-$(PYTHON3_VERSION_MAJOR)$(PYTHON3_VERSION_MINOR).so
+PYTHON3_SO_SUFFIX:=cpython-$(PYTHON3_VERSION_MAJOR)$(PYTHON3_VERSION_MINOR)-*.so
 PYTHON3_PACKAGES_DEPENDS:=
 define Py3BasePackage
   PYTHON3_PACKAGES+=$(1)
@@ -148,7 +148,7 @@ installation.
 endef
 
 # Set READELF here so that the exact same readelf program name can be
-# replaced in _sysconfigdata.py (in Build/Install)
+# replaced in _sysconfigdata_*.py (in Build/Install)
 TARGET_CONFIGURE_OPTS+= \
        READELF="$(TARGET_CROSS)readelf"
 
@@ -200,27 +200,34 @@ define Build/Install
        $(call Build/Install/Default,)
 
        $(SED) 's|$(TARGET_AR)|ar|g;s|$(TARGET_CROSS)readelf|readelf|g;s|$(TARGET_CC)|gcc|g;s|$(TARGET_CXX)|g++|g' \
-               $(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON3_VERSION)/_sysconfigdata.py \
-               $(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON3_VERSION)/config-$(PYTHON3_VERSION)/Makefile
+               $(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON3_VERSION)/_sysconfigdata_*.py \
+               $(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON3_VERSION)/config-$(PYTHON3_VERSION)-*/Makefile
 endef
 
 define Build/InstallDev
-       $(INSTALL_DIR) $(1)/usr/include $(1)/usr/lib $(1)/usr/lib/pkgconfig
-       $(INSTALL_DIR) $(2)/bin
+       $(INSTALL_DIR) $(1)/usr/include
        $(CP) \
                $(PKG_INSTALL_DIR)/usr/include/python$(PYTHON3_VERSION) \
                $(1)/usr/include/
+
+       $(INSTALL_DIR) $(1)/usr/lib
        $(CP) \
                $(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON3_VERSION) \
                $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON3_VERSION).so* \
                $(1)/usr/lib/
-       grep \
-               '^_PYTHON_HOST_PLATFORM=' \
-               $(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON3_VERSION)/config-$(PYTHON3_VERSION)/Makefile > \
-               $(1)/usr/lib/python$(PYTHON3_VERSION)/config-$(PYTHON3_VERSION)/Makefile-vars
+
+       $(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON3_VERSION)/openwrt
+       grep -E \
+               '^(_PYTHON_HOST_PLATFORM|ABIFLAGS|MACHDEP|MULTIARCH)=' \
+               $(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON3_VERSION)/config-$(PYTHON3_VERSION)-*/Makefile > \
+               $(1)/usr/lib/python$(PYTHON3_VERSION)/openwrt/Makefile-vars
+
+       $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
        $(CP) \
                $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/python*.pc \
                $(1)/usr/lib/pkgconfig
+
+       $(INSTALL_DIR) $(2)/bin
        $(INSTALL_BIN) \
                $(PKG_INSTALL_DIR)/usr/bin/python$(PYTHON3_VERSION)-config \
                $(2)/bin/
@@ -233,7 +240,7 @@ PYTHON3_BASE_LIB_FILES:= \
        /usr/lib/python$(PYTHON3_VERSION)/encodings \
        /usr/lib/python$(PYTHON3_VERSION)/_collections_abc.py \
        /usr/lib/python$(PYTHON3_VERSION)/_sitebuiltins.py \
-       /usr/lib/python$(PYTHON3_VERSION)/_sysconfigdata.py \
+       /usr/lib/python$(PYTHON3_VERSION)/_sysconfigdata_*.py \
        /usr/lib/python$(PYTHON3_VERSION)/_weakrefset.py \
        /usr/lib/python$(PYTHON3_VERSION)/abc.py \
        /usr/lib/python$(PYTHON3_VERSION)/codecs.py \
index 3eca521ffa4fceacd1774f3d0a5e59b1a8e519ea..871fff9ee9e7751a481ff6efb8347b4e1f03929b 100644 (file)
@@ -27,7 +27,7 @@ define Py3Package/python3-dev/install
 endef
 
 $(eval $(call Py3BasePackage,python3-dev, \
-    /usr/lib/python$(PYTHON3_VERSION)/config-$(PYTHON3_VERSION) \
+    /usr/lib/python$(PYTHON3_VERSION)/config-$(PYTHON3_VERSION)-* \
     /usr/include/python$(PYTHON3_VERSION) \
     /usr/lib/pkgconfig \
        , \
diff --git a/lang/python/python3/patches/014-remove-platform-so-suffix.patch b/lang/python/python3/patches/014-remove-platform-so-suffix.patch
deleted file mode 100644 (file)
index 2acd9c8..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
---- a/configure
-+++ b/configure
-@@ -23352,7 +23352,7 @@ printf %s "checking ABIFLAGS... " >&6; }
- printf "%s\n" "$ABIFLAGS" >&6; }
- { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking SOABI" >&5
- printf %s "checking SOABI... " >&6; }
--SOABI='cpython-'`echo $VERSION | tr -d .`${ABIFLAGS}${PLATFORM_TRIPLET:+-$PLATFORM_TRIPLET}
-+SOABI='cpython-'`echo $VERSION | tr -d .`
- { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $SOABI" >&5
- printf "%s\n" "$SOABI" >&6; }
---- a/configure.ac
-+++ b/configure.ac
-@@ -5683,7 +5683,7 @@ AC_SUBST(SOABI)
- AC_MSG_CHECKING(ABIFLAGS)
- AC_MSG_RESULT($ABIFLAGS)
- AC_MSG_CHECKING(SOABI)
--SOABI='cpython-'`echo $VERSION | tr -d .`${ABIFLAGS}${PLATFORM_TRIPLET:+-$PLATFORM_TRIPLET}
-+SOABI='cpython-'`echo $VERSION | tr -d .`
- AC_MSG_RESULT($SOABI)
- # Release and debug (Py_DEBUG) ABI are compatible, but not Py_TRACE_REFS ABI
diff --git a/lang/python/python3/patches/016-adjust-config-paths.patch b/lang/python/python3/patches/016-adjust-config-paths.patch
deleted file mode 100644 (file)
index 091bd63..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
---- a/Lib/sysconfig.py
-+++ b/Lib/sysconfig.py
-@@ -461,6 +461,7 @@ def get_makefile_filename():
- def _get_sysconfigdata_name():
-+    return '_sysconfigdata'
-     multiarch = getattr(sys.implementation, '_multiarch', '')
-     return os.environ.get(
-         '_PYTHON_SYSCONFIGDATA_NAME',
---- a/Makefile.pre.in
-+++ b/Makefile.pre.in
-@@ -2111,7 +2111,7 @@ libinstall:      all $(srcdir)/Modules/xxmodu
-                       esac; \
-               done; \
-       done
--      $(INSTALL_DATA) `cat pybuilddir.txt`/_sysconfigdata_$(ABIFLAGS)_$(MACHDEP)_$(MULTIARCH).py \
-+      $(INSTALL_DATA) `cat pybuilddir.txt`/_sysconfigdata*.py \
-               $(DESTDIR)$(LIBDEST); \
-       $(INSTALL_DATA) $(srcdir)/LICENSE $(DESTDIR)$(LIBDEST)/LICENSE.txt
-       if test -d $(DESTDIR)$(LIBDEST)/distutils/tests; then \
-@@ -2273,7 +2273,7 @@ sharedinstall: all
-               --install-scripts=$(BINDIR) \
-               --install-platlib=$(DESTSHARED) \
-               --root=$(DESTDIR)/
--      -rm $(DESTDIR)$(DESTSHARED)/_sysconfigdata_$(ABIFLAGS)_$(MACHDEP)_$(MULTIARCH).py
-+      -rm $(DESTDIR)$(DESTSHARED)/_sysconfigdata*.py
-       -rm -r $(DESTDIR)$(DESTSHARED)/__pycache__
- # Here are a couple of targets for MacOSX again, to install a full
---- a/configure
-+++ b/configure
-@@ -3630,7 +3630,7 @@ fi
-     fi
-         ac_cv_prog_PYTHON_FOR_REGEN=$with_build_python
-     PYTHON_FOR_FREEZE="$with_build_python"
--    PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata_$(ABIFLAGS)_$(MACHDEP)_$(MULTIARCH) '$with_build_python
-+    PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata '$with_build_python
-     { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_build_python" >&5
- printf "%s\n" "$with_build_python" >&6; }
-@@ -23421,7 +23421,7 @@ fi
--if test x$PLATFORM_TRIPLET = x; then
-+if true ; then
-   LIBPL='$(prefix)'"/${PLATLIBDIR}/python${VERSION}/config-${LDVERSION}"
- else
-   LIBPL='$(prefix)'"/${PLATLIBDIR}/python${VERSION}/config-${LDVERSION}-${PLATFORM_TRIPLET}"
---- a/configure.ac
-+++ b/configure.ac
-@@ -162,7 +162,7 @@ AC_ARG_WITH(
-     dnl Build Python interpreter is used for regeneration and freezing.
-     ac_cv_prog_PYTHON_FOR_REGEN=$with_build_python
-     PYTHON_FOR_FREEZE="$with_build_python"
--    PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata_$(ABIFLAGS)_$(MACHDEP)_$(MULTIARCH) '$with_build_python
-+    PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata '$with_build_python
-     AC_MSG_RESULT([$with_build_python])
-   ], [
-     AS_VAR_IF([cross_compiling], [yes],
-@@ -5741,7 +5741,7 @@ fi],
- dnl define LIBPL after ABIFLAGS and LDVERSION is defined.
- AC_SUBST(PY_ENABLE_SHARED)
--if test x$PLATFORM_TRIPLET = x; then
-+if true ; then
-   LIBPL='$(prefix)'"/${PLATLIBDIR}/python${VERSION}/config-${LDVERSION}"
- else
-   LIBPL='$(prefix)'"/${PLATLIBDIR}/python${VERSION}/config-${LDVERSION}-${PLATFORM_TRIPLET}"