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