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