python3: Use default _PYTHON_HOST_PLATFORM
authorJeffery To <redacted>
Wed, 8 Jul 2020 08:02:49 +0000 (16:02 +0800)
committerJeffery To <redacted>
Wed, 8 Jul 2020 09:11:42 +0000 (17:11 +0800)
This lets the Python build process set _PYTHON_HOST_PLATFORM instead of
forcing an explicit value.

Also:

* Save the target _PYTHON_HOST_PLATFORM value during Build/InstallDev
  for use when building target Python packages (in python3-package.mk).

* Use the (mostly) default PYTHON_FOR_BUILD value, instead patch
  configure to remove the platform triplet from the sysconfigdata file
  name.

* Remove the "CROSS_COMPILE=yes" make variable (there is no indication
  that this variable is necessary).

* Force host pip to build packages from source instead of downloading
  binary wheels.

  Previously, host pip can download universal (platform-independent)
  wheels but not platform-specific wheels, because of the custom
  _PYTHON_HOST_PLATFORM value. (Packages that do not have universal
  wheels would be compiled from source.)

  With a correct _PYTHON_HOST_PLATFORM, host pip can install
  platform-specific wheels as well. However, the pre-built shared object
  (.so) files in these wheels will have the host's platform triplet in
  their file names. When target Python packages are built (using the
  target's _PYTHON_HOST_PLATFORM), Python will not use these shared
  object files.

  By forcing host pip to build packages from source, the built shared
  object files will not have the platform triplet in their file names.
  (Host Python has been patched to remove the platform triplet from file
  names.) This allows these packages to be used when building target
  Python packages.

  (The net effect of this complete change is that platform-dependent
  packages will continue to be compiled from source, while
  platform-independent packages will now also be compiled from source.)

Signed-off-by: Jeffery To <redacted>
lang/python/python3-host.mk
lang/python/python3-package.mk
lang/python/python3/Makefile
lang/python/python3/patches/016-adjust-config-paths.patch

index 81b0025b1770af8d953e2d7773a99859b7981354..567b56d59add0b5e4ee0024f64ed21783fc27e4c 100644 (file)
@@ -32,7 +32,6 @@ HOST_PYTHON3_VARS = \
        CFLAGS="$(HOST_CFLAGS)" \
        CPPFLAGS="$(HOST_CPPFLAGS) -I$(HOST_PYTHON3_INC_DIR)" \
        LDFLAGS="$(HOST_LDFLAGS) -lpython$(PYTHON3_VERSION) -Wl$(comma)-rpath=$(STAGING_DIR_HOSTPKG)/lib" \
-       _PYTHON_HOST_PLATFORM=linux2 \
        PYTHONPATH="$(HOST_PYTHON3PATH)" \
        PYTHONDONTWRITEBYTECODE=0 \
        PYTHONOPTIMIZE=""
@@ -57,6 +56,7 @@ define HostPython3/PipInstall
                --disable-pip-version-check \
                --cache-dir "$(DL_DIR)/pip-cache" \
                install \
+               --no-binary :all: \
                $(1)
 endef
 
index fdf2cb0ae97da1ac2516db74e0c56322c1e76ebc..36f4ab07e25b339c742b75640326a30a9540e921 100644 (file)
@@ -20,6 +20,8 @@ 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
+
 # These configure args are needed in detection of path to Python header files
 # using autotools.
 CONFIGURE_ARGS += \
@@ -36,7 +38,7 @@ PYTHON3_VARS = \
        CFLAGS="$(TARGET_CFLAGS)" \
        CPPFLAGS="$(TARGET_CPPFLAGS) -I$(PYTHON3_INC_DIR)" \
        LDFLAGS="$(TARGET_LDFLAGS) -lpython$(PYTHON3_VERSION)" \
-       _PYTHON_HOST_PLATFORM=linux2 \
+       _PYTHON_HOST_PLATFORM="$(_PYTHON_HOST_PLATFORM)" \
        __PYVENV_LAUNCHER__="/usr/bin/$(PYTHON3)" \
        PYTHONPATH="$(PYTHON3PATH)" \
        PYTHONDONTWRITEBYTECODE=1 \
index 87c401842752756c7b73474f21c9723d5becaed6..e3769e501822f4df9e06e7f2d6d1559c329650ab 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
@@ -129,7 +129,6 @@ TARGET_CONFIGURE_OPTS+= \
        READELF="$(TARGET_CROSS)readelf"
 
 MAKE_FLAGS+=\
-       CROSS_COMPILE=yes \
        LD="$(TARGET_CC)"
 
 EXTRA_CFLAGS+= \
@@ -137,13 +136,6 @@ EXTRA_CFLAGS+= \
 EXTRA_LDFLAGS+= \
        -L$(PKG_BUILD_DIR)
 
-PYTHON_FOR_BUILD:= \
-       _PYTHON_PROJECT_BASE=$(PKG_BUILD_DIR) \
-       _PYTHON_HOST_PLATFORM=linux2 \
-       PYTHONPATH="$(PKG_BUILD_DIR)/Lib:$(PKG_BUILD_DIR)/build/lib.linux2-$(PYTHON3_VERSION)" \
-       _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata \
-       $(HOST_PYTHON3_BIN)
-
 DISABLE_BLUETOOTH:= \
        ac_cv_header_bluetooth_bluetooth_h=no \
        ac_cv_header_bluetooth_h=no
@@ -159,7 +151,6 @@ CONFIGURE_ARGS+= \
        $(if $(findstring mips,$(CONFIG_ARCH)),,--with-lto) \
        CONFIG_SITE="$(PKG_BUILD_DIR)/config.site" \
        OPT="$(TARGET_CFLAGS)" \
-       PYTHON_FOR_BUILD="$(PYTHON_FOR_BUILD)" \
        $(if $(CONFIG_PYTHON3_BLUETOOTH_SUPPORT),,$(DISABLE_BLUETOOTH))
 
 define Build/Prepare
@@ -220,6 +211,10 @@ define Build/InstallDev
                $(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
        $(CP) \
                $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/python*.pc \
                $(1)/usr/lib/pkgconfig
index 849346dc757a2d90cc6390e43bf7296da229ac3c..aa9f49e5c3ee24bbdbc893c1c6236da736647efc 100644 (file)
  # Here are a couple of targets for MacOSX again, to install a full
 --- a/configure
 +++ b/configure
+@@ -2951,7 +2951,7 @@ $as_echo_n "checking for python interpre
+       fi
+         { $as_echo "$as_me:${as_lineno-$LINENO}: result: $interp" >&5
+ $as_echo "$interp" >&6; }
+-      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) '$interp
++      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 '$interp
+     fi
+ elif test "$cross_compiling" = maybe; then
+     as_fn_error $? "Cross compiling required --host=HOST-TUPLE and --build=ARCH" "$LINENO" 5
 @@ -15213,7 +15213,7 @@ else
  fi
  
    LIBPL='$(prefix)'"/lib/python${VERSION}/config-${LDVERSION}-${PLATFORM_TRIPLET}"
 --- a/configure.ac
 +++ b/configure.ac
+@@ -75,7 +75,7 @@ if test "$cross_compiling" = yes; then
+           AC_MSG_ERROR([python$PACKAGE_VERSION interpreter not found])
+       fi
+         AC_MSG_RESULT($interp)
+-      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) '$interp
++      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 '$interp
+     fi
+ elif test "$cross_compiling" = maybe; then
+     AC_MSG_ERROR([Cross compiling required --host=HOST-TUPLE and --build=ARCH])
 @@ -4688,7 +4688,7 @@ fi
  
  dnl define LIBPL after ABIFLAGS and LDVERSION is defined.
git clone https://git.99rst.org/PROJECT