diff options
| author | Praveen Kumar <praveen.kumar@windriver.com> | 2025-06-05 20:08:25 +0530 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-06-09 17:43:41 +0100 |
| commit | f64ec011d9d0f523a1971763d78624016c6a4adf (patch) | |
| tree | 1d9a8ccbefc041ef67fba668641fb9c37be6d474 /meta/recipes-devtools/python/python3_3.13.4.bb | |
| parent | a375cb15b9dac5db64667168f0724e79d2792a09 (diff) | |
| download | poky-f64ec011d9d0f523a1971763d78624016c6a4adf.tar.gz | |
python3: upgrade 3.13.3 -> 3.13.4
Security content in this release:
- gh-135034: Fixes multiple issues that allowed tarfile extraction filters
(filter="data" and filter="tar") to be bypassed using crafted symlinks and
hard links. Addresses CVE-2024-12718, CVE-2025-4138, CVE-2025-4330, and
CVE-2025-4517.
- gh-133767: Fix use-after-free in the “unicode-escape” decoder with a non-
“strict” error handler.
- gh-128840: Short-circuit the processing of long IPv6 addresses early in
ipaddress to prevent excessive memory consumption and a minor denial-of-service.
Includes additional standard library improvements and bug fixes.
References:
https://docs.python.org/3/whatsnew/changelog.html#python-3-13-4-final
https://www.python.org/downloads/release/python-3134/
(From OE-Core rev: d2bcfa826aa3a7bd5d6ab250fb8ba083e2688c8b)
Signed-off-by: Praveen Kumar <praveen.kumar@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools/python/python3_3.13.4.bb')
| -rw-r--r-- | meta/recipes-devtools/python/python3_3.13.4.bb | 497 |
1 files changed, 497 insertions, 0 deletions
diff --git a/meta/recipes-devtools/python/python3_3.13.4.bb b/meta/recipes-devtools/python/python3_3.13.4.bb new file mode 100644 index 0000000000..5b49fee3bf --- /dev/null +++ b/meta/recipes-devtools/python/python3_3.13.4.bb | |||
| @@ -0,0 +1,497 @@ | |||
| 1 | SUMMARY = "The Python Programming Language" | ||
| 2 | HOMEPAGE = "http://www.python.org" | ||
| 3 | DESCRIPTION = "Python is a programming language that lets you work more quickly and integrate your systems more effectively." | ||
| 4 | LICENSE = "PSF-2.0" | ||
| 5 | SECTION = "devel/python" | ||
| 6 | |||
| 7 | LIC_FILES_CHKSUM = "file://LICENSE;md5=3f64a4ff490f884d562feb77bf2435f1" | ||
| 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 \ | ||
| 15 | file://reformat_sysconfig.py \ | ||
| 16 | file://0001-Makefile.pre-use-qemu-wrapper-when-gathering-profile.patch \ | ||
| 17 | file://0001-test_locale.py-correct-the-test-output-format.patch \ | ||
| 18 | file://0001-Skip-failing-tests-due-to-load-variability-on-YP-AB.patch \ | ||
| 19 | file://0001-test_ctypes.test_find-skip-without-tools-sdk.patch \ | ||
| 20 | file://makerace.patch \ | ||
| 21 | file://0001-sysconfig.py-use-platlibdir-also-for-purelib.patch \ | ||
| 22 | file://0001-Lib-pty.py-handle-stdin-I-O-errors-same-way-as-maste.patch \ | ||
| 23 | file://valid-dists.patch \ | ||
| 24 | file://0001-Avoid-shebang-overflow-on-python-config.py.patch \ | ||
| 25 | file://0001-Update-test_sysconfig-for-posix_user-purelib.patch \ | ||
| 26 | file://0001-skip-no_stdout_fileno-test-due-to-load-variability.patch \ | ||
| 27 | file://0001-test_storlines-skip-due-to-load-variability.patch \ | ||
| 28 | file://0001-test_shutdown-skip-problematic-test.patch \ | ||
| 29 | file://0001-test_deadlock-skip-problematic-test.patch \ | ||
| 30 | file://0001-test_active_children-skip-problematic-test.patch \ | ||
| 31 | file://0001-test_readline-skip-limited-history-test.patch \ | ||
| 32 | file://0001-Generate-data-for-OpenSSL-3.4-and-add-it-to-multissl.patch \ | ||
| 33 | " | ||
| 34 | |||
| 35 | SRC_URI:append:class-native = " \ | ||
| 36 | file://0001-Lib-sysconfig.py-use-prefix-value-from-build-configu.patch \ | ||
| 37 | " | ||
| 38 | |||
| 39 | SRC_URI[sha256sum] = "27b15a797562a2971dce3ffe31bb216042ce0b995b39d768cf15f784cc757365" | ||
| 40 | |||
| 41 | # exclude pre-releases for both python 2.x and 3.x | ||
| 42 | UPSTREAM_CHECK_REGEX = "[Pp]ython-(?P<pver>\d+(\.\d+)+).tar" | ||
| 43 | |||
| 44 | CVE_PRODUCT = "python cpython" | ||
| 45 | |||
| 46 | CVE_STATUS[CVE-2007-4559] = "disputed: Upstream consider this expected behaviour" | ||
| 47 | CVE_STATUS[CVE-2019-18348] = "not-applicable-config: This is not exploitable when glibc has CVE-2016-10739 fixed" | ||
| 48 | CVE_STATUS[CVE-2020-15523] = "not-applicable-platform: Issue only applies on Windows" | ||
| 49 | CVE_STATUS[CVE-2022-26488] = "not-applicable-platform: Issue only applies on Windows" | ||
| 50 | # The module will be removed in the future and flaws documented. | ||
| 51 | CVE_STATUS[CVE-2015-20107] = "upstream-wontfix: The mailcap module is insecure by design, so this can't be fixed in a meaningful way" | ||
| 52 | CVE_STATUS[CVE-2023-36632] = "disputed: Not an issue, in fact expected behaviour" | ||
| 53 | |||
| 54 | PYTHON_MAJMIN = "3.13" | ||
| 55 | |||
| 56 | S = "${WORKDIR}/Python-${PV}" | ||
| 57 | |||
| 58 | BBCLASSEXTEND = "native nativesdk" | ||
| 59 | |||
| 60 | inherit autotools pkgconfig qemu ptest multilib_header update-alternatives | ||
| 61 | |||
| 62 | MULTILIB_SUFFIX = "${@d.getVar('base_libdir',1).split('/')[-1]}" | ||
| 63 | |||
| 64 | ALTERNATIVE:${PN}-dev = "python3-config" | ||
| 65 | ALTERNATIVE_LINK_NAME[python3-config] = "${bindir}/python${PYTHON_MAJMIN}-config" | ||
| 66 | ALTERNATIVE_TARGET[python3-config] = "${bindir}/python${PYTHON_MAJMIN}-config-${MULTILIB_SUFFIX}" | ||
| 67 | |||
| 68 | |||
| 69 | DEPENDS = "\ | ||
| 70 | autoconf-archive-native \ | ||
| 71 | bzip2 \ | ||
| 72 | bzip2-replacement-native \ | ||
| 73 | expat \ | ||
| 74 | libffi \ | ||
| 75 | ncurses \ | ||
| 76 | openssl \ | ||
| 77 | sqlite3 \ | ||
| 78 | util-linux-libuuid \ | ||
| 79 | virtual/crypt \ | ||
| 80 | virtual/libintl \ | ||
| 81 | xz \ | ||
| 82 | zlib \ | ||
| 83 | " | ||
| 84 | |||
| 85 | DEPENDS:append:class-target = " python3-native" | ||
| 86 | DEPENDS:append:class-nativesdk = " python3-native" | ||
| 87 | |||
| 88 | EXTRA_OECONF = " --without-ensurepip --enable-shared --with-platlibdir=${baselib} --with-system-expat" | ||
| 89 | EXTRA_OECONF:append:class-native = " --bindir=${bindir}/${PN}" | ||
| 90 | EXTRA_OECONF:append:class-target = " --with-build-python=nativepython3" | ||
| 91 | EXTRA_OECONF:append:class-nativesdk = " --with-build-python=nativepython3" | ||
| 92 | |||
| 93 | export CROSSPYTHONPATH = "${STAGING_LIBDIR_NATIVE}/python${PYTHON_MAJMIN}/lib-dynload/" | ||
| 94 | |||
| 95 | EXTRANATIVEPATH += "python3-native" | ||
| 96 | |||
| 97 | # LTO will be enabled via packageconfig depending upong distro features | ||
| 98 | LTO:class-target = "" | ||
| 99 | |||
| 100 | CACHED_CONFIGUREVARS = " \ | ||
| 101 | ac_cv_file__dev_ptmx=yes \ | ||
| 102 | ac_cv_file__dev_ptc=no \ | ||
| 103 | ac_cv_working_tzset=yes \ | ||
| 104 | " | ||
| 105 | CACHED_CONFIGUREVARS:append:class-target = " \ | ||
| 106 | ac_cv_libatomic_needed=yes \ | ||
| 107 | " | ||
| 108 | |||
| 109 | # set thread stack size to 2MB on musl for interpreter and stdlib C extensions | ||
| 110 | # so it does not run into stack limits due to musl's small thread stack | ||
| 111 | # This is only needed to build interpreter and not the subsequent modules | ||
| 112 | # Thats why CFLAGS_NODIST is modified instead of CFLAGS | ||
| 113 | CACHED_CONFIGUREVARS:append:libc-musl = "\ | ||
| 114 | CFLAGS_NODIST='${CFLAGS} -DTHREAD_STACK_SIZE=0x200000' \ | ||
| 115 | " | ||
| 116 | |||
| 117 | # PGO currently causes builds to not be reproducible so disable by default, see YOCTO #13407 | ||
| 118 | PACKAGECONFIG ??= "editline gdbm ${@bb.utils.filter('DISTRO_FEATURES', 'lto', d)}" | ||
| 119 | PACKAGECONFIG[readline] = "--with-readline=readline,,readline,,,editline" | ||
| 120 | PACKAGECONFIG[editline] = "--with-readline=editline,,libedit,,,readline" | ||
| 121 | # Use profile guided optimisation by running PyBench inside qemu-user | ||
| 122 | PACKAGECONFIG[pgo] = "--enable-optimizations,,qemu-native" | ||
| 123 | PACKAGECONFIG[tk] = ",,tk" | ||
| 124 | PACKAGECONFIG[tcl] = ",,tcl" | ||
| 125 | PACKAGECONFIG[gdbm] = ",,gdbm" | ||
| 126 | PACKAGECONFIG[lto] = "--with-lto,--without-lto" | ||
| 127 | PACKAGECONFIG[staticlibpython] = "--with-static-libpython,--without-static-libpython" | ||
| 128 | |||
| 129 | do_configure:prepend () { | ||
| 130 | mkdir -p ${B}/Modules | ||
| 131 | cat > ${B}/Modules/Setup.local << EOF | ||
| 132 | *disabled* | ||
| 133 | ${@bb.utils.contains('PACKAGECONFIG', 'gdbm', '', '_gdbm _dbm', d)} | ||
| 134 | ${@bb.utils.contains_any('PACKAGECONFIG', 'readline editline', '', 'readline', d)} | ||
| 135 | ${@bb.utils.contains('PACKAGECONFIG', 'tk', '', '_tkinter', d)} | ||
| 136 | EOF | ||
| 137 | } | ||
| 138 | |||
| 139 | CPPFLAGS += "-I${STAGING_INCDIR}/ncursesw -I${STAGING_INCDIR}/uuid" | ||
| 140 | |||
| 141 | # COMPILEALL_OPTS= ensures that .pyc are not compiled in parallel | ||
| 142 | # This was found to lock up builds, break reproducibility, and produce strange file ownership | ||
| 143 | # races. | ||
| 144 | # | ||
| 145 | # The upstream commit introducing the change was: | ||
| 146 | # https://github.com/python/cpython/commit/1a2dd82f56bd813aacc570e172cefe55a8a41504 | ||
| 147 | # | ||
| 148 | # The build lock up issue is reported here: | ||
| 149 | # https://bugs.python.org/issue45945 | ||
| 150 | # | ||
| 151 | # The repro failures are documented here: | ||
| 152 | # https://autobuilder.yocto.io/pub/repro-fail/oe-reproducible-20211130-yr_o1a8d/packages/diff-html/ | ||
| 153 | |||
| 154 | EXTRA_OEMAKE = '\ | ||
| 155 | STAGING_LIBDIR=${STAGING_LIBDIR} \ | ||
| 156 | STAGING_INCDIR=${STAGING_INCDIR} \ | ||
| 157 | LIB=${baselib} \ | ||
| 158 | COMPILEALL_OPTS= \ | ||
| 159 | ' | ||
| 160 | |||
| 161 | # Generate a Profile Guided Optimisation wrapper script that uses qemu-user for | ||
| 162 | # all cross builds. | ||
| 163 | write_pgo_wrapper:class-native = ":" | ||
| 164 | write_pgo_wrapper() { | ||
| 165 | if ${@bb.utils.contains('PACKAGECONFIG', 'pgo', 'true', 'false', d)}; then | ||
| 166 | cat >pgo-wrapper <<EOF | ||
| 167 | #!/bin/sh | ||
| 168 | cd ${B} | ||
| 169 | ${@qemu_wrapper_cmdline(d, '${STAGING_DIR_TARGET}', ['${B}', '${STAGING_DIR_TARGET}/${base_libdir}'])} "\$@" | ||
| 170 | EOF | ||
| 171 | chmod +x pgo-wrapper | ||
| 172 | fi | ||
| 173 | } | ||
| 174 | |||
| 175 | do_compile:prepend() { | ||
| 176 | write_pgo_wrapper | ||
| 177 | } | ||
| 178 | |||
| 179 | do_install:prepend() { | ||
| 180 | ${UNPACKDIR}/check_build_completeness.py ${T}/log.do_compile | ||
| 181 | } | ||
| 182 | |||
| 183 | do_install:append:class-target() { | ||
| 184 | oe_multilib_header python${PYTHON_MAJMIN}/pyconfig.h | ||
| 185 | } | ||
| 186 | |||
| 187 | do_install:append:class-native() { | ||
| 188 | # Make sure we use /usr/bin/env python | ||
| 189 | for PYTHSCRIPT in `grep -rIl ${bindir}/${PN}/python ${D}${bindir}/${PN}`; do | ||
| 190 | sed -i -e '1s|^#!.*|#!/usr/bin/env python3|' $PYTHSCRIPT | ||
| 191 | done | ||
| 192 | # Add a symlink to the native Python so that scripts can just invoke | ||
| 193 | # "nativepython" and get the right one without needing absolute paths | ||
| 194 | # (these often end up too long for the #! parser in the kernel as the | ||
| 195 | # buffer is 128 bytes long). | ||
| 196 | ln -s python3-native/python3 ${D}${bindir}/nativepython3 | ||
| 197 | |||
| 198 | # Remove the opt-1.pyc and opt-2.pyc files. There are over 3,000 of them | ||
| 199 | # and the overhead in each recipe-sysroot-native isn't worth it, particularly | ||
| 200 | # when they're only used for python called with -O or -OO. | ||
| 201 | #find ${D} -name *opt-*.pyc -delete | ||
| 202 | # Remove all pyc files. There are a ton of them and it is probably faster to let | ||
| 203 | # python create the ones it wants at runtime rather than manage in the sstate | ||
| 204 | # tarballs and sysroot creation. | ||
| 205 | find ${D} -name *.pyc -delete | ||
| 206 | |||
| 207 | # Nothing should be looking into ${B} for python3-native | ||
| 208 | sed -i -e 's:${B}:/build/path/unavailable/:g' \ | ||
| 209 | ${D}/${libdir}/python${PYTHON_MAJMIN}/config-${PYTHON_MAJMIN}${PYTHON_ABI}*/Makefile | ||
| 210 | |||
| 211 | # disable the lookup in user's site-packages globally | ||
| 212 | sed -i 's#ENABLE_USER_SITE = None#ENABLE_USER_SITE = False#' ${D}${libdir}/python${PYTHON_MAJMIN}/site.py | ||
| 213 | |||
| 214 | # python3-config needs to be in /usr/bin and not in a subdir of it to work properly | ||
| 215 | mv ${D}/${bindir}/${PN}/python*config ${D}/${bindir}/ | ||
| 216 | } | ||
| 217 | |||
| 218 | do_install:append() { | ||
| 219 | for c in ${D}/${libdir}/python${PYTHON_MAJMIN}/_sysconfigdata*.py; do | ||
| 220 | python3 ${UNPACKDIR}/reformat_sysconfig.py $c | ||
| 221 | done | ||
| 222 | rm -f ${D}${libdir}/python${PYTHON_MAJMIN}/__pycache__/_sysconfigdata*.cpython* | ||
| 223 | |||
| 224 | mkdir -p ${D}${libdir}/python-sysconfigdata | ||
| 225 | sysconfigfile=`find ${D} -name _sysconfig*.py` | ||
| 226 | sed -i \ | ||
| 227 | -e "s,^ 'LIBDIR'.*, 'LIBDIR': '${STAGING_LIBDIR}'\,,g" \ | ||
| 228 | -e "s,^ 'INCLUDEDIR'.*, 'INCLUDEDIR': '${STAGING_INCDIR}'\,,g" \ | ||
| 229 | -e "s,^ 'CONFINCLUDEDIR'.*, 'CONFINCLUDEDIR': '${STAGING_INCDIR}'\,,g" \ | ||
| 230 | -e "s,^ 'INCLUDEPY'.*, 'INCLUDEPY': '${STAGING_INCDIR}/python${PYTHON_MAJMIN}'\,,g" \ | ||
| 231 | -e "s,^ 'CONFINCLUDEPY'.*, 'CONFINCLUDEPY': '${STAGING_INCDIR}/python${PYTHON_MAJMIN}'\,,g" \ | ||
| 232 | -e "s,${B},/build/path/unavailable/,g" \ | ||
| 233 | $sysconfigfile | ||
| 234 | cp $sysconfigfile ${D}${libdir}/python-sysconfigdata/_sysconfigdata.py | ||
| 235 | |||
| 236 | # Remove the opt-1.pyc and opt-2.pyc files. They effectively waste space on embedded | ||
| 237 | # style targets as they're only used when python is called with the -O or -OO options | ||
| 238 | # which is rare. | ||
| 239 | find ${D} -name *opt-*.pyc -delete | ||
| 240 | } | ||
| 241 | |||
| 242 | do_install:append:class-nativesdk () { | ||
| 243 | # Make sure we use /usr/bin/env python | ||
| 244 | for PYTHSCRIPT in `grep -rIl ${bindir}/python ${D}${bindir}`; do | ||
| 245 | sed -i -e '1s|^#!.*|#!/usr/bin/env python3|' $PYTHSCRIPT | ||
| 246 | done | ||
| 247 | create_wrapper ${D}${bindir}/python${PYTHON_MAJMIN} TERMINFO_DIRS='${sysconfdir}/terminfo:/etc/terminfo:/usr/share/terminfo:/usr/share/misc/terminfo:/lib/terminfo' PYTHONNOUSERSITE='1' | ||
| 248 | } | ||
| 249 | |||
| 250 | do_install_ptest:append:class-target:libc-musl () { | ||
| 251 | sed -i -e 's|SKIPPED_TESTS=|SKIPPED_TESTS="-x test__locale -x test_c_locale_coercion -x test_locale -x test_os test_re -x test__xxsubinterpreters -x test_threading --ignore test.test_strptime.StrptimeTests.test_date_locale2"|' ${D}${PTEST_PATH}/run-ptest | ||
| 252 | } | ||
| 253 | |||
| 254 | SYSROOT_PREPROCESS_FUNCS:append:class-target = " provide_target_config_script" | ||
| 255 | SYSROOT_PREPROCESS_FUNCS:append:class-nativesdk = " provide_target_config_script" | ||
| 256 | |||
| 257 | # This is installed into /usr/python-target-config/ and not /usr/bin | ||
| 258 | # because adding target sysroot's /usr/bin/ to PATH has unwanted side effects | ||
| 259 | # in components erroneously picking up other target executables from it | ||
| 260 | provide_target_config_script() { | ||
| 261 | install -d ${SYSROOT_DESTDIR}${prefix}/python-target-config/ | ||
| 262 | install ${D}/${bindir}/python3-config ${SYSROOT_DESTDIR}/${prefix}/python-target-config/ | ||
| 263 | install ${D}/${bindir}/python${PYTHON_MAJMIN}-config ${SYSROOT_DESTDIR}/${prefix}/python-target-config/ | ||
| 264 | } | ||
| 265 | SYSROOT_DIRS += "${prefix}/python-target-config/" | ||
| 266 | |||
| 267 | SSTATE_SCAN_FILES += "Makefile _sysconfigdata.py" | ||
| 268 | SSTATE_HASHEQUIV_FILEMAP = " \ | ||
| 269 | populate_sysroot:*/lib*/python3*/_sysconfigdata*.py:${TMPDIR} \ | ||
| 270 | populate_sysroot:*/lib*/python3*/_sysconfigdata*.py:${COREBASE} \ | ||
| 271 | populate_sysroot:*/lib*/python3*/config-*/Makefile:${TMPDIR} \ | ||
| 272 | populate_sysroot:*/lib*/python3*/config-*/Makefile:${COREBASE} \ | ||
| 273 | populate_sysroot:*/lib*/python-sysconfigdata/_sysconfigdata.py:${TMPDIR} \ | ||
| 274 | populate_sysroot:*/lib*/python-sysconfigdata/_sysconfigdata.py:${COREBASE} \ | ||
| 275 | " | ||
| 276 | PACKAGE_PREPROCESS_FUNCS += "py_package_preprocess" | ||
| 277 | |||
| 278 | py_package_preprocess () { | ||
| 279 | # Remove references to buildmachine paths in target Makefile and _sysconfigdata | ||
| 280 | sed -i -e 's:--sysroot=${STAGING_DIR_TARGET}::g' -e s:'--with-libtool-sysroot=${STAGING_DIR_TARGET}'::g \ | ||
| 281 | -e 's|${DEBUG_PREFIX_MAP}||g' \ | ||
| 282 | -e 's:${HOSTTOOLS_DIR}/::g' \ | ||
| 283 | -e 's:${RECIPE_SYSROOT_NATIVE}::g' \ | ||
| 284 | -e 's:${RECIPE_SYSROOT}::g' \ | ||
| 285 | -e 's:${BASE_WORKDIR}/${MULTIMACH_TARGET_SYS}::g' \ | ||
| 286 | ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/config-${PYTHON_MAJMIN}${PYTHON_ABI}*/Makefile \ | ||
| 287 | ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/_sysconfigdata*.py \ | ||
| 288 | ${PKGD}/${bindir}/python${PYTHON_MAJMIN}-config | ||
| 289 | |||
| 290 | # Reformat _sysconfigdata after modifying it so that it remains | ||
| 291 | # reproducible | ||
| 292 | for c in ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/_sysconfigdata*.py; do | ||
| 293 | python3 ${UNPACKDIR}/reformat_sysconfig.py $c | ||
| 294 | done | ||
| 295 | |||
| 296 | # Recompile _sysconfigdata after modifying it | ||
| 297 | cd ${PKGD} | ||
| 298 | sysconfigfile=`find . -name _sysconfigdata_*.py` | ||
| 299 | ${STAGING_BINDIR_NATIVE}/python3-native/python3 \ | ||
| 300 | -c "from py_compile import compile; compile('$sysconfigfile')" | ||
| 301 | ${STAGING_BINDIR_NATIVE}/python3-native/python3 \ | ||
| 302 | -c "from py_compile import compile; compile('$sysconfigfile', optimize=1)" | ||
| 303 | ${STAGING_BINDIR_NATIVE}/python3-native/python3 \ | ||
| 304 | -c "from py_compile import compile; compile('$sysconfigfile', optimize=2)" | ||
| 305 | cd - | ||
| 306 | |||
| 307 | mv ${PKGD}/${bindir}/python${PYTHON_MAJMIN}-config ${PKGD}/${bindir}/python${PYTHON_MAJMIN}-config-${MULTILIB_SUFFIX} | ||
| 308 | |||
| 309 | #Remove the unneeded copy of target sysconfig data | ||
| 310 | rm -rf ${PKGD}/${libdir}/python-sysconfigdata | ||
| 311 | } | ||
| 312 | |||
| 313 | # We want bytecode precompiled .py files (.pyc's) by default | ||
| 314 | # but the user may set it on their own conf | ||
| 315 | INCLUDE_PYCS ?= "1" | ||
| 316 | |||
| 317 | python(){ | ||
| 318 | import collections, json | ||
| 319 | |||
| 320 | filename = os.path.join(d.getVar('THISDIR'), 'python3', 'python3-manifest.json') | ||
| 321 | # This python changes the datastore based on the contents of a file, so mark | ||
| 322 | # that dependency. | ||
| 323 | bb.parse.mark_dependency(d, filename) | ||
| 324 | |||
| 325 | with open(filename) as manifest_file: | ||
| 326 | manifest_str = manifest_file.read() | ||
| 327 | json_start = manifest_str.find('# EOC') + 6 | ||
| 328 | manifest_file.seek(json_start) | ||
| 329 | manifest_str = manifest_file.read() | ||
| 330 | python_manifest = json.loads(manifest_str, object_pairs_hook=collections.OrderedDict) | ||
| 331 | |||
| 332 | # First set RPROVIDES for -native case | ||
| 333 | # Hardcoded since it cant be python3-native-foo, should be python3-foo-native | ||
| 334 | pn = 'python3' | ||
| 335 | rprovides = (d.getVar('RPROVIDES') or "").split() | ||
| 336 | |||
| 337 | # ${PN}-misc-native is not in the manifest | ||
| 338 | rprovides.append(pn + '-misc-native') | ||
| 339 | |||
| 340 | for key in python_manifest: | ||
| 341 | pypackage = pn + '-' + key + '-native' | ||
| 342 | if pypackage not in rprovides: | ||
| 343 | rprovides.append(pypackage) | ||
| 344 | |||
| 345 | d.setVar('RPROVIDES:class-native', ' '.join(rprovides)) | ||
| 346 | |||
| 347 | # Then work on the target | ||
| 348 | include_pycs = d.getVar('INCLUDE_PYCS') | ||
| 349 | |||
| 350 | packages = d.getVar('PACKAGES').split() | ||
| 351 | pn = d.getVar('PN') | ||
| 352 | |||
| 353 | newpackages=[] | ||
| 354 | for key in python_manifest: | ||
| 355 | pypackage = pn + '-' + key | ||
| 356 | |||
| 357 | if pypackage not in packages: | ||
| 358 | # We need to prepend, otherwise python-misc gets everything | ||
| 359 | # so we use a new variable | ||
| 360 | newpackages.append(pypackage) | ||
| 361 | |||
| 362 | # "Build" python's manifest FILES, RDEPENDS and SUMMARY | ||
| 363 | for value in python_manifest[key]['files']: | ||
| 364 | d.appendVar('FILES:' + pypackage, ' ' + value) | ||
| 365 | |||
| 366 | # Add cached files | ||
| 367 | if include_pycs == '1': | ||
| 368 | for value in python_manifest[key]['cached']: | ||
| 369 | d.appendVar('FILES:' + pypackage, ' ' + value) | ||
| 370 | |||
| 371 | for value in python_manifest[key]['rdepends']: | ||
| 372 | # Make it work with or without $PN | ||
| 373 | if '${PN}' in value: | ||
| 374 | value=value.split('-', 1)[1] | ||
| 375 | d.appendVar('RDEPENDS:' + pypackage, ' ' + pn + '-' + value) | ||
| 376 | |||
| 377 | for value in python_manifest[key].get('rrecommends', ()): | ||
| 378 | if '${PN}' in value: | ||
| 379 | value=value.split('-', 1)[1] | ||
| 380 | d.appendVar('RRECOMMENDS:' + pypackage, ' ' + pn + '-' + value) | ||
| 381 | |||
| 382 | d.setVar('SUMMARY:' + pypackage, python_manifest[key]['summary']) | ||
| 383 | |||
| 384 | # Prepending so to avoid python-misc getting everything | ||
| 385 | packages = newpackages + packages | ||
| 386 | d.setVar('PACKAGES', ' '.join(packages)) | ||
| 387 | d.setVar('ALLOW_EMPTY:${PN}-fcntl', '1') | ||
| 388 | d.setVar('ALLOW_EMPTY:${PN}-modules', '1') | ||
| 389 | d.setVar('ALLOW_EMPTY:${PN}-pkgutil', '1') | ||
| 390 | |||
| 391 | if "pgo" in d.getVar("PACKAGECONFIG").split() and not bb.utils.contains('MACHINE_FEATURES', 'qemu-usermode', True, False, d): | ||
| 392 | bb.fatal("pgo cannot be enabled as there is no qemu-usermode support for this architecture/machine") | ||
| 393 | } | ||
| 394 | |||
| 395 | # Files needed to create a new manifest | ||
| 396 | |||
| 397 | do_create_manifest() { | ||
| 398 | # This task should be run with every new release of Python. | ||
| 399 | # We must ensure that PACKAGECONFIG enables everything when creating | ||
| 400 | # a new manifest, this is to base our new manifest on a complete | ||
| 401 | # native python build, containing all dependencies, otherwise the task | ||
| 402 | # wont be able to find the required files. | ||
| 403 | # e.g. BerkeleyDB is an optional build dependency so it may or may not | ||
| 404 | # be present, we must ensure it is. | ||
| 405 | |||
| 406 | cp ${UNPACKDIR}/create_manifest3.py ${WORKDIR} | ||
| 407 | cp ${UNPACKDIR}/python3-manifest.json ${WORKDIR} | ||
| 408 | cp ${UNPACKDIR}/get_module_deps3.py ${WORKDIR} | ||
| 409 | cd ${WORKDIR} | ||
| 410 | # This needs to be executed by python-native and NOT by HOST's python | ||
| 411 | nativepython3 create_manifest3.py ${PYTHON_MAJMIN} | ||
| 412 | cp python3-manifest.json.new ${THISDIR}/python3/python3-manifest.json | ||
| 413 | } | ||
| 414 | |||
| 415 | # bitbake python -c create_manifest | ||
| 416 | # Make sure we have native python ready when we create a new manifest | ||
| 417 | addtask do_create_manifest after do_patch do_prepare_recipe_sysroot | ||
| 418 | |||
| 419 | # manual dependency additions | ||
| 420 | RRECOMMENDS:${PN}-core:append:class-nativesdk = " nativesdk-python3-modules" | ||
| 421 | RRECOMMENDS:${PN}-crypt:append:class-target = " ${MLPREFIX}openssl ${MLPREFIX}ca-certificates" | ||
| 422 | RRECOMMENDS:${PN}-crypt:append:class-nativesdk = " ${MLPREFIX}openssl ${MLPREFIX}ca-certificates" | ||
| 423 | |||
| 424 | # For historical reasons PN is empty and provided by python3-modules | ||
| 425 | FILES:${PN} = "" | ||
| 426 | RPROVIDES:${PN}-modules = "${PN}" | ||
| 427 | |||
| 428 | FILES:${PN}-pydoc += "${bindir}/pydoc${PYTHON_MAJMIN} ${bindir}/pydoc3" | ||
| 429 | FILES:${PN}-idle += "${bindir}/idle3 ${bindir}/idle${PYTHON_MAJMIN}" | ||
| 430 | FILES:${PN}-tkinter += "${libdir}/python${PYTHON_MAJMIN}/lib-dynload/_tkinter.*.so" | ||
| 431 | |||
| 432 | # provide python-pyvenv from python3-venv | ||
| 433 | RPROVIDES:${PN}-venv += "${MLPREFIX}python3-pyvenv" | ||
| 434 | |||
| 435 | # package libpython3 | ||
| 436 | PACKAGES =+ "libpython3 libpython3-staticdev" | ||
| 437 | FILES:libpython3 = "${libdir}/libpython*.so.*" | ||
| 438 | FILES:libpython3-staticdev += "${libdir}/python${PYTHON_MAJMIN}/config-${PYTHON_MAJMIN}-*/libpython${PYTHON_MAJMIN}.a" | ||
| 439 | INSANE_SKIP:${PN}-dev += "dev-elf" | ||
| 440 | INSANE_SKIP:${PN}-ptest = "dev-deps" | ||
| 441 | |||
| 442 | # catch all the rest (unsorted) | ||
| 443 | PACKAGES += "${PN}-misc" | ||
| 444 | RDEPENDS:${PN}-misc += "\ | ||
| 445 | ${PN}-audio \ | ||
| 446 | ${PN}-codecs \ | ||
| 447 | ${PN}-core \ | ||
| 448 | ${PN}-email \ | ||
| 449 | ${PN}-numbers \ | ||
| 450 | ${PN}-pickle \ | ||
| 451 | ${PN}-pydoc \ | ||
| 452 | " | ||
| 453 | RDEPENDS:${PN}-modules:append:class-target = " ${MLPREFIX}python3-misc" | ||
| 454 | RDEPENDS:${PN}-modules:append:class-nativesdk = " ${MLPREFIX}python3-misc" | ||
| 455 | RDEPENDS:${PN}-modules:append:class-target = " ${@bb.utils.contains('PACKAGECONFIG', 'gdbm', '${MLPREFIX}python3-gdbm', '', d)}" | ||
| 456 | FILES:${PN}-misc = "${libdir}/python${PYTHON_MAJMIN} ${libdir}/python${PYTHON_MAJMIN}/lib-dynload" | ||
| 457 | |||
| 458 | # catch manpage | ||
| 459 | PACKAGES += "${PN}-man" | ||
| 460 | FILES:${PN}-man = "${datadir}/man" | ||
| 461 | |||
| 462 | # See https://bugs.python.org/issue18748 and https://bugs.python.org/issue37395 | ||
| 463 | RDEPENDS:libpython3:append:libc-glibc = " libgcc" | ||
| 464 | RRECOMMENDS:${PN}-ctypes:append:libc-glibc = " ${MLPREFIX}ldconfig" | ||
| 465 | RDEPENDS:${PN}-ptest = "\ | ||
| 466 | ${PN}-dev \ | ||
| 467 | ${PN}-modules \ | ||
| 468 | ${PN}-tests \ | ||
| 469 | ${PN}-zipapp \ | ||
| 470 | binutils \ | ||
| 471 | bzip2 \ | ||
| 472 | coreutils \ | ||
| 473 | gcc \ | ||
| 474 | gcc-symlinks \ | ||
| 475 | g++ \ | ||
| 476 | libgcc \ | ||
| 477 | locale-base-fr-fr \ | ||
| 478 | locale-base-en-us \ | ||
| 479 | locale-base-de-de \ | ||
| 480 | sed \ | ||
| 481 | tzdata \ | ||
| 482 | unzip \ | ||
| 483 | " | ||
| 484 | RDEPENDS:${PN}-ptest:append:libc-glibc = " locale-base-tr-tr" | ||
| 485 | RDEPENDS:${PN}-tkinter += "${@bb.utils.contains('PACKAGECONFIG', 'tk', '${MLPREFIX}tk ${MLPREFIX}tk-lib', '', d)}" | ||
| 486 | RDEPENDS:${PN}-idle += "${@bb.utils.contains('PACKAGECONFIG', 'tk', '${PN}-tkinter ${MLPREFIX}tcl', '', d)}" | ||
| 487 | DEV_PKG_DEPENDENCY = "" | ||
| 488 | RDEPENDS:${PN}-pydoc += "${PN}-io" | ||
| 489 | |||
| 490 | RDEPENDS:${PN}-tests:append:class-target = " ${MLPREFIX}bash" | ||
| 491 | RDEPENDS:${PN}-tests:append:class-nativesdk = " ${MLPREFIX}bash" | ||
| 492 | |||
| 493 | # Python's tests contain large numbers of files we don't need in the recipe sysroots | ||
| 494 | SYSROOT_PREPROCESS_FUNCS += " py3_sysroot_cleanup" | ||
| 495 | py3_sysroot_cleanup () { | ||
| 496 | rm -rf ${SYSROOT_DESTDIR}${libdir}/python${PYTHON_MAJMIN}/test | ||
| 497 | } | ||
