summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Orling <tim.orling@konsulko.com>2024-03-01 10:19:30 -0800
committerBruce Ashfield <bruce.ashfield@gmail.com>2024-03-15 17:17:19 +0000
commit9b4acf5185324c244b62aa9e9791fa4afa0bcdb5 (patch)
tree855ca38f522360b39fe16701884ca0526328961a
parent6509f2f6e1a17894a266f14fbc72858a43687024 (diff)
downloadmeta-virtualization-9b4acf5185324c244b62aa9e9791fa4afa0bcdb5.tar.gz
criu: build and install wheels
Mimic what we do with python_pep517.bbclass in do_compile (python3 -m build) and do_install (python3 -m install) to build and install wheels and avoid the heavy handed pip install usage. FIXME: even though lib/pycriu/version.py is properly being dynamically generated, setuptools/config/expand.py is failing to detect the __version__ attr. Signed-off-by: Tim Orling <tim.orling@konsulko.com>
-rw-r--r--recipes-containers/criu/criu_git.bb44
-rw-r--r--recipes-containers/criu/files/0003-crit-pycriu-build-and-install-wheels.patch75
2 files changed, 108 insertions, 11 deletions
diff --git a/recipes-containers/criu/criu_git.bb b/recipes-containers/criu/criu_git.bb
index 7cadda24..c4539e34 100644
--- a/recipes-containers/criu/criu_git.bb
+++ b/recipes-containers/criu/criu_git.bb
@@ -19,11 +19,12 @@ PV = "3.19.0+git"
19SRC_URI = "git://github.com/checkpoint-restore/criu.git;branch=master;protocol=https \ 19SRC_URI = "git://github.com/checkpoint-restore/criu.git;branch=master;protocol=https \
20 file://0001-criu-Skip-documentation-install.patch \ 20 file://0001-criu-Skip-documentation-install.patch \
21 file://0002-criu-Change-libraries-install-directory.patch \ 21 file://0002-criu-Change-libraries-install-directory.patch \
22 file://0003-crit-pycriu-build-and-install-wheels.patch \
22 " 23 "
23 24
24COMPATIBLE_HOST = "(x86_64|arm|aarch64).*-linux" 25COMPATIBLE_HOST = "(x86_64|arm|aarch64).*-linux"
25 26
26DEPENDS += "libnl libcap protobuf-c-native protobuf-c util-linux-native libbsd libnet python3-pip-native" 27DEPENDS += "libnl libcap protobuf-c-native protobuf-c util-linux-native libbsd libnet"
27RDEPENDS:${PN} = "bash cgroup-lite" 28RDEPENDS:${PN} = "bash cgroup-lite"
28 29
29S = "${WORKDIR}/git" 30S = "${WORKDIR}/git"
@@ -40,7 +41,7 @@ EXTRA_OEMAKE:aarch64 += "ARCH=aarch64 WERROR=0"
40EXTRA_OEMAKE:append = " SBINDIR=${sbindir} LIBDIR=${libdir} INCLUDEDIR=${includedir} PIEGEN=no" 41EXTRA_OEMAKE:append = " SBINDIR=${sbindir} LIBDIR=${libdir} INCLUDEDIR=${includedir} PIEGEN=no"
41EXTRA_OEMAKE:append = " LOGROTATEDIR=${sysconfdir} SYSTEMDUNITDIR=${systemd_unitdir}" 42EXTRA_OEMAKE:append = " LOGROTATEDIR=${sysconfdir} SYSTEMDUNITDIR=${systemd_unitdir}"
42 43
43CFLAGS += "-D__USE_GNU -D_GNU_SOURCE " 44CFLAGS += "-D__USE_GNU -D_GNU_SOURCE "
44 45
45CFLAGS += " -I${STAGING_INCDIR} -I${STAGING_INCDIR}/libnl3" 46CFLAGS += " -I${STAGING_INCDIR} -I${STAGING_INCDIR}/libnl3"
46CFLAGS:arm += "-D__WORDSIZE" 47CFLAGS:arm += "-D__WORDSIZE"
@@ -53,7 +54,8 @@ export BUILD_SYS
53export HOST_SYS 54export HOST_SYS
54export HOSTCFLAGS = "${BUILD_CFLAGS}" 55export HOSTCFLAGS = "${BUILD_CFLAGS}"
55 56
56inherit setuptools3 57inherit python_setuptools_build_meta
58#inherit setuptools3
57inherit pkgconfig 59inherit pkgconfig
58 60
59B = "${S}" 61B = "${S}"
@@ -71,27 +73,47 @@ do_compile:prepend() {
71 ln -s ${PKG_CONFIG_SYSROOT_DIR}/usr/include/google/protobuf/descriptor.proto ${S}/images/google/protobuf/descriptor.proto 73 ln -s ${PKG_CONFIG_SYSROOT_DIR}/usr/include/google/protobuf/descriptor.proto ${S}/images/google/protobuf/descriptor.proto
72} 74}
73 75
76#PEP517_SOURCE_PATH ="${S}/lib"
77
78#do_compile[network] = "1"
79
74do_compile () { 80do_compile () {
75 oe_runmake FULL_PYTHON=${PYTHON} PYTHON=python3 81 #python_pep517_do_compile
82 #export PEP517_SOURCE_PATH="${S}/crit"
83 #python_pep517_do_compile
84 #oe_runmake
85 #oe_runmake #PIP_BREAK_SYSTEM_PACKAGES=1
86 export PEP517_WHEEL_PATH="${PEP517_WHEEL_PATH}"
87 oe_runmake FULL_PYTHON=${PYTHON} PYTHON=nativepython3
76} 88}
77 89
90#do_install[network] = "1"
91
78do_install () { 92do_install () {
79 export INSTALL_LIB="${libdir}/${PYTHON_DIR}/site-packages" 93 export INSTALL_LIB="${libdir}/${PYTHON_DIR}/site-packages"
80 oe_runmake PREFIX=${exec_prefix} LIBDIR=${libdir} DESTDIR="${D}" PLUGINDIR="${localstatedir}/lib" FULL_PYTHON=${PYTHON} PYTHON=python3 install 94 export PEP517_WHEEL_PATH="${PEP517_WHEEL_PATH}"
95 #oe_runmake PREFIX=${exec_prefix} LIBDIR=${libdir} DESTDIR="${D}" PLUGINDIR="${localstatedir}/lib" PIP_BREAK_SYSTEM_PACKAGES=1 install
96 oe_runmake PREFIX=${exec_prefix} LIBDIR=${libdir} DESTDIR="${D}" PLUGINDIR="${localstatedir}/lib" FULL_PYTHON=${PYTHON} PYTHON=nativepython3 install
81 97
82 # python3's distutils has a feature of rewriting the interpeter on setup installed 98 # python3's distutils has a feature of rewriting the interpeter on setup installed
83 # scripts. 'crit' is one of those scripts. The "executable" or "e" option to the 99 # scripts. 'crit' is one of those scripts. The "executable" or "e" option to the
84 # setup call should fix it, but it is being ignored. So to avoid getting our native 100 # setup call should fix it, but it is being ignored. So to avoid getting our native
85 # intepreter replaced in the script, we'll do an explicit update ourselves. 101 # intepreter replaced in the script, we'll do an explicit update ourselves.
86 sed -i 's%^\#\!.*%\#\!/usr/bin/env python3%' ${D}/usr/bin/crit ${D}${libdir}/python3*/site-packages/crit-*-py3*.egg/EGG-INFO/scripts/crit 102 #
87 103 # we're building wheels now, so EGG-INFO need not apply
88 rm -rf ${D}/__pycache__ 104 #sed -i 's%^\#\!.*%\#\!/usr/bin/env python3%' ${D}/usr/bin/crit ${D}${libdir}/python3*/site-packages/crit-*-py3*.egg/EGG-INFO/scripts/crit
105
106 # all the __pycache__ contains references to TMPDIR and these will be built the first time
107 # it runs on the target anyway
108 for pycachedir in $(find ${D} -name __pycache__); do
109 rm -rf $pycachedir
110 done
89} 111}
90 112
91FILES:${PN} += "${systemd_unitdir}/ \ 113FILES:${PN} += "${systemd_unitdir}/ \
92 ${libdir}/python3*/site-packages/ \ 114 #${libdir}/python3*/site-packages/ \
93 ${libdir}/pycriu/ \ 115 #${libdir}/pycriu/ \
94 ${libdir}/crit-0.0.1-py3*.egg-info \ 116 #${libdir}/crit-0.0.1-py3*.egg-info \
95 " 117 "
96 118
97FILES:${PN}-staticdev += " \ 119FILES:${PN}-staticdev += " \
diff --git a/recipes-containers/criu/files/0003-crit-pycriu-build-and-install-wheels.patch b/recipes-containers/criu/files/0003-crit-pycriu-build-and-install-wheels.patch
new file mode 100644
index 00000000..2da96f44
--- /dev/null
+++ b/recipes-containers/criu/files/0003-crit-pycriu-build-and-install-wheels.patch
@@ -0,0 +1,75 @@
1From 40d2f0735d668dca893a5f0e787f1f11af74cf25 Mon Sep 17 00:00:00 2001
2From: Tim Orling <tim.orling@konsulko.com>
3Date: Fri, 1 Mar 2024 22:22:37 -0800
4Subject: [PATCH] crit/pycriu: build and install wheels
5
6Rather than using heavy handed pip (which requires network access to
7fetch the index), mimic what we do in python_pep517.bbclass do_compile
8and do_install for both crit/ and lib/pycriu
9
10Signed-off-by: Tim Orling <tim.orling@konsulko.com>
11---
12 crit/Makefile | 8 ++++++--
13 lib/Makefile | 11 +++++++++--
14 2 files changed, 15 insertions(+), 4 deletions(-)
15
16diff --git a/crit/Makefile b/crit/Makefile
17index 9a856db6d..9b36f4be1 100644
18--- a/crit/Makefile
19+++ b/crit/Makefile
20@@ -1,5 +1,7 @@
21 PYTHON_EXTERNALLY_MANAGED := $(shell $(PYTHON) -c 'import os, sysconfig; print(int(os.path.isfile(os.path.join(sysconfig.get_path("stdlib"), "EXTERNALLY-MANAGED"))))')
22 PIP_BREAK_SYSTEM_PACKAGES := 0
23+PEP517_SOURCE_PATH := ./crit
24+PEP517_BUILD_OPTS :=
25
26 VERSION_FILE := $(if $(obj),$(addprefix $(obj)/,crit/version.py),crit/version.py)
27
28@@ -16,11 +18,13 @@ ifeq ($(PIP_BREAK_SYSTEM_PACKAGES),0)
29 $(E) " Consider using PIP_BREAK_SYSTEM_PACKAGES=1 make install"
30 else
31 $(E) " INSTALL " crit
32- $(Q) $(PYTHON) -m pip install --upgrade --ignore-installed --prefix=$(DESTDIR)$(PREFIX) ./crit
33+ $(Q) $(PYTHON) -m build --no-isolation --wheel --outdir $(PEP517_WHEEL_PATH) $(PEP517_SOURCE_PATH) $(PEP517_BUILD_OPTS)
34 endif
35 else
36+ $(E) " BUILD " crit
37+ $(Q) $(PYTHON) -m build --no-isolation --wheel --outdir $(PEP517_WHEEL_PATH) $(PEP517_SOURCE_PATH) $(PEP517_BUILD_OPTS)
38 $(E) " INSTALL " crit
39- $(Q) $(PYTHON) -m pip install --upgrade --ignore-installed --prefix=$(DESTDIR)$(PREFIX) ./crit
40+ $(Q) $(PYTHON) -m installer $(INSTALL_WHEEL_COMPILE_BYTECODE) --interpreter "$(USRBINPATH)/env $(PEP517_INSTALL_PYTHON)" --destdir=$(DESTDIR) $(PEP517_WHEEL_PATH)/crit-*.whl
41 endif
42 .PHONY: install
43
44diff --git a/lib/Makefile b/lib/Makefile
45index ae371e78e..b5f147482 100644
46--- a/lib/Makefile
47+++ b/lib/Makefile
48@@ -1,6 +1,9 @@
49 CRIU_SO := libcriu.so
50 CRIU_A := libcriu.a
51 UAPI_HEADERS := lib/c/criu.h images/rpc.proto images/rpc.pb-c.h criu/include/version.h
52+PEP517_SOURCE_PATH := ./lib
53+PEP517_BUILD_OPTS :=
54+INSTALL_WHEEL_COMPILE_BYTECODE ?= "--compile-bytecode=0"
55
56 all-y += lib-c lib-a lib-py
57
58@@ -63,11 +66,15 @@ ifeq ($(PIP_BREAK_SYSTEM_PACKAGES),0)
59 $(E) " Consider using PIP_BREAK_SYSTEM_PACKAGES=1 make install"
60 else
61 $(E) " INSTALL " pycriu
62- $(Q) $(PYTHON) -m pip install --upgrade --ignore-installed --prefix=$(DESTDIR)$(PREFIX) ./lib
63+ $(Q) $(PYTHON) -m build --no-isolation --wheel --outdir $(PEP517_WHEEL_PATH) $(PEP517_SOURCE_PATH) $(PEP517_BUILD_OPTS)
64 endif
65 else
66+ $(E) " BUILD " pycriu
67+ $(Q) $(PYTHON) -m build --no-isolation --wheel --outdir $(PEP517_WHEEL_PATH) $(PEP517_SOURCE_PATH) $(PEP517_BUILD_OPTS)
68 $(E) " INSTALL " pycriu
69- $(Q) $(PYTHON) -m pip install --upgrade --ignore-installed --prefix=$(DESTDIR)$(PREFIX) ./lib
70+ #nativepython3 -m installer ${INSTALL_WHEEL_COMPILE_BYTECODE} --interpreter "${USRBINPATH}/env ${PEP517_INSTALL_PYTHON}" --destdir=${D} ${PEP517_WHEEL_PATH}/*.whl
71+
72+ $(Q) $(PYTHON) -m installer $(INSTALL_WHEEL_COMPILE_BYTECODE) --interpreter "$(USRBINPATH)/env $(PEP517_INSTALL_PYTHON)" --destdir=$(DESTDIR) $(PEP517_WHEEL_PATH)/pycriu-*.whl
73 endif
74 .PHONY: install
75