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