On 10.03.22 12:40, Ross Burton wrote:
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

Signed-off-by: Ross Burton <ross.bur...@arm.com>
---
  meta/classes/pip_install_wheel.bbclass                    | 6 ++++++
  meta/recipes-devtools/python/python3-flit-core_3.7.1.bb   | 3 +--
  meta/recipes-devtools/python/python3-pip_22.0.3.bb        | 4 +---
  meta/recipes-devtools/python/python3-setuptools_59.5.0.bb | 4 +---
  meta/recipes-devtools/python/python3-wheel_0.37.1.bb      | 4 +---
  5 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/meta/classes/pip_install_wheel.bbclass 
b/meta/classes/pip_install_wheel.bbclass
index 3861dae75a..29cd544aa3 100644
--- a/meta/classes/pip_install_wheel.bbclass
+++ b/meta/classes/pip_install_wheel.bbclass
@@ -40,4 +40,10 @@ pip_install_wheel_do_install () {
      done
  }
+# A manual do_install that just uses unzip for bootstrapping purposes. Callers should DEPEND on unzip-native.

Minor nitpick - wouldn't it make sense to add a hard DEPENDS on unzip-native right here into the class - it should do no harm when done like DEPENDS:append:class-native = " 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
+}

I think these two lines could be moved into a generic do_install:native - and then removing all the override code from the recipes below.

Or is there some special case I'm not seeing here that would require having this extra function.


Thanks for the patches - after all these rounds code looks good and should provide a seamless transition for most of the layers

+
  EXPORT_FUNCTIONS do_install
diff --git a/meta/recipes-devtools/python/python3-flit-core_3.7.1.bb 
b/meta/recipes-devtools/python/python3-flit-core_3.7.1.bb
index 196e391a8d..1f14345d50 100644
--- a/meta/recipes-devtools/python/python3-flit-core_3.7.1.bb
+++ b/meta/recipes-devtools/python/python3-flit-core_3.7.1.bb
@@ -21,8 +21,7 @@ PYPI_PACKAGE = "flit"
  PEP517_SOURCE_PATH = "${S}/flit_core"
do_install:class-native () {
-    install -d ${D}${PYTHON_SITEPACKAGES_DIR}
-    unzip -d ${D}${PYTHON_SITEPACKAGES_DIR} 
${PIP_INSTALL_DIST_PATH}/flit_core*.whl
+    pip_install_wheel_do_bootstrap_install
  }
PACKAGES =+ "${PN}-tests"
diff --git a/meta/recipes-devtools/python/python3-pip_22.0.3.bb 
b/meta/recipes-devtools/python/python3-pip_22.0.3.bb
index d7000b891a..f7fcf47c06 100644
--- a/meta/recipes-devtools/python/python3-pip_22.0.3.bb
+++ b/meta/recipes-devtools/python/python3-pip_22.0.3.bb
@@ -19,9 +19,7 @@ SRC_URI += "file://reproducible.patch"
  SRC_URI[sha256sum] = 
"f29d589df8c8ab99c060e68ad294c4a9ed896624f6368c5349d70aa581b333d0"
do_install:class-native() {
-    # Bootstrap to prevent dependency loop in python3-pip-native
-    install -d ${D}${PYTHON_SITEPACKAGES_DIR}
-    unzip -d ${D}${PYTHON_SITEPACKAGES_DIR} ${PIP_INSTALL_DIST_PATH}/*.whl
+    pip_install_wheel_do_bootstrap_install
# pip install would normally generate [console_scripts] in ${bindir}
      install -d ${D}/${bindir}
diff --git a/meta/recipes-devtools/python/python3-setuptools_59.5.0.bb 
b/meta/recipes-devtools/python/python3-setuptools_59.5.0.bb
index 9d2c2fd744..7cd67b85f9 100644
--- a/meta/recipes-devtools/python/python3-setuptools_59.5.0.bb
+++ b/meta/recipes-devtools/python/python3-setuptools_59.5.0.bb
@@ -22,9 +22,7 @@ DEPENDS:remove:class-native = "python3-pip-native 
python3-setuptools-native"
  DEPENDS:append:class-native = " unzip-native"
do_install:class-native() {
-    # Bootstrap to prevent dependency loop in python3-pip-native
-    install -d ${D}${PYTHON_SITEPACKAGES_DIR}
-    unzip -d ${D}${PYTHON_SITEPACKAGES_DIR} ${PIP_INSTALL_DIST_PATH}/*.whl
+    pip_install_wheel_do_bootstrap_install
  }
RDEPENDS:${PN} = "\
diff --git a/meta/recipes-devtools/python/python3-wheel_0.37.1.bb 
b/meta/recipes-devtools/python/python3-wheel_0.37.1.bb
index 83a7c986a8..cf0d8191b4 100644
--- a/meta/recipes-devtools/python/python3-wheel_0.37.1.bb
+++ b/meta/recipes-devtools/python/python3-wheel_0.37.1.bb
@@ -13,9 +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 () {
-    # We need to bootstrap python3-wheel-native
-    install -d ${D}${PYTHON_SITEPACKAGES_DIR}
-    unzip -d ${D}${PYTHON_SITEPACKAGES_DIR} ${PIP_INSTALL_DIST_PATH}/*.whl
+    pip_install_wheel_do_bootstrap_install
# pip install would normally generate [project.scripts] in ${bindir}
      install -d ${D}/${bindir}





-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#163016): 
https://lists.openembedded.org/g/openembedded-core/message/163016
Mute This Topic: https://lists.openembedded.org/mt/89684105/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to