summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoss Burton <ross@burtonini.com>2022-03-04 11:55:25 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-03-05 10:45:13 +0000
commit47905882113e2905a8fc9664c5ab338e038c533b (patch)
treeec918c8b694417bc1ab8272088e1bdada316ab40
parenta25c07622502727ca1b0e01d32127b57f75d28fb (diff)
downloadpoky-47905882113e2905a8fc9664c5ab338e038c533b.tar.gz
classes: add setuptools3_legacy
Following a good discussion with PyPA upstream[1] the migration of the setuptools3.bbclass to use bdist_wheel+pip turns out to be more complex than thought. Essentially, we're midway through a lot of changes: the future of Python packaging is wheels and pip, but those by design are not as flexible as traditional distutils and setup.py. Specifically, with traditional distutils the package can implement its own install task and write arbitrary files (such as init scripts). With wheels this is explicity impossible, so packages that do this cannot use the new setuptools class and must continue to use the build/install tasks as before. This class is the old setuptools behaviour, bought back. However, as distutils and the setuptools install task are both deprecated and will soon be removed entirely, any users of this class should be moving to an alternative build tool, be it a modern Python tool which works with wheels, or a non-Pythonic tool such as Meson. [1] https://github.com/pypa/packaging-problems/issues/576 (From OE-Core rev: 341d2b35986e48e4954c591be8bc037a5557452a) Signed-off-by: Ross Burton <ross.burton@arm.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/setuptools3_legacy.bbclass78
1 files changed, 78 insertions, 0 deletions
diff --git a/meta/classes/setuptools3_legacy.bbclass b/meta/classes/setuptools3_legacy.bbclass
new file mode 100644
index 0000000000..5a99daadb5
--- /dev/null
+++ b/meta/classes/setuptools3_legacy.bbclass
@@ -0,0 +1,78 @@
1# This class is for packages which use the deprecated setuptools behaviour,
2# specifically custom install tasks which don't work correctly with bdist_wheel.
3# This behaviour is deprecated in setuptools[1] and won't work in the future, so
4# all users of this should consider their options: pure Python modules can use a
5# modern Python tool such as build[2], or packages which are doing more (such as
6# installing init scripts) should use a fully-featured build system such as Meson.
7#
8# [1] https://setuptools.pypa.io/en/latest/history.html#id142
9# [2] https://pypi.org/project/build/
10
11inherit setuptools3-base
12
13B = "${WORKDIR}/build"
14
15SETUPTOOLS_BUILD_ARGS ?= ""
16SETUPTOOLS_INSTALL_ARGS ?= "--root=${D} \
17 --prefix=${prefix} \
18 --install-lib=${PYTHON_SITEPACKAGES_DIR} \
19 --install-data=${datadir}"
20
21SETUPTOOLS_PYTHON = "python3"
22SETUPTOOLS_PYTHON:class-native = "nativepython3"
23
24SETUPTOOLS_SETUP_PATH ?= "${S}"
25
26setuptools3_legacy_do_configure() {
27 :
28}
29
30setuptools3_legacy_do_compile() {
31 cd ${SETUPTOOLS_SETUP_PATH}
32 NO_FETCH_BUILD=1 \
33 STAGING_INCDIR=${STAGING_INCDIR} \
34 STAGING_LIBDIR=${STAGING_LIBDIR} \
35 ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py \
36 build --build-base=${B} ${SETUPTOOLS_BUILD_ARGS} || \
37 bbfatal_log "'${PYTHON_PN} setup.py build ${SETUPTOOLS_BUILD_ARGS}' execution failed."
38}
39setuptools3_legacy_do_compile[vardepsexclude] = "MACHINE"
40
41setuptools3_legacy_do_install() {
42 cd ${SETUPTOOLS_SETUP_PATH}
43 install -d ${D}${PYTHON_SITEPACKAGES_DIR}
44 STAGING_INCDIR=${STAGING_INCDIR} \
45 STAGING_LIBDIR=${STAGING_LIBDIR} \
46 PYTHONPATH=${D}${PYTHON_SITEPACKAGES_DIR} \
47 ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py \
48 build --build-base=${B} install --skip-build ${SETUPTOOLS_INSTALL_ARGS} || \
49 bbfatal_log "'${PYTHON_PN} setup.py install ${SETUPTOOLS_INSTALL_ARGS}' execution failed."
50
51 # support filenames with *spaces*
52 find ${D} -name "*.py" -exec grep -q ${D} {} \; \
53 -exec sed -i -e s:${D}::g {} \;
54
55 for i in ${D}${bindir}/* ${D}${sbindir}/*; do
56 if [ -f "$i" ]; then
57 sed -i -e s:${PYTHON}:${USRBINPATH}/env\ ${SETUPTOOLS_PYTHON}:g $i
58 sed -i -e s:${STAGING_BINDIR_NATIVE}:${bindir}:g $i
59 fi
60 done
61
62 rm -f ${D}${PYTHON_SITEPACKAGES_DIR}/easy-install.pth
63
64 #
65 # FIXME: Bandaid against wrong datadir computation
66 #
67 if [ -e ${D}${datadir}/share ]; then
68 mv -f ${D}${datadir}/share/* ${D}${datadir}/
69 rmdir ${D}${datadir}/share
70 fi
71}
72setuptools3_legacy_do_install[vardepsexclude] = "MACHINE"
73
74EXPORT_FUNCTIONS do_configure do_compile do_install
75
76export LDSHARED="${CCLD} -shared"
77DEPENDS += "python3-setuptools-native"
78