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