Skip to contentSkip to conversation

pip_install_wheel: add a generic do_install for bootstrapping

PATCH In review Ross Burton 3 participants 6 messages Mar 10, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 pip_install_wheel: add a generic do_install for bootstrapping

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

---
 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(-)
meta/classes/pip_install_wheel.bbclass +6 -0
index 3861dae75a..29cd544aa3 100644
@@ -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.
+pip_install_wheel_do_bootstrap_install () {
+    install -d ${D}${PYTHON_SITEPACKAGES_DIR}
+    unzip -d ${D}${PYTHON_SITEPACKAGES_DIR} ${PIP_INSTALL_DIST_PATH}/*.whl
+}
+
 EXPORT_FUNCTIONS do_install
meta/recipes-devtools/python/python3-flit-core_3.7.1.bb +1 -2
index 196e391a8d..1f14345d50 100644
@@ -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"
meta/recipes-devtools/python/python3-pip_22.0.3.bb +1 -3
index d7000b891a..f7fcf47c06 100644
@@ -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}
meta/recipes-devtools/python/python3-setuptools_59.5.0.bb +1 -3
index 9d2c2fd744..7cd67b85f9 100644
@@ -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} = "\
meta/recipes-devtools/python/python3-wheel_0.37.1.bb +1 -3
index 83a7c986a8..cf0d8191b4 100644
@@ -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}
Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/3 python3-pip: remove redundant DEPENDS on python3-setuptools-native

This recipe inherits setuptools_build_meta which already depends on python3-setuptools-native.

---
 meta/recipes-devtools/python/python3-pip_22.0.3.bb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-devtools/python/python3-pip_22.0.3.bb +1 -1
index f7fcf47c06..bce3b68861 100644
@@ -6,7 +6,7 @@ LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=63ec52baf95163b597008bb46db68030"
 
 inherit pypi setuptools_build_meta
 
-DEPENDS += "python3 python3-setuptools-native"
+DEPENDS += "python3"
 
 # To avoid a dependency loop; we bootstrap -native
 DEPENDS:remove:class-native = "python3-pip-native"
Signature · 1 line
2.25.1
#2 lore raw

PATCH 3/3 flit_core: remove redundant python3-pip-native DEPENDS

In reply to Ross Burton

PIP is not needed by this class directly, but is used by pip_install_wheel which already depends on python3-pip-native.

---
 meta/classes/flit_core.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/classes/flit_core.bbclass +1 -1
index 7b578967a9..ce162bb75b 100644
@@ -1,6 +1,6 @@
 inherit pip_install_wheel python3native python3-dir setuptools3-base
 
-DEPENDS += "python3 python3-flit-core-native python3-pip-native"
+DEPENDS += "python3 python3-flit-core-native"
 
 flit_core_do_configure () {
     :
Signature · 1 line
2.25.1
#3 lore raw
In reply to Ross Burton
Quoted 24 lines · Ross Burton

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

---
  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(-)
meta/classes/pip_install_wheel.bbclass +0 -0
index 3861dae75a..29cd544aa3 100644

meta/classes/pip_install_wheel.bbclass pip_install_wheel_do_install () { · line 43

Quoted 4 lines
meta/classes/pip_install_wheel.bbclass +1 -0
@@ -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"

meta/classes/pip_install_wheel.bbclass pip_install_wheel_do_install () { · line 47

Quoted 4 lines
meta/classes/pip_install_wheel.bbclass +4 -0
+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

Quoted 72 lines
meta/classes/pip_install_wheel.bbclass +1 -0
+
  EXPORT_FUNCTIONS do_install
meta/recipes-devtools/python/python3-flit-core_3.7.1.bb +1 -2
index 196e391a8d..1f14345d50 100644
@@ -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"
meta/recipes-devtools/python/python3-pip_22.0.3.bb +1 -3
index d7000b891a..f7fcf47c06 100644
@@ -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}
meta/recipes-devtools/python/python3-setuptools_59.5.0.bb +1 -3
index 9d2c2fd744..7cd67b85f9 100644
@@ -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} = "\
meta/recipes-devtools/python/python3-wheel_0.37.1.bb +1 -4
index 83a7c986a8..cf0d8191b4 100644
@@ -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 (#163014): https://lists.openembedded.org/g/openembedded-core/message/163014
Mute This Topic: https://lists.openembedded.org/mt/89684105/3647476
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#4 lore raw
Quoted 7 lines · Konrad Weihmann

meta/classes/pip_install_wheel.bbclass pip_install_wheel_do_install () { · line 47

Quoted 4 lines
meta/classes/pip_install_wheel.bbclass +4 -0
+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.

There's only a few recipes which need this bootstrap, 99% of native recipes can use pip: it's just flit_core/pip/setuptools/wheel which can't as they're needed to build pip itself.

(and once installer is used instead of pip, it's just installer and flit_core)

I may send a v2 to this, as we should be byte-compiling the bootstrap code too.

Ross

#5 lore raw
Quoted 10 lines · Ross Burton
Quoted 7 lines · Konrad Weihmann

meta/classes/pip_install_wheel.bbclass pip_install_wheel_do_install () { · line 47

Quoted 4 lines
meta/classes/pip_install_wheel.bbclass +4 -0
+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.

Quoted 7 lines

There's only a few recipes which need this bootstrap, 99% of native recipes can use pip: it's just flit_core/pip/setuptools/wheel which can't as they're needed to build pip itself.

(and once installer is used instead of pip, it's just installer and flit_core)

I may send a v2 to this, as we should be byte-compiling the bootstrap code too.

I won't send a v2 as this causes interesting problems which are not easy to fix...

Ross