Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 1 | SUMMARY = "The Python Programming Language" |
| 2 | HOMEPAGE = "http://www.python.org" |
Andrew Geissler | 90fd73c | 2021-03-05 15:25:55 -0600 | [diff] [blame] | 3 | DESCRIPTION = "Python is a programming language that lets you work more quickly and integrate your systems more effectively." |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 4 | LICENSE = "PSFv2" |
| 5 | SECTION = "devel/python" |
| 6 | |
Andrew Geissler | 90fd73c | 2021-03-05 15:25:55 -0600 | [diff] [blame] | 7 | LIC_FILES_CHKSUM = "file://LICENSE;md5=c22d2438294c784731bf9dd224a467b7" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 8 | |
| 9 | SRC_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 Geissler | 6ce62a2 | 2020-11-30 19:58:47 -0600 | [diff] [blame] | 15 | file://reformat_sysconfig.py \ |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 16 | 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 Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 22 | file://0001-python3-use-cc_basename-to-replace-CC-for-checking-c.patch \ |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 23 | file://0001-bpo-36852-proper-detection-of-mips-architecture-for-.patch \ |
| 24 | file://crosspythonpath.patch \ |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 25 | 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 Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 30 | file://0020-configure.ac-setup.py-do-not-add-a-curses-include-pa.patch \ |
Andrew Geissler | 6ce62a2 | 2020-11-30 19:58:47 -0600 | [diff] [blame] | 31 | file://0001-Lib-sysconfig.py-use-libdir-values-from-configuratio.patch \ |
Andrew Geissler | 3b8a17c | 2021-04-15 15:55:55 -0500 | [diff] [blame] | 32 | file://0001-Skip-failing-tests-due-to-load-variability-on-YP-AB.patch \ |
Andrew Geissler | 5f35090 | 2021-07-23 13:09:54 -0400 | [diff] [blame] | 33 | file://0001-test_ctypes.test_find-skip-without-tools-sdk.patch \ |
| 34 | file://makerace.patch \ |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 35 | " |
| 36 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 37 | SRC_URI:append:class-native = " \ |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 38 | 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 Geissler | 5f35090 | 2021-07-23 13:09:54 -0400 | [diff] [blame] | 42 | SRC_URI[sha256sum] = "397920af33efc5b97f2e0b57e91923512ef89fc5b3c1d21dbfc8c4828ce0108a" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 43 | |
| 44 | # exclude pre-releases for both python 2.x and 3.x |
| 45 | UPSTREAM_CHECK_REGEX = "[Pp]ython-(?P<pver>\d+(\.\d+)+).tar" |
Andrew Geissler | 4c19ea1 | 2020-10-27 13:52:24 -0500 | [diff] [blame] | 46 | UPSTREAM_CHECK_URI = "https://www.python.org/downloads/source/" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 47 | |
| 48 | CVE_PRODUCT = "python" |
| 49 | |
Andrew Geissler | 6ce62a2 | 2020-11-30 19:58:47 -0600 | [diff] [blame] | 50 | # Upstream consider this expected behaviour |
| 51 | CVE_CHECK_WHITELIST += "CVE-2007-4559" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 52 | # This is not exploitable when glibc has CVE-2016-10739 fixed. |
| 53 | CVE_CHECK_WHITELIST += "CVE-2019-18348" |
| 54 | |
Andrew Geissler | 6ce62a2 | 2020-11-30 19:58:47 -0600 | [diff] [blame] | 55 | # This is windows only issue. |
| 56 | CVE_CHECK_WHITELIST += "CVE-2020-15523" |
| 57 | |
| 58 | PYTHON_MAJMIN = "3.9" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 59 | |
| 60 | S = "${WORKDIR}/Python-${PV}" |
| 61 | |
| 62 | BBCLASSEXTEND = "native nativesdk" |
| 63 | |
| 64 | inherit autotools pkgconfig qemu ptest multilib_header update-alternatives |
| 65 | |
| 66 | MULTILIB_SUFFIX = "${@d.getVar('base_libdir',1).split('/')[-1]}" |
| 67 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 68 | ALTERNATIVE:${PN}-dev = "python3-config" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 69 | ALTERNATIVE_LINK_NAME[python3-config] = "${bindir}/python${PYTHON_MAJMIN}-config" |
| 70 | ALTERNATIVE_TARGET[python3-config] = "${bindir}/python${PYTHON_MAJMIN}-config-${MULTILIB_SUFFIX}" |
| 71 | |
| 72 | |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 73 | DEPENDS = "bzip2-replacement-native libffi bzip2 openssl sqlite3 zlib virtual/libintl xz virtual/crypt util-linux libtirpc libnsl2 autoconf-archive-native" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 74 | DEPENDS:append:class-target = " python3-native" |
| 75 | DEPENDS:append:class-nativesdk = " python3-native" |
| 76 | |
| 77 | # force to use the mutex+cond implementation (https://bugs.python.org/issue41710) |
| 78 | CFLAGS += "-DHAVE_BROKEN_POSIX_SEMAPHORES" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 79 | |
Andrew Geissler | 6ce62a2 | 2020-11-30 19:58:47 -0600 | [diff] [blame] | 80 | EXTRA_OECONF = " --without-ensurepip --enable-shared --with-platlibdir=${baselib}" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 81 | EXTRA_OECONF:append:class-native = " --bindir=${bindir}/${PN}" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 82 | |
| 83 | export CROSSPYTHONPATH="${STAGING_LIBDIR_NATIVE}/python${PYTHON_MAJMIN}/lib-dynload/" |
| 84 | |
| 85 | EXTRANATIVEPATH += "python3-native" |
| 86 | |
Andrew Geissler | 6ce62a2 | 2020-11-30 19:58:47 -0600 | [diff] [blame] | 87 | # LTO will be enabled via packageconfig depending upong distro features |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 88 | LTO:class-target = "" |
Andrew Geissler | 6ce62a2 | 2020-11-30 19:58:47 -0600 | [diff] [blame] | 89 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 90 | CACHED_CONFIGUREVARS = " \ |
| 91 | ac_cv_file__dev_ptmx=yes \ |
| 92 | ac_cv_file__dev_ptc=no \ |
| 93 | ac_cv_working_tzset=yes \ |
| 94 | " |
Andrew Geissler | d25ed32 | 2020-06-27 00:28:28 -0500 | [diff] [blame] | 95 | |
| 96 | def possibly_include_pgo(d): |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 97 | # 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 Geissler | d25ed32 | 2020-06-27 00:28:28 -0500 | [diff] [blame] | 100 | return 'pgo' |
| 101 | |
| 102 | return '' |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 103 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 104 | PACKAGECONFIG:class-target ??= "readline ${@possibly_include_pgo(d)} gdbm ${@bb.utils.filter('DISTRO_FEATURES', 'lto', d)}" |
| 105 | PACKAGECONFIG:class-native ??= "readline gdbm" |
| 106 | PACKAGECONFIG:class-nativesdk ??= "readline gdbm" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 107 | PACKAGECONFIG[readline] = ",,readline" |
| 108 | # Use profile guided optimisation by running PyBench inside qemu-user |
| 109 | PACKAGECONFIG[pgo] = "--enable-optimizations,,qemu-native" |
| 110 | PACKAGECONFIG[tk] = ",,tk" |
| 111 | PACKAGECONFIG[gdbm] = ",,gdbm" |
Andrew Geissler | 6ce62a2 | 2020-11-30 19:58:47 -0600 | [diff] [blame] | 112 | PACKAGECONFIG[lto] = "--with-lto,," |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 113 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 114 | do_configure:prepend () { |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 115 | 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)} |
| 120 | EOF |
| 121 | } |
| 122 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 123 | CPPFLAGS:append = " -I${STAGING_INCDIR}/ncursesw -I${STAGING_INCDIR}/uuid" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 124 | |
| 125 | EXTRA_OEMAKE = '\ |
| 126 | STAGING_LIBDIR=${STAGING_LIBDIR} \ |
| 127 | STAGING_INCDIR=${STAGING_INCDIR} \ |
| 128 | LIB=${baselib} \ |
| 129 | ' |
| 130 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 131 | do_compile:prepend:class-target() { |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 132 | 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 |
| 136 | cd ${B} |
| 137 | $qemu_binary "\$@" |
| 138 | EOF |
| 139 | chmod +x pgo-wrapper |
| 140 | fi |
| 141 | } |
| 142 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 143 | do_install:prepend() { |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 144 | ${WORKDIR}/check_build_completeness.py ${T}/log.do_compile |
| 145 | } |
| 146 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 147 | do_install:append:class-target() { |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 148 | oe_multilib_header python${PYTHON_MAJMIN}/pyconfig.h |
| 149 | } |
| 150 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 151 | do_install:append:class-native() { |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 152 | # 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 Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 163 | do_install:append() { |
Patrick Williams | 93c203f | 2021-10-06 16:15:23 -0500 | [diff] [blame] | 164 | 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 Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 169 | 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 Geissler | 6ce62a2 | 2020-11-30 19:58:47 -0600 | [diff] [blame] | 180 | |
| 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 Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 188 | } |
| 189 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 190 | do_install:append:class-nativesdk () { |
Andrew Geissler | 90fd73c | 2021-03-05 15:25:55 -0600 | [diff] [blame] | 191 | # 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 Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 195 | 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 | |
| 198 | SSTATE_SCAN_FILES += "Makefile _sysconfigdata.py" |
Patrick Williams | 93c203f | 2021-10-06 16:15:23 -0500 | [diff] [blame] | 199 | SSTATE_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 Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 207 | PACKAGE_PREPROCESS_FUNCS += "py_package_preprocess" |
| 208 | |
| 209 | py_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 |
| 246 | INCLUDE_PYCS ?= "1" |
| 247 | |
| 248 | python(){ |
| 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 Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 266 | rprovides = (d.getVar('RPROVIDES') or "").split() |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 267 | |
| 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 Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 276 | d.setVar('RPROVIDES:class-native', ' '.join(rprovides)) |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 277 | |
| 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 Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 294 | d.setVar('FILES:' + pypackage, '') |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 295 | for value in python_manifest[key]['files']: |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 296 | d.appendVar('FILES:' + pypackage, ' ' + value) |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 297 | |
| 298 | # Add cached files |
| 299 | if include_pycs == '1': |
| 300 | for value in python_manifest[key]['cached']: |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 301 | d.appendVar('FILES:' + pypackage, ' ' + value) |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 302 | |
| 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 Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 307 | d.appendVar('RDEPENDS:' + pypackage, ' ' + pn + '-' + value) |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 308 | |
| 309 | for value in python_manifest[key].get('rrecommends', ()): |
| 310 | if '${PN}' in value: |
| 311 | value=value.split('-', 1)[1] |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 312 | d.appendVar('RRECOMMENDS:' + pypackage, ' ' + pn + '-' + value) |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 313 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 314 | d.setVar('SUMMARY:' + pypackage, python_manifest[key]['summary']) |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 315 | |
| 316 | # Prepending so to avoid python-misc getting everything |
| 317 | packages = newpackages + packages |
| 318 | d.setVar('PACKAGES', ' '.join(packages)) |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 319 | d.setVar('ALLOW_EMPTY:${PN}-modules', '1') |
| 320 | d.setVar('ALLOW_EMPTY:${PN}-pkgutil', '1') |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 321 | } |
| 322 | |
| 323 | # Files needed to create a new manifest |
| 324 | |
| 325 | do_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 Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 341 | # Make sure we have native python ready when we create a new manifest |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 342 | addtask do_create_manifest after do_patch do_prepare_recipe_sysroot |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 343 | |
| 344 | # manual dependency additions |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 345 | RRECOMMENDS:${PN}-core:append:class-nativesdk = " nativesdk-python3-modules" |
| 346 | RRECOMMENDS:${PN}-crypt:append:class-target = " ${MLPREFIX}openssl ${MLPREFIX}ca-certificates" |
| 347 | RRECOMMENDS:${PN}-crypt:append:class-nativesdk = " ${MLPREFIX}openssl ${MLPREFIX}ca-certificates" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 348 | |
| 349 | # For historical reasons PN is empty and provided by python3-modules |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 350 | FILES:${PN} = "" |
| 351 | RPROVIDES:${PN}-modules = "${PN}" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 352 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 353 | FILES:${PN}-pydoc += "${bindir}/pydoc${PYTHON_MAJMIN} ${bindir}/pydoc3" |
| 354 | FILES:${PN}-idle += "${bindir}/idle3 ${bindir}/idle${PYTHON_MAJMIN}" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 355 | |
| 356 | # provide python-pyvenv from python3-venv |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 357 | RPROVIDES:${PN}-venv += "${MLPREFIX}python3-pyvenv" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 358 | |
| 359 | # package libpython3 |
| 360 | PACKAGES =+ "libpython3 libpython3-staticdev" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 361 | FILES:libpython3 = "${libdir}/libpython*.so.*" |
| 362 | FILES:libpython3-staticdev += "${libdir}/python${PYTHON_MAJMIN}/config-${PYTHON_MAJMIN}-*/libpython${PYTHON_MAJMIN}.a" |
| 363 | INSANE_SKIP:${PN}-dev += "dev-elf" |
| 364 | INSANE_SKIP:${PN}-ptest = "dev-deps" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 365 | |
| 366 | # catch all the rest (unsorted) |
| 367 | PACKAGES += "${PN}-misc" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 368 | RDEPENDS:${PN}-misc += "\ |
Andrew Geissler | d25ed32 | 2020-06-27 00:28:28 -0500 | [diff] [blame] | 369 | ${PN}-core \ |
| 370 | ${PN}-email \ |
| 371 | ${PN}-codecs \ |
| 372 | ${PN}-pydoc \ |
| 373 | ${PN}-pickle \ |
| 374 | ${PN}-audio \ |
| 375 | ${PN}-numbers \ |
| 376 | " |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 377 | RDEPENDS:${PN}-modules:append:class-target = " ${MLPREFIX}python3-misc" |
| 378 | RDEPENDS:${PN}-modules:append:class-nativesdk = " ${MLPREFIX}python3-misc" |
| 379 | FILES:${PN}-misc = "${libdir}/python${PYTHON_MAJMIN} ${libdir}/python${PYTHON_MAJMIN}/lib-dynload" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 380 | |
| 381 | # catch manpage |
| 382 | PACKAGES += "${PN}-man" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 383 | FILES:${PN}-man = "${datadir}/man" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 384 | |
| 385 | # See https://bugs.python.org/issue18748 and https://bugs.python.org/issue37395 |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 386 | RDEPENDS:libpython3:append:libc-glibc = " libgcc" |
| 387 | RDEPENDS:${PN}-ctypes:append:libc-glibc = " ${MLPREFIX}ldconfig" |
| 388 | RDEPENDS:${PN}-ptest = "${PN}-modules ${PN}-tests ${PN}-dev unzip bzip2 libgcc tzdata-europe coreutils sed" |
| 389 | RDEPENDS:${PN}-ptest:append:libc-glibc = " locale-base-tr-tr.iso-8859-9" |
Andrew Geissler | 5199d83 | 2021-09-24 16:47:35 -0500 | [diff] [blame] | 390 | RDEPENDS:${PN}-tkinter += "${@bb.utils.contains('PACKAGECONFIG', 'tk', '${MLPREFIX}tk ${MLPREFIX}tk-lib', '', d)}" |
| 391 | RDEPENDS:${PN}-idle += "${@bb.utils.contains('PACKAGECONFIG', 'tk', '${PN}-tkinter ${MLPREFIX}tcl', '', d)}" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 392 | RDEPENDS:${PN}-dev = "" |
| 393 | RDEPENDS:${PN}-pydoc += "${PN}-io" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 394 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 395 | RDEPENDS:${PN}-tests:append:class-target = " ${MLPREFIX}bash" |
| 396 | RDEPENDS:${PN}-tests:append:class-nativesdk = " ${MLPREFIX}bash" |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 397 | |
| 398 | # Python's tests contain large numbers of files we don't need in the recipe sysroots |
| 399 | SYSROOT_PREPROCESS_FUNCS += " py3_sysroot_cleanup" |
| 400 | py3_sysroot_cleanup () { |
| 401 | rm -rf ${SYSROOT_DESTDIR}${libdir}/python${PYTHON_MAJMIN}/test |
| 402 | } |