summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/python/python3-pip_22.0.3.bb
blob: e02ea5bd3d2c786b7a074be3268bb1fea01281d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
SUMMARY = "The PyPA recommended tool for installing Python packages"
HOMEPAGE = "https://pypi.org/project/pip"
SECTION = "devel/python"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=63ec52baf95163b597008bb46db68030"

inherit pypi setuptools_build_meta

DEPENDS += "python3 python3-setuptools-native"

# 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[sha256sum] = "f29d589df8c8ab99c060e68ad294c4a9ed896624f6368c5349d70aa581b333d0"

PYPA_WHEEL ?= "${B}/dist/${PYPI_PACKAGE}-${PV}-*.whl"

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} ${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() {
    # Install as pip3 and leave pip2 as default
    if [ -e ${D}/${bindir}/pip ]; then
        rm ${D}/${bindir}/pip
    fi
}

RDEPENDS:${PN} = "\
  python3-compile \
  python3-io \
  python3-html \
  python3-json \
  python3-multiprocessing \
  python3-netserver \
  python3-setuptools \
  python3-unixadmin \
  python3-xmlrpc \
  python3-pickle \
"

BBCLASSEXTEND = "native nativesdk"