diff options
| author | Ross Burton <ross@burtonini.com> | 2022-03-11 12:03:02 +0000 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-03-13 12:23:48 +0000 |
| commit | a50bf48f900b4a67d622c9833c391b049a04d2da (patch) | |
| tree | 765a69f48eb7a888bf9c2c3bf5eba20063c28973 /meta/classes/python_pep517.bbclass | |
| parent | b6a535068dadbc6540c6f5cf49cb9fba777fe727 (diff) | |
| download | poky-a50bf48f900b4a67d622c9833c391b049a04d2da.tar.gz | |
meta: rename pip_install_wheel.bbclass to python_pep517.bbclass
pip_install_wheel shouldn't restricted to just using Pip to install
wheels (the installer module is simplier and likely a better option),
and in the future may be extended to also provide do_compile() using
the build module.
(From OE-Core rev: 3bdf64b97facce9706cc579bdbc9a80e0d48428f)
Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/python_pep517.bbclass')
| -rw-r--r-- | meta/classes/python_pep517.bbclass | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/meta/classes/python_pep517.bbclass b/meta/classes/python_pep517.bbclass new file mode 100644 index 0000000000..76660e70f8 --- /dev/null +++ b/meta/classes/python_pep517.bbclass | |||
| @@ -0,0 +1,52 @@ | |||
| 1 | # Common infrastructure for Python packages that use PEP-517 compliant packaging. | ||
| 2 | # https://www.python.org/dev/peps/pep-0517/ | ||
| 3 | |||
| 4 | DEPENDS:append = " python3-pip-native" | ||
| 5 | |||
| 6 | # The directory where wheels should be written too. Build classes | ||
| 7 | # will ideally [cleandirs] this but we don't do that here in case | ||
| 8 | # a recipe wants to install prebuilt wheels. | ||
| 9 | PEP517_WHEEL_PATH ?= "${WORKDIR}/dist" | ||
| 10 | |||
| 11 | PIP_INSTALL_ARGS = "\ | ||
| 12 | -vvvv \ | ||
| 13 | --ignore-installed \ | ||
| 14 | --no-cache \ | ||
| 15 | --no-deps \ | ||
| 16 | --no-index \ | ||
| 17 | --root=${D} \ | ||
| 18 | --prefix=${prefix} \ | ||
| 19 | " | ||
| 20 | |||
| 21 | PEP517_INSTALL_PYTHON = "python3" | ||
| 22 | PEP517_INSTALL_PYTHON:class-native = "nativepython3" | ||
| 23 | |||
| 24 | python_pep517_do_install () { | ||
| 25 | COUNT=$(find ${PEP517_WHEEL_PATH} -name '*.whl' | wc -l) | ||
| 26 | if test $COUNT -eq 0; then | ||
| 27 | bbfatal No wheels found in ${PEP517_WHEEL_PATH} | ||
| 28 | elif test $COUNT -gt 1; then | ||
| 29 | bbfatal More than one wheel found in ${PEP517_WHEEL_PATH}, this should not happen | ||
| 30 | fi | ||
| 31 | |||
| 32 | nativepython3 -m pip install ${PIP_INSTALL_ARGS} ${PEP517_WHEEL_PATH}/*.whl | ||
| 33 | |||
| 34 | cd ${D} | ||
| 35 | for i in ${D}${bindir}/* ${D}${sbindir}/*; do | ||
| 36 | if [ -f "$i" ]; then | ||
| 37 | sed -i -e "1s,#!.*nativepython3,#!${USRBINPATH}/env ${PEP517_INSTALL_PYTHON}," $i | ||
| 38 | sed -i -e "s:${PYTHON}:${USRBINPATH}/env\ ${PEP517_INSTALL_PYTHON}:g" $i | ||
| 39 | sed -i -e "s:${STAGING_BINDIR_NATIVE}:${bindir}:g" $i | ||
| 40 | # Not everything we find may be Python, so ignore errors | ||
| 41 | nativepython3 -mpy_compile $(realpath --relative-to=${D} $i) || true | ||
| 42 | fi | ||
| 43 | done | ||
| 44 | } | ||
| 45 | |||
| 46 | # A manual do_install that just uses unzip for bootstrapping purposes. Callers should DEPEND on unzip-native. | ||
| 47 | python_pep517_do_bootstrap_install () { | ||
| 48 | install -d ${D}${PYTHON_SITEPACKAGES_DIR} | ||
| 49 | unzip -d ${D}${PYTHON_SITEPACKAGES_DIR} ${PEP517_WHEEL_PATH}/*.whl | ||
| 50 | } | ||
| 51 | |||
| 52 | EXPORT_FUNCTIONS do_install | ||
