diff options
| author | Jeffery To <jeffery.to@gmail.com> | 2023-05-10 12:11:07 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-10 12:11:07 +0800 |
| commit | 8a36b03870fd2f6b75b8890ce912660e00ccade8 (patch) | |
| tree | 5e03f31c967408fe8ce0e7e3d470f4d5eb0a3863 /lang/python/python3-package.mk | |
| parent | 83dd66fd34792c692a477c2ed8430f81802d8f22 (diff) | |
| parent | b1b008f42ff0a6da96b801e2eaf68be4e2f2b5bb (diff) | |
Merge pull request #20801 from jefferyto/python-pyproject
python: Add proper support for pyproject.toml-based builds, update Python packages for new build process
Diffstat (limited to 'lang/python/python3-package.mk')
| -rw-r--r-- | lang/python/python3-package.mk | 90 |
1 files changed, 66 insertions, 24 deletions
diff --git a/lang/python/python3-package.mk b/lang/python/python3-package.mk index f2336b8fc..d5d4f8a0f 100644 --- a/lang/python/python3-package.mk +++ b/lang/python/python3-package.mk @@ -56,18 +56,6 @@ define Python3/Run $(HOST_PYTHON3_BIN) $(2) endef -# $(1) => build subdir -# $(2) => additional arguments to setup.py -# $(3) => additional variables -define Python3/ModSetup - $(INSTALL_DIR) $(PKG_INSTALL_DIR)/$(PYTHON3_PKG_DIR) - $(call SetupPyShim,$(PKG_BUILD_DIR)/$(strip $(1))) - $(call Python3/Run, \ - $(PKG_BUILD_DIR)/$(strip $(1)), \ - setup.py $(2), \ - $(3) PY_PKG_VERSION=$(PKG_VERSION)) -endef - define Python3/FixShebang $(SED) "1"'!'"b;s,^#"'!'".*python.*,#"'!'"/usr/bin/python3," -i --follow-symlinks $(1) endef @@ -189,10 +177,26 @@ endef # Py3Build -PYTHON3_PKG_SETUP_DIR ?= -PYTHON3_PKG_SETUP_GLOBAL_ARGS ?= -PYTHON3_PKG_SETUP_ARGS ?= --single-version-externally-managed -PYTHON3_PKG_SETUP_VARS ?= +PYTHON3_PKG_BUILD?=1 +PYTHON3_PKG_FORCE_DISTUTILS_SETUP?= + +PYTHON3_PKG_SETUP_DIR?= +PYTHON3_PKG_SETUP_GLOBAL_ARGS?= +PYTHON3_PKG_SETUP_ARGS?=--single-version-externally-managed +PYTHON3_PKG_SETUP_VARS?= + +PYTHON3_PKG_BUILD_CONFIG_SETTINGS?= +PYTHON3_PKG_BUILD_VARS?=$(PYTHON3_PKG_SETUP_VARS) +PYTHON3_PKG_BUILD_ARGS?= +PYTHON3_PKG_BUILD_PATH?=$(PYTHON3_PKG_SETUP_DIR) + +PYTHON3_PKG_INSTALL_VARS?= + +PYTHON3_PKG_WHEEL_NAME?=$(subst -,_,$(if $(PYPI_SOURCE_NAME),$(PYPI_SOURCE_NAME),$(PKG_NAME))) +PYTHON3_PKG_WHEEL_VERSION?=$(PKG_VERSION) + +PYTHON3_PKG_BUILD_DIR?=$(PKG_BUILD_DIR)/$(PYTHON3_PKG_BUILD_PATH) + PYTHON3_PKG_HOST_PIP_INSTALL_ARGS = \ $(foreach req,$(HOST_PYTHON3_PACKAGE_BUILD_DEPENDS), \ @@ -224,21 +228,58 @@ define Py3Build/InstallBuildDepends ) endef -define Py3Build/Compile/Default +define Py3Build/Compile/Distutils $(call Py3Build/InstallBuildDepends) - $(call Python3/ModSetup, \ - $(PYTHON3_PKG_SETUP_DIR), \ - $(PYTHON3_PKG_SETUP_GLOBAL_ARGS) \ - install --prefix="/usr" --root="$(PKG_INSTALL_DIR)" \ - $(PYTHON3_PKG_SETUP_ARGS), \ + $(INSTALL_DIR) $(PKG_INSTALL_DIR)/$(PYTHON3_PKG_DIR) + $(call Python3/Run, \ + $(PKG_BUILD_DIR)/$(strip $(PYTHON3_PKG_SETUP_DIR)), \ + setup.py \ + $(PYTHON3_PKG_SETUP_GLOBAL_ARGS) \ + install \ + --prefix="/usr" \ + --root="$(PKG_INSTALL_DIR)" \ + $(PYTHON3_PKG_SETUP_ARGS) \ + , \ $(PYTHON3_PKG_SETUP_VARS) \ ) endef -Py3Build/Configure=$(Py3Build/Configure/Default) +define Py3Build/Compile/Default + $(call Py3Build/InstallBuildDepends) + $(call Python3/Run, \ + $(PKG_BUILD_DIR), \ + -m build \ + --no-isolation \ + --outdir "$(PYTHON3_PKG_BUILD_DIR)"/openwrt-build \ + --wheel \ + $(foreach setting,$(PYTHON3_PKG_BUILD_CONFIG_SETTINGS),--config-setting=$(setting)) \ + $(PYTHON3_PKG_BUILD_ARGS) \ + "$(PYTHON3_PKG_BUILD_DIR)" \ + , \ + $(PYTHON3_PKG_BUILD_VARS) \ + ) +endef + +define Py3Build/Install/Default + $(call Python3/Run, \ + $(PKG_BUILD_DIR), \ + -m installer \ + --destdir "$(PKG_INSTALL_DIR)" \ + --no-compile-bytecode \ + --prefix /usr \ + "$(PYTHON3_PKG_BUILD_DIR)"/openwrt-build/$(PYTHON3_PKG_WHEEL_NAME)-$(PYTHON3_PKG_WHEEL_VERSION)-*.whl \ + , \ + $(PYTHON3_PKG_INSTALL_VARS) \ + ) +endef + Py3Build/Compile=$(Py3Build/Compile/Default) +Py3Build/Install=$(Py3Build/Install/Default) -PYTHON3_PKG_BUILD ?= 1 +ifeq ($(strip $(PYTHON3_PKG_FORCE_DISTUTILS_SETUP)),1) + Py3Build/Compile=$(Py3Build/Compile/Distutils) + Py3Build/Install:=: +endif ifeq ($(strip $(PYTHON3_PKG_BUILD)),1) ifeq ($(PY3),stdlib) @@ -246,4 +287,5 @@ ifeq ($(strip $(PYTHON3_PKG_BUILD)),1) endif Hooks/Configure/Post+=Py3Build/CheckHostPipVersionMatch Build/Compile=$(Py3Build/Compile) + Build/Install=$(Py3Build/Install) endif |
