Files
poky/meta/classes/pip_install_wheel.bbclass
Ross Burton 5331d29a89 pip_install_wheel: add a generic do_install for bootstrapping
Several recipes are duplicating the same bootstrap logic for installing
a wheel without using any tools.  Add an implementation to
pip_install_wheel to centralise the code, and remove the duplicated code
from the following recipes:

- python3-flit-core
- python3-pip
- python3-setuptools
- python3-wheel

(From OE-Core rev: d5d702a2cd06f863340f8e4cdce0904c9d86384d)

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2022-03-11 06:56:01 +00:00

50 lines
1.7 KiB
Plaintext

DEPENDS:append = " python3-pip-native"
# The directory where wheels should be written too. Build classes
# will ideally [cleandirs] this but we don't do that here in case
# a recipe wants to install prebuilt wheels.
PIP_INSTALL_DIST_PATH ?= "${WORKDIR}/dist"
PIP_INSTALL_ARGS = "\
-vvvv \
--ignore-installed \
--no-cache \
--no-deps \
--no-index \
--root=${D} \
--prefix=${prefix} \
"
PIP_INSTALL_PYTHON = "python3"
PIP_INSTALL_PYTHON:class-native = "nativepython3"
pip_install_wheel_do_install () {
COUNT=$(find ${PIP_INSTALL_DIST_PATH} -name '*.whl' | wc -l)
if test $COUNT -eq 0; then
bbfatal No wheels found in ${PIP_INSTALL_DIST_PATH}
elif test $COUNT -gt 1; then
bbfatal More than one wheel found in ${PIP_INSTALL_DIST_PATH}, this should not happen
fi
nativepython3 -m pip install ${PIP_INSTALL_ARGS} ${PIP_INSTALL_DIST_PATH}/*.whl
cd ${D}
for i in ${D}${bindir}/* ${D}${sbindir}/*; do
if [ -f "$i" ]; then
sed -i -e "1s,#!.*nativepython3,#!${USRBINPATH}/env ${PIP_INSTALL_PYTHON}," $i
sed -i -e "s:${PYTHON}:${USRBINPATH}/env\ ${PIP_INSTALL_PYTHON}:g" $i
sed -i -e "s:${STAGING_BINDIR_NATIVE}:${bindir}:g" $i
# Not everything we find may be Python, so ignore errors
nativepython3 -mpy_compile $(realpath --relative-to=${D} $i) || true
fi
done
}
# A manual do_install that just uses unzip for bootstrapping purposes. Callers should DEPEND on unzip-native.
pip_install_wheel_do_bootstrap_install () {
install -d ${D}${PYTHON_SITEPACKAGES_DIR}
unzip -d ${D}${PYTHON_SITEPACKAGES_DIR} ${PIP_INSTALL_DIST_PATH}/*.whl
}
EXPORT_FUNCTIONS do_install