Message ID | 20220130090535.404853-1-james.hilliard1@gmail.com |
---|---|
State | Accepted |
Headers | show |
Series | [1/1] package/pkg-python: fix get_platform for target builds | expand |
On 30/01/2022 10:05, James Hilliard wrote: > Replicate the logic used to set _PYTHON_HOST_PLATFORM in configure.ac: > https://github.com/python/cpython/blob/v3.10.2/configure.ac#L441-L446 > > This should correctly set the sysconfig platform for cross builds: > https://github.com/python/cpython/blob/v3.10.2/Lib/sysconfig.py#L704-L706 > > Not setting this appears to cause distutils/setuptools to use the > wrong build directory names for c extensions, however this doesn't > seem to cause build or runtime errors as the installation paths still > appear to be correct for staging/target installs. > > Signed-off-by: James Hilliard <james.hilliard1@gmail.com> Applied to master, thanks. Regards, Arnout > --- > package/pkg-python.mk | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/package/pkg-python.mk b/package/pkg-python.mk > index 22ea77352c..d751311791 100644 > --- a/package/pkg-python.mk > +++ b/package/pkg-python.mk > @@ -20,6 +20,13 @@ > # > ################################################################################ > > +ifeq ($(BR2_arm)$(BR2_armeb),y) > +PKG_PYTHON_ARCH = arm > +else > +PKG_PYTHON_ARCH = $(ARCH) > +endif > +PKG_PYTHON_HOST_PLATFORM = linux-$(PKG_PYTHON_ARCH) > + > # basename does not evaluate if a file exists, so we must check to ensure > # the _sysconfigdata__linux_*.py file exists. The "|| true" is added to return > # an empty string if the file does not exist. > @@ -33,6 +40,7 @@ PKG_PYTHON_DISTUTILS_ENV = \ > LDSHARED="$(TARGET_CROSS)gcc -shared" \ > PYTHONPATH="$(if $(BR2_PACKAGE_PYTHON3),$(PYTHON3_PATH),$(PYTHON_PATH))" \ > PYTHONNOUSERSITE=1 \ > + _PYTHON_HOST_PLATFORM="$(PKG_PYTHON_HOST_PLATFORM)" \ > _PYTHON_SYSCONFIGDATA_NAME="$(PKG_PYTHON_SYSCONFIGDATA_NAME)" \ > _python_sysroot=$(STAGING_DIR) \ > _python_prefix=/usr \ > @@ -60,6 +68,7 @@ HOST_PKG_PYTHON_DISTUTILS_INSTALL_OPTS = \ > > # Target setuptools-based packages > PKG_PYTHON_SETUPTOOLS_ENV = \ > + _PYTHON_HOST_PLATFORM="$(PKG_PYTHON_HOST_PLATFORM)" \ > _PYTHON_SYSCONFIGDATA_NAME="$(PKG_PYTHON_SYSCONFIGDATA_NAME)" \ > PATH=$(BR_PATH) \ > $(TARGET_CONFIGURE_OPTS) \
diff --git a/package/pkg-python.mk b/package/pkg-python.mk index 22ea77352c..d751311791 100644 --- a/package/pkg-python.mk +++ b/package/pkg-python.mk @@ -20,6 +20,13 @@ # ################################################################################ +ifeq ($(BR2_arm)$(BR2_armeb),y) +PKG_PYTHON_ARCH = arm +else +PKG_PYTHON_ARCH = $(ARCH) +endif +PKG_PYTHON_HOST_PLATFORM = linux-$(PKG_PYTHON_ARCH) + # basename does not evaluate if a file exists, so we must check to ensure # the _sysconfigdata__linux_*.py file exists. The "|| true" is added to return # an empty string if the file does not exist. @@ -33,6 +40,7 @@ PKG_PYTHON_DISTUTILS_ENV = \ LDSHARED="$(TARGET_CROSS)gcc -shared" \ PYTHONPATH="$(if $(BR2_PACKAGE_PYTHON3),$(PYTHON3_PATH),$(PYTHON_PATH))" \ PYTHONNOUSERSITE=1 \ + _PYTHON_HOST_PLATFORM="$(PKG_PYTHON_HOST_PLATFORM)" \ _PYTHON_SYSCONFIGDATA_NAME="$(PKG_PYTHON_SYSCONFIGDATA_NAME)" \ _python_sysroot=$(STAGING_DIR) \ _python_prefix=/usr \ @@ -60,6 +68,7 @@ HOST_PKG_PYTHON_DISTUTILS_INSTALL_OPTS = \ # Target setuptools-based packages PKG_PYTHON_SETUPTOOLS_ENV = \ + _PYTHON_HOST_PLATFORM="$(PKG_PYTHON_HOST_PLATFORM)" \ _PYTHON_SYSCONFIGDATA_NAME="$(PKG_PYTHON_SYSCONFIGDATA_NAME)" \ PATH=$(BR_PATH) \ $(TARGET_CONFIGURE_OPTS) \
Replicate the logic used to set _PYTHON_HOST_PLATFORM in configure.ac: https://github.com/python/cpython/blob/v3.10.2/configure.ac#L441-L446 This should correctly set the sysconfig platform for cross builds: https://github.com/python/cpython/blob/v3.10.2/Lib/sysconfig.py#L704-L706 Not setting this appears to cause distutils/setuptools to use the wrong build directory names for c extensions, however this doesn't seem to cause build or runtime errors as the installation paths still appear to be correct for staging/target installs. Signed-off-by: James Hilliard <james.hilliard1@gmail.com> --- package/pkg-python.mk | 9 +++++++++ 1 file changed, 9 insertions(+)