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