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