diff options
Diffstat (limited to 'meta/recipes-devtools/python/python3_3.12.1.bb')
-rw-r--r-- | meta/recipes-devtools/python/python3_3.12.1.bb | 470 |
1 files changed, 470 insertions, 0 deletions
diff --git a/meta/recipes-devtools/python/python3_3.12.1.bb b/meta/recipes-devtools/python/python3_3.12.1.bb new file mode 100644 index 0000000000..ece7539c51 --- /dev/null +++ b/meta/recipes-devtools/python/python3_3.12.1.bb | |||
@@ -0,0 +1,470 @@ | |||
1 | SUMMARY = "The Python Programming Language" | ||
2 | HOMEPAGE = "http://www.python.org" | ||
3 | DESCRIPTION = "Python is a programming language that lets you work more quickly and integrate your systems more effectively." | ||
4 | LICENSE = "PSF-2.0" | ||
5 | SECTION = "devel/python" | ||
6 | |||
7 | LIC_FILES_CHKSUM = "file://LICENSE;md5=fcf6b249c2641540219a727f35d8d2c2" | ||
8 | |||
9 | SRC_URI = "http://www.python.org/ftp/python/${PV}/Python-${PV}.tar.xz \ | ||
10 | file://run-ptest \ | ||
11 | file://create_manifest3.py \ | ||
12 | file://get_module_deps3.py \ | ||
13 | file://python3-manifest.json \ | ||
14 | file://check_build_completeness.py \ | ||
15 | file://reformat_sysconfig.py \ | ||
16 | file://cgi_py.patch \ | ||
17 | file://0001-Makefile.pre-use-qemu-wrapper-when-gathering-profile.patch \ | ||
18 | file://0001-python3-use-cc_basename-to-replace-CC-for-checking-c.patch \ | ||
19 | file://crosspythonpath.patch \ | ||
20 | file://0001-test_locale.py-correct-the-test-output-format.patch \ | ||
21 | file://0020-configure.ac-setup.py-do-not-add-a-curses-include-pa.patch \ | ||
22 | file://0001-Skip-failing-tests-due-to-load-variability-on-YP-AB.patch \ | ||
23 | file://0001-test_ctypes.test_find-skip-without-tools-sdk.patch \ | ||
24 | file://makerace.patch \ | ||
25 | file://0001-sysconfig.py-use-platlibdir-also-for-purelib.patch \ | ||
26 | file://0001-Lib-pty.py-handle-stdin-I-O-errors-same-way-as-maste.patch \ | ||
27 | file://deterministic_imports.patch \ | ||
28 | file://0001-Avoid-shebang-overflow-on-python-config.py.patch \ | ||
29 | file://0001-Update-test_sysconfig-for-posix_user-purelib.patch \ | ||
30 | file://0001-skip-no_stdout_fileno-test-due-to-load-variability.patch \ | ||
31 | file://0001-test_storlines-skip-due-to-load-variability.patch \ | ||
32 | " | ||
33 | |||
34 | SRC_URI:append:class-native = " \ | ||
35 | file://0001-Lib-sysconfig.py-use-prefix-value-from-build-configu.patch \ | ||
36 | " | ||
37 | |||
38 | SRC_URI[sha256sum] = "8dfb8f426fcd226657f9e2bd5f1e96e53264965176fa17d32658e873591aeb21" | ||
39 | |||
40 | # exclude pre-releases for both python 2.x and 3.x | ||
41 | UPSTREAM_CHECK_REGEX = "[Pp]ython-(?P<pver>\d+(\.\d+)+).tar" | ||
42 | UPSTREAM_CHECK_URI = "https://www.python.org/downloads/source/" | ||
43 | |||
44 | CVE_PRODUCT = "python cpython" | ||
45 | |||
46 | CVE_STATUS[CVE-2007-4559] = "disputed: Upstream consider this expected behaviour" | ||
47 | CVE_STATUS[CVE-2019-18348] = "not-applicable-config: This is not exploitable when glibc has CVE-2016-10739 fixed" | ||
48 | CVE_STATUS[CVE-2020-15523] = "not-applicable-platform: Issue only applies on Windows" | ||
49 | CVE_STATUS[CVE-2022-26488] = "not-applicable-platform: Issue only applies on Windows" | ||
50 | # The module will be removed in the future and flaws documented. | ||
51 | CVE_STATUS[CVE-2015-20107] = "upstream-wontfix: The mailcap module is insecure by design, so this can't be fixed in a meaningful way" | ||
52 | CVE_STATUS[CVE-2023-36632] = "disputed: Not an issue, in fact expected behaviour" | ||
53 | |||
54 | PYTHON_MAJMIN = "3.12" | ||
55 | |||
56 | S = "${WORKDIR}/Python-${PV}" | ||
57 | |||
58 | BBCLASSEXTEND = "native nativesdk" | ||
59 | |||
60 | inherit autotools pkgconfig qemu ptest multilib_header update-alternatives | ||
61 | |||
62 | MULTILIB_SUFFIX = "${@d.getVar('base_libdir',1).split('/')[-1]}" | ||
63 | |||
64 | ALTERNATIVE:${PN}-dev = "python3-config" | ||
65 | ALTERNATIVE_LINK_NAME[python3-config] = "${bindir}/python${PYTHON_MAJMIN}-config" | ||
66 | ALTERNATIVE_TARGET[python3-config] = "${bindir}/python${PYTHON_MAJMIN}-config-${MULTILIB_SUFFIX}" | ||
67 | |||
68 | |||
69 | DEPENDS = "bzip2-replacement-native expat libffi bzip2 openssl sqlite3 zlib virtual/libintl xz virtual/crypt util-linux-libuuid libtirpc libnsl2 autoconf-archive-native ncurses" | ||
70 | DEPENDS:append:class-target = " python3-native" | ||
71 | DEPENDS:append:class-nativesdk = " python3-native" | ||
72 | |||
73 | EXTRA_OECONF = " --without-ensurepip --enable-shared --with-platlibdir=${baselib} --with-system-expat" | ||
74 | EXTRA_OECONF:append:class-native = " --bindir=${bindir}/${PN}" | ||
75 | EXTRA_OECONF:append:class-target = " --with-build-python=nativepython3" | ||
76 | EXTRA_OECONF:append:class-nativesdk = " --with-build-python=nativepython3" | ||
77 | |||
78 | export CROSSPYTHONPATH="${STAGING_LIBDIR_NATIVE}/python${PYTHON_MAJMIN}/lib-dynload/" | ||
79 | |||
80 | EXTRANATIVEPATH += "python3-native" | ||
81 | |||
82 | # LTO will be enabled via packageconfig depending upong distro features | ||
83 | LTO:class-target = "" | ||
84 | |||
85 | CACHED_CONFIGUREVARS = " \ | ||
86 | ac_cv_file__dev_ptmx=yes \ | ||
87 | ac_cv_file__dev_ptc=no \ | ||
88 | ac_cv_working_tzset=yes \ | ||
89 | " | ||
90 | # set thread stack size to 2MB on musl for interpreter and stdlib C extensions | ||
91 | # so it does not run into stack limits due to musl's small thread stack | ||
92 | # This is only needed to build interpreter and not the subsequent modules | ||
93 | # Thats why CFLAGS_NODIST is modified instead of CFLAGS | ||
94 | CACHED_CONFIGUREVARS:append:libc-musl = "\ | ||
95 | CFLAGS_NODIST='${CFLAGS} -DTHREAD_STACK_SIZE=0x200000' \ | ||
96 | " | ||
97 | |||
98 | # PGO currently causes builds to not be reproducible so disable by default, see YOCTO #13407 | ||
99 | PACKAGECONFIG ??= "editline gdbm ${@bb.utils.filter('DISTRO_FEATURES', 'lto', d)}" | ||
100 | PACKAGECONFIG[readline] = "--with-readline=readline,,readline,,,editline" | ||
101 | PACKAGECONFIG[editline] = "--with-readline=editline,,libedit,,,readline" | ||
102 | # Use profile guided optimisation by running PyBench inside qemu-user | ||
103 | PACKAGECONFIG[pgo] = "--enable-optimizations,,qemu-native" | ||
104 | PACKAGECONFIG[tk] = ",,tk" | ||
105 | PACKAGECONFIG[tcl] = ",,tcl" | ||
106 | PACKAGECONFIG[gdbm] = ",,gdbm" | ||
107 | PACKAGECONFIG[lto] = "--with-lto,--without-lto" | ||
108 | |||
109 | do_configure:prepend () { | ||
110 | mkdir -p ${B}/Modules | ||
111 | cat > ${B}/Modules/Setup.local << EOF | ||
112 | *disabled* | ||
113 | ${@bb.utils.contains('PACKAGECONFIG', 'gdbm', '', '_gdbm _dbm', d)} | ||
114 | ${@bb.utils.contains('PACKAGECONFIG', 'readline', '', 'readline', d)} | ||
115 | ${@bb.utils.contains('PACKAGECONFIG', 'tk', '', '_tkinter', d)} | ||
116 | EOF | ||
117 | } | ||
118 | |||
119 | CPPFLAGS:append = " -I${STAGING_INCDIR}/ncursesw -I${STAGING_INCDIR}/uuid" | ||
120 | |||
121 | # COMPILEALL_OPTS= ensures that .pyc are not compiled in parallel | ||
122 | # This was found to lock up builds, break reproducibility, and produce strange file ownership | ||
123 | # races. | ||
124 | # | ||
125 | # The upstream commit introducing the change was: | ||
126 | # https://github.com/python/cpython/commit/1a2dd82f56bd813aacc570e172cefe55a8a41504 | ||
127 | # | ||
128 | # The build lock up issue is reported here: | ||
129 | # https://bugs.python.org/issue45945 | ||
130 | # | ||
131 | # The repro failures are documented here: | ||
132 | # https://autobuilder.yocto.io/pub/repro-fail/oe-reproducible-20211130-yr_o1a8d/packages/diff-html/ | ||
133 | |||
134 | EXTRA_OEMAKE = '\ | ||
135 | STAGING_LIBDIR=${STAGING_LIBDIR} \ | ||
136 | STAGING_INCDIR=${STAGING_INCDIR} \ | ||
137 | LIB=${baselib} \ | ||
138 | COMPILEALL_OPTS= \ | ||
139 | ' | ||
140 | |||
141 | # Generate a Profile Guided Optimisation wrapper script that uses qemu-user for | ||
142 | # all cross builds. | ||
143 | write_pgo_wrapper:class-native = ":" | ||
144 | write_pgo_wrapper() { | ||
145 | if ${@bb.utils.contains('PACKAGECONFIG', 'pgo', 'true', 'false', d)}; then | ||
146 | cat >pgo-wrapper <<EOF | ||
147 | #!/bin/sh | ||
148 | cd ${B} | ||
149 | ${@qemu_wrapper_cmdline(d, '${STAGING_DIR_TARGET}', ['${B}', '${STAGING_DIR_TARGET}/${base_libdir}'])} "\$@" | ||
150 | EOF | ||
151 | chmod +x pgo-wrapper | ||
152 | fi | ||
153 | } | ||
154 | |||
155 | do_compile:prepend() { | ||
156 | write_pgo_wrapper | ||
157 | } | ||
158 | |||
159 | do_install:prepend() { | ||
160 | ${WORKDIR}/check_build_completeness.py ${T}/log.do_compile | ||
161 | } | ||
162 | |||
163 | do_install:append:class-target() { | ||
164 | oe_multilib_header python${PYTHON_MAJMIN}/pyconfig.h | ||
165 | } | ||
166 | |||
167 | do_install:append:class-native() { | ||
168 | # Make sure we use /usr/bin/env python | ||
169 | for PYTHSCRIPT in `grep -rIl ${bindir}/${PN}/python ${D}${bindir}/${PN}`; do | ||
170 | sed -i -e '1s|^#!.*|#!/usr/bin/env python3|' $PYTHSCRIPT | ||
171 | done | ||
172 | # Add a symlink to the native Python so that scripts can just invoke | ||
173 | # "nativepython" and get the right one without needing absolute paths | ||
174 | # (these often end up too long for the #! parser in the kernel as the | ||
175 | # buffer is 128 bytes long). | ||
176 | ln -s python3-native/python3 ${D}${bindir}/nativepython3 | ||
177 | |||
178 | # Remove the opt-1.pyc and opt-2.pyc files. There are over 3,000 of them | ||
179 | # and the overhead in each recipe-sysroot-native isn't worth it, particularly | ||
180 | # when they're only used for python called with -O or -OO. | ||
181 | #find ${D} -name *opt-*.pyc -delete | ||
182 | # Remove all pyc files. There are a ton of them and it is probably faster to let | ||
183 | # python create the ones it wants at runtime rather than manage in the sstate | ||
184 | # tarballs and sysroot creation. | ||
185 | find ${D} -name *.pyc -delete | ||
186 | |||
187 | # Nothing should be looking into ${B} for python3-native | ||
188 | sed -i -e 's:${B}:/build/path/unavailable/:g' \ | ||
189 | ${D}/${libdir}/python${PYTHON_MAJMIN}/config-${PYTHON_MAJMIN}${PYTHON_ABI}*/Makefile | ||
190 | |||
191 | # disable the lookup in user's site-packages globally | ||
192 | sed -i 's#ENABLE_USER_SITE = None#ENABLE_USER_SITE = False#' ${D}${libdir}/python${PYTHON_MAJMIN}/site.py | ||
193 | |||
194 | # python3-config needs to be in /usr/bin and not in a subdir of it to work properly | ||
195 | mv ${D}/${bindir}/${PN}/python*config ${D}/${bindir}/ | ||
196 | } | ||
197 | |||
198 | do_install:append() { | ||
199 | for c in ${D}/${libdir}/python${PYTHON_MAJMIN}/_sysconfigdata*.py; do | ||
200 | python3 ${WORKDIR}/reformat_sysconfig.py $c | ||
201 | done | ||
202 | rm -f ${D}${libdir}/python${PYTHON_MAJMIN}/__pycache__/_sysconfigdata*.cpython* | ||
203 | |||
204 | mkdir -p ${D}${libdir}/python-sysconfigdata | ||
205 | sysconfigfile=`find ${D} -name _sysconfig*.py` | ||
206 | sed -i \ | ||
207 | -e "s,^ 'LIBDIR'.*, 'LIBDIR': '${STAGING_LIBDIR}'\,,g" \ | ||
208 | -e "s,^ 'INCLUDEDIR'.*, 'INCLUDEDIR': '${STAGING_INCDIR}'\,,g" \ | ||
209 | -e "s,^ 'CONFINCLUDEDIR'.*, 'CONFINCLUDEDIR': '${STAGING_INCDIR}'\,,g" \ | ||
210 | -e "s,^ 'INCLUDEPY'.*, 'INCLUDEPY': '${STAGING_INCDIR}/python${PYTHON_MAJMIN}'\,,g" \ | ||
211 | -e "s,^ 'CONFINCLUDEPY'.*, 'CONFINCLUDEPY': '${STAGING_INCDIR}/python${PYTHON_MAJMIN}'\,,g" \ | ||
212 | -e "s,${B},/build/path/unavailable/,g" \ | ||
213 | $sysconfigfile | ||
214 | cp $sysconfigfile ${D}${libdir}/python-sysconfigdata/_sysconfigdata.py | ||
215 | |||
216 | |||
217 | # Unfortunately the following pyc files are non-deterministc due to 'frozenset' | ||
218 | # being written without strict ordering, even with PYTHONHASHSEED = 0 | ||
219 | # Upstream is discussing ways to solve the issue properly, until then let's | ||
220 | # just not install the problematic files. | ||
221 | # More info: http://benno.id.au/blog/2013/01/15/python-determinism | ||
222 | rm -f ${D}${libdir}/python${PYTHON_MAJMIN}/test/__pycache__/test_range.cpython* | ||
223 | rm -f ${D}${libdir}/python${PYTHON_MAJMIN}/test/__pycache__/test_xml_etree.cpython* | ||
224 | |||
225 | # Similar to the above, we're getting reproducibility issues with | ||
226 | # /usr/lib/python3.10/__pycache__/traceback.cpython-310.pyc | ||
227 | # so remove it too | ||
228 | rm -f ${D}${libdir}/python${PYTHON_MAJMIN}/__pycache__/traceback.cpython* | ||
229 | |||
230 | # Remove the opt-1.pyc and opt-2.pyc files. They effectively waste space on embedded | ||
231 | # style targets as they're only used when python is called with the -O or -OO options | ||
232 | # which is rare. | ||
233 | find ${D} -name *opt-*.pyc -delete | ||
234 | } | ||
235 | |||
236 | do_install:append:class-nativesdk () { | ||
237 | # Make sure we use /usr/bin/env python | ||
238 | for PYTHSCRIPT in `grep -rIl ${bindir}/python ${D}${bindir}`; do | ||
239 | sed -i -e '1s|^#!.*|#!/usr/bin/env python3|' $PYTHSCRIPT | ||
240 | done | ||
241 | create_wrapper ${D}${bindir}/python${PYTHON_MAJMIN} TERMINFO_DIRS='${sysconfdir}/terminfo:/etc/terminfo:/usr/share/terminfo:/usr/share/misc/terminfo:/lib/terminfo' PYTHONNOUSERSITE='1' | ||
242 | } | ||
243 | |||
244 | do_install_ptest:append:class-target:libc-musl () { | ||
245 | sed -i -e 's|SKIPPED_TESTS=|SKIPPED_TESTS="-x test__locale -x test_c_locale_coercion -x test_locale -x test_os test_re -x test__xxsubinterpreters -x test_threading"|' ${D}${PTEST_PATH}/run-ptest | ||
246 | } | ||
247 | |||
248 | SYSROOT_PREPROCESS_FUNCS:append:class-target = " provide_target_config_script" | ||
249 | SYSROOT_PREPROCESS_FUNCS:append:class-nativesdk = " provide_target_config_script" | ||
250 | |||
251 | # This is installed into /usr/python-target-config/ and not /usr/bin | ||
252 | # because adding target sysroot's /usr/bin/ to PATH has unwanted side effects | ||
253 | # in components erroneously picking up other target executables from it | ||
254 | provide_target_config_script() { | ||
255 | install -d ${SYSROOT_DESTDIR}${prefix}/python-target-config/ | ||
256 | install ${D}/${bindir}/python3-config ${SYSROOT_DESTDIR}/${prefix}/python-target-config/ | ||
257 | install ${D}/${bindir}/python${PYTHON_MAJMIN}-config ${SYSROOT_DESTDIR}/${prefix}/python-target-config/ | ||
258 | } | ||
259 | SYSROOT_DIRS += "${prefix}/python-target-config/" | ||
260 | |||
261 | SSTATE_SCAN_FILES += "Makefile _sysconfigdata.py" | ||
262 | SSTATE_HASHEQUIV_FILEMAP = " \ | ||
263 | populate_sysroot:*/lib*/python3*/_sysconfigdata*.py:${TMPDIR} \ | ||
264 | populate_sysroot:*/lib*/python3*/_sysconfigdata*.py:${COREBASE} \ | ||
265 | populate_sysroot:*/lib*/python3*/config-*/Makefile:${TMPDIR} \ | ||
266 | populate_sysroot:*/lib*/python3*/config-*/Makefile:${COREBASE} \ | ||
267 | populate_sysroot:*/lib*/python-sysconfigdata/_sysconfigdata.py:${TMPDIR} \ | ||
268 | populate_sysroot:*/lib*/python-sysconfigdata/_sysconfigdata.py:${COREBASE} \ | ||
269 | " | ||
270 | PACKAGE_PREPROCESS_FUNCS += "py_package_preprocess" | ||
271 | |||
272 | py_package_preprocess () { | ||
273 | # Remove references to buildmachine paths in target Makefile and _sysconfigdata | ||
274 | sed -i -e 's:--sysroot=${STAGING_DIR_TARGET}::g' -e s:'--with-libtool-sysroot=${STAGING_DIR_TARGET}'::g \ | ||
275 | -e 's|${DEBUG_PREFIX_MAP}||g' \ | ||
276 | -e 's:${HOSTTOOLS_DIR}/::g' \ | ||
277 | -e 's:${RECIPE_SYSROOT_NATIVE}::g' \ | ||
278 | -e 's:${RECIPE_SYSROOT}::g' \ | ||
279 | -e 's:${BASE_WORKDIR}/${MULTIMACH_TARGET_SYS}::g' \ | ||
280 | ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/config-${PYTHON_MAJMIN}${PYTHON_ABI}*/Makefile \ | ||
281 | ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/_sysconfigdata*.py \ | ||
282 | ${PKGD}/${bindir}/python${PYTHON_MAJMIN}-config | ||
283 | |||
284 | # Reformat _sysconfigdata after modifying it so that it remains | ||
285 | # reproducible | ||
286 | for c in ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/_sysconfigdata*.py; do | ||
287 | python3 ${WORKDIR}/reformat_sysconfig.py $c | ||
288 | done | ||
289 | |||
290 | # Recompile _sysconfigdata after modifying it | ||
291 | cd ${PKGD} | ||
292 | sysconfigfile=`find . -name _sysconfigdata_*.py` | ||
293 | ${STAGING_BINDIR_NATIVE}/python3-native/python3 \ | ||
294 | -c "from py_compile import compile; compile('$sysconfigfile')" | ||
295 | ${STAGING_BINDIR_NATIVE}/python3-native/python3 \ | ||
296 | -c "from py_compile import compile; compile('$sysconfigfile', optimize=1)" | ||
297 | ${STAGING_BINDIR_NATIVE}/python3-native/python3 \ | ||
298 | -c "from py_compile import compile; compile('$sysconfigfile', optimize=2)" | ||
299 | cd - | ||
300 | |||
301 | mv ${PKGD}/${bindir}/python${PYTHON_MAJMIN}-config ${PKGD}/${bindir}/python${PYTHON_MAJMIN}-config-${MULTILIB_SUFFIX} | ||
302 | |||
303 | #Remove the unneeded copy of target sysconfig data | ||
304 | rm -rf ${PKGD}/${libdir}/python-sysconfigdata | ||
305 | } | ||
306 | |||
307 | # We want bytecode precompiled .py files (.pyc's) by default | ||
308 | # but the user may set it on their own conf | ||
309 | INCLUDE_PYCS ?= "1" | ||
310 | |||
311 | python(){ | ||
312 | import collections, json | ||
313 | |||
314 | filename = os.path.join(d.getVar('THISDIR'), 'python3', 'python3-manifest.json') | ||
315 | # This python changes the datastore based on the contents of a file, so mark | ||
316 | # that dependency. | ||
317 | bb.parse.mark_dependency(d, filename) | ||
318 | |||
319 | with open(filename) as manifest_file: | ||
320 | manifest_str = manifest_file.read() | ||
321 | json_start = manifest_str.find('# EOC') + 6 | ||
322 | manifest_file.seek(json_start) | ||
323 | manifest_str = manifest_file.read() | ||
324 | python_manifest = json.loads(manifest_str, object_pairs_hook=collections.OrderedDict) | ||
325 | |||
326 | # First set RPROVIDES for -native case | ||
327 | # Hardcoded since it cant be python3-native-foo, should be python3-foo-native | ||
328 | pn = 'python3' | ||
329 | rprovides = (d.getVar('RPROVIDES') or "").split() | ||
330 | |||
331 | # ${PN}-misc-native is not in the manifest | ||
332 | rprovides.append(pn + '-misc-native') | ||
333 | |||
334 | for key in python_manifest: | ||
335 | pypackage = pn + '-' + key + '-native' | ||
336 | if pypackage not in rprovides: | ||
337 | rprovides.append(pypackage) | ||
338 | |||
339 | d.setVar('RPROVIDES:class-native', ' '.join(rprovides)) | ||
340 | |||
341 | # Then work on the target | ||
342 | include_pycs = d.getVar('INCLUDE_PYCS') | ||
343 | |||
344 | packages = d.getVar('PACKAGES').split() | ||
345 | pn = d.getVar('PN') | ||
346 | |||
347 | newpackages=[] | ||
348 | for key in python_manifest: | ||
349 | pypackage = pn + '-' + key | ||
350 | |||
351 | if pypackage not in packages: | ||
352 | # We need to prepend, otherwise python-misc gets everything | ||
353 | # so we use a new variable | ||
354 | newpackages.append(pypackage) | ||
355 | |||
356 | # "Build" python's manifest FILES, RDEPENDS and SUMMARY | ||
357 | d.setVar('FILES:' + pypackage, '') | ||
358 | for value in python_manifest[key]['files']: | ||
359 | d.appendVar('FILES:' + pypackage, ' ' + value) | ||
360 | |||
361 | # Add cached files | ||
362 | if include_pycs == '1': | ||
363 | for value in python_manifest[key]['cached']: | ||
364 | d.appendVar('FILES:' + pypackage, ' ' + value) | ||
365 | |||
366 | for value in python_manifest[key]['rdepends']: | ||
367 | # Make it work with or without $PN | ||
368 | if '${PN}' in value: | ||
369 | value=value.split('-', 1)[1] | ||
370 | d.appendVar('RDEPENDS:' + pypackage, ' ' + pn + '-' + value) | ||
371 | |||
372 | for value in python_manifest[key].get('rrecommends', ()): | ||
373 | if '${PN}' in value: | ||
374 | value=value.split('-', 1)[1] | ||
375 | d.appendVar('RRECOMMENDS:' + pypackage, ' ' + pn + '-' + value) | ||
376 | |||
377 | d.setVar('SUMMARY:' + pypackage, python_manifest[key]['summary']) | ||
378 | |||
379 | # Prepending so to avoid python-misc getting everything | ||
380 | packages = newpackages + packages | ||
381 | d.setVar('PACKAGES', ' '.join(packages)) | ||
382 | d.setVar('ALLOW_EMPTY:${PN}-modules', '1') | ||
383 | d.setVar('ALLOW_EMPTY:${PN}-pkgutil', '1') | ||
384 | |||
385 | if "pgo" in d.getVar("PACKAGECONFIG").split() and not bb.utils.contains('MACHINE_FEATURES', 'qemu-usermode', True, False, d): | ||
386 | bb.fatal("pgo cannot be enabled as there is no qemu-usermode support for this architecture/machine") | ||
387 | } | ||
388 | |||
389 | # Files needed to create a new manifest | ||
390 | |||
391 | do_create_manifest() { | ||
392 | # This task should be run with every new release of Python. | ||
393 | # We must ensure that PACKAGECONFIG enables everything when creating | ||
394 | # a new manifest, this is to base our new manifest on a complete | ||
395 | # native python build, containing all dependencies, otherwise the task | ||
396 | # wont be able to find the required files. | ||
397 | # e.g. BerkeleyDB is an optional build dependency so it may or may not | ||
398 | # be present, we must ensure it is. | ||
399 | |||
400 | cd ${WORKDIR} | ||
401 | # This needs to be executed by python-native and NOT by HOST's python | ||
402 | nativepython3 create_manifest3.py ${PYTHON_MAJMIN} | ||
403 | cp python3-manifest.json.new ${THISDIR}/python3/python3-manifest.json | ||
404 | } | ||
405 | |||
406 | # bitbake python -c create_manifest | ||
407 | # Make sure we have native python ready when we create a new manifest | ||
408 | addtask do_create_manifest after do_patch do_prepare_recipe_sysroot | ||
409 | |||
410 | # manual dependency additions | ||
411 | RRECOMMENDS:${PN}-core:append:class-nativesdk = " nativesdk-python3-modules" | ||
412 | RRECOMMENDS:${PN}-crypt:append:class-target = " ${MLPREFIX}openssl ${MLPREFIX}ca-certificates" | ||
413 | RRECOMMENDS:${PN}-crypt:append:class-nativesdk = " ${MLPREFIX}openssl ${MLPREFIX}ca-certificates" | ||
414 | |||
415 | # For historical reasons PN is empty and provided by python3-modules | ||
416 | FILES:${PN} = "" | ||
417 | RPROVIDES:${PN}-modules = "${PN}" | ||
418 | |||
419 | FILES:${PN}-pydoc += "${bindir}/pydoc${PYTHON_MAJMIN} ${bindir}/pydoc3" | ||
420 | FILES:${PN}-idle += "${bindir}/idle3 ${bindir}/idle${PYTHON_MAJMIN}" | ||
421 | |||
422 | # provide python-pyvenv from python3-venv | ||
423 | RPROVIDES:${PN}-venv += "${MLPREFIX}python3-pyvenv" | ||
424 | |||
425 | # package libpython3 | ||
426 | PACKAGES =+ "libpython3 libpython3-staticdev" | ||
427 | FILES:libpython3 = "${libdir}/libpython*.so.*" | ||
428 | FILES:libpython3-staticdev += "${libdir}/python${PYTHON_MAJMIN}/config-${PYTHON_MAJMIN}-*/libpython${PYTHON_MAJMIN}.a" | ||
429 | INSANE_SKIP:${PN}-dev += "dev-elf" | ||
430 | INSANE_SKIP:${PN}-ptest = "dev-deps" | ||
431 | |||
432 | # catch all the rest (unsorted) | ||
433 | PACKAGES += "${PN}-misc" | ||
434 | RDEPENDS:${PN}-misc += "\ | ||
435 | ${PN}-audio \ | ||
436 | ${PN}-codecs \ | ||
437 | ${PN}-core \ | ||
438 | ${PN}-email \ | ||
439 | ${PN}-numbers \ | ||
440 | ${PN}-pickle \ | ||
441 | ${PN}-pydoc \ | ||
442 | " | ||
443 | RDEPENDS:${PN}-modules:append:class-target = " ${MLPREFIX}python3-misc" | ||
444 | RDEPENDS:${PN}-modules:append:class-nativesdk = " ${MLPREFIX}python3-misc" | ||
445 | RDEPENDS:${PN}-modules:append:class-target = " ${@bb.utils.contains('PACKAGECONFIG', 'gdbm', '${MLPREFIX}python3-gdbm', '', d)}" | ||
446 | FILES:${PN}-misc = "${libdir}/python${PYTHON_MAJMIN} ${libdir}/python${PYTHON_MAJMIN}/lib-dynload" | ||
447 | |||
448 | # catch manpage | ||
449 | PACKAGES += "${PN}-man" | ||
450 | FILES:${PN}-man = "${datadir}/man" | ||
451 | |||
452 | # See https://bugs.python.org/issue18748 and https://bugs.python.org/issue37395 | ||
453 | RDEPENDS:libpython3:append:libc-glibc = " libgcc" | ||
454 | RDEPENDS:${PN}-ctypes:append:libc-glibc = " ${MLPREFIX}ldconfig" | ||
455 | RDEPENDS:${PN}-ptest = "${PN}-modules ${PN}-tests ${PN}-dev ${PN}-cgitb ${PN}-zipapp unzip bzip2 libgcc tzdata coreutils sed gcc g++ binutils \ | ||
456 | locale-base-fr-fr locale-base-en-us locale-base-de-de" | ||
457 | RDEPENDS:${PN}-ptest:append:libc-glibc = " locale-base-tr-tr" | ||
458 | RDEPENDS:${PN}-tkinter += "${@bb.utils.contains('PACKAGECONFIG', 'tk', '${MLPREFIX}tk ${MLPREFIX}tk-lib', '', d)}" | ||
459 | RDEPENDS:${PN}-idle += "${@bb.utils.contains('PACKAGECONFIG', 'tk', '${PN}-tkinter ${MLPREFIX}tcl', '', d)}" | ||
460 | DEV_PKG_DEPENDENCY = "" | ||
461 | RDEPENDS:${PN}-pydoc += "${PN}-io" | ||
462 | |||
463 | RDEPENDS:${PN}-tests:append:class-target = " ${MLPREFIX}bash" | ||
464 | RDEPENDS:${PN}-tests:append:class-nativesdk = " ${MLPREFIX}bash" | ||
465 | |||
466 | # Python's tests contain large numbers of files we don't need in the recipe sysroots | ||
467 | SYSROOT_PREPROCESS_FUNCS += " py3_sysroot_cleanup" | ||
468 | py3_sysroot_cleanup () { | ||
469 | rm -rf ${SYSROOT_DESTDIR}${libdir}/python${PYTHON_MAJMIN}/test | ||
470 | } | ||