subtree updates

meta-arm: 025f76a14f..aba9250494:
  Anusmita Dutta Mazumder (2):
        arm-bsp/linux-yocto: Remove EOL Linux yocto kernel 6.1
        arm-bsp/n1sdp: update to linux yocto kernel 6.6

  Bence Balogh (1):
        arm-bsp/trusted-firmware-m: disable libmetal doc generation

  Drew Reed (5):
        meta-arm: Support firmware building under a multiconfig
        bsp,ci: Build Corstone-1000 firmware under multiconfig
        bsp: Restore the ability to build firmware only
        ci: Add back testing of firmware only builds
        ci: Ensure tests are in the Corstone-1000 flash image

meta-raspberrypi: dbf1113a82..95a9103f91:
  Khem Raj (1):
        python3-sense-hat: Drop PYTHON_PN

  Martin Jansa (2):
        sdcard_image-rpi.bbclass: include ${IMAGE_NAME_SUFFIX} directly in both ${IMAGE_NAME} and ${IMAGE_LINK_NAME}
        sdimage-raspberrypi.wks: increase /boot partition minimal size from 20 to 100

meta-openembedded: 528f273006..9f0e513211:
  Andreas Mützel (1):
        python3-pynacl: allow -native build

  Chen Qi (1):
        unixodbc: fix odbc.pc file generation

  Daniel Ammann (1):
        sdmon: add new package

  Derek Straka (9):
        python3-trustme: add runtime dependency for tests and re-add to ptest
        python3-gunicorn: re-enable working ptests for the package
        python-inotify: re-enable working ptests for the package
        python3-license-expression: re-enable passing ptests for the package
        python3-jdcal: re-add functional ptests
        python3-msgpack: re-add functional ptests
        python3-parse: re-add functional ptests
        python3-typeguard: update ptest dependencies and re-enable functional tests
        python3-service-identity: add missing ptest dependencies and re-enable functional tests

  Jan Vermaete (1):
        netdata: version bump 1.43.2 -> 1.44.3

  Joerg Hofrichter (1):
        python3-gevent: adding missing dependency to python3-zopeevent

  Khawaja Shaheryar (2):
        libdaq: add recipe
        snort: add snort3 initial recipe

  Khem Raj (25):
        python3-pocketsphinx: Upgrade to 5.0.3
        snort: Do not use llvm libunwind
        snort3: Fix contains reference to TMPDIR [buildpaths] warnings
        libcamera: Replace VLAs with alloca
        dav1d: Inherit missing pkgconfig
        webkitgtk3: Fix build on 32bit x86
        ptest-packagelists-meta-oe: Remove oprofile for rv32/rv64
        python3-jsmin: Fix ptests to run with python 3.12+
        python3-ordered-set: Use automake formatter for ptest output
        fuse3: Add missing runtime deps for ptests
        python3-looseversion: Add recipe
        sshfs-fuse: Fix ptest builds with python 3.12
        meta-filesystems: Add meta-filesystems-image-ptest
        meta-multimedia-image-ptest: Add images to enable BBCLASSEXTEND parallel execution
        meta-networking-image-ptest: Add images to enable BBCLASSEXTEND parallel execution
        python3-scapy: Add missing rdeps for ptests
        ptest-packagelists-meta-oe.inc: Remove oprofile from PTESTS_PROBLEMS_META_OE
        ptest-packagelists-meta-networking: firewalld hangs therefore disabled
        ptest-packagelists-meta-perl.inc: Move couple of test to PTESTS_FAST_META_PERL
        openhpi: Fix ptest run time failures
        squid: Add missing bash dependency for ptest package
        meta-networking: Express dependency on meta-python
        ostree: Remove strace from ptest rdeps
        python3-pydantic-core,python3-pydantic: Update to 2.16.3 and 2.6.3 respectively
        python3-pydantic-core: Fix build for arches without 64bit atomics

  Lei Maohui (1):
        Fix install error when enable multilib.

  Markus Volk (7):
        iwd: update 2.13 -> 2.14
        libgedit-gtksourceview: update 299.0.5 -> 299.1.0
        gedit: update 46.1 -> 46.2
        mutter: update 45.3 -> 45.4
        gnome-shell: update 45.3 -> 45.4
        gnome-control-center: update 45.2 -> 45.3
        dav1d: update 1.3.0 -> 1.4.0

  Martin Jansa (5):
        python3-httpx: respect libdir in packaging
        snort3: drop SRCPV from PV
        snort3: fix snort.pc
        gattlib: use python3native and depend on python3-packaging-native
        networkmanager-fortisslvpn: use python3native and depend on python3-packaging-native

  Mingli Yu (1):
        mariadb: Upgrade to 10.11.7

  Niko Mauno (2):
        python3-pybind11: Migrate to python_setuptools_build_meta
        python3-pybind11: Restore strip prevention patch

  Oleh Matiusha (1):
        yasm: improve reproducibility

  Peter Marko (1):
        dnsmasq: Upgrade 2.89 -> 2.90

  Romain Naour (1):
        wavemon: add recipe for version 0.9.5

  Sascha Hauer (1):
        signing.bbclass: fix wrong function name

  Tim Orling (16):
        python_mesonpy.bbclass: move to oe-core
        python3-meson-python: move to oe-core
        python3-pyproject-metadata: move to oe-core
        meta-python: drop ${PYTHON_PN}
        meta-oe: drop ${PYTHON_PN}
        meta-filesystems: drop ${PYTHON_PN}
        meta-networking: drop ${PYTHON_PN}
        meta-gnome: drop ${PYTHON_PN}
        python3-pytest-lazy-fixtures: add 1.0.5
        python3-prettytable: upgrade 3.9.0 => 3.10.0; fix ptests
        python3-pytest-lazy-fixture: drop recipe
        meta-oe-image-ptest: add PTESTS_PROBLEMS_META_OE
        meta-perl-image-ptest: add PTESTS_PROBLEMS_META_PERL
        meta-python-image-ptest: add PTESTS_PROBLEMS_META_PYTHON
        libencode-perl: drop recipe
        libencode-locale-perl: drop recipe

  Wang Mingyu (49):
        babl: upgrade 0.1.106 -> 0.1.108
        btop: upgrade 1.3.0 -> 1.3.2
        gegl: upgrade 0.4.46 -> 0.4.48
        gjs: upgrade 1.78.3 -> 1.78.4
        gnome-bluetooth: upgrade 42.7 -> 42.8
        gnome-keyring: upgrade 42.1 -> 46.1
        isomd5sum: upgrade 1.2.3 -> 1.2.4
        libei: upgrade 1.2.0 -> 1.2.1
        libmanette: upgrade 0.2.6 -> 0.2.7
        libmime-types-perl: upgrade 2.24 -> 2.26
        logwatch: upgrade 7.9 -> 7.10
        mpich: upgrade 4.1.2 -> 4.2.0
        ostree: upgrade 2024.1 -> 2024.3
        python3-aiohue: upgrade 4.7.0 -> 4.7.1
        python3-awesomeversion: upgrade 23.11.0 -> 24.2.0
        python3-bidict: upgrade 0.22.1 -> 0.23.0
        python3-cantools: upgrade 39.4.3 -> 39.4.4
        python3-cmake: upgrade 3.28.1 -> 3.28.3
        python3-django: upgrade 5.0.1 -> 5.0.2
        python3-dnspython: upgrade 2.5.0 -> 2.6.0
        python3-elementpath: upgrade 4.2.0 -> 4.3.0
        python3-engineio: upgrade 4.8.2 -> 4.9.0
        python3-gevent: upgrade 23.9.1 -> 24.2.1
        unbound: upgrade 1.19.0 -> 1.19.1
        wireshark: upgrade 4.2.2 -> 4.2.3
        protobuf: upgrade 4.25.2 -> 4.25.3
        webkitgtk3: upgrade 2.42.4 -> 2.42.5
        python3-tqdm: upgrade 4.66.1 -> 4.66.2
        python3-google-api-python-client: upgrade 2.116.0 -> 2.118.0
        python3-httpcore: upgrade 1.0.2 -> 1.0.3
        python3-jsbeautifier: upgrade 1.14.11 -> 1.15.1
        python3-langtable: upgrade 0.0.64 -> 0.0.65
        python3-polyline: upgrade 2.0.1 -> 2.0.2
        python3-protobuf: upgrade 4.25.2 -> 4.25.3
        python3-pymisp: upgrade 2.4.184 -> 2.4.185
        python3-pymodbus: upgrade 3.6.3 -> 3.6.4
        python3-pytest-asyncio: upgrade 0.23.4 -> 0.23.5
        python3-tox: upgrade 4.12.1 -> 4.13.0
        python3-twine: upgrade 4.0.2 -> 5.0.0
        python3-watchdog: upgrade 3.0.0 -> 4.0.0
        python3-zopeinterface: upgrade 6.1 -> 6.2
        remmina: upgrade 1.4.33 -> 1.4.34
        sip: upgrade 6.8.2 -> 6.8.3
        python3-google-auth: upgrade 2.27.0 -> 2.28.0
        python3-gspread: upgrade 6.0.1 -> 6.0.2
        python3-socketio: upgrade 5.11.0 -> 5.11.1
        python3-sentry-sdk: upgrade 1.40.0 -> 1.40.4
        python3-pydantic-core: upgrade 2.14.6 -> 2.16.1
        python3-pydantic: upgrade 2.5.3 -> 2.6.0

  William Lyu (1):
        e2tools: Add ptest

  Yi Zhao (1):
        audit: upgrade 3.1.2 -> 4.0

  Yoann Congal (2):
        influxdb: Fix /etc files owner
        influxdb: Add missing group to static id

  chenheyun (1):
        dropwatch: Use header files from sysroot instead of build host

poky: fc8e5d7c13..25d60ac6f6:
  Adrian Freihofer (5):
        devtool: ide-sdk python 3.12 escaping
        sdk-manual: extensible.rst: cover devtool ide-sdk
        devtool: ide-sdk launch.json per recipe only
        devtool: ide-sdk prefer sources from workspace
        oe-selftest devtool: ide-sdk tests

  Alexander Kanavin (1):
        dbus: disable assertions and enable only modular tests

  Alexis Lothoré (7):
        testimage: log exception when failing to retrieve artifacts
        lib/oeqa: share get_json_result_dir helper
        testimage: create a list of failed test post actions
        oeqa/utils/postactions: isolate directory creation in dedicated action
        oeqa/utils/postactions: add target disk usage stat as post action
        oeqa/utils/postactions: testimage: add host disk usage stat as post action
        oeqa/lib/utils/postactions: fix host disk usage stats retrieval

  Bruce Ashfield (8):
        linux-yocto/6.6: update to v6.6.17
        linux-yocto/6.6: update CVE exclusions
        linux-yocto/6.6: enable squashfs for selftests
        linux-yocto/6.6: config: x86 tidy & consolidation
        kern-tools: depend on git-replacement-native
        linux-yocto/6.6: genericarm64 configuration/definition
        linux-yocto/6.6: update to v6.6.18
        linux-yocto/6.6: update CVE exclusions

  Christoph Vogtländer (1):
        overlayfs: add missing vardeps

  Claus Stovgaard (1):
        wpa-supplicant: Fix CVE-2023-52160

  Eilís 'pidge' Ní Fhlannagáin (2):
        creategroup*: Remove coreutils-native as a DEPENDS
        selftest-users: Convoluted selftest for USERADD_DEPENDS

  Emil Kronborg (1):
        bluez5: remove configuration files from install task

  Enguerrand de Ribaucourt (4):
        devtool: ide: define compilerPath for meson projects
        Revert "meson: use absolute cross-compiler paths"
        bitbake: bitbake: progressbar: accept value over initial maxval
        devtool: ide-sdk source mapping for vscode

  Enrico Jörns (1):
        wic: 'empty' plugin: fix typo in comment

  Joe Slater (1):
        qemuboot: predictable network interface names

  Jonathan GUILLOT (2):
        lib/oe/package: fix LOCALE_PATHS scan to create locale packages
        glibc-locale: add an explicit dedicated package for locale.alias file

  Jose Quaresma (1):
        go: update 1.20.13 -> 1.20.14

  Joshua Watt (1):
        bitbake: asyncrpc: Add support for server headers

  Khem Raj (6):
        ncurses: Always pass -D_GNU_SOURCE
        linux-yocto: Remove unused patch
        ref-manual: variables: remove PYTHON_PN
        python3-bcrypt: Fix build break on arches without 64 bit atomics
        python3-maturin: Recognise riscv32 architecture
        llvm: Update to 18.1.0 RC4

  Lee Chee Yang (1):
        migration-guide: add release notes for 4.3.3

  Lei Maohui (1):
        rpm: Fix the following error when run nativesdk-rpm in nativesdk environment.

  Martin Jansa (1):
        glib-2.0: backport a switch from distutils to packaging in codegen

  Michael Halstead (1):
        yocto-uninative: Update to 4.4 for glibc 2.39

  Michael Opdenacker (5):
        ref-manual: system-requirements: update packages to build docs
        ref-manual: release-process: grammar fix
        manuals: suppress excess use of "following" word
        dev-manual: packages: clarify shared PR service constraint
        dev-manual: packages: need enough free space

  Munehisa Kamata (1):
        kernel.bbclass: Set pkg-config variables for building modules

  Nick Owens (1):
        python3: dont disable readline module for editline

  Philip Lorenz (1):
        bitbake: fetch2: Ensure that git LFS objects are available

  Piotr Łobacz (1):
        useradd.bbclass: Fix order of postinst-useradd-*

  Richard Purdie (6):
        numactl: Upgrade 2.0.17 -> 2.0.18
        lttng-ust: Upgrade 2.13.6 -> 2.13.7
        oeqa/selftest/rust: Simplify the rust testsuite output gathering/processing
        recipetool: Fix errors with meta-poky bbappend
        bitbake: runqueue: Add support for BB_LOADFACTOR_MAX
        mirrors: Switch llvm to use shallow cloning

  Ross Burton (4):
        base-files: add usage warning to motd
        libexif: remove unused version_underscore
        gstreamer1.0: skip a test that is known to be flaky
        linux-firmware: split out more firmware pieces

  Simone Weiß (6):
        patchtest: provide further guidance for failed testcases
        patchtest: Skip test for CVE_CHECK_IGNORE for older branches
        meta: Remove some not needed CVE_STATUS
        meta: Update CVE_STATUS for incorrect cpes
        cve-check: Log if CVE_STATUS set but not reported for component
        dev-manual: Rephrase spdx creation

  Soumya Sambu (1):
        bind: Upgrade 9.18.21 -> 9.18.24

  Tim Orling (3):
        bitbake: layerindexlib: fix missing layer branch backtrace
        python3-cryptography{-vectors}: upgrade to 42.0.5
        python3-attrs: disable Hypothesis deadline

  Tobias Hagelborn (1):
        bitbake: hashserv: Re-enable connection pooling with psycopg 3 driver

  Trevor Gamblin (1):
        python3-git: upgrade 3.1.41 -> 3.1.42

  Trevor Woerner (1):
        wic: allow imager-specific filename extensions

  Ulrich Ölmann (1):
        bitbake: taskexp_ncurses: fix execution example in introductory comment

  Wang Mingyu (44):
        bash-completion: upgrade 2.11 -> 2.12.0
        ccache: upgrade 4.9 -> 4.9.1
        createrepo-c: upgrade 1.0.3 -> 1.0.4
        ed: upgrade 1.20 -> 1.20.1
        efivar: upgrade 38 -> 39
        gcr: upgrade 4.1.0 -> 4.2.0
        git: upgrade 2.43.0 -> 2.44.0
        libffi: upgrade 3.4.5 -> 3.4.6
        libgpg-error: upgrade 1.47 -> 1.48
        libhandy: upgrade 1.8.2 -> 1.8.3
        libksba: upgrade 1.6.5 -> 1.6.6
        libmicrohttpd: upgrade 0.9.77 -> 1.0.1
        libpng: upgrade 1.6.41 -> 1.6.42
        libsecret: upgrade 0.21.2 -> 0.21.4
        libunistring: upgrade 1.1 -> 1.2
        liburi-perl: upgrade 5.25 -> 5.27
        libxext: upgrade 1.3.5 -> 1.3.6
        libxkbfile: upgrade 1.1.2 -> 1.1.3
        libxvmc: upgrade 1.0.13 -> 1.0.14
        lighttpd: upgrade 1.4.73 -> 1.4.74
        makedepend: upgrade 1.0.8 -> 1.0.9
        mpg123: upgrade 1.32.4 -> 1.32.5
        ofono: upgrade 2.3 -> 2.4
        pango: upgrade 1.51.0 -> 1.52.0
        pciutils: upgrade 3.10.0 -> 3.11.1
        pkgconf: upgrade 2.1.0 -> 2.1.1
        python3-beartype: upgrade 0.17.0 -> 0.17.2
        python3-certifi: upgrade 2023.11.17 -> 2024.2.2
        python3-dbusmock: upgrade 0.30.2 -> 0.31.1
        python3-hypothesis: upgrade 6.97.3 -> 6.98.12
        python3-pip: upgrade 23.3.2 -> 24.0
        python3-pycairo: upgrade 1.25.1 -> 1.26.0
        python3-pytest: upgrade 8.0.0 -> 8.0.2
        python3-pytz: upgrade 2023.4 -> 2024.1
        python3-setuptools-rust: upgrade 1.8.1 -> 1.9.0
        python3-trove-classifiers: upgrade 2024.1.8 -> 2024.2.23
        python3-typing-extensions: upgrade 4.9.0 -> 4.10.0
        python3: upgrade 3.12.1 -> 3.12.2
        python3-urllib3: upgrade 2.1.0 -> 2.2.1
        python3-yamllint: upgrade 1.33.0 -> 1.35.1
        swig: upgrade 4.2.0 -> 4.2.1
        xkbcomp: upgrade 1.4.6 -> 1.4.7
        xkeyboard-config: upgrade 2.40 -> 2.41
        xprop: upgrade 1.2.6 -> 1.2.7

  Xiangyu Chen (2):
        systemd-systemctl: fix dead loop when multi services enable each other
        libc-locale: fix ASCII compatible warning cause build failure.

  Xiaotian Wu (2):
        loongarch64: change -march to loongarch64
        openssl: Match target name for loongarch64

  Yash Shinde (3):
        rust: Upgrade 1.74.1 -> 1.75.0
        rust: Revert PGO to it's default
        rust: reproducibility issue fix with v1.75

  Yoann Congal (1):
        waf: Improve version parsing to avoid failing on warnings

Change-Id: I6dfb848feb4ec8f5aae56a9ccbff475f4eb1edc6
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/poky/meta/recipes-devtools/python/python3_3.12.2.bb b/poky/meta/recipes-devtools/python/python3_3.12.2.bb
new file mode 100644
index 0000000..61991cd
--- /dev/null
+++ b/poky/meta/recipes-devtools/python/python3_3.12.2.bb
@@ -0,0 +1,472 @@
+SUMMARY = "The Python Programming Language"
+HOMEPAGE = "http://www.python.org"
+DESCRIPTION = "Python is a programming language that lets you work more quickly and integrate your systems more effectively."
+LICENSE = "PSF-2.0"
+SECTION = "devel/python"
+
+LIC_FILES_CHKSUM = "file://LICENSE;md5=fcf6b249c2641540219a727f35d8d2c2"
+
+SRC_URI = "http://www.python.org/ftp/python/${PV}/Python-${PV}.tar.xz \
+           file://run-ptest \
+           file://create_manifest3.py \
+           file://get_module_deps3.py \
+           file://python3-manifest.json \
+           file://check_build_completeness.py \
+           file://reformat_sysconfig.py \
+           file://cgi_py.patch \
+           file://0001-Makefile.pre-use-qemu-wrapper-when-gathering-profile.patch \
+           file://0001-python3-use-cc_basename-to-replace-CC-for-checking-c.patch \
+           file://crosspythonpath.patch \
+           file://0001-test_locale.py-correct-the-test-output-format.patch \
+           file://0020-configure.ac-setup.py-do-not-add-a-curses-include-pa.patch \
+           file://0001-Skip-failing-tests-due-to-load-variability-on-YP-AB.patch \
+           file://0001-test_ctypes.test_find-skip-without-tools-sdk.patch \
+           file://makerace.patch \
+           file://0001-sysconfig.py-use-platlibdir-also-for-purelib.patch \
+           file://0001-Lib-pty.py-handle-stdin-I-O-errors-same-way-as-maste.patch \
+           file://deterministic_imports.patch \
+           file://0001-Avoid-shebang-overflow-on-python-config.py.patch \
+           file://0001-Update-test_sysconfig-for-posix_user-purelib.patch \
+           file://0001-skip-no_stdout_fileno-test-due-to-load-variability.patch \
+           file://0001-test_storlines-skip-due-to-load-variability.patch \
+           file://0001-gh-114492-Initialize-struct-termios-before-calling-t.patch \
+           file://0001-test_xml_etree.py-Fix-for-Expat-2.6.0-with-reparse-d.patch \
+           "
+
+SRC_URI:append:class-native = " \
+           file://0001-Lib-sysconfig.py-use-prefix-value-from-build-configu.patch \
+           "
+
+SRC_URI[sha256sum] = "be28112dac813d2053545c14bf13a16401a21877f1a69eb6ea5d84c4a0f3d870"
+
+# exclude pre-releases for both python 2.x and 3.x
+UPSTREAM_CHECK_REGEX = "[Pp]ython-(?P<pver>\d+(\.\d+)+).tar"
+UPSTREAM_CHECK_URI = "https://www.python.org/downloads/source/"
+
+CVE_PRODUCT = "python cpython"
+
+CVE_STATUS[CVE-2007-4559] = "disputed: Upstream consider this expected behaviour"
+CVE_STATUS[CVE-2019-18348] = "not-applicable-config: This is not exploitable when glibc has CVE-2016-10739 fixed"
+CVE_STATUS[CVE-2020-15523] = "not-applicable-platform: Issue only applies on Windows"
+CVE_STATUS[CVE-2022-26488] = "not-applicable-platform: Issue only applies on Windows"
+# The module will be removed in the future and flaws documented.
+CVE_STATUS[CVE-2015-20107] = "upstream-wontfix: The mailcap module is insecure by design, so this can't be fixed in a meaningful way"
+CVE_STATUS[CVE-2023-36632] = "disputed: Not an issue, in fact expected behaviour"
+
+PYTHON_MAJMIN = "3.12"
+
+S = "${WORKDIR}/Python-${PV}"
+
+BBCLASSEXTEND = "native nativesdk"
+
+inherit autotools pkgconfig qemu ptest multilib_header update-alternatives
+
+MULTILIB_SUFFIX = "${@d.getVar('base_libdir',1).split('/')[-1]}"
+
+ALTERNATIVE:${PN}-dev = "python3-config"
+ALTERNATIVE_LINK_NAME[python3-config] = "${bindir}/python${PYTHON_MAJMIN}-config"
+ALTERNATIVE_TARGET[python3-config] = "${bindir}/python${PYTHON_MAJMIN}-config-${MULTILIB_SUFFIX}"
+
+
+DEPENDS = "bzip2-replacement-native expat libffi bzip2 openssl sqlite3 zlib virtual/libintl xz virtual/crypt util-linux-libuuid libtirpc libnsl2 autoconf-archive-native ncurses"
+DEPENDS:append:class-target = " python3-native"
+DEPENDS:append:class-nativesdk = " python3-native"
+
+EXTRA_OECONF = " --without-ensurepip --enable-shared --with-platlibdir=${baselib} --with-system-expat"
+EXTRA_OECONF:append:class-native = " --bindir=${bindir}/${PN}"
+EXTRA_OECONF:append:class-target = " --with-build-python=nativepython3"
+EXTRA_OECONF:append:class-nativesdk = " --with-build-python=nativepython3"
+
+export CROSSPYTHONPATH="${STAGING_LIBDIR_NATIVE}/python${PYTHON_MAJMIN}/lib-dynload/"
+
+EXTRANATIVEPATH += "python3-native"
+
+# LTO will be enabled via packageconfig depending upong distro features
+LTO:class-target = ""
+
+CACHED_CONFIGUREVARS = " \
+                ac_cv_file__dev_ptmx=yes \
+                ac_cv_file__dev_ptc=no \
+                ac_cv_working_tzset=yes \
+"
+# set thread stack size to 2MB on musl for interpreter and stdlib C extensions
+# so it does not run into stack limits due to musl's small thread stack
+# This is only needed to build interpreter and not the subsequent modules
+# Thats why CFLAGS_NODIST is modified instead of CFLAGS
+CACHED_CONFIGUREVARS:append:libc-musl = "\
+    CFLAGS_NODIST='${CFLAGS} -DTHREAD_STACK_SIZE=0x200000' \
+"
+
+# PGO currently causes builds to not be reproducible so disable by default, see YOCTO #13407
+PACKAGECONFIG ??= "editline gdbm ${@bb.utils.filter('DISTRO_FEATURES', 'lto', d)}"
+PACKAGECONFIG[readline] = "--with-readline=readline,,readline,,,editline"
+PACKAGECONFIG[editline] = "--with-readline=editline,,libedit,,,readline"
+# Use profile guided optimisation by running PyBench inside qemu-user
+PACKAGECONFIG[pgo] = "--enable-optimizations,,qemu-native"
+PACKAGECONFIG[tk] = ",,tk"
+PACKAGECONFIG[tcl] = ",,tcl"
+PACKAGECONFIG[gdbm] = ",,gdbm"
+PACKAGECONFIG[lto] = "--with-lto,--without-lto"
+
+do_configure:prepend () {
+    mkdir -p ${B}/Modules
+    cat > ${B}/Modules/Setup.local << EOF
+*disabled*
+${@bb.utils.contains('PACKAGECONFIG', 'gdbm', '', '_gdbm _dbm', d)}
+${@bb.utils.contains_any('PACKAGECONFIG', 'readline editline', '', 'readline', d)}
+${@bb.utils.contains('PACKAGECONFIG', 'tk', '', '_tkinter', d)}
+EOF
+}
+
+CPPFLAGS:append = " -I${STAGING_INCDIR}/ncursesw -I${STAGING_INCDIR}/uuid"
+
+# COMPILEALL_OPTS= ensures that .pyc are not compiled in parallel
+# This was found to lock up builds, break reproducibility, and produce strange file ownership
+# races.
+#
+# The upstream commit introducing the change was:
+# https://github.com/python/cpython/commit/1a2dd82f56bd813aacc570e172cefe55a8a41504
+#
+# The build lock up issue is reported here:
+# https://bugs.python.org/issue45945
+#
+# The repro failures are documented here:
+# https://autobuilder.yocto.io/pub/repro-fail/oe-reproducible-20211130-yr_o1a8d/packages/diff-html/
+
+EXTRA_OEMAKE = '\
+  STAGING_LIBDIR=${STAGING_LIBDIR} \
+  STAGING_INCDIR=${STAGING_INCDIR} \
+  LIB=${baselib} \
+  COMPILEALL_OPTS= \
+'
+
+# Generate a Profile Guided Optimisation wrapper script that uses qemu-user for
+# all cross builds.
+write_pgo_wrapper:class-native = ":"
+write_pgo_wrapper() {
+       if ${@bb.utils.contains('PACKAGECONFIG', 'pgo', 'true', 'false', d)}; then
+                cat >pgo-wrapper <<EOF
+#!/bin/sh
+cd ${B}
+${@qemu_wrapper_cmdline(d, '${STAGING_DIR_TARGET}', ['${B}', '${STAGING_DIR_TARGET}/${base_libdir}'])} "\$@"
+EOF
+                chmod +x pgo-wrapper
+        fi
+}
+
+do_compile:prepend() {
+        write_pgo_wrapper
+}
+
+do_install:prepend() {
+        ${WORKDIR}/check_build_completeness.py ${T}/log.do_compile
+}
+
+do_install:append:class-target() {
+        oe_multilib_header python${PYTHON_MAJMIN}/pyconfig.h
+}
+
+do_install:append:class-native() {
+        # Make sure we use /usr/bin/env python
+        for PYTHSCRIPT in `grep -rIl ${bindir}/${PN}/python ${D}${bindir}/${PN}`; do
+                sed -i -e '1s|^#!.*|#!/usr/bin/env python3|' $PYTHSCRIPT
+        done
+        # Add a symlink to the native Python so that scripts can just invoke
+        # "nativepython" and get the right one without needing absolute paths
+        # (these often end up too long for the #! parser in the kernel as the
+        # buffer is 128 bytes long).
+        ln -s python3-native/python3 ${D}${bindir}/nativepython3
+
+        # Remove the opt-1.pyc and opt-2.pyc files. There are over 3,000 of them
+        # and the overhead in each recipe-sysroot-native isn't worth it, particularly
+        # when they're only used for python called with -O or -OO.
+        #find ${D} -name *opt-*.pyc -delete
+        # Remove all pyc files. There are a ton of them and it is probably faster to let
+        # python create the ones it wants at runtime rather than manage in the sstate 
+        # tarballs and sysroot creation.
+        find ${D} -name *.pyc -delete
+
+        # Nothing should be looking into ${B} for python3-native
+        sed -i -e 's:${B}:/build/path/unavailable/:g' \
+                ${D}/${libdir}/python${PYTHON_MAJMIN}/config-${PYTHON_MAJMIN}${PYTHON_ABI}*/Makefile
+        
+        # disable the lookup in user's site-packages globally
+        sed -i 's#ENABLE_USER_SITE = None#ENABLE_USER_SITE = False#' ${D}${libdir}/python${PYTHON_MAJMIN}/site.py
+
+        # python3-config needs to be in /usr/bin and not in a subdir of it to work properly
+        mv ${D}/${bindir}/${PN}/python*config ${D}/${bindir}/
+}
+
+do_install:append() {
+        for c in ${D}/${libdir}/python${PYTHON_MAJMIN}/_sysconfigdata*.py; do
+            python3 ${WORKDIR}/reformat_sysconfig.py $c
+        done
+        rm -f ${D}${libdir}/python${PYTHON_MAJMIN}/__pycache__/_sysconfigdata*.cpython*
+
+        mkdir -p ${D}${libdir}/python-sysconfigdata
+        sysconfigfile=`find ${D} -name _sysconfig*.py`
+        sed -i  \
+                -e "s,^ 'LIBDIR'.*, 'LIBDIR': '${STAGING_LIBDIR}'\,,g" \
+                -e "s,^ 'INCLUDEDIR'.*, 'INCLUDEDIR': '${STAGING_INCDIR}'\,,g" \
+                -e "s,^ 'CONFINCLUDEDIR'.*, 'CONFINCLUDEDIR': '${STAGING_INCDIR}'\,,g" \
+                -e "s,^ 'INCLUDEPY'.*, 'INCLUDEPY': '${STAGING_INCDIR}/python${PYTHON_MAJMIN}'\,,g" \
+                -e "s,^ 'CONFINCLUDEPY'.*, 'CONFINCLUDEPY': '${STAGING_INCDIR}/python${PYTHON_MAJMIN}'\,,g" \
+                -e "s,${B},/build/path/unavailable/,g" \
+                $sysconfigfile
+        cp $sysconfigfile ${D}${libdir}/python-sysconfigdata/_sysconfigdata.py
+
+
+        # Unfortunately the following pyc files are non-deterministc due to 'frozenset'
+        # being written without strict ordering, even with PYTHONHASHSEED = 0
+        # Upstream is discussing ways to solve the issue properly, until then let's
+        # just not install the problematic files.
+        # More info: http://benno.id.au/blog/2013/01/15/python-determinism
+        rm -f ${D}${libdir}/python${PYTHON_MAJMIN}/test/__pycache__/test_range.cpython*
+        rm -f ${D}${libdir}/python${PYTHON_MAJMIN}/test/__pycache__/test_xml_etree.cpython*
+
+        # Similar to the above, we're getting reproducibility issues with 
+        # /usr/lib/python3.10/__pycache__/traceback.cpython-310.pyc
+        # so remove it too
+        rm -f ${D}${libdir}/python${PYTHON_MAJMIN}/__pycache__/traceback.cpython*
+
+        # Remove the opt-1.pyc and opt-2.pyc files. They effectively waste space on embedded
+        # style targets as they're only used when python is called with the -O or -OO options
+        # which is rare.
+        find ${D} -name *opt-*.pyc -delete
+}
+
+do_install:append:class-nativesdk () {
+    # Make sure we use /usr/bin/env python
+    for PYTHSCRIPT in `grep -rIl ${bindir}/python ${D}${bindir}`; do
+         sed -i -e '1s|^#!.*|#!/usr/bin/env python3|' $PYTHSCRIPT
+    done
+    create_wrapper ${D}${bindir}/python${PYTHON_MAJMIN} TERMINFO_DIRS='${sysconfdir}/terminfo:/etc/terminfo:/usr/share/terminfo:/usr/share/misc/terminfo:/lib/terminfo' PYTHONNOUSERSITE='1'
+}
+
+do_install_ptest:append:class-target:libc-musl () {
+    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"|' ${D}${PTEST_PATH}/run-ptest
+}
+
+SYSROOT_PREPROCESS_FUNCS:append:class-target = " provide_target_config_script"
+SYSROOT_PREPROCESS_FUNCS:append:class-nativesdk = " provide_target_config_script"
+
+# This is installed into /usr/python-target-config/ and not /usr/bin
+# because adding target sysroot's /usr/bin/ to PATH has unwanted side effects
+# in components erroneously picking up other target executables from it
+provide_target_config_script() {
+        install -d ${SYSROOT_DESTDIR}${prefix}/python-target-config/
+        install ${D}/${bindir}/python3-config ${SYSROOT_DESTDIR}/${prefix}/python-target-config/
+        install ${D}/${bindir}/python${PYTHON_MAJMIN}-config ${SYSROOT_DESTDIR}/${prefix}/python-target-config/
+}
+SYSROOT_DIRS += "${prefix}/python-target-config/"
+
+SSTATE_SCAN_FILES += "Makefile _sysconfigdata.py"
+SSTATE_HASHEQUIV_FILEMAP = " \
+    populate_sysroot:*/lib*/python3*/_sysconfigdata*.py:${TMPDIR} \
+    populate_sysroot:*/lib*/python3*/_sysconfigdata*.py:${COREBASE} \
+    populate_sysroot:*/lib*/python3*/config-*/Makefile:${TMPDIR} \
+    populate_sysroot:*/lib*/python3*/config-*/Makefile:${COREBASE} \
+    populate_sysroot:*/lib*/python-sysconfigdata/_sysconfigdata.py:${TMPDIR} \
+    populate_sysroot:*/lib*/python-sysconfigdata/_sysconfigdata.py:${COREBASE} \
+    "
+PACKAGE_PREPROCESS_FUNCS += "py_package_preprocess"
+
+py_package_preprocess () {
+        # Remove references to buildmachine paths in target Makefile and _sysconfigdata
+        sed -i -e 's:--sysroot=${STAGING_DIR_TARGET}::g' -e s:'--with-libtool-sysroot=${STAGING_DIR_TARGET}'::g \
+                -e 's|${DEBUG_PREFIX_MAP}||g' \
+                -e 's:${HOSTTOOLS_DIR}/::g' \
+                -e 's:${RECIPE_SYSROOT_NATIVE}::g' \
+                -e 's:${RECIPE_SYSROOT}::g' \
+                -e 's:${BASE_WORKDIR}/${MULTIMACH_TARGET_SYS}::g' \
+                ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/config-${PYTHON_MAJMIN}${PYTHON_ABI}*/Makefile \
+                ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/_sysconfigdata*.py \
+                ${PKGD}/${bindir}/python${PYTHON_MAJMIN}-config
+
+        # Reformat _sysconfigdata after modifying it so that it remains
+        # reproducible
+        for c in ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/_sysconfigdata*.py; do
+            python3 ${WORKDIR}/reformat_sysconfig.py $c
+        done
+
+        # Recompile _sysconfigdata after modifying it
+        cd ${PKGD}
+        sysconfigfile=`find . -name _sysconfigdata_*.py`
+        ${STAGING_BINDIR_NATIVE}/python3-native/python3 \
+             -c "from py_compile import compile; compile('$sysconfigfile')"
+        ${STAGING_BINDIR_NATIVE}/python3-native/python3 \
+             -c "from py_compile import compile; compile('$sysconfigfile', optimize=1)"
+        ${STAGING_BINDIR_NATIVE}/python3-native/python3 \
+             -c "from py_compile import compile; compile('$sysconfigfile', optimize=2)"
+        cd -
+
+        mv ${PKGD}/${bindir}/python${PYTHON_MAJMIN}-config ${PKGD}/${bindir}/python${PYTHON_MAJMIN}-config-${MULTILIB_SUFFIX}
+        
+        #Remove the unneeded copy of target sysconfig data
+        rm -rf ${PKGD}/${libdir}/python-sysconfigdata
+}
+
+# We want bytecode precompiled .py files (.pyc's) by default
+# but the user may set it on their own conf
+INCLUDE_PYCS ?= "1"
+
+python(){
+    import collections, json
+
+    filename = os.path.join(d.getVar('THISDIR'), 'python3', 'python3-manifest.json')
+    # This python changes the datastore based on the contents of a file, so mark
+    # that dependency.
+    bb.parse.mark_dependency(d, filename)
+
+    with open(filename) as manifest_file:
+        manifest_str =  manifest_file.read()
+        json_start = manifest_str.find('# EOC') + 6
+        manifest_file.seek(json_start)
+        manifest_str = manifest_file.read()
+        python_manifest = json.loads(manifest_str, object_pairs_hook=collections.OrderedDict)
+
+    # First set RPROVIDES for -native case
+    # Hardcoded since it cant be python3-native-foo, should be python3-foo-native
+    pn = 'python3'
+    rprovides = (d.getVar('RPROVIDES') or "").split()
+
+    # ${PN}-misc-native is not in the manifest
+    rprovides.append(pn + '-misc-native')
+
+    for key in python_manifest:
+        pypackage = pn + '-' + key + '-native'
+        if pypackage not in rprovides:
+              rprovides.append(pypackage)
+
+    d.setVar('RPROVIDES:class-native', ' '.join(rprovides))
+
+    # Then work on the target
+    include_pycs = d.getVar('INCLUDE_PYCS')
+
+    packages = d.getVar('PACKAGES').split()
+    pn = d.getVar('PN')
+
+    newpackages=[]
+    for key in python_manifest:
+        pypackage = pn + '-' + key
+
+        if pypackage not in packages:
+            # We need to prepend, otherwise python-misc gets everything
+            # so we use a new variable
+            newpackages.append(pypackage)
+
+        # "Build" python's manifest FILES, RDEPENDS and SUMMARY
+        d.setVar('FILES:' + pypackage, '')
+        for value in python_manifest[key]['files']:
+            d.appendVar('FILES:' + pypackage, ' ' + value)
+
+        # Add cached files
+        if include_pycs == '1':
+            for value in python_manifest[key]['cached']:
+                    d.appendVar('FILES:' + pypackage, ' ' + value)
+
+        for value in python_manifest[key]['rdepends']:
+            # Make it work with or without $PN
+            if '${PN}' in value:
+                value=value.split('-', 1)[1]
+            d.appendVar('RDEPENDS:' + pypackage, ' ' + pn + '-' + value)
+
+        for value in python_manifest[key].get('rrecommends', ()):
+            if '${PN}' in value:
+                value=value.split('-', 1)[1]
+            d.appendVar('RRECOMMENDS:' + pypackage, ' ' + pn + '-' + value)
+
+        d.setVar('SUMMARY:' + pypackage, python_manifest[key]['summary'])
+
+    # Prepending so to avoid python-misc getting everything
+    packages = newpackages + packages
+    d.setVar('PACKAGES', ' '.join(packages))
+    d.setVar('ALLOW_EMPTY:${PN}-modules', '1')
+    d.setVar('ALLOW_EMPTY:${PN}-pkgutil', '1')
+
+    if "pgo" in d.getVar("PACKAGECONFIG").split() and not bb.utils.contains('MACHINE_FEATURES', 'qemu-usermode', True, False, d):
+        bb.fatal("pgo cannot be enabled as there is no qemu-usermode support for this architecture/machine")
+}
+
+# Files needed to create a new manifest
+
+do_create_manifest() {
+    # This task should be run with every new release of Python.
+    # We must ensure that PACKAGECONFIG enables everything when creating
+    # a new manifest, this is to base our new manifest on a complete
+    # native python build, containing all dependencies, otherwise the task
+    # wont be able to find the required files.
+    # e.g. BerkeleyDB is an optional build dependency so it may or may not
+    # be present, we must ensure it is.
+
+    cd ${WORKDIR}
+    # This needs to be executed by python-native and NOT by HOST's python
+    nativepython3 create_manifest3.py ${PYTHON_MAJMIN}
+    cp python3-manifest.json.new ${THISDIR}/python3/python3-manifest.json
+}
+
+# bitbake python -c create_manifest
+# Make sure we have native python ready when we create a new manifest
+addtask do_create_manifest after do_patch do_prepare_recipe_sysroot
+
+# manual dependency additions
+RRECOMMENDS:${PN}-core:append:class-nativesdk = " nativesdk-python3-modules"
+RRECOMMENDS:${PN}-crypt:append:class-target = " ${MLPREFIX}openssl ${MLPREFIX}ca-certificates"
+RRECOMMENDS:${PN}-crypt:append:class-nativesdk = " ${MLPREFIX}openssl ${MLPREFIX}ca-certificates"
+
+# For historical reasons PN is empty and provided by python3-modules
+FILES:${PN} = ""
+RPROVIDES:${PN}-modules = "${PN}"
+
+FILES:${PN}-pydoc += "${bindir}/pydoc${PYTHON_MAJMIN} ${bindir}/pydoc3"
+FILES:${PN}-idle += "${bindir}/idle3 ${bindir}/idle${PYTHON_MAJMIN}"
+
+# provide python-pyvenv from python3-venv
+RPROVIDES:${PN}-venv += "${MLPREFIX}python3-pyvenv"
+
+# package libpython3
+PACKAGES =+ "libpython3 libpython3-staticdev"
+FILES:libpython3 = "${libdir}/libpython*.so.*"
+FILES:libpython3-staticdev += "${libdir}/python${PYTHON_MAJMIN}/config-${PYTHON_MAJMIN}-*/libpython${PYTHON_MAJMIN}.a"
+INSANE_SKIP:${PN}-dev += "dev-elf"
+INSANE_SKIP:${PN}-ptest = "dev-deps"
+
+# catch all the rest (unsorted)
+PACKAGES += "${PN}-misc"
+RDEPENDS:${PN}-misc += "\
+  ${PN}-audio \
+  ${PN}-codecs \
+  ${PN}-core \
+  ${PN}-email \
+  ${PN}-numbers \
+  ${PN}-pickle \
+  ${PN}-pydoc \
+"
+RDEPENDS:${PN}-modules:append:class-target = " ${MLPREFIX}python3-misc"
+RDEPENDS:${PN}-modules:append:class-nativesdk = " ${MLPREFIX}python3-misc"
+RDEPENDS:${PN}-modules:append:class-target = " ${@bb.utils.contains('PACKAGECONFIG', 'gdbm', '${MLPREFIX}python3-gdbm', '', d)}"
+FILES:${PN}-misc = "${libdir}/python${PYTHON_MAJMIN} ${libdir}/python${PYTHON_MAJMIN}/lib-dynload"
+
+# catch manpage
+PACKAGES += "${PN}-man"
+FILES:${PN}-man = "${datadir}/man"
+
+# See https://bugs.python.org/issue18748 and https://bugs.python.org/issue37395
+RDEPENDS:libpython3:append:libc-glibc = " libgcc"
+RDEPENDS:${PN}-ctypes:append:libc-glibc = " ${MLPREFIX}ldconfig"
+RDEPENDS:${PN}-ptest = "${PN}-modules ${PN}-tests ${PN}-dev ${PN}-cgitb ${PN}-zipapp unzip bzip2 libgcc tzdata coreutils sed gcc g++ binutils \
+                        locale-base-fr-fr locale-base-en-us locale-base-de-de"
+RDEPENDS:${PN}-ptest:append:libc-glibc = " locale-base-tr-tr"
+RDEPENDS:${PN}-tkinter += "${@bb.utils.contains('PACKAGECONFIG', 'tk', '${MLPREFIX}tk ${MLPREFIX}tk-lib', '', d)}"
+RDEPENDS:${PN}-idle += "${@bb.utils.contains('PACKAGECONFIG', 'tk', '${PN}-tkinter ${MLPREFIX}tcl', '', d)}"
+DEV_PKG_DEPENDENCY = ""
+RDEPENDS:${PN}-pydoc += "${PN}-io"
+
+RDEPENDS:${PN}-tests:append:class-target = " ${MLPREFIX}bash"
+RDEPENDS:${PN}-tests:append:class-nativesdk = " ${MLPREFIX}bash"
+
+# Python's tests contain large numbers of files we don't need in the recipe sysroots
+SYSROOT_PREPROCESS_FUNCS += " py3_sysroot_cleanup"
+py3_sysroot_cleanup () {
+	rm -rf ${SYSROOT_DESTDIR}${libdir}/python${PYTHON_MAJMIN}/test
+}