blob: 21748f922ad6fd112a363480bb1cf10e5e05b998 [file] [log] [blame]
Patrick Williams92b42cb2022-09-03 06:53:57 -05001#
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
17inherit setuptools3-base
18
19B = "${WORKDIR}/build"
20
21SETUPTOOLS_BUILD_ARGS ?= ""
22SETUPTOOLS_INSTALL_ARGS ?= "--root=${D} \
23 --prefix=${prefix} \
24 --install-lib=${PYTHON_SITEPACKAGES_DIR} \
25 --install-data=${datadir}"
26
27SETUPTOOLS_PYTHON = "python3"
28SETUPTOOLS_PYTHON:class-native = "nativepython3"
29
30SETUPTOOLS_SETUP_PATH ?= "${S}"
31
32setuptools3_legacy_do_configure() {
33 :
34}
35
36setuptools3_legacy_do_compile() {
37 cd ${SETUPTOOLS_SETUP_PATH}
38 NO_FETCH_BUILD=1 \
39 STAGING_INCDIR=${STAGING_INCDIR} \
40 STAGING_LIBDIR=${STAGING_LIBDIR} \
41 ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py \
42 build --build-base=${B} ${SETUPTOOLS_BUILD_ARGS} || \
43 bbfatal_log "'${PYTHON_PN} setup.py build ${SETUPTOOLS_BUILD_ARGS}' execution failed."
44}
45setuptools3_legacy_do_compile[vardepsexclude] = "MACHINE"
46
47setuptools3_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} \
52 PYTHONPATH=${D}${PYTHON_SITEPACKAGES_DIR} \
53 ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py \
54 build --build-base=${B} install --skip-build ${SETUPTOOLS_INSTALL_ARGS} || \
55 bbfatal_log "'${PYTHON_PN} setup.py install ${SETUPTOOLS_INSTALL_ARGS}' execution failed."
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}
78setuptools3_legacy_do_install[vardepsexclude] = "MACHINE"
79
80EXPORT_FUNCTIONS do_configure do_compile do_install
81
82export LDSHARED="${CCLD} -shared"
83DEPENDS += "python3-setuptools-native"
84