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