Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame^] | 1 | SUMMARY = "The PyPA recommended tool for installing Python packages" |
| 2 | HOMEPAGE = "https://pypi.org/project/pip" |
| 3 | SECTION = "devel/python" |
| 4 | LICENSE = "MIT" |
| 5 | LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=63ec52baf95163b597008bb46db68030" |
| 6 | |
| 7 | inherit pypi setuptools_build_meta |
| 8 | |
| 9 | DEPENDS += "python3 python3-setuptools-native" |
| 10 | |
| 11 | # To avoid a dependency loop; we bootstrap -native |
| 12 | DEPENDS:remove:class-native = "python3-pip-native" |
| 13 | DEPENDS:append:class-native = " unzip-native" |
| 14 | |
| 15 | SRC_URI += "file://0001-change-shebang-to-python3.patch" |
| 16 | SRC_URI += "file://no_shebang_mangling.patch" |
| 17 | SRC_URI += "file://reproducible.patch" |
| 18 | |
| 19 | SRC_URI[sha256sum] = "f29d589df8c8ab99c060e68ad294c4a9ed896624f6368c5349d70aa581b333d0" |
| 20 | |
| 21 | PYPA_WHEEL ?= "${B}/dist/${PYPI_PACKAGE}-${PV}-*.whl" |
| 22 | |
| 23 | do_install:class-native() { |
| 24 | # Bootstrap to prevent dependency loop in python3-pip-native |
| 25 | install -d ${D}${PYTHON_SITEPACKAGES_DIR} |
| 26 | unzip -d ${D}${PYTHON_SITEPACKAGES_DIR} ${PYPA_WHEEL} || \ |
| 27 | bbfatal_log "Failed to unzip wheel: ${PYPA_WHEEL}. Check the logs." |
| 28 | |
| 29 | # pip install would normally generate [console_scripts] in ${bindir} |
| 30 | install -d ${D}/${bindir} |
| 31 | # We will skip the ${bindir}/pip variant as we would just remove it in the do_install:append |
| 32 | cat << EOF >> ${D}/${bindir}/pip3 | tee ${D}/${bindir}/pip${PYTHON_BASEVERSION} |
| 33 | #!/bin/sh |
| 34 | '''exec' ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} "\$0" "\$@" |
| 35 | ' ''' |
| 36 | # -*- coding: utf-8 -*- |
| 37 | import re |
| 38 | import sys |
| 39 | from pip._internal.cli.main import main |
| 40 | if __name__ == '__main__': |
| 41 | sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) |
| 42 | sys.exit(main()) |
| 43 | EOF |
| 44 | chmod 0755 ${D}${bindir}/pip3 ${D}${bindir}/pip${PYTHON_BASEVERSION} |
| 45 | } |
| 46 | |
| 47 | do_install:append() { |
| 48 | # Install as pip3 and leave pip2 as default |
| 49 | if [ -e ${D}/${bindir}/pip ]; then |
| 50 | rm ${D}/${bindir}/pip |
| 51 | fi |
| 52 | } |
| 53 | |
| 54 | RDEPENDS:${PN} = "\ |
| 55 | python3-compile \ |
| 56 | python3-io \ |
| 57 | python3-html \ |
| 58 | python3-json \ |
| 59 | python3-multiprocessing \ |
| 60 | python3-netserver \ |
| 61 | python3-setuptools \ |
| 62 | python3-unixadmin \ |
| 63 | python3-xmlrpc \ |
| 64 | python3-pickle \ |
| 65 | " |
| 66 | |
| 67 | BBCLASSEXTEND = "native nativesdk" |