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