All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tim Orling <ticotimo@gmail.com>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH v2 05/32] pip_install_wheel.bbclass: add helper class
Date: Mon, 21 Feb 2022 13:23:20 -0800	[thread overview]
Message-ID: <90dfa42cc21c4beec1e02d8efb1855bf4ee96c60.1645478020.git.tim.orling@konsulko.com> (raw)
In-Reply-To: <cover.1645478020.git.tim.orling@konsulko.com>

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.

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]

Signed-off-by: Tim Orling <tim.orling@konsulko.com>
---
 meta/classes/pip_install_wheel.bbclass | 37 ++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 meta/classes/pip_install_wheel.bbclass

diff --git a/meta/classes/pip_install_wheel.bbclass b/meta/classes/pip_install_wheel.bbclass
new file mode 100644
index 00000000000..c7b62c59ea8
--- /dev/null
+++ b/meta/classes/pip_install_wheel.bbclass
@@ -0,0 +1,37 @@
+DEPENDS:append = " python3-pip-native"
+
+PIP_INSTALL_PACKAGE ?= "${PYPI_PACKAGE}"
+PIP_INSTALL_DIST_PATH ?= "${B}/dist"
+PYPA_WHEEL ??= "${PIP_INSTALL_DIST_PATH}/${PIP_INSTALL_PACKAGE}-${PV}-*.whl"
+
+PIP_INSTALL_ARGS ?= "\
+    -vvvv \
+    --no-deps \
+    --no-index \
+    --root=${D} \
+    --prefix=${prefix} \
+"
+
+pip_install_wheel_do_install:prepend () {
+    install -d ${D}${PYTHON_SITEPACKAGES_DIR}
+}
+
+export PYPA_WHEEL
+
+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."
+
+    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
+        fi
+    done
+}
+
+EXPORT_FUNCTIONS do_install
-- 
2.30.2



  parent reply	other threads:[~2022-02-21 21:24 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-21 21:23 [PATCH v2 00/32] Python PEP-517: build wheels and install with pip Tim Orling
2022-02-21 21:23 ` [PATCH v2 01/32] python3-wheel: move 0.37.0 from meta-python Tim Orling
2022-02-23 16:01   ` [OE-core] " Khem Raj
2022-02-23 17:01     ` Tim Orling
2022-02-21 21:23 ` [PATCH v2 02/32] python3-flit-core: add recipe for 3.6.0 Tim Orling
2022-02-21 21:23 ` [PATCH v2 03/32] flit_core.bbclass: add helper for newer python packaging Tim Orling
2022-02-21 21:23 ` [PATCH v2 04/32] python3-wheel: inherit flit_core Tim Orling
2022-02-21 21:23 ` Tim Orling [this message]
2022-02-21 21:23 ` [PATCH v2 06/32] setuptools_build_meta.bbclass: add helper class Tim Orling
2022-02-21 21:23 ` [PATCH v2 07/32] python3-pip: inherit setuptools_build_meta Tim Orling
2022-02-21 21:23 ` [PATCH v2 08/32] python3-attrs: " Tim Orling
2022-02-21 21:23 ` [PATCH v2 09/32] python3-git: " Tim Orling
2022-02-21 21:23 ` [PATCH v2 10/32] python3-pytest: " Tim Orling
2022-02-21 21:23 ` [PATCH v2 11/32] python3-setuptools-scm: " Tim Orling
2022-02-21 21:23 ` [PATCH v2 12/32] python3-zipp: " Tim Orling
2022-02-21 21:23 ` [PATCH v2 13/32] python3-iniconfig: " Tim Orling
2022-02-21 21:23 ` [PATCH v2 14/32] python3-py: " Tim Orling
2022-02-21 21:23 ` [PATCH v2 15/32] python3-pluggy: " Tim Orling
2022-02-21 21:23 ` [PATCH v2 16/32] python3-setuptools: inherit setuptools_base_meta Tim Orling
2022-02-21 21:23 ` [PATCH v2 17/32] setuptools3.bbclass: refactor for wheels Tim Orling
2022-02-21 21:23 ` [PATCH v2 18/32] python3-more-itertools: set PIP_INSTALL_PACKAGE Tim Orling
2022-02-21 21:23 ` [PATCH v2 19/32] meson: inherit setuptools_build_meta Tim Orling
2022-02-22  6:55   ` [OE-core] " Oleksiy Obitotskyi -X (oobitots - GLOBALLOGIC INC at Cisco)
2022-02-21 21:23 ` [PATCH v2 20/32] python3-libarchive-d: set PIP_INSTALL_PACKAGE Tim Orling
2022-02-21 21:23 ` [PATCH v2 21/32] python3-smartypants: patch hash bang to python3 Tim Orling
2022-02-21 21:23 ` [PATCH v2 22/32] python3-scons: merge -native recipe Tim Orling
2022-02-21 21:23 ` [PATCH v2 23/32] python3-subunit: merge inc; set PIP_INSTALL_PACKAGE Tim Orling
2022-02-21 21:23 ` [PATCH v2 24/32] python3-magic: " Tim Orling
2022-02-21 21:23 ` [PATCH v2 25/32] bmap-tools: set PIP_INSTALL_PACKAGE, BASEVER Tim Orling
2022-02-21 21:23 ` [PATCH v2 26/32] asciidoc: set PIP_INSTALL_PACKAGE Tim Orling
2022-02-21 21:23 ` [PATCH v2 27/32] gi-docgen: " Tim Orling
2022-02-21 21:23 ` [PATCH v2 28/32] numpy: " Tim Orling
2022-02-21 21:23 ` [PATCH v2 29/32] python3-dbusmock: " Tim Orling
2022-02-21 21:23 ` [PATCH v2 30/32] python3-mako: inherit setuptools_build_meta Tim Orling
2022-02-21 21:23 ` [PATCH v2 31/32] python3-packaging: " Tim Orling
2022-02-21 21:23 ` [PATCH v2 32/32] python3-nose: drop recipe Tim Orling
2022-02-22 22:24   ` [OE-core] " Khem Raj
2022-02-22 22:33     ` Tim Orling
2022-02-22 17:22 ` [OE-core] [PATCH v2 00/32] Python PEP-517: build wheels and install with pip Khem Raj
2022-02-22 18:21   ` Tim Orling
2022-02-22 18:23     ` Khem Raj
2022-02-22 18:39       ` Tim Orling
2022-02-22 18:43         ` Tim Orling
2022-02-22 19:18         ` Khem Raj
2022-02-22 19:22           ` Tim Orling
2022-02-24  4:06             ` Khem Raj
2022-02-24  4:50               ` Tim Orling
     [not found]               ` <16D69FA5F268A6BB.31711@lists.openembedded.org>
2022-02-24  5:42                 ` Tim Orling

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=90dfa42cc21c4beec1e02d8efb1855bf4ee96c60.1645478020.git.tim.orling@konsulko.com \
    --to=ticotimo@gmail.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.