blob: 9f9feda6ee0e41f20f25e567118e5b5440c57462 [file] [log] [blame]
Andrew Geissler7e0e3c02022-02-25 20:34:39 +00001DEPENDS:append = " python3-pip-native"
2
3def guess_pip_install_package_name(d):
4 '''https://www.python.org/dev/peps/pep-0491/#escaping-and-unicode'''
5 return (d.getVar('PYPI_PACKAGE') or d.getVar('PN')).replace('-', '_')
6
7PIP_INSTALL_PACKAGE ?= "${@guess_pip_install_package_name(d)}"
8PIP_INSTALL_DIST_PATH ?= "${B}/dist"
9PYPA_WHEEL ??= "${PIP_INSTALL_DIST_PATH}/${PIP_INSTALL_PACKAGE}-${PV}-*.whl"
10
11PIP_INSTALL_ARGS ?= "\
12 -vvvv \
13 --ignore-installed \
14 --no-cache \
15 --no-deps \
16 --no-index \
17 --root=${D} \
18 --prefix=${prefix} \
19"
20
21pip_install_wheel_do_install:prepend () {
22 install -d ${D}${PYTHON_SITEPACKAGES_DIR}
23}
24
25export PYPA_WHEEL
26
27PIP_INSTALL_PYTHON = "python3"
28PIP_INSTALL_PYTHON:class-native = "nativepython3"
29
30pip_install_wheel_do_install () {
31 nativepython3 -m pip install ${PIP_INSTALL_ARGS} ${PYPA_WHEEL} ||
32 bbfatal_log "Failed to pip install wheel. Check the logs."
33
34 for i in ${D}${bindir}/* ${D}${sbindir}/*; do
35 if [ -f "$i" ]; then
36 sed -i -e "1s,#!.*nativepython3,#!${USRBINPATH}/env ${PIP_INSTALL_PYTHON}," $i
37 sed -i -e "s:${PYTHON}:${USRBINPATH}/env\ ${PIP_INSTALL_PYTHON}:g" $i
38 sed -i -e "s:${STAGING_BINDIR_NATIVE}:${bindir}:g" $i
39 # Recompile after modifying it
40 cd ${D}
41 file=`echo $i | sed 's:^${D}/::'`
42 ${STAGING_BINDIR_NATIVE}/python3-native/python3 -c "from py_compile import compile; compile('$file')"
43 cd -
44 fi
45 done
46}
47
48EXPORT_FUNCTIONS do_install