summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/python/python3_3.10.0.bb
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/python/python3_3.10.0.bb')
-rw-r--r--meta/recipes-devtools/python/python3_3.10.0.bb404
1 files changed, 404 insertions, 0 deletions
diff --git a/meta/recipes-devtools/python/python3_3.10.0.bb b/meta/recipes-devtools/python/python3_3.10.0.bb
new file mode 100644
index 0000000000..2e850710b6
--- /dev/null
+++ b/meta/recipes-devtools/python/python3_3.10.0.bb
@@ -0,0 +1,404 @@
1SUMMARY = "The Python Programming Language"
2HOMEPAGE = "http://www.python.org"
3DESCRIPTION = "Python is a programming language that lets you work more quickly and integrate your systems more effectively."
4LICENSE = "PSFv2"
5SECTION = "devel/python"
6
7LIC_FILES_CHKSUM = "file://LICENSE;md5=3dd7bed622743ef9b77169b3736f7990"
8
9SRC_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-Do-not-add-usr-lib-termcap-to-linker-flags-to-avoid-.patch \
18 ${@bb.utils.contains('PACKAGECONFIG', 'tk', '', 'file://avoid_warning_about_tkinter.patch', d)} \
19 file://0001-Do-not-use-the-shell-version-of-python-config-that-w.patch \
20 file://python-config.patch \
21 file://0001-Makefile.pre-use-qemu-wrapper-when-gathering-profile.patch \
22 file://0001-python3-use-cc_basename-to-replace-CC-for-checking-c.patch \
23 file://0001-bpo-36852-proper-detection-of-mips-architecture-for-.patch \
24 file://crosspythonpath.patch \
25 file://0001-Use-FLAG_REF-always-for-interned-strings.patch \
26 file://0001-test_locale.py-correct-the-test-output-format.patch \
27 file://0017-setup.py-do-not-report-missing-dependencies-for-disa.patch \
28 file://0001-setup.py-pass-missing-libraries-to-Extension-for-mul.patch \
29 file://0001-Makefile-do-not-compile-.pyc-in-parallel.patch \
30 file://0020-configure.ac-setup.py-do-not-add-a-curses-include-pa.patch \
31 file://0001-Skip-failing-tests-due-to-load-variability-on-YP-AB.patch \
32 file://0001-test_ctypes.test_find-skip-without-tools-sdk.patch \
33 file://makerace.patch \
34 file://0001-sysconfig.py-use-platlibdir-also-for-purelib.patch \
35 file://0001-Lib-pty.py-handle-stdin-I-O-errors-same-way-as-maste.patch \
36 "
37
38SRC_URI:append:class-native = " \
39 file://0001-Lib-sysconfig.py-use-prefix-value-from-build-configu.patch \
40 file://0001-distutils-sysconfig-append-STAGING_LIBDIR-python-sys.patch \
41 file://12-distutils-prefix-is-inside-staging-area.patch \
42 file://0001-Don-t-search-system-for-headers-libraries.patch \
43 "
44SRC_URI[sha256sum] = "5a99f8e7a6a11a7b98b4e75e0d1303d3832cada5534068f69c7b6222a7b1b002"
45
46# exclude pre-releases for both python 2.x and 3.x
47UPSTREAM_CHECK_REGEX = "[Pp]ython-(?P<pver>\d+(\.\d+)+).tar"
48UPSTREAM_CHECK_URI = "https://www.python.org/downloads/source/"
49
50CVE_PRODUCT = "python"
51
52# Upstream consider this expected behaviour
53CVE_CHECK_WHITELIST += "CVE-2007-4559"
54# This is not exploitable when glibc has CVE-2016-10739 fixed.
55CVE_CHECK_WHITELIST += "CVE-2019-18348"
56
57# This is windows only issue.
58CVE_CHECK_WHITELIST += "CVE-2020-15523"
59
60PYTHON_MAJMIN = "3.10"
61
62S = "${WORKDIR}/Python-${PV}"
63
64BBCLASSEXTEND = "native nativesdk"
65
66inherit autotools pkgconfig qemu ptest multilib_header update-alternatives
67
68MULTILIB_SUFFIX = "${@d.getVar('base_libdir',1).split('/')[-1]}"
69
70ALTERNATIVE:${PN}-dev = "python3-config"
71ALTERNATIVE_LINK_NAME[python3-config] = "${bindir}/python${PYTHON_MAJMIN}-config"
72ALTERNATIVE_TARGET[python3-config] = "${bindir}/python${PYTHON_MAJMIN}-config-${MULTILIB_SUFFIX}"
73
74
75DEPENDS = "bzip2-replacement-native libffi bzip2 openssl sqlite3 zlib virtual/libintl xz virtual/crypt util-linux libtirpc libnsl2 autoconf-archive-native"
76DEPENDS:append:class-target = " python3-native"
77DEPENDS:append:class-nativesdk = " python3-native"
78
79# force to use the mutex+cond implementation (https://bugs.python.org/issue41710)
80CFLAGS += "-DHAVE_BROKEN_POSIX_SEMAPHORES"
81
82EXTRA_OECONF = " --without-ensurepip --enable-shared --with-platlibdir=${baselib}"
83EXTRA_OECONF:append:class-native = " --bindir=${bindir}/${PN}"
84
85export CROSSPYTHONPATH="${STAGING_LIBDIR_NATIVE}/python${PYTHON_MAJMIN}/lib-dynload/"
86
87EXTRANATIVEPATH += "python3-native"
88
89# LTO will be enabled via packageconfig depending upong distro features
90LTO:class-target = ""
91
92CACHED_CONFIGUREVARS = " \
93 ac_cv_file__dev_ptmx=yes \
94 ac_cv_file__dev_ptc=no \
95 ac_cv_working_tzset=yes \
96"
97
98def possibly_include_pgo(d):
99 # PGO currently causes builds to not be reproducible, so disable it for
100 # now. See YOCTO #13407
101 if bb.utils.contains('MACHINE_FEATURES', 'qemu-usermode', True, False, d) and d.getVar('BUILD_REPRODUCIBLE_BINARIES') != '1':
102 return 'pgo'
103
104 return ''
105
106PACKAGECONFIG:class-target ??= "readline ${@possibly_include_pgo(d)} gdbm ${@bb.utils.filter('DISTRO_FEATURES', 'lto', d)}"
107PACKAGECONFIG:class-native ??= "readline gdbm"
108PACKAGECONFIG:class-nativesdk ??= "readline gdbm"
109PACKAGECONFIG[readline] = ",,readline"
110# Use profile guided optimisation by running PyBench inside qemu-user
111PACKAGECONFIG[pgo] = "--enable-optimizations,,qemu-native"
112PACKAGECONFIG[tk] = ",,tk"
113PACKAGECONFIG[gdbm] = ",,gdbm"
114PACKAGECONFIG[lto] = "--with-lto,,"
115
116do_configure:prepend () {
117 mkdir -p ${B}/Modules
118 cat > ${B}/Modules/Setup.local << EOF
119*disabled*
120${@bb.utils.contains('PACKAGECONFIG', 'gdbm', '', '_gdbm _dbm', d)}
121${@bb.utils.contains('PACKAGECONFIG', 'readline', '', 'readline', d)}
122EOF
123}
124
125CPPFLAGS:append = " -I${STAGING_INCDIR}/ncursesw -I${STAGING_INCDIR}/uuid"
126
127EXTRA_OEMAKE = '\
128 STAGING_LIBDIR=${STAGING_LIBDIR} \
129 STAGING_INCDIR=${STAGING_INCDIR} \
130 LIB=${baselib} \
131'
132
133do_compile:prepend:class-target() {
134 if ${@bb.utils.contains('PACKAGECONFIG', 'pgo', 'true', 'false', d)}; then
135 qemu_binary="${@qemu_wrapper_cmdline(d, '${STAGING_DIR_TARGET}', ['${B}', '${STAGING_DIR_TARGET}/${base_libdir}'])}"
136 cat >pgo-wrapper <<EOF
137#!/bin/sh
138cd ${B}
139$qemu_binary "\$@"
140EOF
141 chmod +x pgo-wrapper
142 fi
143}
144
145do_install:prepend() {
146 ${WORKDIR}/check_build_completeness.py ${T}/log.do_compile
147}
148
149do_install:append:class-target() {
150 oe_multilib_header python${PYTHON_MAJMIN}/pyconfig.h
151}
152
153do_install:append:class-native() {
154 # Make sure we use /usr/bin/env python
155 for PYTHSCRIPT in `grep -rIl ${bindir}/${PN}/python ${D}${bindir}/${PN}`; do
156 sed -i -e '1s|^#!.*|#!/usr/bin/env python3|' $PYTHSCRIPT
157 done
158 # Add a symlink to the native Python so that scripts can just invoke
159 # "nativepython" and get the right one without needing absolute paths
160 # (these often end up too long for the #! parser in the kernel as the
161 # buffer is 128 bytes long).
162 ln -s python3-native/python3 ${D}${bindir}/nativepython3
163}
164
165do_install:append() {
166 for c in ${D}/${libdir}/python${PYTHON_MAJMIN}/_sysconfigdata*.py; do
167 python3 ${WORKDIR}/reformat_sysconfig.py $c
168 done
169 rm ${D}${libdir}/python${PYTHON_MAJMIN}/__pycache__/_sysconfigdata*.cpython*
170
171 mkdir -p ${D}${libdir}/python-sysconfigdata
172 sysconfigfile=`find ${D} -name _sysconfig*.py`
173 cp $sysconfigfile ${D}${libdir}/python-sysconfigdata/_sysconfigdata.py
174
175 sed -i \
176 -e "s,^ 'LIBDIR'.*, 'LIBDIR': '${STAGING_LIBDIR}'\,,g" \
177 -e "s,^ 'INCLUDEDIR'.*, 'INCLUDEDIR': '${STAGING_INCDIR}'\,,g" \
178 -e "s,^ 'CONFINCLUDEDIR'.*, 'CONFINCLUDEDIR': '${STAGING_INCDIR}'\,,g" \
179 -e "/^ 'INCLDIRSTOMAKE'/{N; s,/usr/include,${STAGING_INCDIR},g}" \
180 -e "/^ 'INCLUDEPY'/s,/usr/include,${STAGING_INCDIR},g" \
181 ${D}${libdir}/python-sysconfigdata/_sysconfigdata.py
182
183 # Unfortunately the following pyc files are non-deterministc due to 'frozenset'
184 # being written without strict ordering, even with PYTHONHASHSEED = 0
185 # Upstream is discussing ways to solve the issue properly, until then let's
186 # just not install the problematic files.
187 # More info: http://benno.id.au/blog/2013/01/15/python-determinism
188 rm ${D}${libdir}/python${PYTHON_MAJMIN}/test/__pycache__/test_range.cpython*
189 rm ${D}${libdir}/python${PYTHON_MAJMIN}/test/__pycache__/test_xml_etree.cpython*
190}
191
192do_install:append:class-nativesdk () {
193 # Make sure we use /usr/bin/env python
194 for PYTHSCRIPT in `grep -rIl ${bindir}/python ${D}${bindir}`; do
195 sed -i -e '1s|^#!.*|#!/usr/bin/env python3|' $PYTHSCRIPT
196 done
197 create_wrapper ${D}${bindir}/python${PYTHON_MAJMIN} TERMINFO_DIRS='${sysconfdir}/terminfo:/etc/terminfo:/usr/share/terminfo:/usr/share/misc/terminfo:/lib/terminfo' PYTHONNOUSERSITE='1'
198}
199
200SSTATE_SCAN_FILES += "Makefile _sysconfigdata.py"
201SSTATE_HASHEQUIV_FILEMAP = " \
202 populate_sysroot:*/lib*/python3*/_sysconfigdata*.py:${TMPDIR} \
203 populate_sysroot:*/lib*/python3*/_sysconfigdata*.py:${COREBASE} \
204 populate_sysroot:*/lib*/python3*/config-*/Makefile:${TMPDIR} \
205 populate_sysroot:*/lib*/python3*/config-*/Makefile:${COREBASE} \
206 populate_sysroot:*/lib*/python-sysconfigdata/_sysconfigdata.py:${TMPDIR} \
207 populate_sysroot:*/lib*/python-sysconfigdata/_sysconfigdata.py:${COREBASE} \
208 "
209PACKAGE_PREPROCESS_FUNCS += "py_package_preprocess"
210
211py_package_preprocess () {
212 # Remove references to buildmachine paths in target Makefile and _sysconfigdata
213 sed -i -e 's:--sysroot=${STAGING_DIR_TARGET}::g' -e s:'--with-libtool-sysroot=${STAGING_DIR_TARGET}'::g \
214 -e 's|${DEBUG_PREFIX_MAP}||g' \
215 -e 's:${HOSTTOOLS_DIR}/::g' \
216 -e 's:${RECIPE_SYSROOT_NATIVE}::g' \
217 -e 's:${RECIPE_SYSROOT}::g' \
218 -e 's:${BASE_WORKDIR}/${MULTIMACH_TARGET_SYS}::g' \
219 ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/config-${PYTHON_MAJMIN}${PYTHON_ABI}*/Makefile \
220 ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/_sysconfigdata*.py \
221 ${PKGD}/${bindir}/python${PYTHON_MAJMIN}-config
222
223 # Reformat _sysconfigdata after modifying it so that it remains
224 # reproducible
225 for c in ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/_sysconfigdata*.py; do
226 python3 ${WORKDIR}/reformat_sysconfig.py $c
227 done
228
229 # Recompile _sysconfigdata after modifying it
230 cd ${PKGD}
231 sysconfigfile=`find . -name _sysconfigdata_*.py`
232 ${STAGING_BINDIR_NATIVE}/python3-native/python3 \
233 -c "from py_compile import compile; compile('$sysconfigfile')"
234 ${STAGING_BINDIR_NATIVE}/python3-native/python3 \
235 -c "from py_compile import compile; compile('$sysconfigfile', optimize=1)"
236 ${STAGING_BINDIR_NATIVE}/python3-native/python3 \
237 -c "from py_compile import compile; compile('$sysconfigfile', optimize=2)"
238 cd -
239
240 mv ${PKGD}/${bindir}/python${PYTHON_MAJMIN}-config ${PKGD}/${bindir}/python${PYTHON_MAJMIN}-config-${MULTILIB_SUFFIX}
241
242 #Remove the unneeded copy of target sysconfig data
243 rm -rf ${PKGD}/${libdir}/python-sysconfigdata
244}
245
246# We want bytecode precompiled .py files (.pyc's) by default
247# but the user may set it on their own conf
248INCLUDE_PYCS ?= "1"
249
250python(){
251 import collections, json
252
253 filename = os.path.join(d.getVar('THISDIR'), 'python3', 'python3-manifest.json')
254 # This python changes the datastore based on the contents of a file, so mark
255 # that dependency.
256 bb.parse.mark_dependency(d, filename)
257
258 with open(filename) as manifest_file:
259 manifest_str = manifest_file.read()
260 json_start = manifest_str.find('# EOC') + 6
261 manifest_file.seek(json_start)
262 manifest_str = manifest_file.read()
263 python_manifest = json.loads(manifest_str, object_pairs_hook=collections.OrderedDict)
264
265 # First set RPROVIDES for -native case
266 # Hardcoded since it cant be python3-native-foo, should be python3-foo-native
267 pn = 'python3'
268 rprovides = (d.getVar('RPROVIDES') or "").split()
269
270 # ${PN}-misc-native is not in the manifest
271 rprovides.append(pn + '-misc-native')
272
273 for key in python_manifest:
274 pypackage = pn + '-' + key + '-native'
275 if pypackage not in rprovides:
276 rprovides.append(pypackage)
277
278 d.setVar('RPROVIDES:class-native', ' '.join(rprovides))
279
280 # Then work on the target
281 include_pycs = d.getVar('INCLUDE_PYCS')
282
283 packages = d.getVar('PACKAGES').split()
284 pn = d.getVar('PN')
285
286 newpackages=[]
287 for key in python_manifest:
288 pypackage = pn + '-' + key
289
290 if pypackage not in packages:
291 # We need to prepend, otherwise python-misc gets everything
292 # so we use a new variable
293 newpackages.append(pypackage)
294
295 # "Build" python's manifest FILES, RDEPENDS and SUMMARY
296 d.setVar('FILES:' + pypackage, '')
297 for value in python_manifest[key]['files']:
298 d.appendVar('FILES:' + pypackage, ' ' + value)
299
300 # Add cached files
301 if include_pycs == '1':
302 for value in python_manifest[key]['cached']:
303 d.appendVar('FILES:' + pypackage, ' ' + value)
304
305 for value in python_manifest[key]['rdepends']:
306 # Make it work with or without $PN
307 if '${PN}' in value:
308 value=value.split('-', 1)[1]
309 d.appendVar('RDEPENDS:' + pypackage, ' ' + pn + '-' + value)
310
311 for value in python_manifest[key].get('rrecommends', ()):
312 if '${PN}' in value:
313 value=value.split('-', 1)[1]
314 d.appendVar('RRECOMMENDS:' + pypackage, ' ' + pn + '-' + value)
315
316 d.setVar('SUMMARY:' + pypackage, python_manifest[key]['summary'])
317
318 # Prepending so to avoid python-misc getting everything
319 packages = newpackages + packages
320 d.setVar('PACKAGES', ' '.join(packages))
321 d.setVar('ALLOW_EMPTY:${PN}-modules', '1')
322 d.setVar('ALLOW_EMPTY:${PN}-pkgutil', '1')
323}
324
325# Files needed to create a new manifest
326
327do_create_manifest() {
328 # This task should be run with every new release of Python.
329 # We must ensure that PACKAGECONFIG enables everything when creating
330 # a new manifest, this is to base our new manifest on a complete
331 # native python build, containing all dependencies, otherwise the task
332 # wont be able to find the required files.
333 # e.g. BerkeleyDB is an optional build dependency so it may or may not
334 # be present, we must ensure it is.
335
336 cd ${WORKDIR}
337 # This needs to be executed by python-native and NOT by HOST's python
338 nativepython3 create_manifest3.py ${PYTHON_MAJMIN}
339 cp python3-manifest.json.new ${THISDIR}/python3/python3-manifest.json
340}
341
342# bitbake python -c create_manifest
343# Make sure we have native python ready when we create a new manifest
344addtask do_create_manifest after do_patch do_prepare_recipe_sysroot
345
346# manual dependency additions
347RRECOMMENDS:${PN}-core:append:class-nativesdk = " nativesdk-python3-modules"
348RRECOMMENDS:${PN}-crypt:append:class-target = " ${MLPREFIX}openssl ${MLPREFIX}ca-certificates"
349RRECOMMENDS:${PN}-crypt:append:class-nativesdk = " ${MLPREFIX}openssl ${MLPREFIX}ca-certificates"
350
351# For historical reasons PN is empty and provided by python3-modules
352FILES:${PN} = ""
353RPROVIDES:${PN}-modules = "${PN}"
354
355FILES:${PN}-pydoc += "${bindir}/pydoc${PYTHON_MAJMIN} ${bindir}/pydoc3"
356FILES:${PN}-idle += "${bindir}/idle3 ${bindir}/idle${PYTHON_MAJMIN}"
357
358# provide python-pyvenv from python3-venv
359RPROVIDES:${PN}-venv += "${MLPREFIX}python3-pyvenv"
360
361# package libpython3
362PACKAGES =+ "libpython3 libpython3-staticdev"
363FILES:libpython3 = "${libdir}/libpython*.so.*"
364FILES:libpython3-staticdev += "${libdir}/python${PYTHON_MAJMIN}/config-${PYTHON_MAJMIN}-*/libpython${PYTHON_MAJMIN}.a"
365INSANE_SKIP:${PN}-dev += "dev-elf"
366INSANE_SKIP:${PN}-ptest = "dev-deps"
367
368# catch all the rest (unsorted)
369PACKAGES += "${PN}-misc"
370RDEPENDS:${PN}-misc += "\
371 ${PN}-core \
372 ${PN}-email \
373 ${PN}-codecs \
374 ${PN}-pydoc \
375 ${PN}-pickle \
376 ${PN}-audio \
377 ${PN}-numbers \
378"
379RDEPENDS:${PN}-modules:append:class-target = " ${MLPREFIX}python3-misc"
380RDEPENDS:${PN}-modules:append:class-nativesdk = " ${MLPREFIX}python3-misc"
381FILES:${PN}-misc = "${libdir}/python${PYTHON_MAJMIN} ${libdir}/python${PYTHON_MAJMIN}/lib-dynload"
382
383# catch manpage
384PACKAGES += "${PN}-man"
385FILES:${PN}-man = "${datadir}/man"
386
387# See https://bugs.python.org/issue18748 and https://bugs.python.org/issue37395
388RDEPENDS:libpython3:append:libc-glibc = " libgcc"
389RDEPENDS:${PN}-ctypes:append:libc-glibc = " ${MLPREFIX}ldconfig"
390RDEPENDS:${PN}-ptest = "${PN}-modules ${PN}-tests ${PN}-dev unzip bzip2 libgcc tzdata-europe coreutils sed"
391RDEPENDS:${PN}-ptest:append:libc-glibc = " locale-base-tr-tr.iso-8859-9"
392RDEPENDS:${PN}-tkinter += "${@bb.utils.contains('PACKAGECONFIG', 'tk', '${MLPREFIX}tk ${MLPREFIX}tk-lib', '', d)}"
393RDEPENDS:${PN}-idle += "${@bb.utils.contains('PACKAGECONFIG', 'tk', '${PN}-tkinter ${MLPREFIX}tcl', '', d)}"
394RDEPENDS:${PN}-dev = ""
395RDEPENDS:${PN}-pydoc += "${PN}-io"
396
397RDEPENDS:${PN}-tests:append:class-target = " ${MLPREFIX}bash"
398RDEPENDS:${PN}-tests:append:class-nativesdk = " ${MLPREFIX}bash"
399
400# Python's tests contain large numbers of files we don't need in the recipe sysroots
401SYSROOT_PREPROCESS_FUNCS += " py3_sysroot_cleanup"
402py3_sysroot_cleanup () {
403 rm -rf ${SYSROOT_DESTDIR}${libdir}/python${PYTHON_MAJMIN}/test
404}