From 60aa067d74e41a7a598eb7ac44978f84d77a0eae Mon Sep 17 00:00:00 2001 From: James Hilliard Date: Thu, 28 Apr 2022 16:17:25 -0600 Subject: [PATCH] package/pkg-python: deduplicate common env/opts variables There are many varibles shared via setuptools, distutils and pep517, combine those common env/opts variables to make them easier to maintain. Signed-off-by: James Hilliard Signed-off-by: Arnout Vandecappelle (Essensium/Mind) --- package/pkg-python.mk | 98 +++++++++++++++++++------------------------ 1 file changed, 44 insertions(+), 54 deletions(-) diff --git a/package/pkg-python.mk b/package/pkg-python.mk index e9de5cb8d3..b86e12423f 100644 --- a/package/pkg-python.mk +++ b/package/pkg-python.mk @@ -33,78 +33,77 @@ PKG_PYTHON_HOST_PLATFORM = linux-$(PKG_PYTHON_ARCH) PKG_PYTHON_SYSCONFIGDATA_PATH = $(PYTHON3_PATH)/_sysconfigdata__linux_*.py PKG_PYTHON_SYSCONFIGDATA_NAME = `{ [ -e $(PKG_PYTHON_SYSCONFIGDATA_PATH) ] && basename $(PKG_PYTHON_SYSCONFIGDATA_PATH) .py; } || true` -# Target distutils-based packages -PKG_PYTHON_DISTUTILS_ENV = \ - PATH=$(BR_PATH) \ - $(TARGET_CONFIGURE_OPTS) \ - LDSHARED="$(TARGET_CROSS)gcc -shared" \ - PYTHONPATH="$(PYTHON3_PATH)" \ - PYTHONNOUSERSITE=1 \ - SETUPTOOLS_USE_DISTUTILS=stdlib \ +# Target python packages +PKG_PYTHON_ENV = \ _PYTHON_HOST_PLATFORM="$(PKG_PYTHON_HOST_PLATFORM)" \ _PYTHON_PROJECT_BASE="$(PYTHON3_DIR)" \ _PYTHON_SYSCONFIGDATA_NAME="$(PKG_PYTHON_SYSCONFIGDATA_NAME)" \ + PATH=$(BR_PATH) \ + $(TARGET_CONFIGURE_OPTS) \ + PYTHONPATH="$(PYTHON3_PATH)" \ + PYTHONNOUSERSITE=1 \ _python_sysroot=$(STAGING_DIR) \ _python_prefix=/usr \ _python_exec_prefix=/usr +# Host python packages +HOST_PKG_PYTHON_ENV = \ + PATH=$(BR_PATH) \ + PYTHONNOUSERSITE=1 \ + $(HOST_CONFIGURE_OPTS) + +# Target distutils-based packages +PKG_PYTHON_DISTUTILS_ENV = \ + $(PKG_PYTHON_ENV) \ + LDSHARED="$(TARGET_CROSS)gcc -shared" \ + SETUPTOOLS_USE_DISTUTILS=stdlib \ + PKG_PYTHON_DISTUTILS_BUILD_OPTS = \ --executable=/usr/bin/python -PKG_PYTHON_DISTUTILS_INSTALL_TARGET_OPTS = \ +PKG_PYTHON_DISTUTILS_INSTALL_OPTS = \ --install-headers=/usr/include/python$(PYTHON3_VERSION_MAJOR) \ - --prefix=/usr \ + --prefix=/usr + +PKG_PYTHON_DISTUTILS_INSTALL_TARGET_OPTS = \ + $(PKG_PYTHON_DISTUTILS_INSTALL_OPTS) \ --root=$(TARGET_DIR) PKG_PYTHON_DISTUTILS_INSTALL_STAGING_OPTS = \ - --install-headers=/usr/include/python$(PYTHON3_VERSION_MAJOR) \ - --prefix=/usr \ + $(PKG_PYTHON_DISTUTILS_INSTALL_OPTS) \ --root=$(STAGING_DIR) # Host distutils-based packages HOST_PKG_PYTHON_DISTUTILS_ENV = \ - PATH=$(BR_PATH) \ - PYTHONNOUSERSITE=1 \ - SETUPTOOLS_USE_DISTUTILS=stdlib \ - $(HOST_CONFIGURE_OPTS) + $(HOST_PKG_PYTHON_ENV) \ + SETUPTOOLS_USE_DISTUTILS=stdlib HOST_PKG_PYTHON_DISTUTILS_INSTALL_OPTS = \ --prefix=$(HOST_DIR) # Target setuptools-based packages PKG_PYTHON_SETUPTOOLS_ENV = \ - _PYTHON_HOST_PLATFORM="$(PKG_PYTHON_HOST_PLATFORM)" \ - _PYTHON_PROJECT_BASE="$(PYTHON3_DIR)" \ - _PYTHON_SYSCONFIGDATA_NAME="$(PKG_PYTHON_SYSCONFIGDATA_NAME)" \ - PATH=$(BR_PATH) \ - $(TARGET_CONFIGURE_OPTS) \ - PYTHONPATH="$(PYTHON3_PATH)" \ - PYTHONNOUSERSITE=1 \ - SETUPTOOLS_USE_DISTUTILS=stdlib \ - _python_sysroot=$(STAGING_DIR) \ - _python_prefix=/usr \ - _python_exec_prefix=/usr + $(PKG_PYTHON_ENV) \ + SETUPTOOLS_USE_DISTUTILS=stdlib -PKG_PYTHON_SETUPTOOLS_INSTALL_TARGET_OPTS = \ +PKG_PYTHON_SETUPTOOLS_INSTALL_OPTS = \ --install-headers=/usr/include/python$(PYTHON3_VERSION_MAJOR) \ --prefix=/usr \ --executable=/usr/bin/python \ - --single-version-externally-managed \ + --single-version-externally-managed + +PKG_PYTHON_SETUPTOOLS_INSTALL_TARGET_OPTS = \ + $(PKG_PYTHON_SETUPTOOLS_INSTALL_OPTS) \ --root=$(TARGET_DIR) PKG_PYTHON_SETUPTOOLS_INSTALL_STAGING_OPTS = \ - --install-headers=/usr/include/python$(PYTHON3_VERSION_MAJOR) \ - --prefix=/usr \ - --executable=/usr/bin/python \ - --single-version-externally-managed \ + $(PKG_PYTHON_SETUPTOOLS_INSTALL_OPTS) \ --root=$(STAGING_DIR) # Host setuptools-based packages HOST_PKG_PYTHON_SETUPTOOLS_ENV = \ - PATH=$(BR_PATH) \ - PYTHONNOUSERSITE=1 \ - SETUPTOOLS_USE_DISTUTILS=stdlib \ - $(HOST_CONFIGURE_OPTS) + $(HOST_PKG_PYTHON_ENV) \ + SETUPTOOLS_USE_DISTUTILS=stdlib HOST_PKG_PYTHON_SETUPTOOLS_INSTALL_OPTS = \ --prefix=$(HOST_DIR) \ @@ -113,28 +112,21 @@ HOST_PKG_PYTHON_SETUPTOOLS_INSTALL_OPTS = \ # Target pep517-based packages PKG_PYTHON_PEP517_ENV = \ - _PYTHON_HOST_PLATFORM="$(PKG_PYTHON_HOST_PLATFORM)" \ - _PYTHON_PROJECT_BASE="$(PYTHON3_DIR)" \ - _PYTHON_SYSCONFIGDATA_NAME="$(PKG_PYTHON_SYSCONFIGDATA_NAME)" \ - PATH=$(BR_PATH) \ - $(TARGET_CONFIGURE_OPTS) \ - PYTHONPATH="$(PYTHON3_PATH)" \ - PYTHONNOUSERSITE=1 \ - _python_sysroot=$(STAGING_DIR) \ - _python_prefix=/usr \ - _python_exec_prefix=/usr + $(PKG_PYTHON_ENV) + +PKG_PYTHON_PEP517_INSTALL_OPTS = \ + --interpreter=/usr/bin/python \ + --script-kind=posix PKG_PYTHON_PEP517_INSTALL_TARGET_OPTS = \ - --interpreter=/usr/bin/python \ - --script-kind=posix \ + $(PKG_PYTHON_PEP517_INSTALL_OPTS) \ --purelib=$(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/site-packages \ --headers=$(TARGET_DIR)/usr/include/python$(PYTHON3_VERSION_MAJOR) \ --scripts=$(TARGET_DIR)/usr/bin \ --data=$(TARGET_DIR)/usr PKG_PYTHON_PEP517_INSTALL_STAGING_OPTS = \ - --interpreter=/usr/bin/python \ - --script-kind=posix \ + $(PKG_PYTHON_PEP517_INSTALL_OPTS) \ --purelib=$(STAGING_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/site-packages \ --headers=$(STAGING_DIR)/usr/include/python$(PYTHON3_VERSION_MAJOR) \ --scripts=$(STAGING_DIR)/usr/bin \ @@ -142,9 +134,7 @@ PKG_PYTHON_PEP517_INSTALL_STAGING_OPTS = \ # Host pep517-based packages HOST_PKG_PYTHON_PEP517_ENV = \ - PATH=$(BR_PATH) \ - PYTHONNOUSERSITE=1 \ - $(HOST_CONFIGURE_OPTS) + $(HOST_PKG_PYTHON_ENV) HOST_PKG_PYTHON_PEP517_BOOTSTRAP_INSTALL_OPTS = \ --installdir=$(HOST_DIR)/lib/python$(PYTHON3_VERSION_MAJOR)/site-packages