diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-08-10 14:35:29 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-08-12 15:27:17 +0100 |
commit | fd1517e2b51a170f2427122c6b95396db251d827 (patch) | |
tree | dabfe3e631339c2fc99a9ee7febb0f9c128e325e /meta/classes-recipe/python_pep517.bbclass | |
parent | 10317912ee319ccf7f83605d438b5cbf9663f296 (diff) | |
download | poky-fd1517e2b51a170f2427122c6b95396db251d827.tar.gz |
classes: Update classes to match new bitbake class scope functionality
Move classes to classes-global or classes-recipe as appropriate to take
advantage of new bitbake functionality to check class scope/usage.
(From OE-Core rev: f5c128008365e141082c129417eb72d2751e8045)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes-recipe/python_pep517.bbclass')
-rw-r--r-- | meta/classes-recipe/python_pep517.bbclass | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/meta/classes-recipe/python_pep517.bbclass b/meta/classes-recipe/python_pep517.bbclass new file mode 100644 index 0000000000..202dde0bc3 --- /dev/null +++ b/meta/classes-recipe/python_pep517.bbclass | |||
@@ -0,0 +1,60 @@ | |||
1 | # | ||
2 | # Copyright OpenEmbedded Contributors | ||
3 | # | ||
4 | # SPDX-License-Identifier: MIT | ||
5 | # | ||
6 | |||
7 | # Common infrastructure for Python packages that use PEP-517 compliant packaging. | ||
8 | # https://www.python.org/dev/peps/pep-0517/ | ||
9 | # | ||
10 | # This class will build a wheel in do_compile, and use pypa/installer to install | ||
11 | # it in do_install. | ||
12 | |||
13 | DEPENDS:append = " python3-picobuild-native python3-installer-native" | ||
14 | |||
15 | # Where to execute the build process from | ||
16 | PEP517_SOURCE_PATH ?= "${S}" | ||
17 | |||
18 | # The directory where wheels will be written | ||
19 | PEP517_WHEEL_PATH ?= "${WORKDIR}/dist" | ||
20 | |||
21 | PEP517_PICOBUILD_OPTS ?= "" | ||
22 | |||
23 | # The interpreter to use for installed scripts | ||
24 | PEP517_INSTALL_PYTHON = "python3" | ||
25 | PEP517_INSTALL_PYTHON:class-native = "nativepython3" | ||
26 | |||
27 | # pypa/installer option to control the bytecode compilation | ||
28 | INSTALL_WHEEL_COMPILE_BYTECODE ?= "--compile-bytecode=0" | ||
29 | |||
30 | # PEP517 doesn't have a specific configure step, so set an empty do_configure to avoid | ||
31 | # running base_do_configure. | ||
32 | python_pep517_do_configure () { | ||
33 | : | ||
34 | } | ||
35 | |||
36 | # When we have Python 3.11 we can parse pyproject.toml to determine the build | ||
37 | # API entry point directly | ||
38 | python_pep517_do_compile () { | ||
39 | nativepython3 -m picobuild --source ${PEP517_SOURCE_PATH} --dest ${PEP517_WHEEL_PATH} --wheel ${PEP517_PICOBUILD_OPTS} | ||
40 | } | ||
41 | do_compile[cleandirs] += "${PEP517_WHEEL_PATH}" | ||
42 | |||
43 | python_pep517_do_install () { | ||
44 | COUNT=$(find ${PEP517_WHEEL_PATH} -name '*.whl' | wc -l) | ||
45 | if test $COUNT -eq 0; then | ||
46 | bbfatal No wheels found in ${PEP517_WHEEL_PATH} | ||
47 | elif test $COUNT -gt 1; then | ||
48 | bbfatal More than one wheel found in ${PEP517_WHEEL_PATH}, this should not happen | ||
49 | fi | ||
50 | |||
51 | nativepython3 -m installer ${INSTALL_WHEEL_COMPILE_BYTECODE} --interpreter "${USRBINPATH}/env ${PEP517_INSTALL_PYTHON}" --destdir=${D} ${PEP517_WHEEL_PATH}/*.whl | ||
52 | } | ||
53 | |||
54 | # A manual do_install that just uses unzip for bootstrapping purposes. Callers should DEPEND on unzip-native. | ||
55 | python_pep517_do_bootstrap_install () { | ||
56 | install -d ${D}${PYTHON_SITEPACKAGES_DIR} | ||
57 | unzip -d ${D}${PYTHON_SITEPACKAGES_DIR} ${PEP517_WHEEL_PATH}/*.whl | ||
58 | } | ||
59 | |||
60 | EXPORT_FUNCTIONS do_configure do_compile do_install | ||