]> code.ossystems Code Review - openembedded-core.git/commitdiff
pip_install_wheel: install wheel with a glob
authorRoss Burton <ross@burtonini.com>
Wed, 9 Mar 2022 16:51:13 +0000 (16:51 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 10 Mar 2022 13:06:22 +0000 (13:06 +0000)
Now that the build systems that use pip_install_wheel are all building
their wheel into a directory that we knew was empty before, we can just
install *.whl and not need to know the precise names.

By design a pyproject.toml will always build a single wheel, so there
shouldn't be any way for this to end up installing more than expected.

This obsoletes PIP_INSTALL_PACKAGE and PYPA_WHEEL, neither of which are
needed anymore.

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes/pip_install_wheel.bbclass

index 954a6b750f7ca15ad323425cfa6b311ae74ea068..3861dae75ab47e029f7c86d3b0ba3566358666ea 100644 (file)
@@ -1,20 +1,10 @@
 DEPENDS:append = " python3-pip-native"
 
-def guess_pip_install_package_name(d):
-    import re
-    '''https://www.python.org/dev/peps/pep-0491/#escaping-and-unicode'''
-    name = d.getVar('PYPI_PACKAGE') or re.sub(r"^python3-", "", d.getVar('BPN'))
-    return name.replace('-', '_')
-
-PIP_INSTALL_PACKAGE ?= "${@guess_pip_install_package_name(d)}"
-
 # 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"
 
-PYPA_WHEEL ??= "${PIP_INSTALL_DIST_PATH}/${PIP_INSTALL_PACKAGE}-*-*.whl"
-
 PIP_INSTALL_ARGS = "\
     -vvvv \
     --ignore-installed \
@@ -29,8 +19,14 @@ PIP_INSTALL_PYTHON = "python3"
 PIP_INSTALL_PYTHON:class-native = "nativepython3"
 
 pip_install_wheel_do_install () {
-    nativepython3 -m pip install ${PIP_INSTALL_ARGS} ${PYPA_WHEEL} ||
-      bbfatal_log "Failed to pip install wheel. Check the logs."
+    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