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