]> code.ossystems Code Review - openembedded-core.git/commitdiff
meta: rename pip_install_wheel.bbclass to python_pep517.bbclass
authorRoss Burton <ross@burtonini.com>
Fri, 11 Mar 2022 12:03:02 +0000 (12:03 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Sun, 13 Mar 2022 12:21:07 +0000 (12:21 +0000)
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.

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes/flit_core.bbclass
meta/classes/python_pep517.bbclass [moved from meta/classes/pip_install_wheel.bbclass with 56% similarity]
meta/classes/setuptools3.bbclass
meta/classes/setuptools_build_meta.bbclass
meta/recipes-devtools/python/python3-flit-core_3.7.1.bb
meta/recipes-devtools/python/python3-pip_22.0.3.bb
meta/recipes-devtools/python/python3-setuptools_59.5.0.bb
meta/recipes-devtools/python/python3-wheel_0.37.1.bb

index ce162bb75b9a33ce8585b4b900ae9d291d087132..1ef8ce9429e31478c8241fe2b7ef72cfdf5953a9 100644 (file)
@@ -1,4 +1,4 @@
-inherit pip_install_wheel python3native python3-dir setuptools3-base
+inherit python_pep517 python3native python3-dir setuptools3-base
 
 DEPENDS += "python3 python3-flit-core-native"
 
@@ -12,8 +12,8 @@ PEP517_SOURCE_PATH ?= "${S}"
 # TODO: ideally this uses pypa/build
 flit_core_do_compile () {
     cd ${PEP517_SOURCE_PATH}
-    nativepython3 -mflit_core.wheel --outdir ${PIP_INSTALL_DIST_PATH}
+    nativepython3 -mflit_core.wheel --outdir ${PEP517_WHEEL_PATH}
 }
-do_compile[cleandirs] += "${PIP_INSTALL_DIST_PATH}"
+do_compile[cleandirs] += "${PEP517_WHEEL_PATH}"
 
 EXPORT_FUNCTIONS do_configure do_compile
similarity index 56%
rename from meta/classes/pip_install_wheel.bbclass
rename to meta/classes/python_pep517.bbclass
index 29cd544aa3d1ad3316ac0ccbc9e86fb1af74afe6..76660e70f85ab5bdcd9800c2ebba1575663a1f12 100644 (file)
@@ -1,9 +1,12 @@
+# Common infrastructure for Python packages that use PEP-517 compliant packaging.
+# https://www.python.org/dev/peps/pep-0517/
+
 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"
+PEP517_WHEEL_PATH ?= "${WORKDIR}/dist"
 
 PIP_INSTALL_ARGS = "\
     -vvvv \
@@ -15,24 +18,24 @@ PIP_INSTALL_ARGS = "\
     --prefix=${prefix} \
 "
 
-PIP_INSTALL_PYTHON = "python3"
-PIP_INSTALL_PYTHON:class-native = "nativepython3"
+PEP517_INSTALL_PYTHON = "python3"
+PEP517_INSTALL_PYTHON:class-native = "nativepython3"
 
-pip_install_wheel_do_install () {
-    COUNT=$(find ${PIP_INSTALL_DIST_PATH} -name '*.whl' | wc -l)
+python_pep517_do_install () {
+    COUNT=$(find ${PEP517_WHEEL_PATH} -name '*.whl' | wc -l)
     if test $COUNT -eq 0; then
-        bbfatal No wheels found in ${PIP_INSTALL_DIST_PATH}
+        bbfatal No wheels found in ${PEP517_WHEEL_PATH}
     elif test $COUNT -gt 1; then
-        bbfatal More than one wheel found in ${PIP_INSTALL_DIST_PATH}, this should not happen
+        bbfatal More than one wheel found in ${PEP517_WHEEL_PATH}, this should not happen
     fi
 
-    nativepython3 -m pip install ${PIP_INSTALL_ARGS} ${PIP_INSTALL_DIST_PATH}/*.whl
+    nativepython3 -m pip install ${PIP_INSTALL_ARGS} ${PEP517_WHEEL_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 "1s,#!.*nativepython3,#!${USRBINPATH}/env ${PEP517_INSTALL_PYTHON}," $i
+            sed -i -e "s:${PYTHON}:${USRBINPATH}/env\ ${PEP517_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
@@ -41,9 +44,9 @@ pip_install_wheel_do_install () {
 }
 
 # A manual do_install that just uses unzip for bootstrapping purposes. Callers should DEPEND on unzip-native.
-pip_install_wheel_do_bootstrap_install () {
+python_pep517_do_bootstrap_install () {
     install -d ${D}${PYTHON_SITEPACKAGES_DIR}
-    unzip -d ${D}${PYTHON_SITEPACKAGES_DIR} ${PIP_INSTALL_DIST_PATH}/*.whl
+    unzip -d ${D}${PYTHON_SITEPACKAGES_DIR} ${PEP517_WHEEL_PATH}/*.whl
 }
 
 EXPORT_FUNCTIONS do_install
index dcf3561b8d50ab537aec7e37e36068ec89e631b6..556bc801af71cf8fe3b1f5c1db498ccc52dd7a22 100644 (file)
@@ -1,4 +1,4 @@
-inherit setuptools3-base pip_install_wheel
+inherit setuptools3-base python_pep517
 
 # bdist_wheel builds in ./dist
 #B = "${WORKDIR}/build"
@@ -17,14 +17,14 @@ setuptools3_do_compile() {
         STAGING_INCDIR=${STAGING_INCDIR} \
         STAGING_LIBDIR=${STAGING_LIBDIR} \
         ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py \
-        bdist_wheel --verbose --dist-dir ${PIP_INSTALL_DIST_PATH} ${SETUPTOOLS_BUILD_ARGS} || \
+        bdist_wheel --verbose --dist-dir ${PEP517_WHEEL_PATH} ${SETUPTOOLS_BUILD_ARGS} || \
         bbfatal_log "'${PYTHON_PN} setup.py bdist_wheel ${SETUPTOOLS_BUILD_ARGS}' execution failed."
 }
 setuptools3_do_compile[vardepsexclude] = "MACHINE"
-do_compile[cleandirs] += "${PIP_INSTALL_DIST_PATH}"
+do_compile[cleandirs] += "${PEP517_WHEEL_PATH}"
 
 setuptools3_do_install() {
-        pip_install_wheel_do_install
+        python_pep517_do_install
 }
 
 EXPORT_FUNCTIONS do_configure do_compile do_install
index 787fbd5f36bf87214dd1f62d497f1e7a2a526cd8..424be856080b898bf6e067436dff55e5ea8e88ca 100644 (file)
@@ -1,4 +1,4 @@
-inherit pip_install_wheel setuptools3-base
+inherit setuptools3-base python_pep517
 
 DEPENDS += "python3-setuptools-native python3-wheel-native"
 
@@ -12,8 +12,8 @@ setuptools_build_meta_do_configure () {
 # TODO: ideally this uses pypa/build
 setuptools_build_meta_do_compile () {
     cd ${PEP517_SOURCE_PATH}
-    nativepython3 -c "from setuptools import build_meta; build_meta.build_wheel('${PIP_INSTALL_DIST_PATH}')"
+    nativepython3 -c "from setuptools import build_meta; build_meta.build_wheel('${PEP517_WHEEL_PATH}')"
 }
-do_compile[cleandirs] += "${PIP_INSTALL_DIST_PATH}"
+do_compile[cleandirs] += "${PEP517_WHEEL_PATH}"
 
 EXPORT_FUNCTIONS do_configure do_compile
index 1f14345d503da51461fc5af4608ff9bd8af7bc62..b12b8e42d78cc7d921821f93a9ca12b6d5124a73 100644 (file)
@@ -21,7 +21,7 @@ PYPI_PACKAGE = "flit"
 PEP517_SOURCE_PATH = "${S}/flit_core"
 
 do_install:class-native () {
-    pip_install_wheel_do_bootstrap_install
+    python_pep517_do_bootstrap_install
 }
 
 PACKAGES =+ "${PN}-tests"
index bce3b68861a943b4dd384b118c5b25be335db56d..bfeeee789cee12034fa7471c80357f2400c615c7 100644 (file)
@@ -19,7 +19,7 @@ SRC_URI += "file://reproducible.patch"
 SRC_URI[sha256sum] = "f29d589df8c8ab99c060e68ad294c4a9ed896624f6368c5349d70aa581b333d0"
 
 do_install:class-native() {
-    pip_install_wheel_do_bootstrap_install
+    python_pep517_do_bootstrap_install
 
     # pip install would normally generate [console_scripts] in ${bindir}
     install -d ${D}/${bindir}
index 7cd67b85f9d072173efc1293fa04464613478ee3..d93972b9a0120f86d36a9be0ca4ce0eb129b8cdf 100644 (file)
@@ -22,7 +22,7 @@ DEPENDS:remove:class-native = "python3-pip-native python3-setuptools-native"
 DEPENDS:append:class-native = " unzip-native"
 
 do_install:class-native() {
-    pip_install_wheel_do_bootstrap_install
+    python_pep517_do_bootstrap_install
 }
 
 RDEPENDS:${PN} = "\
index cf0d8191b4da37bdc1e4193c1e771693cc46fd9a..a339e658246959364b2295e06298eb6ac8093f3b 100644 (file)
@@ -13,7 +13,7 @@ SRC_URI += " file://0001-Backport-pyproject.toml-from-flit-backend-branch.patch"
 DEPENDS:remove:class-native = "python3-pip-native"
 
 do_install:class-native () {
-    pip_install_wheel_do_bootstrap_install
+    python_pep517_do_bootstrap_install
 
     # pip install would normally generate [project.scripts] in ${bindir}
     install -d ${D}/${bindir}