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