summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/python/python3_3.5.6.bb
diff options
context:
space:
mode:
authorAlexander Kanavin <alex.kanavin@gmail.com>2019-02-06 17:26:34 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-02-08 10:57:19 +0000
commite2c3247c233876ab090c9ce3d5325a6d46ab350f (patch)
treecf38957a3510be612cde924f6184a5251b968a43 /meta/recipes-devtools/python/python3_3.5.6.bb
parentcd6c61a26177296e24b442e2eda1514b5f931c0a (diff)
downloadpoky-e2c3247c233876ab090c9ce3d5325a6d46ab350f.tar.gz
python3: upgrade to 3.7.2
I took the same approach as the recent perl upgrade: write recipe from scratch, taking the pieces from the old recipe only when they were proven to be necessary. The pgo, manifest and ptest features are all preserved. New features: - native and target recipes are now unified into one recipe - check_build_completeness.py runs right after do_compile() and verifies that all optional modules have been built (a notorious source of regressions) - a new approach to sysconfig.py and distutils/sysconfig.py returning values appropriate for native or target builds: we copy the configuration file to a separate folder, add that folder to sys.path (through environment variable that differs between native and target builds), and point python to the file through another environment variable. There were a few other patches where it was difficult to decide if the patch is still relevant, and how to test that it works correctly; please add those as-needed by testing the new python. (From OE-Core rev: 02714c105426b0d687620913c1a7401b386428b6) Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools/python/python3_3.5.6.bb')
-rw-r--r--meta/recipes-devtools/python/python3_3.5.6.bb334
1 files changed, 0 insertions, 334 deletions
diff --git a/meta/recipes-devtools/python/python3_3.5.6.bb b/meta/recipes-devtools/python/python3_3.5.6.bb
deleted file mode 100644
index d64cb18c38..0000000000
--- a/meta/recipes-devtools/python/python3_3.5.6.bb
+++ /dev/null
@@ -1,334 +0,0 @@
1require recipes-devtools/python/python3.inc
2
3DEPENDS = "python3-native libffi bzip2 gdbm openssl \
4 sqlite3 zlib virtual/libintl xz qemu-native \
5 qemu-helper-native virtual/crypt"
6
7DISTRO_SRC_URI ?= "file://sitecustomize.py"
8DISTRO_SRC_URI_linuxstdbase = ""
9SRC_URI = "http://www.python.org/ftp/python/${PV}/Python-${PV}.tar.xz \
10file://python-config.patch \
11file://030-fixup-include-dirs.patch \
12file://130-readline-setup.patch \
13file://150-fix-setupterm.patch \
14file://0001-h2py-Fix-issue-13032-where-it-fails-with-UnicodeDeco.patch \
15file://tweak-MULTIARCH-for-powerpc-linux-gnuspe.patch \
16file://tweak-MULTIARCH-for-powerpc-linux-musl.patch \
17file://support_SOURCE_DATE_EPOCH_in_py_compile.patch \
18${DISTRO_SRC_URI} \
19"
20
21SRC_URI += "\
22 file://03-fix-tkinter-detection.patch \
23 ${@bb.utils.contains('PACKAGECONFIG', 'tk', '', 'file://avoid_warning_about_tkinter.patch', d)} \
24 file://cgi_py.patch \
25 file://host_include_contamination.patch \
26 file://python-3.3-multilib.patch \
27 file://sysroot-include-headers.patch \
28 file://unixccompiler.patch \
29 file://avoid-ncursesw-include-path.patch \
30 file://python3-use-CROSSPYTHONPATH-for-PYTHON_FOR_BUILD.patch \
31 file://sysconfig.py-add-_PYTHON_PROJECT_SRC.patch \
32 file://setup.py-check-cross_compiling-when-get-FLAGS.patch \
33 file://configure.ac-fix-LIBPL.patch \
34 file://0001-Issue-21272-Use-_sysconfigdata.py-to-initialize-dist.patch \
35 file://pass-missing-libraries-to-Extension-for-mul.patch \
36 file://Use-correct-CFLAGS-for-extensions-when-cross-compili.patch \
37 file://0002-Makefile-add-target-to-split-profile-generation.patch \
38 file://float-endian.patch \
39 file://ftplib.patch \
40 file://signal.patch \
41 file://0001-Issue-28043-SSLContext-has-improved-default-settings.patch \
42 file://0002-bpo-29136-Add-TLS-1.3-cipher-suites-and-OP_NO_TLSv1_.patch \
43 file://0003-bpo-32947-Fixes-for-TLS-1.3-and-OpenSSL-1.1.1-GH-876.patch \
44 file://0004-bpo-33570-TLS-1.3-ciphers-for-OpenSSL-1.1.1-GH-6976.patch \
45 file://0005-bpo-30714-ALPN-changes-for-OpenSSL-1.1.0f-2305.patch \
46 file://run-ptest \
47 file://0001-python3-use-cc_basename-to-replace-CC-for-checking-c.patch \
48 "
49
50inherit multilib_header python3native update-alternatives qemu ptest
51
52MULTILIB_SUFFIX = "${@d.getVar('base_libdir',1).split('/')[-1]}"
53
54ALTERNATIVE_${PN}-dev = "python-config"
55ALTERNATIVE_LINK_NAME[python-config] = "${bindir}/python${PYTHON_BINABI}-config"
56ALTERNATIVE_TARGET[python-config] = "${bindir}/python${PYTHON_BINABI}-config-${MULTILIB_SUFFIX}"
57
58CONFIGUREOPTS += " --with-system-ffi "
59
60CACHED_CONFIGUREVARS = "ac_cv_have_chflags=no \
61 ac_cv_have_lchflags=no \
62 ac_cv_have_long_long_format=yes \
63 ac_cv_buggy_getaddrinfo=no \
64 ac_cv_file__dev_ptmx=yes \
65 ac_cv_file__dev_ptc=no \
66"
67
68TARGET_CC_ARCH += "-DNDEBUG -fno-inline"
69SDK_CC_ARCH += "-DNDEBUG -fno-inline"
70EXTRA_OEMAKE += "CROSS_COMPILE=yes"
71EXTRA_OECONF += "CROSSPYTHONPATH=${STAGING_LIBDIR_NATIVE}/python${PYTHON_MAJMIN}/lib-dynload/ --without-ensurepip"
72
73PYTHON3_PROFILE_TASK ?= "./python -m test.regrtest --pgo test_grammar test_opcodes test_dict test_builtin test_exceptions test_types test_support || true"
74
75export CROSS_COMPILE = "${TARGET_PREFIX}"
76export CCSHARED = "-fPIC"
77
78# Fix cross compilation of different modules
79export CROSSPYTHONPATH = "${STAGING_LIBDIR_NATIVE}/python${PYTHON_MAJMIN}/lib-dynload/:${B}/build/lib.linux-${TARGET_ARCH}-${PYTHON_MAJMIN}:${S}/Lib:${S}/Lib/plat-linux"
80
81PACKAGECONFIG ??= "readline ${@bb.utils.contains('MACHINE_FEATURES', 'qemu-usermode', 'pgo', '', d)}"
82PACKAGECONFIG[readline] = ",,readline"
83# Use profile guided optimisation by running PyBench inside qemu-user
84PACKAGECONFIG[pgo] = "--enable-optimizations"
85PACKAGECONFIG[tk] = ",,tk"
86
87do_configure_append() {
88 rm -f ${S}/Makefile.orig
89}
90
91run_make() {
92 oe_runmake PGEN=${STAGING_BINDIR_NATIVE}/python3-native/pgen \
93 HOSTPYTHON=${STAGING_BINDIR_NATIVE}/python3-native/python3 \
94 STAGING_LIBDIR=${STAGING_LIBDIR} \
95 STAGING_INCDIR=${STAGING_INCDIR} \
96 STAGING_BASELIBDIR=${STAGING_BASELIBDIR} \
97 LIB=${baselib} \
98 ARCH=${TARGET_ARCH} \
99 OPT="${CFLAGS}" \
100 "$@"
101}
102
103do_compile() {
104 # regenerate platform specific files, because they depend on system headers
105 cd ${S}/Lib/plat-linux*
106 include=${STAGING_INCDIR} ${STAGING_BINDIR_NATIVE}/python3-native/python3 \
107 ${S}/Tools/scripts/h2py.py -i '(u_long)' \
108 ${STAGING_INCDIR}/dlfcn.h \
109 ${STAGING_INCDIR}/linux/cdrom.h \
110 ${STAGING_INCDIR}/netinet/in.h \
111 ${STAGING_INCDIR}/sys/types.h
112 sed -e 's,${STAGING_DIR_HOST},,g' -i *.py
113 cd -
114
115 # remove any bogus LD_LIBRARY_PATH
116 sed -i -e s,RUNSHARED=.*,RUNSHARED=, Makefile
117
118 if [ ! -f Makefile.orig ]; then
119 install -m 0644 Makefile Makefile.orig
120 fi
121 sed -i -e 's,^CONFIGURE_LDFLAGS=.*,CONFIGURE_LDFLAGS=-L. -L${STAGING_LIBDIR},g' \
122 -e 's,libdir=${libdir},libdir=${STAGING_LIBDIR},g' \
123 -e 's,libexecdir=${libexecdir},libexecdir=${STAGING_DIR_HOST}${libexecdir},g' \
124 -e 's,^LIBDIR=.*,LIBDIR=${STAGING_LIBDIR},g' \
125 -e 's,includedir=${includedir},includedir=${STAGING_INCDIR},g' \
126 -e 's,^INCLUDEDIR=.*,INCLUDE=${STAGING_INCDIR},g' \
127 -e 's,^CONFINCLUDEDIR=.*,CONFINCLUDE=${STAGING_INCDIR},g' \
128 Makefile
129 # save copy of it now, because if we do it in do_install and
130 # then call do_install twice we get Makefile.orig == Makefile.sysroot
131 install -m 0644 Makefile Makefile.sysroot
132
133 if ${@bb.utils.contains('PACKAGECONFIG', 'pgo', 'true', 'false', d)}; then
134 run_make profile-opt
135 qemu_binary="${@qemu_wrapper_cmdline(d, '${STAGING_DIR_TARGET}', ['${B}', '${STAGING_DIR_TARGET}/${base_libdir}'])}"
136 cat >pgo-wrapper <<EOF
137#!/bin/sh
138cd ${B}
139$qemu_binary "\$@"
140EOF
141 chmod +x pgo-wrapper
142 bbnote Gathering profiling data
143 ./pgo-wrapper ${PYTHON3_PROFILE_TASK}
144 bbnote Profiling data gathered, rebuilding
145 run_make clean_and_use_profile
146 else
147 run_make libpython3.so
148 run_make
149 fi
150}
151
152do_install() {
153 # make install needs the original Makefile, or otherwise the inclues would
154 # go to ${D}${STAGING...}/...
155 install -m 0644 Makefile.orig Makefile
156
157 install -d ${D}${libdir}/pkgconfig
158 install -d ${D}${libdir}/python${PYTHON_MAJMIN}/config
159
160 # rerun the build once again with original makefile this time
161 # run install in a separate step to avoid compile/install race
162 if ${@bb.utils.contains('PACKAGECONFIG', 'pgo', 'true', 'false', d)}; then
163 run_make DESTDIR=${D} LIBDIR=${libdir} build_all_use_profile
164 else
165 run_make DESTDIR=${D} LIBDIR=${libdir}
166 fi
167
168 run_make DESTDIR=${D} LIBDIR=${libdir} install
169
170 # avoid conflict with 2to3 from Python 2
171 rm -f ${D}/${bindir}/2to3
172
173 install -m 0644 Makefile.sysroot ${D}/${libdir}/python${PYTHON_MAJMIN}/config/Makefile
174 install -m 0644 Makefile.sysroot ${D}/${libdir}/python${PYTHON_MAJMIN}/config-${PYTHON_MAJMIN}${PYTHON_ABI}/Makefile
175
176 if [ -e ${WORKDIR}/sitecustomize.py ]; then
177 install -m 0644 ${WORKDIR}/sitecustomize.py ${D}/${libdir}/python${PYTHON_MAJMIN}
178 fi
179
180 oe_multilib_header python${PYTHON_BINABI}/pyconfig.h
181}
182
183do_install_append_class-nativesdk () {
184 create_wrapper ${D}${bindir}/python${PYTHON_MAJMIN} PYTHONHOME='${prefix}' TERMINFO_DIRS='${sysconfdir}/terminfo:/etc/terminfo:/usr/share/terminfo:/usr/share/misc/terminfo:/lib/terminfo' PYTHONNOUSERSITE='1'
185}
186
187SSTATE_SCAN_FILES += "Makefile"
188PACKAGE_PREPROCESS_FUNCS += "py_package_preprocess"
189
190py_package_preprocess () {
191 # copy back the old Makefile to fix target package
192 install -m 0644 ${B}/Makefile.orig ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/config/Makefile
193 install -m 0644 ${B}/Makefile.orig ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/config-${PYTHON_MAJMIN}${PYTHON_ABI}/Makefile
194 # Remove references to buildmachine paths in target Makefile and _sysconfigdata
195 sed -i -e 's:--sysroot=${STAGING_DIR_TARGET}::g' -e s:'--with-libtool-sysroot=${STAGING_DIR_TARGET}'::g \
196 -e 's|${DEBUG_PREFIX_MAP}||g' \
197 -e 's:${HOSTTOOLS_DIR}/::g' \
198 -e 's:${RECIPE_SYSROOT_NATIVE}::g' \
199 -e 's:${RECIPE_SYSROOT}::g' \
200 -e 's:${BASE_WORKDIR}/${MULTIMACH_TARGET_SYS}::g' \
201 ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/config/Makefile \
202 ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/config-${PYTHON_MAJMIN}${PYTHON_ABI}/Makefile \
203 ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/_sysconfigdata.py \
204 ${PKGD}/${bindir}/python${PYTHON_BINABI}-config
205
206 # Recompile _sysconfigdata after modifying it
207 cd ${PKGD}
208 ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} \
209 -c "from py_compile import compile; compile('./${libdir}/python${PYTHON_MAJMIN}/_sysconfigdata.py')"
210 ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} \
211 -c "from py_compile import compile; compile('./${libdir}/python${PYTHON_MAJMIN}/_sysconfigdata.py', optimize=1)"
212 ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} \
213 -c "from py_compile import compile; compile('./${libdir}/python${PYTHON_MAJMIN}/_sysconfigdata.py', optimize=2)"
214 cd -
215
216 mv ${PKGD}/${bindir}/python${PYTHON_BINABI}-config ${PKGD}/${bindir}/python${PYTHON_BINABI}-config-${MULTILIB_SUFFIX}
217}
218
219PACKAGES_remove = "${PN}"
220
221# manual dependency additions
222RPROVIDES_${PN}-modules = "${PN}"
223RRECOMMENDS_${PN}-core_append_class-nativesdk = " nativesdk-python3-modules"
224RRECOMMENDS_${PN}-crypt = "openssl ca-certificates"
225
226FILES_${PN}-2to3 += "${bindir}/2to3-${PYTHON_MAJMIN}"
227FILES_${PN}-pydoc += "${bindir}/pydoc${PYTHON_MAJMIN} ${bindir}/pydoc3"
228FILES_${PN}-idle += "${bindir}/idle3 ${bindir}/idle${PYTHON_MAJMIN}"
229
230# provide python-pyvenv from python3-venv
231RPROVIDES_${PN}-venv += "${PN}-pyvenv"
232
233# package libpython3
234PACKAGES =+ "libpython3 libpython3-staticdev"
235FILES_libpython3 = "${libdir}/libpython*.so.*"
236FILES_libpython3-staticdev += "${libdir}/python${PYTHON_MAJMIN}/config-${PYTHON_BINABI}/libpython${PYTHON_BINABI}.a"
237INSANE_SKIP_${PN}-dev += "dev-elf"
238
239# catch all the rest (unsorted)
240PACKAGES += "${PN}-misc"
241RDEPENDS_${PN}-misc += "${PN}-core ${PN}-email ${PN}-codecs"
242RDEPENDS_${PN}-modules += "${PN}-misc"
243FILES_${PN}-misc = "${libdir}/python${PYTHON_MAJMIN}"
244
245# catch manpage
246PACKAGES += "${PN}-man"
247FILES_${PN}-man = "${datadir}/man"
248
249RDEPENDS_${PN}-ptest = "${PN}-modules ${PN}-tests unzip bzip2"
250RDEPENDS_${PN}-tkinter += "${@bb.utils.contains('PACKAGECONFIG', 'tk', 'tk', '', d)}"
251RDEPENDS_${PN}-dev = ""
252
253BBCLASSEXTEND = "nativesdk"
254
255# We want bytecode precompiled .py files (.pyc's) by default
256# but the user may set it on their own conf
257INCLUDE_PYCS ?= "1"
258
259python(){
260 import collections, json
261
262 filename = os.path.join(d.getVar('THISDIR'), 'python3', 'python3-manifest.json')
263 # This python changes the datastore based on the contents of a file, so mark
264 # that dependency.
265 bb.parse.mark_dependency(d, filename)
266
267 with open(filename) as manifest_file:
268 manifest_str = manifest_file.read()
269 json_start = manifest_str.find('# EOC') + 6
270 manifest_file.seek(json_start)
271 manifest_str = manifest_file.read()
272 python_manifest = json.loads(manifest_str, object_pairs_hook=collections.OrderedDict)
273
274 include_pycs = d.getVar('INCLUDE_PYCS')
275
276 packages = d.getVar('PACKAGES').split()
277 pn = d.getVar('PN')
278
279 newpackages=[]
280 for key in python_manifest:
281 pypackage= pn + '-' + key
282
283 if pypackage not in packages:
284 # We need to prepend, otherwise python-misc gets everything
285 # so we use a new variable
286 newpackages.append(pypackage)
287
288 # "Build" python's manifest FILES, RDEPENDS and SUMMARY
289 d.setVar('FILES_' + pypackage, '')
290 for value in python_manifest[key]['files']:
291 d.appendVar('FILES_' + pypackage, ' ' + value)
292
293 # Add cached files
294 if include_pycs == '1':
295 for value in python_manifest[key]['cached']:
296 d.appendVar('FILES_' + pypackage, ' ' + value)
297
298 for value in python_manifest[key]['rdepends']:
299 # Make it work with or without $PN
300 if '${PN}' in value:
301 value=value.split('-')[1]
302 d.appendVar('RDEPENDS_' + pypackage, ' ' + pn + '-' + value)
303 d.setVar('SUMMARY_' + pypackage, python_manifest[key]['summary'])
304
305 # Prepending so to avoid python-misc getting everything
306 packages = newpackages + packages
307 d.setVar('PACKAGES', ' '.join(packages))
308 d.setVar('ALLOW_EMPTY_${PN}-modules', '1')
309}
310
311# Files needed to create a new manifest
312SRC_URI += "file://create_manifest3.py file://get_module_deps3.py file://python3-manifest.json"
313
314do_create_manifest() {
315 # This task should be run with every new release of Python.
316 # We must ensure that PACKAGECONFIG enables everything when creating
317 # a new manifest, this is to base our new manifest on a complete
318 # native python build, containing all dependencies, otherwise the task
319 # wont be able to find the required files.
320 # e.g. BerkeleyDB is an optional build dependency so it may or may not
321 # be present, we must ensure it is.
322
323 cd ${WORKDIR}
324 # This needs to be executed by python-native and NOT by HOST's python
325 nativepython3 create_manifest3.py ${PYTHON_MAJMIN}
326 cp python3-manifest.json.new ${THISDIR}/python3/python3-manifest.json
327}
328
329# bitbake python -c create_manifest
330addtask do_create_manifest
331
332# Make sure we have native python ready when we create a new manifest
333do_create_manifest[depends] += "python3:do_prepare_recipe_sysroot"
334do_create_manifest[depends] += "python3:do_patch"