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