python3: Add Py3Build/InstallBuildDepends recipe
authorJeffery To <jeffery.to@gmail.com>
Mon, 7 Mar 2022 13:29:56 +0000 (21:29 +0800)
committerRosen Penev <rosenp@gmail.com>
Thu, 17 Mar 2022 18:38:19 +0000 (11:38 -0700)
This adds a recipe, Py3Build/InstallBuildDepends, that installs the
requirements listed in HOST_PYTHON3_PACKAGE_BUILD_DEPENDS. This allows
other (non-Python) packages to install host Python packages by calling
this recipe, without having to know the internals of python3-package.mk.

This also updates apparmor to call this recipe.

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
lang/python/README.md
lang/python/python3-package.mk
utils/apparmor/Makefile

index 5681cb5d35d027bd6d6a34aba7ac292233435d36..2a05d3c00a5df348440001239548a70e06cc491b 100644 (file)
@@ -369,3 +369,30 @@ HOST_PYTHON3_PACKAGE_BUILD_DEPENDS:=setuptools-scm
 ```
 
 The Python package will be installed in `$(STAGING_DIR_HOSTPKG)/lib/pythonX.Y/site-packages`.
+
+#### Non-Python packages installing host-side Python packages
+
+Non-Python packages can also install host-side Python packages using the same mechanism:
+
+* Set `HOST_PYTHON3_PACKAGE_BUILD_DEPENDS` (see above for details).
+
+* Include `python3-package.mk` (set `PYTHON3_PKG_BUILD:=0` to avoid using the default Python package build recipes).
+
+* Call `Py3Build/InstallBuildDepends` to initiate the installation.
+
+For example:
+
+```
+PYTHON3_PKG_BUILD:=0
+HOST_PYTHON3_PACKAGE_BUILD_DEPENDS:=setuptools-scm
+
+include $(INCLUDE_DIR)/package.mk
+include ../../lang/python/python3-package.mk
+# If outside of the packages feed:
+# include $(TOPDIR)/feeds/packages/lang/python/python3-package.mk
+
+define Build/Compile
+       $(call Py3Build/InstallBuildDepends)
+       $(call Build/Compile/Default)
+endef
+```
index 20c8ca58ae71e0ee11d3431d8b86153412846ac5..c2617f69ce877f84e6037f8db48b5081c809e85b 100644 (file)
@@ -215,10 +215,14 @@ define Py3Build/CheckHostPipVersionMatch
 endef
 endif
 
-define Py3Build/Compile/Default
+define Py3Build/InstallBuildDepends
        $(if $(PYTHON3_PKG_HOST_PIP_INSTALL_ARGS), \
                $(call HostPython3/PipInstall,$(PYTHON3_PKG_HOST_PIP_INSTALL_ARGS)) \
        )
+endef
+
+define Py3Build/Compile/Default
+       $(call Py3Build/InstallBuildDepends)
        $(call Python3/ModSetup, \
                $(PYTHON3_PKG_SETUP_DIR), \
                $(PYTHON3_PKG_SETUP_GLOBAL_ARGS) \
index 3073fb605115745a9aab988896eafc4d98bdbd3d..a77a17b8006aae2dddc24ffd5a73522e6d45381f 100644 (file)
@@ -132,9 +132,7 @@ endef
 
 define Build/Install
        # Make sure we have python's setup tools installed
-       $(if $(PYTHON3_PKG_HOST_PIP_INSTALL_ARGS), \
-               $(call HostPython3/PipInstall,$(PYTHON3_PKG_HOST_PIP_INSTALL_ARGS)) \
-       )
+       $(call Py3Build/InstallBuildDepends)
        $(INSTALL_DIR) $(PKG_INSTALL_DIR)-libapparmor $(PKG_INSTALL_DIR)-utils $(PKG_INSTALL_DIR)-profiles
        # Installing libapparmor
        +$(MAKE_VARS) PYTHON=$(HOST_PYTHON) VERSION=$(PYTHON3_VERSION) \