blob: 8a638b142b5faa58f90893d51ea70107481e1028 [file] [log] [blame]
Andrew Geissler82c905d2020-04-13 13:39:40 -05001SUMMARY = "The Python Programming Language"
2HOMEPAGE = "http://www.python.org"
Andrew Geissler90fd73c2021-03-05 15:25:55 -06003DESCRIPTION = "Python is a programming language that lets you work more quickly and integrate your systems more effectively."
Andrew Geissler82c905d2020-04-13 13:39:40 -05004LICENSE = "PSFv2"
5SECTION = "devel/python"
6
Andrew Geissler90fd73c2021-03-05 15:25:55 -06007LIC_FILES_CHKSUM = "file://LICENSE;md5=c22d2438294c784731bf9dd224a467b7"
Andrew Geissler82c905d2020-04-13 13:39:40 -05008
9SRC_URI = "http://www.python.org/ftp/python/${PV}/Python-${PV}.tar.xz \
10 file://run-ptest \
11 file://create_manifest3.py \
12 file://get_module_deps3.py \
13 file://python3-manifest.json \
14 file://check_build_completeness.py \
Andrew Geissler6ce62a22020-11-30 19:58:47 -060015 file://reformat_sysconfig.py \
Andrew Geissler82c905d2020-04-13 13:39:40 -050016 file://cgi_py.patch \
17 file://0001-Do-not-add-usr-lib-termcap-to-linker-flags-to-avoid-.patch \
18 ${@bb.utils.contains('PACKAGECONFIG', 'tk', '', 'file://avoid_warning_about_tkinter.patch', d)} \
19 file://0001-Do-not-use-the-shell-version-of-python-config-that-w.patch \
20 file://python-config.patch \
21 file://0001-Makefile.pre-use-qemu-wrapper-when-gathering-profile.patch \
Andrew Geissler82c905d2020-04-13 13:39:40 -050022 file://0001-python3-use-cc_basename-to-replace-CC-for-checking-c.patch \
Andrew Geissler82c905d2020-04-13 13:39:40 -050023 file://0001-bpo-36852-proper-detection-of-mips-architecture-for-.patch \
24 file://crosspythonpath.patch \
Andrew Geissler82c905d2020-04-13 13:39:40 -050025 file://0001-Use-FLAG_REF-always-for-interned-strings.patch \
26 file://0001-test_locale.py-correct-the-test-output-format.patch \
27 file://0017-setup.py-do-not-report-missing-dependencies-for-disa.patch \
28 file://0001-setup.py-pass-missing-libraries-to-Extension-for-mul.patch \
29 file://0001-Makefile-do-not-compile-.pyc-in-parallel.patch \
Andrew Geissler82c905d2020-04-13 13:39:40 -050030 file://0020-configure.ac-setup.py-do-not-add-a-curses-include-pa.patch \
Andrew Geissler6ce62a22020-11-30 19:58:47 -060031 file://0001-Lib-sysconfig.py-use-libdir-values-from-configuratio.patch \
Andrew Geissler3b8a17c2021-04-15 15:55:55 -050032 file://0001-Skip-failing-tests-due-to-load-variability-on-YP-AB.patch \
Andrew Geissler5f350902021-07-23 13:09:54 -040033 file://0001-test_ctypes.test_find-skip-without-tools-sdk.patch \
34 file://makerace.patch \
Andrew Geissler82c905d2020-04-13 13:39:40 -050035 "
36
Patrick Williams213cb262021-08-07 19:21:33 -050037SRC_URI:append:class-native = " \
Andrew Geissler82c905d2020-04-13 13:39:40 -050038 file://0001-distutils-sysconfig-append-STAGING_LIBDIR-python-sys.patch \
39 file://12-distutils-prefix-is-inside-staging-area.patch \
40 file://0001-Don-t-search-system-for-headers-libraries.patch \
41 "
Andrew Geissler5f350902021-07-23 13:09:54 -040042SRC_URI[sha256sum] = "397920af33efc5b97f2e0b57e91923512ef89fc5b3c1d21dbfc8c4828ce0108a"
Andrew Geissler82c905d2020-04-13 13:39:40 -050043
44# exclude pre-releases for both python 2.x and 3.x
45UPSTREAM_CHECK_REGEX = "[Pp]ython-(?P<pver>\d+(\.\d+)+).tar"
Andrew Geissler4c19ea12020-10-27 13:52:24 -050046UPSTREAM_CHECK_URI = "https://www.python.org/downloads/source/"
Andrew Geissler82c905d2020-04-13 13:39:40 -050047
48CVE_PRODUCT = "python"
49
Andrew Geissler6ce62a22020-11-30 19:58:47 -060050# Upstream consider this expected behaviour
51CVE_CHECK_WHITELIST += "CVE-2007-4559"
Andrew Geissler82c905d2020-04-13 13:39:40 -050052# This is not exploitable when glibc has CVE-2016-10739 fixed.
53CVE_CHECK_WHITELIST += "CVE-2019-18348"
54
Andrew Geissler6ce62a22020-11-30 19:58:47 -060055# This is windows only issue.
56CVE_CHECK_WHITELIST += "CVE-2020-15523"
57
58PYTHON_MAJMIN = "3.9"
Andrew Geissler82c905d2020-04-13 13:39:40 -050059
60S = "${WORKDIR}/Python-${PV}"
61
62BBCLASSEXTEND = "native nativesdk"
63
64inherit autotools pkgconfig qemu ptest multilib_header update-alternatives
65
66MULTILIB_SUFFIX = "${@d.getVar('base_libdir',1).split('/')[-1]}"
67
Patrick Williams213cb262021-08-07 19:21:33 -050068ALTERNATIVE:${PN}-dev = "python3-config"
Andrew Geissler82c905d2020-04-13 13:39:40 -050069ALTERNATIVE_LINK_NAME[python3-config] = "${bindir}/python${PYTHON_MAJMIN}-config"
70ALTERNATIVE_TARGET[python3-config] = "${bindir}/python${PYTHON_MAJMIN}-config-${MULTILIB_SUFFIX}"
71
72
Andrew Geisslerc926e172021-05-07 16:11:35 -050073DEPENDS = "bzip2-replacement-native libffi bzip2 openssl sqlite3 zlib virtual/libintl xz virtual/crypt util-linux libtirpc libnsl2 autoconf-archive-native"
Patrick Williams213cb262021-08-07 19:21:33 -050074DEPENDS:append:class-target = " python3-native"
75DEPENDS:append:class-nativesdk = " python3-native"
76
77# force to use the mutex+cond implementation (https://bugs.python.org/issue41710)
78CFLAGS += "-DHAVE_BROKEN_POSIX_SEMAPHORES"
Andrew Geissler82c905d2020-04-13 13:39:40 -050079
Andrew Geissler6ce62a22020-11-30 19:58:47 -060080EXTRA_OECONF = " --without-ensurepip --enable-shared --with-platlibdir=${baselib}"
Patrick Williams213cb262021-08-07 19:21:33 -050081EXTRA_OECONF:append:class-native = " --bindir=${bindir}/${PN}"
Andrew Geissler82c905d2020-04-13 13:39:40 -050082
83export CROSSPYTHONPATH="${STAGING_LIBDIR_NATIVE}/python${PYTHON_MAJMIN}/lib-dynload/"
84
85EXTRANATIVEPATH += "python3-native"
86
Andrew Geissler6ce62a22020-11-30 19:58:47 -060087# LTO will be enabled via packageconfig depending upong distro features
Patrick Williams213cb262021-08-07 19:21:33 -050088LTO:class-target = ""
Andrew Geissler6ce62a22020-11-30 19:58:47 -060089
Andrew Geissler82c905d2020-04-13 13:39:40 -050090CACHED_CONFIGUREVARS = " \
91 ac_cv_file__dev_ptmx=yes \
92 ac_cv_file__dev_ptc=no \
93 ac_cv_working_tzset=yes \
94"
Andrew Geisslerd25ed322020-06-27 00:28:28 -050095
96def possibly_include_pgo(d):
Andrew Geissler82c905d2020-04-13 13:39:40 -050097 # PGO currently causes builds to not be reproducible, so disable it for
98 # now. See YOCTO #13407
99 if bb.utils.contains('MACHINE_FEATURES', 'qemu-usermode', True, False, d) and d.getVar('BUILD_REPRODUCIBLE_BINARIES') != '1':
Andrew Geisslerd25ed322020-06-27 00:28:28 -0500100 return 'pgo'
101
102 return ''
Andrew Geissler82c905d2020-04-13 13:39:40 -0500103
Patrick Williams213cb262021-08-07 19:21:33 -0500104PACKAGECONFIG:class-target ??= "readline ${@possibly_include_pgo(d)} gdbm ${@bb.utils.filter('DISTRO_FEATURES', 'lto', d)}"
105PACKAGECONFIG:class-native ??= "readline gdbm"
106PACKAGECONFIG:class-nativesdk ??= "readline gdbm"
Andrew Geissler82c905d2020-04-13 13:39:40 -0500107PACKAGECONFIG[readline] = ",,readline"
108# Use profile guided optimisation by running PyBench inside qemu-user
109PACKAGECONFIG[pgo] = "--enable-optimizations,,qemu-native"
110PACKAGECONFIG[tk] = ",,tk"
111PACKAGECONFIG[gdbm] = ",,gdbm"
Andrew Geissler6ce62a22020-11-30 19:58:47 -0600112PACKAGECONFIG[lto] = "--with-lto,,"
Andrew Geissler82c905d2020-04-13 13:39:40 -0500113
Patrick Williams213cb262021-08-07 19:21:33 -0500114do_configure:prepend () {
Andrew Geissler82c905d2020-04-13 13:39:40 -0500115 mkdir -p ${B}/Modules
116 cat > ${B}/Modules/Setup.local << EOF
117*disabled*
118${@bb.utils.contains('PACKAGECONFIG', 'gdbm', '', '_gdbm _dbm', d)}
119${@bb.utils.contains('PACKAGECONFIG', 'readline', '', 'readline', d)}
120EOF
121}
122
Patrick Williams213cb262021-08-07 19:21:33 -0500123CPPFLAGS:append = " -I${STAGING_INCDIR}/ncursesw -I${STAGING_INCDIR}/uuid"
Andrew Geissler82c905d2020-04-13 13:39:40 -0500124
125EXTRA_OEMAKE = '\
126 STAGING_LIBDIR=${STAGING_LIBDIR} \
127 STAGING_INCDIR=${STAGING_INCDIR} \
128 LIB=${baselib} \
129'
130
Patrick Williams213cb262021-08-07 19:21:33 -0500131do_compile:prepend:class-target() {
Andrew Geissler82c905d2020-04-13 13:39:40 -0500132 if ${@bb.utils.contains('PACKAGECONFIG', 'pgo', 'true', 'false', d)}; then
133 qemu_binary="${@qemu_wrapper_cmdline(d, '${STAGING_DIR_TARGET}', ['${B}', '${STAGING_DIR_TARGET}/${base_libdir}'])}"
134 cat >pgo-wrapper <<EOF
135#!/bin/sh
136cd ${B}
137$qemu_binary "\$@"
138EOF
139 chmod +x pgo-wrapper
140 fi
141}
142
Patrick Williams213cb262021-08-07 19:21:33 -0500143do_install:prepend() {
Andrew Geissler82c905d2020-04-13 13:39:40 -0500144 ${WORKDIR}/check_build_completeness.py ${T}/log.do_compile
145}
146
Patrick Williams213cb262021-08-07 19:21:33 -0500147do_install:append:class-target() {
Andrew Geissler82c905d2020-04-13 13:39:40 -0500148 oe_multilib_header python${PYTHON_MAJMIN}/pyconfig.h
149}
150
Patrick Williams213cb262021-08-07 19:21:33 -0500151do_install:append:class-native() {
Andrew Geissler82c905d2020-04-13 13:39:40 -0500152 # Make sure we use /usr/bin/env python
153 for PYTHSCRIPT in `grep -rIl ${bindir}/${PN}/python ${D}${bindir}/${PN}`; do
154 sed -i -e '1s|^#!.*|#!/usr/bin/env python3|' $PYTHSCRIPT
155 done
156 # Add a symlink to the native Python so that scripts can just invoke
157 # "nativepython" and get the right one without needing absolute paths
158 # (these often end up too long for the #! parser in the kernel as the
159 # buffer is 128 bytes long).
160 ln -s python3-native/python3 ${D}${bindir}/nativepython3
161}
162
Patrick Williams213cb262021-08-07 19:21:33 -0500163do_install:append() {
Patrick Williams93c203f2021-10-06 16:15:23 -0500164 for c in ${D}/${libdir}/python${PYTHON_MAJMIN}/_sysconfigdata*.py; do
165 python3 ${WORKDIR}/reformat_sysconfig.py $c
166 done
167 rm ${D}${libdir}/python${PYTHON_MAJMIN}/__pycache__/_sysconfigdata*.cpython*
168
Andrew Geissler82c905d2020-04-13 13:39:40 -0500169 mkdir -p ${D}${libdir}/python-sysconfigdata
170 sysconfigfile=`find ${D} -name _sysconfig*.py`
171 cp $sysconfigfile ${D}${libdir}/python-sysconfigdata/_sysconfigdata.py
172
173 sed -i \
174 -e "s,^ 'LIBDIR'.*, 'LIBDIR': '${STAGING_LIBDIR}'\,,g" \
175 -e "s,^ 'INCLUDEDIR'.*, 'INCLUDEDIR': '${STAGING_INCDIR}'\,,g" \
176 -e "s,^ 'CONFINCLUDEDIR'.*, 'CONFINCLUDEDIR': '${STAGING_INCDIR}'\,,g" \
177 -e "/^ 'INCLDIRSTOMAKE'/{N; s,/usr/include,${STAGING_INCDIR},g}" \
178 -e "/^ 'INCLUDEPY'/s,/usr/include,${STAGING_INCDIR},g" \
179 ${D}${libdir}/python-sysconfigdata/_sysconfigdata.py
Andrew Geissler6ce62a22020-11-30 19:58:47 -0600180
181 # Unfortunately the following pyc files are non-deterministc due to 'frozenset'
182 # being written without strict ordering, even with PYTHONHASHSEED = 0
183 # Upstream is discussing ways to solve the issue properly, until then let's
184 # just not install the problematic files.
185 # More info: http://benno.id.au/blog/2013/01/15/python-determinism
186 rm ${D}${libdir}/python${PYTHON_MAJMIN}/test/__pycache__/test_range.cpython*
187 rm ${D}${libdir}/python${PYTHON_MAJMIN}/test/__pycache__/test_xml_etree.cpython*
Andrew Geissler82c905d2020-04-13 13:39:40 -0500188}
189
Patrick Williams213cb262021-08-07 19:21:33 -0500190do_install:append:class-nativesdk () {
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600191 # Make sure we use /usr/bin/env python
192 for PYTHSCRIPT in `grep -rIl ${bindir}/python ${D}${bindir}`; do
193 sed -i -e '1s|^#!.*|#!/usr/bin/env python3|' $PYTHSCRIPT
194 done
Andrew Geissler82c905d2020-04-13 13:39:40 -0500195 create_wrapper ${D}${bindir}/python${PYTHON_MAJMIN} TERMINFO_DIRS='${sysconfdir}/terminfo:/etc/terminfo:/usr/share/terminfo:/usr/share/misc/terminfo:/lib/terminfo' PYTHONNOUSERSITE='1'
196}
197
198SSTATE_SCAN_FILES += "Makefile _sysconfigdata.py"
Patrick Williams93c203f2021-10-06 16:15:23 -0500199SSTATE_HASHEQUIV_FILEMAP = " \
200 populate_sysroot:*/lib*/python3*/_sysconfigdata*.py:${TMPDIR} \
201 populate_sysroot:*/lib*/python3*/_sysconfigdata*.py:${COREBASE} \
202 populate_sysroot:*/lib*/python3*/config-*/Makefile:${TMPDIR} \
203 populate_sysroot:*/lib*/python3*/config-*/Makefile:${COREBASE} \
204 populate_sysroot:*/lib*/python-sysconfigdata/_sysconfigdata.py:${TMPDIR} \
205 populate_sysroot:*/lib*/python-sysconfigdata/_sysconfigdata.py:${COREBASE} \
206 "
Andrew Geissler82c905d2020-04-13 13:39:40 -0500207PACKAGE_PREPROCESS_FUNCS += "py_package_preprocess"
208
209py_package_preprocess () {
210 # Remove references to buildmachine paths in target Makefile and _sysconfigdata
211 sed -i -e 's:--sysroot=${STAGING_DIR_TARGET}::g' -e s:'--with-libtool-sysroot=${STAGING_DIR_TARGET}'::g \
212 -e 's|${DEBUG_PREFIX_MAP}||g' \
213 -e 's:${HOSTTOOLS_DIR}/::g' \
214 -e 's:${RECIPE_SYSROOT_NATIVE}::g' \
215 -e 's:${RECIPE_SYSROOT}::g' \
216 -e 's:${BASE_WORKDIR}/${MULTIMACH_TARGET_SYS}::g' \
217 ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/config-${PYTHON_MAJMIN}${PYTHON_ABI}*/Makefile \
218 ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/_sysconfigdata*.py \
219 ${PKGD}/${bindir}/python${PYTHON_MAJMIN}-config
220
221 # Reformat _sysconfigdata after modifying it so that it remains
222 # reproducible
223 for c in ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/_sysconfigdata*.py; do
224 python3 ${WORKDIR}/reformat_sysconfig.py $c
225 done
226
227 # Recompile _sysconfigdata after modifying it
228 cd ${PKGD}
229 sysconfigfile=`find . -name _sysconfigdata_*.py`
230 ${STAGING_BINDIR_NATIVE}/python3-native/python3 \
231 -c "from py_compile import compile; compile('$sysconfigfile')"
232 ${STAGING_BINDIR_NATIVE}/python3-native/python3 \
233 -c "from py_compile import compile; compile('$sysconfigfile', optimize=1)"
234 ${STAGING_BINDIR_NATIVE}/python3-native/python3 \
235 -c "from py_compile import compile; compile('$sysconfigfile', optimize=2)"
236 cd -
237
238 mv ${PKGD}/${bindir}/python${PYTHON_MAJMIN}-config ${PKGD}/${bindir}/python${PYTHON_MAJMIN}-config-${MULTILIB_SUFFIX}
239
240 #Remove the unneeded copy of target sysconfig data
241 rm -rf ${PKGD}/${libdir}/python-sysconfigdata
242}
243
244# We want bytecode precompiled .py files (.pyc's) by default
245# but the user may set it on their own conf
246INCLUDE_PYCS ?= "1"
247
248python(){
249 import collections, json
250
251 filename = os.path.join(d.getVar('THISDIR'), 'python3', 'python3-manifest.json')
252 # This python changes the datastore based on the contents of a file, so mark
253 # that dependency.
254 bb.parse.mark_dependency(d, filename)
255
256 with open(filename) as manifest_file:
257 manifest_str = manifest_file.read()
258 json_start = manifest_str.find('# EOC') + 6
259 manifest_file.seek(json_start)
260 manifest_str = manifest_file.read()
261 python_manifest = json.loads(manifest_str, object_pairs_hook=collections.OrderedDict)
262
263 # First set RPROVIDES for -native case
264 # Hardcoded since it cant be python3-native-foo, should be python3-foo-native
265 pn = 'python3'
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600266 rprovides = (d.getVar('RPROVIDES') or "").split()
Andrew Geissler82c905d2020-04-13 13:39:40 -0500267
268 # ${PN}-misc-native is not in the manifest
269 rprovides.append(pn + '-misc-native')
270
271 for key in python_manifest:
272 pypackage = pn + '-' + key + '-native'
273 if pypackage not in rprovides:
274 rprovides.append(pypackage)
275
Patrick Williams213cb262021-08-07 19:21:33 -0500276 d.setVar('RPROVIDES:class-native', ' '.join(rprovides))
Andrew Geissler82c905d2020-04-13 13:39:40 -0500277
278 # Then work on the target
279 include_pycs = d.getVar('INCLUDE_PYCS')
280
281 packages = d.getVar('PACKAGES').split()
282 pn = d.getVar('PN')
283
284 newpackages=[]
285 for key in python_manifest:
286 pypackage = pn + '-' + key
287
288 if pypackage not in packages:
289 # We need to prepend, otherwise python-misc gets everything
290 # so we use a new variable
291 newpackages.append(pypackage)
292
293 # "Build" python's manifest FILES, RDEPENDS and SUMMARY
Patrick Williams213cb262021-08-07 19:21:33 -0500294 d.setVar('FILES:' + pypackage, '')
Andrew Geissler82c905d2020-04-13 13:39:40 -0500295 for value in python_manifest[key]['files']:
Patrick Williams213cb262021-08-07 19:21:33 -0500296 d.appendVar('FILES:' + pypackage, ' ' + value)
Andrew Geissler82c905d2020-04-13 13:39:40 -0500297
298 # Add cached files
299 if include_pycs == '1':
300 for value in python_manifest[key]['cached']:
Patrick Williams213cb262021-08-07 19:21:33 -0500301 d.appendVar('FILES:' + pypackage, ' ' + value)
Andrew Geissler82c905d2020-04-13 13:39:40 -0500302
303 for value in python_manifest[key]['rdepends']:
304 # Make it work with or without $PN
305 if '${PN}' in value:
306 value=value.split('-', 1)[1]
Patrick Williams213cb262021-08-07 19:21:33 -0500307 d.appendVar('RDEPENDS:' + pypackage, ' ' + pn + '-' + value)
Andrew Geissler82c905d2020-04-13 13:39:40 -0500308
309 for value in python_manifest[key].get('rrecommends', ()):
310 if '${PN}' in value:
311 value=value.split('-', 1)[1]
Patrick Williams213cb262021-08-07 19:21:33 -0500312 d.appendVar('RRECOMMENDS:' + pypackage, ' ' + pn + '-' + value)
Andrew Geissler82c905d2020-04-13 13:39:40 -0500313
Patrick Williams213cb262021-08-07 19:21:33 -0500314 d.setVar('SUMMARY:' + pypackage, python_manifest[key]['summary'])
Andrew Geissler82c905d2020-04-13 13:39:40 -0500315
316 # Prepending so to avoid python-misc getting everything
317 packages = newpackages + packages
318 d.setVar('PACKAGES', ' '.join(packages))
Patrick Williams213cb262021-08-07 19:21:33 -0500319 d.setVar('ALLOW_EMPTY:${PN}-modules', '1')
320 d.setVar('ALLOW_EMPTY:${PN}-pkgutil', '1')
Andrew Geissler82c905d2020-04-13 13:39:40 -0500321}
322
323# Files needed to create a new manifest
324
325do_create_manifest() {
326 # This task should be run with every new release of Python.
327 # We must ensure that PACKAGECONFIG enables everything when creating
328 # a new manifest, this is to base our new manifest on a complete
329 # native python build, containing all dependencies, otherwise the task
330 # wont be able to find the required files.
331 # e.g. BerkeleyDB is an optional build dependency so it may or may not
332 # be present, we must ensure it is.
333
334 cd ${WORKDIR}
335 # This needs to be executed by python-native and NOT by HOST's python
336 nativepython3 create_manifest3.py ${PYTHON_MAJMIN}
337 cp python3-manifest.json.new ${THISDIR}/python3/python3-manifest.json
338}
339
340# bitbake python -c create_manifest
Andrew Geissler82c905d2020-04-13 13:39:40 -0500341# Make sure we have native python ready when we create a new manifest
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600342addtask do_create_manifest after do_patch do_prepare_recipe_sysroot
Andrew Geissler82c905d2020-04-13 13:39:40 -0500343
344# manual dependency additions
Patrick Williams213cb262021-08-07 19:21:33 -0500345RRECOMMENDS:${PN}-core:append:class-nativesdk = " nativesdk-python3-modules"
346RRECOMMENDS:${PN}-crypt:append:class-target = " ${MLPREFIX}openssl ${MLPREFIX}ca-certificates"
347RRECOMMENDS:${PN}-crypt:append:class-nativesdk = " ${MLPREFIX}openssl ${MLPREFIX}ca-certificates"
Andrew Geissler82c905d2020-04-13 13:39:40 -0500348
349# For historical reasons PN is empty and provided by python3-modules
Patrick Williams213cb262021-08-07 19:21:33 -0500350FILES:${PN} = ""
351RPROVIDES:${PN}-modules = "${PN}"
Andrew Geissler82c905d2020-04-13 13:39:40 -0500352
Patrick Williams213cb262021-08-07 19:21:33 -0500353FILES:${PN}-pydoc += "${bindir}/pydoc${PYTHON_MAJMIN} ${bindir}/pydoc3"
354FILES:${PN}-idle += "${bindir}/idle3 ${bindir}/idle${PYTHON_MAJMIN}"
Andrew Geissler82c905d2020-04-13 13:39:40 -0500355
356# provide python-pyvenv from python3-venv
Patrick Williams213cb262021-08-07 19:21:33 -0500357RPROVIDES:${PN}-venv += "${MLPREFIX}python3-pyvenv"
Andrew Geissler82c905d2020-04-13 13:39:40 -0500358
359# package libpython3
360PACKAGES =+ "libpython3 libpython3-staticdev"
Patrick Williams213cb262021-08-07 19:21:33 -0500361FILES:libpython3 = "${libdir}/libpython*.so.*"
362FILES:libpython3-staticdev += "${libdir}/python${PYTHON_MAJMIN}/config-${PYTHON_MAJMIN}-*/libpython${PYTHON_MAJMIN}.a"
363INSANE_SKIP:${PN}-dev += "dev-elf"
364INSANE_SKIP:${PN}-ptest = "dev-deps"
Andrew Geissler82c905d2020-04-13 13:39:40 -0500365
366# catch all the rest (unsorted)
367PACKAGES += "${PN}-misc"
Patrick Williams213cb262021-08-07 19:21:33 -0500368RDEPENDS:${PN}-misc += "\
Andrew Geisslerd25ed322020-06-27 00:28:28 -0500369 ${PN}-core \
370 ${PN}-email \
371 ${PN}-codecs \
372 ${PN}-pydoc \
373 ${PN}-pickle \
374 ${PN}-audio \
375 ${PN}-numbers \
376"
Patrick Williams213cb262021-08-07 19:21:33 -0500377RDEPENDS:${PN}-modules:append:class-target = " ${MLPREFIX}python3-misc"
378RDEPENDS:${PN}-modules:append:class-nativesdk = " ${MLPREFIX}python3-misc"
379FILES:${PN}-misc = "${libdir}/python${PYTHON_MAJMIN} ${libdir}/python${PYTHON_MAJMIN}/lib-dynload"
Andrew Geissler82c905d2020-04-13 13:39:40 -0500380
381# catch manpage
382PACKAGES += "${PN}-man"
Patrick Williams213cb262021-08-07 19:21:33 -0500383FILES:${PN}-man = "${datadir}/man"
Andrew Geissler82c905d2020-04-13 13:39:40 -0500384
385# See https://bugs.python.org/issue18748 and https://bugs.python.org/issue37395
Patrick Williams213cb262021-08-07 19:21:33 -0500386RDEPENDS:libpython3:append:libc-glibc = " libgcc"
387RDEPENDS:${PN}-ctypes:append:libc-glibc = " ${MLPREFIX}ldconfig"
388RDEPENDS:${PN}-ptest = "${PN}-modules ${PN}-tests ${PN}-dev unzip bzip2 libgcc tzdata-europe coreutils sed"
389RDEPENDS:${PN}-ptest:append:libc-glibc = " locale-base-tr-tr.iso-8859-9"
Andrew Geissler5199d832021-09-24 16:47:35 -0500390RDEPENDS:${PN}-tkinter += "${@bb.utils.contains('PACKAGECONFIG', 'tk', '${MLPREFIX}tk ${MLPREFIX}tk-lib', '', d)}"
391RDEPENDS:${PN}-idle += "${@bb.utils.contains('PACKAGECONFIG', 'tk', '${PN}-tkinter ${MLPREFIX}tcl', '', d)}"
Patrick Williams213cb262021-08-07 19:21:33 -0500392RDEPENDS:${PN}-dev = ""
393RDEPENDS:${PN}-pydoc += "${PN}-io"
Andrew Geissler82c905d2020-04-13 13:39:40 -0500394
Patrick Williams213cb262021-08-07 19:21:33 -0500395RDEPENDS:${PN}-tests:append:class-target = " ${MLPREFIX}bash"
396RDEPENDS:${PN}-tests:append:class-nativesdk = " ${MLPREFIX}bash"
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600397
398# Python's tests contain large numbers of files we don't need in the recipe sysroots
399SYSROOT_PREPROCESS_FUNCS += " py3_sysroot_cleanup"
400py3_sysroot_cleanup () {
401 rm -rf ${SYSROOT_DESTDIR}${libdir}/python${PYTHON_MAJMIN}/test
402}