Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 1 | # |
| 2 | # Copyright OpenEmbedded Contributors |
| 3 | # |
| 4 | # SPDX-License-Identifier: MIT |
| 5 | # |
| 6 | |
| 7 | # This class is for packages which use the deprecated setuptools behaviour, |
| 8 | # specifically custom install tasks which don't work correctly with bdist_wheel. |
| 9 | # This behaviour is deprecated in setuptools[1] and won't work in the future, so |
| 10 | # all users of this should consider their options: pure Python modules can use a |
| 11 | # modern Python tool such as build[2], or packages which are doing more (such as |
| 12 | # installing init scripts) should use a fully-featured build system such as Meson. |
| 13 | # |
| 14 | # [1] https://setuptools.pypa.io/en/latest/history.html#id142 |
| 15 | # [2] https://pypi.org/project/build/ |
| 16 | |
| 17 | inherit setuptools3-base |
| 18 | |
| 19 | B = "${WORKDIR}/build" |
| 20 | |
| 21 | SETUPTOOLS_BUILD_ARGS ?= "" |
| 22 | SETUPTOOLS_INSTALL_ARGS ?= "--root=${D} \ |
| 23 | --prefix=${prefix} \ |
| 24 | --install-lib=${PYTHON_SITEPACKAGES_DIR} \ |
| 25 | --install-data=${datadir}" |
| 26 | |
| 27 | SETUPTOOLS_PYTHON = "python3" |
| 28 | SETUPTOOLS_PYTHON:class-native = "nativepython3" |
| 29 | |
| 30 | SETUPTOOLS_SETUP_PATH ?= "${S}" |
| 31 | |
| 32 | setuptools3_legacy_do_configure() { |
| 33 | : |
| 34 | } |
| 35 | |
| 36 | setuptools3_legacy_do_compile() { |
| 37 | cd ${SETUPTOOLS_SETUP_PATH} |
| 38 | NO_FETCH_BUILD=1 \ |
| 39 | STAGING_INCDIR=${STAGING_INCDIR} \ |
| 40 | STAGING_LIBDIR=${STAGING_LIBDIR} \ |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 41 | ${STAGING_BINDIR_NATIVE}/python3-native/python3 setup.py \ |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 42 | build --build-base=${B} ${SETUPTOOLS_BUILD_ARGS} || \ |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 43 | bbfatal_log "'python3 setup.py build ${SETUPTOOLS_BUILD_ARGS}' execution failed." |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 44 | } |
| 45 | setuptools3_legacy_do_compile[vardepsexclude] = "MACHINE" |
| 46 | |
| 47 | setuptools3_legacy_do_install() { |
| 48 | cd ${SETUPTOOLS_SETUP_PATH} |
| 49 | install -d ${D}${PYTHON_SITEPACKAGES_DIR} |
| 50 | STAGING_INCDIR=${STAGING_INCDIR} \ |
| 51 | STAGING_LIBDIR=${STAGING_LIBDIR} \ |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 52 | PYTHONPATH=${D}${PYTHON_SITEPACKAGES_DIR}:$PYTHONPATH \ |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 53 | ${STAGING_BINDIR_NATIVE}/python3-native/python3 setup.py \ |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 54 | build --build-base=${B} install --skip-build ${SETUPTOOLS_INSTALL_ARGS} || \ |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 55 | bbfatal_log "'python3 setup.py install ${SETUPTOOLS_INSTALL_ARGS}' execution failed." |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 56 | |
| 57 | # support filenames with *spaces* |
| 58 | find ${D} -name "*.py" -exec grep -q ${D} {} \; \ |
| 59 | -exec sed -i -e s:${D}::g {} \; |
| 60 | |
| 61 | for i in ${D}${bindir}/* ${D}${sbindir}/*; do |
| 62 | if [ -f "$i" ]; then |
| 63 | sed -i -e s:${PYTHON}:${USRBINPATH}/env\ ${SETUPTOOLS_PYTHON}:g $i |
| 64 | sed -i -e s:${STAGING_BINDIR_NATIVE}:${bindir}:g $i |
| 65 | fi |
| 66 | done |
| 67 | |
| 68 | rm -f ${D}${PYTHON_SITEPACKAGES_DIR}/easy-install.pth |
| 69 | |
| 70 | # |
| 71 | # FIXME: Bandaid against wrong datadir computation |
| 72 | # |
| 73 | if [ -e ${D}${datadir}/share ]; then |
| 74 | mv -f ${D}${datadir}/share/* ${D}${datadir}/ |
| 75 | rmdir ${D}${datadir}/share |
| 76 | fi |
| 77 | } |
| 78 | setuptools3_legacy_do_install[vardepsexclude] = "MACHINE" |
| 79 | |
| 80 | EXPORT_FUNCTIONS do_configure do_compile do_install |
| 81 | |
| 82 | export LDSHARED="${CCLD} -shared" |
| 83 | DEPENDS += "python3-setuptools-native" |
| 84 | |