xref: /OK3568_Linux_fs/yocto/poky/meta/classes/setuptools3_legacy.bbclass (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun# This class is for packages which use the deprecated setuptools behaviour,
2*4882a593Smuzhiyun# specifically custom install tasks which don't work correctly with bdist_wheel.
3*4882a593Smuzhiyun# This behaviour is deprecated in setuptools[1] and won't work in the future, so
4*4882a593Smuzhiyun# all users of this should consider their options: pure Python modules can use a
5*4882a593Smuzhiyun# modern Python tool such as build[2], or packages which are doing more (such as
6*4882a593Smuzhiyun# installing init scripts) should use a fully-featured build system such as Meson.
7*4882a593Smuzhiyun#
8*4882a593Smuzhiyun# [1] https://setuptools.pypa.io/en/latest/history.html#id142
9*4882a593Smuzhiyun# [2] https://pypi.org/project/build/
10*4882a593Smuzhiyun
11*4882a593Smuzhiyuninherit setuptools3-base
12*4882a593Smuzhiyun
13*4882a593SmuzhiyunB = "${WORKDIR}/build"
14*4882a593Smuzhiyun
15*4882a593SmuzhiyunSETUPTOOLS_BUILD_ARGS ?= ""
16*4882a593SmuzhiyunSETUPTOOLS_INSTALL_ARGS ?= "--root=${D} \
17*4882a593Smuzhiyun    --prefix=${prefix} \
18*4882a593Smuzhiyun    --install-lib=${PYTHON_SITEPACKAGES_DIR} \
19*4882a593Smuzhiyun    --install-data=${datadir}"
20*4882a593Smuzhiyun
21*4882a593SmuzhiyunSETUPTOOLS_PYTHON = "python3"
22*4882a593SmuzhiyunSETUPTOOLS_PYTHON:class-native = "nativepython3"
23*4882a593Smuzhiyun
24*4882a593SmuzhiyunSETUPTOOLS_SETUP_PATH ?= "${S}"
25*4882a593Smuzhiyun
26*4882a593Smuzhiyunsetuptools3_legacy_do_configure() {
27*4882a593Smuzhiyun    :
28*4882a593Smuzhiyun}
29*4882a593Smuzhiyun
30*4882a593Smuzhiyunsetuptools3_legacy_do_compile() {
31*4882a593Smuzhiyun        cd ${SETUPTOOLS_SETUP_PATH}
32*4882a593Smuzhiyun        NO_FETCH_BUILD=1 \
33*4882a593Smuzhiyun        STAGING_INCDIR=${STAGING_INCDIR} \
34*4882a593Smuzhiyun        STAGING_LIBDIR=${STAGING_LIBDIR} \
35*4882a593Smuzhiyun        ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py \
36*4882a593Smuzhiyun        build --build-base=${B} ${SETUPTOOLS_BUILD_ARGS} || \
37*4882a593Smuzhiyun        bbfatal_log "'${PYTHON_PN} setup.py build ${SETUPTOOLS_BUILD_ARGS}' execution failed."
38*4882a593Smuzhiyun}
39*4882a593Smuzhiyunsetuptools3_legacy_do_compile[vardepsexclude] = "MACHINE"
40*4882a593Smuzhiyun
41*4882a593Smuzhiyunsetuptools3_legacy_do_install() {
42*4882a593Smuzhiyun        cd ${SETUPTOOLS_SETUP_PATH}
43*4882a593Smuzhiyun        install -d ${D}${PYTHON_SITEPACKAGES_DIR}
44*4882a593Smuzhiyun        STAGING_INCDIR=${STAGING_INCDIR} \
45*4882a593Smuzhiyun        STAGING_LIBDIR=${STAGING_LIBDIR} \
46*4882a593Smuzhiyun        PYTHONPATH=${D}${PYTHON_SITEPACKAGES_DIR} \
47*4882a593Smuzhiyun        ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py \
48*4882a593Smuzhiyun        build --build-base=${B} install --skip-build ${SETUPTOOLS_INSTALL_ARGS} || \
49*4882a593Smuzhiyun        bbfatal_log "'${PYTHON_PN} setup.py install ${SETUPTOOLS_INSTALL_ARGS}' execution failed."
50*4882a593Smuzhiyun
51*4882a593Smuzhiyun        # support filenames with *spaces*
52*4882a593Smuzhiyun        find ${D} -name "*.py" -exec grep -q ${D} {} \; \
53*4882a593Smuzhiyun                               -exec sed -i -e s:${D}::g {} \;
54*4882a593Smuzhiyun
55*4882a593Smuzhiyun        for i in ${D}${bindir}/* ${D}${sbindir}/*; do
56*4882a593Smuzhiyun            if [ -f "$i" ]; then
57*4882a593Smuzhiyun                sed -i -e s:${PYTHON}:${USRBINPATH}/env\ ${SETUPTOOLS_PYTHON}:g $i
58*4882a593Smuzhiyun                sed -i -e s:${STAGING_BINDIR_NATIVE}:${bindir}:g $i
59*4882a593Smuzhiyun            fi
60*4882a593Smuzhiyun        done
61*4882a593Smuzhiyun
62*4882a593Smuzhiyun        rm -f ${D}${PYTHON_SITEPACKAGES_DIR}/easy-install.pth
63*4882a593Smuzhiyun
64*4882a593Smuzhiyun        #
65*4882a593Smuzhiyun        # FIXME: Bandaid against wrong datadir computation
66*4882a593Smuzhiyun        #
67*4882a593Smuzhiyun        if [ -e ${D}${datadir}/share ]; then
68*4882a593Smuzhiyun            mv -f ${D}${datadir}/share/* ${D}${datadir}/
69*4882a593Smuzhiyun            rmdir ${D}${datadir}/share
70*4882a593Smuzhiyun        fi
71*4882a593Smuzhiyun}
72*4882a593Smuzhiyunsetuptools3_legacy_do_install[vardepsexclude] = "MACHINE"
73*4882a593Smuzhiyun
74*4882a593SmuzhiyunEXPORT_FUNCTIONS do_configure do_compile do_install
75*4882a593Smuzhiyun
76*4882a593Smuzhiyunexport LDSHARED="${CCLD} -shared"
77*4882a593SmuzhiyunDEPENDS += "python3-setuptools-native"
78*4882a593Smuzhiyun
79