From 8b4f831f36cd653504f38023f909f76912730534 Mon Sep 17 00:00:00 2001 From: James Hilliard Date: Sun, 24 Apr 2022 15:39:54 -0600 Subject: [PATCH] package/pkg-python: migrate flit to new bootstrapping sequence There are a number of flit toolchain dependencies currently in the process of deprecating distutils based fallbacks. This will be needed in order to update tomli. We need to migrate these to use a new bootstrap based build+install sequence which relies on flit's bootstrap wheel build+install features to build and install host-python-pypa-build and host-python-installer which gives us a full pep517 toolchain. Note that one can run host-python-flit-core commands for building and installing itself since the package build directory is the cwd. We need to add a special flit-bootstrap SETUP_TYPE for dependencies of host-python-pypa-build and host-python-installer which can not use the normal flit SETUP_TYPE which would cause a circular dependency issue. To avoid further special casing for host-python-flit-core and host-python-installer, we add two additional changes: - _BASE_INSTALL_CMD is set with ?=, so it can be overridden by the package; - No _DEPENDENCIES are added for host-python-flit-core and host-python-installer, to avoid circular dependencies. These two are responsible for their own dependencies. Although flit-bootstrap _BASE_ variables are almost identical to the flit/pep517 variables, only _BASE_ENV is really identical. To make things easier to understand, treat flit-bootstrap as a completely separate SETUP_TYPE. This also allows us to check that it is only used for host packages. Signed-off-by: James Hilliard Cc: "Yann E. MORIN" Cc: Arnout Vandecappelle [Arnout: simplify things by delegating some special casing to the packages themselves; add check that it's only for host.] Signed-off-by: Arnout Vandecappelle (Essensium/Mind) --- package/pkg-python.mk | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/package/pkg-python.mk b/package/pkg-python.mk index 867341fc7b..464578a35c 100644 --- a/package/pkg-python.mk +++ b/package/pkg-python.mk @@ -154,6 +154,9 @@ HOST_PKG_PYTHON_PEP517_INSTALL_OPTS = \ --scripts=$(HOST_DIR)/bin \ --data=$(HOST_DIR) +HOST_PKG_PYTHON_PEP517_BOOTSTRAP_INSTALL_OPTS = \ + --installdir=$(HOST_DIR)/lib/python$(PYTHON3_VERSION_MAJOR)/site-packages + ################################################################################ # inner-python-package -- defines how the configuration, compilation # and installation of a Python package should be done, implements a @@ -214,6 +217,14 @@ $(2)_BASE_ENV = $$(HOST_PKG_PYTHON_PEP517_ENV) $(2)_BASE_BUILD_CMD = -m build -n -w $(2)_BASE_INSTALL_CMD = $(TOPDIR)/support/scripts/pyinstaller.py dist/* $$(HOST_PKG_PYTHON_PEP517_INSTALL_OPTS) endif +else ifeq ($$($(2)_SETUP_TYPE),flit-bootstrap) +ifeq ($(4),target) +$$(error flit-bootstrap setup type only supported for host packages) +else +$(2)_BASE_ENV = $$(HOST_PKG_PYTHON_PEP517_ENV) +$(2)_BASE_BUILD_CMD = -m flit_core.wheel +$(2)_BASE_INSTALL_CMD ?= $(TOPDIR)/support/scripts/pyinstaller.py dist/* $$(HOST_PKG_PYTHON_PEP517_INSTALL_OPTS) +endif else $$(error "Invalid $(2)_SETUP_TYPE. Valid options are 'distutils', 'setuptools', 'pep517' or 'flit'.") endif @@ -239,6 +250,10 @@ $(2)_DEPENDENCIES += host-python-pypa-build host-python-installer ifeq ($$($(2)_SETUP_TYPE),flit) $(2)_DEPENDENCIES += host-python-flit-core endif +else ifeq ($$($(2)_SETUP_TYPE),flit-bootstrap) +ifeq ($$(filter host-python-flit-core host-python-installer,$(1)),) +$(2)_DEPENDENCIES += host-python-flit-core host-python-installer +endif endif # SETUP_TYPE # Python interpreter to use for building the package.