blob: 7eb9fb69ba4a7279f2b8e657c37ccf740c93ffe9 [file] [log] [blame]
Andrew Geissler7e0e3c02022-02-25 20:34:39 +00001SUMMARY = "The PyPA recommended tool for installing Python packages"
2HOMEPAGE = "https://pypi.org/project/pip"
3SECTION = "devel/python"
4LICENSE = "MIT"
5LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=63ec52baf95163b597008bb46db68030"
6
7inherit pypi setuptools_build_meta
8
9DEPENDS += "python3 python3-setuptools-native"
10
11# To avoid a dependency loop; we bootstrap -native
12DEPENDS:remove:class-native = "python3-pip-native"
13DEPENDS:append:class-native = " unzip-native"
14
15SRC_URI += "file://0001-change-shebang-to-python3.patch"
16SRC_URI += "file://no_shebang_mangling.patch"
17SRC_URI += "file://reproducible.patch"
18
19SRC_URI[sha256sum] = "f29d589df8c8ab99c060e68ad294c4a9ed896624f6368c5349d70aa581b333d0"
20
21PYPA_WHEEL ?= "${B}/dist/${PYPI_PACKAGE}-${PV}-*.whl"
22
23do_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 -*-
37import re
38import sys
39from pip._internal.cli.main import main
40if __name__ == '__main__':
41 sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
42 sys.exit(main())
43EOF
44 chmod 0755 ${D}${bindir}/pip3 ${D}${bindir}/pip${PYTHON_BASEVERSION}
45}
46
47do_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
54RDEPENDS:${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
67BBCLASSEXTEND = "native nativesdk"