Skip to contentSkip to conversation

python3-pip-native: install scripts in ${bindir}

PATCH In review Tim Orling 2 participants 5 messages Feb 23, 2022 – Feb 24, 2022

lore
Share & tools
lore

Tim Orling

author
#0 lore raw

PATCH 1/4 python3-pip-native: install scripts in ${bindir}

The naïve approach of simply unzipping the built wheel is not sufficient. 'pip install' would normally have created the [console_scripts] from entry-points.txt in ${D}${bindir}.

For bootstrapping purposes, hardcode the scripts and install them into ${D}${bindir}. Skip the ${bindir}/pip variant.

[YOCTO #14739]

---
 .../python/python3-pip_22.0.3.bb                | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
meta/recipes-devtools/python/python3-pip_22.0.3.bb +17 -0
index 482a210ee99..5a77cb72d70 100644
@@ -23,6 +23,23 @@ do_install:class-native() {
     install -d ${D}${PYTHON_SITEPACKAGES_DIR}
     unzip -d ${D}${PYTHON_SITEPACKAGES_DIR} ${PYPA_WHEEL} || \
     bbfatal_log "Failed to unzip wheel: ${PYPA_WHEEL}. Check the logs."
+
+    # pip install would normally generate [console_scripts] in ${bindir}
+    install -d ${D}/${bindir}
+    # We will skip the ${bindir}/pip variant as we would just remove it in the do_install:append
+    cat << EOF >> ${D}/${bindir}/pip3 | tee ${D}/${bindir}/pip${PYTHON_BASEVERSION}
+#!/bin/sh
+'''exec' ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} "\$0" "\$@"
+' '''
+# -*- coding: utf-8 -*-
+import re
+import sys
+from pip._internal.cli.main import main
+if __name__ == '__main__':
+    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
+    sys.exit(main())
+EOF
+    chmod 0755 ${D}${bindir}/pip3 ${D}${bindir}/pip${PYTHON_BASEVERSION}
 }
 
 do_install:append() {
Signature · 1 line
2.30.2
author
#1 lore raw

PATCH 2/4 python3-scons-native: drop from maintainers.inc

The python3-scons and python3-scons-native recipes have been merged into one.

---
 meta/conf/distro/include/maintainers.inc | 1 -
 1 file changed, 1 deletion(-)
meta/conf/distro/include/maintainers.inc +0 -1
index 333685cd8b8..3fceb6701bb 100644
@@ -635,7 +635,6 @@ RECIPE_MAINTAINER:pn-python3-rfc3986-validator = "Bruce Ashfield <bruce.ashfield
 RECIPE_MAINTAINER:pn-python3-rfc3987 = "Bruce Ashfield <[email protected]>"
 RECIPE_MAINTAINER:pn-python3-ruamel-yaml = "Bruce Ashfield <[email protected]>"
 RECIPE_MAINTAINER:pn-python3-scons = "Tim Orling <[email protected]>"
-RECIPE_MAINTAINER:pn-python3-scons-native = "Tim Orling <[email protected]>"
 RECIPE_MAINTAINER:pn-python3-setuptools = "Oleksandr Kravchuk <[email protected]>"
 RECIPE_MAINTAINER:pn-python3-setuptools-scm = "Tim Orling <[email protected]>"
 RECIPE_MAINTAINER:pn-python3-six = "Zang Ruochen <[email protected]>"
Signature · 1 line
2.30.2
author
#2 lore raw

PATCH 3/4 python3-flit-core: SUMMARY DESCRIPTION HOMEPAGE

In reply to Tim Orling

Add SUMMARY DESCRIPTION HOMEPAGE and BUGTRACKER definitions.

---
 meta/recipes-devtools/python/python3-flit-core_3.6.0.bb | 7 +++++++
 1 file changed, 7 insertions(+)
meta/recipes-devtools/python/python3-flit-core_3.6.0.bb +7 -0
index d0b88c3fa50..6dfacafd31c 100644
@@ -1,3 +1,10 @@
+SUMMARY = "This provides a PEP 517 build backend for packages using Flit."
+DESCRIPTION = "This provides a PEP 517 build backend for packages using \
+Flit. The only public interface is the API specified by PEP 517, at \
+flit_core.buildapi."
+HOMEPAGE = "https://github.com/pypa/flit"
+BUGTRACKER = "https://github.com/pypa/flit/issues"
+
 LICENSE = "BSD-3-Clause"
 LIC_FILES_CHKSUM = "file://LICENSE;md5=41eb78fa8a872983a882c694a8305f08"
 
Signature · 1 line
2.30.2
author
#3 lore raw

PATCH 4/4 python3-wheel-native: install ${bindir}/wheel

In reply to Tim Orling

pip install would normally install [project.scripts] to ${D}${bindir} but our naïve bootstrapping only unzipps the wheel to ${D}${PYTHON_SITEPACKAGES_DIR}. Correct this by creating the equivalent script in do_install:class-native

[YOCTO #14739]

---
 .../python/python3-wheel_0.37.1.bb               | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
meta/recipes-devtools/python/python3-wheel_0.37.1.bb +16 -0
index c7354c9d982..91bff825097 100644
@@ -18,6 +18,22 @@ do_install:class-native () {
     PYPA_WHEEL="${B}/dist/${PYPI_PACKAGE}-${PV}-*.whl"
     unzip -d ${D}${PYTHON_SITEPACKAGES_DIR} ${PYPA_WHEEL} || \
     bbfatal_log "Failed to install"
+
+    # pip install would normally generate [project.scripts] in ${bindir}
+    install -d ${D}/${bindir}
+    cat << EOF >> ${D}/${bindir}/wheel
+#!/bin/sh
+'''exec' ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} "\$0" "\$@"
+' '''
+# -*- coding: utf-8 -*-
+import re
+import sys
+from wheel.cli import main
+if __name__ == '__main__':
+    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
+    sys.exit(main())
+EOF
+    chmod 0755 ${D}${bindir}/wheel
 }
 
 BBCLASSEXTEND = "native nativesdk"
Signature · 1 line
2.30.2
#4 lore raw
In reply to Tim Orling

meta/recipes-devtools/python/python3-pip_22.0.3.bb do_install:class-native() {

Quoted 29 lines

-----Original Message-----
From: [email protected] <openembedded- [email protected]> On Behalf Of Tim Orling
Sent: den 23 februari 2022 23:09
To: [email protected]
Cc: Tim Orling <[email protected]>
Subject: [OE-core] [PATCH 1/4] python3-pip-native: install scripts in ${bindir}

The naïve approach of simply unzipping the built wheel is not sufficient. 'pip install' would normally have created the [console_scripts] from entry-points.txt in ${D}${bindir}.

For bootstrapping purposes, hardcode the scripts and install them into ${D}${bindir}. Skip the ${bindir}/pip variant.

[YOCTO #14739]

---
 .../python/python3-pip_22.0.3.bb                | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
meta/recipes-devtools/python/python3-pip_22.0.3.bb +0 -0
index 482a210ee99..5a77cb72d70 100644
@@ -23,6 +23,23 @@ do_install:class-native() {

For the record, OE-Core uses tabs to indent shell code, compared to OpenEmbedded, which uses four spaces...

meta/recipes-devtools/python/python3-pip_22.0.3.bb do_install:class-native() { · line 24

Quoted 2 lines
meta/recipes-devtools/python/python3-pip_22.0.3.bb +0 -0
     install -d ${D}${PYTHON_SITEPACKAGES_DIR}
     unzip -d ${D}${PYTHON_SITEPACKAGES_DIR} ${PYPA_WHEEL} || \

There is no reason for the backslash at the end of the line above. However, the line below should be indented to indicate that it is a continuation of the line above,

meta/recipes-devtools/python/python3-pip_22.0.3.bb do_install:class-native() { · line 28

Quoted 4 lines
meta/recipes-devtools/python/python3-pip_22.0.3.bb +3 -0
     bbfatal_log "Failed to unzip wheel: ${PYPA_WHEEL}. Check the logs."
+
+    # pip install would normally generate [console_scripts] in ${bindir}
+    install -d ${D}/${bindir}

Change "${D}/${bindir}" to "${D}${bindir}".

meta/recipes-devtools/python/python3-pip_22.0.3.bb do_install:class-native() { · line 30

Quoted 2 lines
meta/recipes-devtools/python/python3-pip_22.0.3.bb +2 -0
+    # We will skip the ${bindir}/pip variant as we would just remove it in the do_install:append
+    cat << EOF >> ${D}/${bindir}/pip3 | tee ${D}/${bindir}/pip${PYTHON_BASEVERSION}

Change the above to:

cat << EOF > pip3

or even better would be:

	cat <<-EOF > pip3

as you then can indent the code below.

And the creation of the file belongs in do_compile:class-native() instead.

meta/recipes-devtools/python/python3-pip_22.0.3.bb do_install:class-native() { · line 33

Quoted 3 lines
meta/recipes-devtools/python/python3-pip_22.0.3.bb +3 -0
+#!/bin/sh
+'''exec' ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} "\$0" "\$@"
+' '''

What's the reason for the above construct? Why doesn't this work:

#!${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN}

If it doesn't, then there should be a comment explaining what's going on.

meta/recipes-devtools/python/python3-pip_22.0.3.bb do_install:class-native() { · line 41

Quoted 8 lines
meta/recipes-devtools/python/python3-pip_22.0.3.bb +8 -0
+# -*- coding: utf-8 -*-
+import re
+import sys
+from pip._internal.cli.main import main
+if __name__ == '__main__':
+    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
+    sys.exit(main())
+EOF

Isn't the code for pip3 available somewhere in the source code so it could be copied from there instead? What happens if upstream decides to change the implementation of pip3?

meta/recipes-devtools/python/python3-pip_22.0.3.bb do_install:class-native() { · line 42

Quoted 1 line
meta/recipes-devtools/python/python3-pip_22.0.3.bb +1 -0
+    chmod 0755 ${D}${bindir}/pip3 ${D}${bindir}/pip${PYTHON_BASEVERSION}

Change the above to:

	install pip3 ${D}${bindir}
	install pip3 ${D}${bindir}/pip${PYTHON_BASEVERSION}
Quoted 5 lines
meta/recipes-devtools/python/python3-pip_22.0.3.bb +0 -1
 }
 
 do_install:append() {
--

2.30.2

Most of the above comments also apply to the patch for python3-wheel-native.

//Peter