# Common infrastructure for Python packages that use PEP-517 compliant packaging.
# https://www.python.org/dev/peps/pep-0517/
-DEPENDS:append = " python3-pip-native"
+DEPENDS:append = " python3-installer-native"
# Where to execute the build process from
PEP517_SOURCE_PATH ?= "${S}"
# a recipe wants to install prebuilt wheels.
PEP517_WHEEL_PATH ?= "${WORKDIR}/dist"
-PIP_INSTALL_ARGS = "\
- -vvvv \
- --ignore-installed \
- --no-cache \
- --no-deps \
- --no-index \
- --root=${D} \
- --prefix=${prefix} \
-"
-
PEP517_INSTALL_PYTHON = "python3"
PEP517_INSTALL_PYTHON:class-native = "nativepython3"
+INSTALL_WHEEL_COMPILE_BYTECODE ?= "--compile-bytecode=0"
+
python_pep517_do_install () {
COUNT=$(find ${PEP517_WHEEL_PATH} -name '*.whl' | wc -l)
if test $COUNT -eq 0; then
bbfatal More than one wheel found in ${PEP517_WHEEL_PATH}, this should not happen
fi
- 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 ${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
- fi
- done
+ nativepython3 -m installer ${INSTALL_WHEEL_COMPILE_BYTECODE} --interpreter "${USRBINPATH}/env ${PEP517_INSTALL_PYTHON}" --destdir=${D} ${PEP517_WHEEL_PATH}/*.whl
}
# A manual do_install that just uses unzip for bootstrapping purposes. Callers should DEPEND on unzip-native.
inherit pypi flit_core
# Need to install by hand as there's a dependency loop
-DEPENDS:remove:class-native = " python3-pip-native"
+DEPENDS:remove:class-native = " python3-installer-native"
DEPENDS:append:class-native = " unzip-native"
# We need the full flit tarball
inherit pypi setuptools_build_meta
-DEPENDS += "python3"
-
-# To avoid a dependency loop; we bootstrap -native
-DEPENDS:remove:class-native = "python3-pip-native"
-DEPENDS:append:class-native = " unzip-native"
-
SRC_URI += "file://0001-change-shebang-to-python3.patch"
SRC_URI += "file://no_shebang_mangling.patch"
SRC_URI += "file://reproducible.patch"
SRC_URI[sha256sum] = "f29d589df8c8ab99c060e68ad294c4a9ed896624f6368c5349d70aa581b333d0"
-do_install:class-native() {
- python_pep517_do_bootstrap_install
-
- # 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() {
- if [ -e ${D}/${bindir}/pip ]; then
- rm ${D}/${bindir}/pip
- fi
+ rm -f ${D}/${bindir}/pip
}
RDEPENDS:${PN} = "\
"
BBCLASSEXTEND = "native nativesdk"
+
+# This used to use the bootstrap install which didn't compile. Until we bump the
+# tmpdir version we can't compile the native otherwise the sysroot unpack fails
+INSTALL_WHEEL_COMPILE_BYTECODE:class-native = "--no-compile-bytecode"
DEPENDS += "${PYTHON_PN}"
-# Avoid dependency loop; we bootstrap -native
-DEPENDS:remove:class-native = "python3-pip-native python3-setuptools-native"
-DEPENDS:append:class-native = " unzip-native"
-
-do_install:class-native() {
- python_pep517_do_bootstrap_install
-}
-
RDEPENDS:${PN} = "\
${PYTHON_PN}-2to3 \
${PYTHON_PN}-compile \
${PYTHON_PN}-plistlib \
${PYTHON_PN}-pprint \
"
+
+# This used to use the bootstrap install which didn't compile. Until we bump the
+# tmpdir version we can't compile the native otherwise the sysroot unpack fails
+INSTALL_WHEEL_COMPILE_BYTECODE:class-native = "--no-compile-bytecode"
SRC_URI += " file://0001-Backport-pyproject.toml-from-flit-backend-branch.patch"
-DEPENDS:remove:class-native = "python3-pip-native"
-
-do_install:class-native () {
- python_pep517_do_bootstrap_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"
+
+# This used to use the bootstrap install which didn't compile. Until we bump the
+# tmpdir version we can't compile the native otherwise the sysroot unpack fails
+INSTALL_WHEEL_COMPILE_BYTECODE:class-native = "--no-compile-bytecode"