summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Orling <ticotimo@gmail.com>2022-02-22 11:16:31 -0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-02-25 15:07:50 +0000
commit4be36f585893758092de88865976bf9e513cfd03 (patch)
tree28ca392bf794efc371209b59c9f894b452f87980
parentf4c43d7921e51b6d0700d4cc7e257b9932bd4e30 (diff)
downloadpoky-4be36f585893758092de88865976bf9e513cfd03.tar.gz
pip_install_wheel.bbclass: add helper class
Provide a helper class to use pip to install wheels built by either bdist_wheel or a PEP-517 backend. Set pip install arguments via PIP_INSTALL_ARGS, which can be overriden by recipes. Pass --root and --prefix to ensure that pip installs things into the proper place in sysroot. By passing --no-deps and --no-index we avoid finicky dependency checking (pip expects wheels in its cache) and avoid trying to fetch wheels from pypi.org. This is basically the same behavior we have now, the dependencies should be declared in the recipe. Also pass --force-reinstall to make sure built wheels are always installed so that FILES gets properly populated. Pass --no-cache to avoid a (harmless) warning about the pip cache in $HOME be avoiding use of cache. We do not likely want wheels cached anyway, pip install changes the python interpreter in scripts installed in ${bindir}, e.g. to #!/usr/bin/nativepython3, correct the behavior after install to #!/usr/bin/env python3. [YOCTO #14638] (From OE-Core rev: 32a61afde0e7d8df6634b88525d8c3e8c6c3516e) Signed-off-by: Tim Orling <tim.orling@konsulko.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/pip_install_wheel.bbclass39
1 files changed, 39 insertions, 0 deletions
diff --git a/meta/classes/pip_install_wheel.bbclass b/meta/classes/pip_install_wheel.bbclass
new file mode 100644
index 0000000000..70f47d6f79
--- /dev/null
+++ b/meta/classes/pip_install_wheel.bbclass
@@ -0,0 +1,39 @@
1DEPENDS:append = " python3-pip-native"
2
3PIP_INSTALL_PACKAGE ?= "${PYPI_PACKAGE}"
4PIP_INSTALL_DIST_PATH ?= "${B}/dist"
5PYPA_WHEEL ??= "${PIP_INSTALL_DIST_PATH}/${PIP_INSTALL_PACKAGE}-${PV}-*.whl"
6
7PIP_INSTALL_ARGS ?= "\
8 -vvvv \
9 --force-reinstall \
10 --no-cache \
11 --no-deps \
12 --no-index \
13 --root=${D} \
14 --prefix=${prefix} \
15"
16
17pip_install_wheel_do_install:prepend () {
18 install -d ${D}${PYTHON_SITEPACKAGES_DIR}
19}
20
21export PYPA_WHEEL
22
23PIP_INSTALL_PYTHON = "python3"
24PIP_INSTALL_PYTHON:class-native = "nativepython3"
25
26pip_install_wheel_do_install () {
27 nativepython3 -m pip install ${PIP_INSTALL_ARGS} ${PYPA_WHEEL} ||
28 bbfatal_log "Failed to pip install wheel. Check the logs."
29
30 for i in ${D}${bindir}/* ${D}${sbindir}/*; do
31 if [ -f "$i" ]; then
32 sed -i -e "1s,#!.*nativepython3,#!${USRBINPATH}/env ${PIP_INSTALL_PYTHON}," $i
33 sed -i -e "s:${PYTHON}:${USRBINPATH}/env\ ${PIP_INSTALL_PYTHON}:g" $i
34 sed -i -e "s:${STAGING_BINDIR_NATIVE}:${bindir}:g" $i
35 fi
36 done
37}
38
39EXPORT_FUNCTIONS do_install