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() { |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 164 | mkdir -p ${D}${libdir}/python-sysconfigdata |
| 165 | sysconfigfile=`find ${D} -name _sysconfig*.py` |
| 166 | cp $sysconfigfile ${D}${libdir}/python-sysconfigdata/_sysconfigdata.py |
| 167 | |
| 168 | sed -i \ |
| 169 | -e "s,^ 'LIBDIR'.*, 'LIBDIR': '${STAGING_LIBDIR}'\,,g" \ |
| 170 | -e "s,^ 'INCLUDEDIR'.*, 'INCLUDEDIR': '${STAGING_INCDIR}'\,,g" \ |
| 171 | -e "s,^ 'CONFINCLUDEDIR'.*, 'CONFINCLUDEDIR': '${STAGING_INCDIR}'\,,g" \ |
| 172 | -e "/^ 'INCLDIRSTOMAKE'/{N; s,/usr/include,${STAGING_INCDIR},g}" \ |
| 173 | -e "/^ 'INCLUDEPY'/s,/usr/include,${STAGING_INCDIR},g" \ |
| 174 | ${D}${libdir}/python-sysconfigdata/_sysconfigdata.py |
Andrew Geissler | 6ce62a2 | 2020-11-30 19:58:47 -0600 | [diff] [blame] | 175 | |
| 176 | # Unfortunately the following pyc files are non-deterministc due to 'frozenset' |
| 177 | # being written without strict ordering, even with PYTHONHASHSEED = 0 |
| 178 | # Upstream is discussing ways to solve the issue properly, until then let's |
| 179 | # just not install the problematic files. |
| 180 | # More info: http://benno.id.au/blog/2013/01/15/python-determinism |
| 181 | rm ${D}${libdir}/python${PYTHON_MAJMIN}/test/__pycache__/test_range.cpython* |
| 182 | rm ${D}${libdir}/python${PYTHON_MAJMIN}/test/__pycache__/test_xml_etree.cpython* |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 183 | } |
| 184 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 185 | do_install:append:class-nativesdk () { |
Andrew Geissler | 90fd73c | 2021-03-05 15:25:55 -0600 | [diff] [blame] | 186 | # Make sure we use /usr/bin/env python |
| 187 | for PYTHSCRIPT in `grep -rIl ${bindir}/python ${D}${bindir}`; do |
| 188 | sed -i -e '1s|^#!.*|#!/usr/bin/env python3|' $PYTHSCRIPT |
| 189 | done |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 190 | create_wrapper ${D}${bindir}/python${PYTHON_MAJMIN} TERMINFO_DIRS='${sysconfdir}/terminfo:/etc/terminfo:/usr/share/terminfo:/usr/share/misc/terminfo:/lib/terminfo' PYTHONNOUSERSITE='1' |
| 191 | } |
| 192 | |
| 193 | SSTATE_SCAN_FILES += "Makefile _sysconfigdata.py" |
| 194 | PACKAGE_PREPROCESS_FUNCS += "py_package_preprocess" |
| 195 | |
| 196 | py_package_preprocess () { |
| 197 | # Remove references to buildmachine paths in target Makefile and _sysconfigdata |
| 198 | sed -i -e 's:--sysroot=${STAGING_DIR_TARGET}::g' -e s:'--with-libtool-sysroot=${STAGING_DIR_TARGET}'::g \ |
| 199 | -e 's|${DEBUG_PREFIX_MAP}||g' \ |
| 200 | -e 's:${HOSTTOOLS_DIR}/::g' \ |
| 201 | -e 's:${RECIPE_SYSROOT_NATIVE}::g' \ |
| 202 | -e 's:${RECIPE_SYSROOT}::g' \ |
| 203 | -e 's:${BASE_WORKDIR}/${MULTIMACH_TARGET_SYS}::g' \ |
| 204 | ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/config-${PYTHON_MAJMIN}${PYTHON_ABI}*/Makefile \ |
| 205 | ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/_sysconfigdata*.py \ |
| 206 | ${PKGD}/${bindir}/python${PYTHON_MAJMIN}-config |
| 207 | |
| 208 | # Reformat _sysconfigdata after modifying it so that it remains |
| 209 | # reproducible |
| 210 | for c in ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/_sysconfigdata*.py; do |
| 211 | python3 ${WORKDIR}/reformat_sysconfig.py $c |
| 212 | done |
| 213 | |
| 214 | # Recompile _sysconfigdata after modifying it |
| 215 | cd ${PKGD} |
| 216 | sysconfigfile=`find . -name _sysconfigdata_*.py` |
| 217 | ${STAGING_BINDIR_NATIVE}/python3-native/python3 \ |
| 218 | -c "from py_compile import compile; compile('$sysconfigfile')" |
| 219 | ${STAGING_BINDIR_NATIVE}/python3-native/python3 \ |
| 220 | -c "from py_compile import compile; compile('$sysconfigfile', optimize=1)" |
| 221 | ${STAGING_BINDIR_NATIVE}/python3-native/python3 \ |
| 222 | -c "from py_compile import compile; compile('$sysconfigfile', optimize=2)" |
| 223 | cd - |
| 224 | |
| 225 | mv ${PKGD}/${bindir}/python${PYTHON_MAJMIN}-config ${PKGD}/${bindir}/python${PYTHON_MAJMIN}-config-${MULTILIB_SUFFIX} |
| 226 | |
| 227 | #Remove the unneeded copy of target sysconfig data |
| 228 | rm -rf ${PKGD}/${libdir}/python-sysconfigdata |
| 229 | } |
| 230 | |
| 231 | # We want bytecode precompiled .py files (.pyc's) by default |
| 232 | # but the user may set it on their own conf |
| 233 | INCLUDE_PYCS ?= "1" |
| 234 | |
| 235 | python(){ |
| 236 | import collections, json |
| 237 | |
| 238 | filename = os.path.join(d.getVar('THISDIR'), 'python3', 'python3-manifest.json') |
| 239 | # This python changes the datastore based on the contents of a file, so mark |
| 240 | # that dependency. |
| 241 | bb.parse.mark_dependency(d, filename) |
| 242 | |
| 243 | with open(filename) as manifest_file: |
| 244 | manifest_str = manifest_file.read() |
| 245 | json_start = manifest_str.find('# EOC') + 6 |
| 246 | manifest_file.seek(json_start) |
| 247 | manifest_str = manifest_file.read() |
| 248 | python_manifest = json.loads(manifest_str, object_pairs_hook=collections.OrderedDict) |
| 249 | |
| 250 | # First set RPROVIDES for -native case |
| 251 | # Hardcoded since it cant be python3-native-foo, should be python3-foo-native |
| 252 | pn = 'python3' |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 253 | rprovides = (d.getVar('RPROVIDES') or "").split() |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 254 | |
| 255 | # ${PN}-misc-native is not in the manifest |
| 256 | rprovides.append(pn + '-misc-native') |
| 257 | |
| 258 | for key in python_manifest: |
| 259 | pypackage = pn + '-' + key + '-native' |
| 260 | if pypackage not in rprovides: |
| 261 | rprovides.append(pypackage) |
| 262 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 263 | d.setVar('RPROVIDES:class-native', ' '.join(rprovides)) |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 264 | |
| 265 | # Then work on the target |
| 266 | include_pycs = d.getVar('INCLUDE_PYCS') |
| 267 | |
| 268 | packages = d.getVar('PACKAGES').split() |
| 269 | pn = d.getVar('PN') |
| 270 | |
| 271 | newpackages=[] |
| 272 | for key in python_manifest: |
| 273 | pypackage = pn + '-' + key |
| 274 | |
| 275 | if pypackage not in packages: |
| 276 | # We need to prepend, otherwise python-misc gets everything |
| 277 | # so we use a new variable |
| 278 | newpackages.append(pypackage) |
| 279 | |
| 280 | # "Build" python's manifest FILES, RDEPENDS and SUMMARY |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 281 | d.setVar('FILES:' + pypackage, '') |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 282 | for value in python_manifest[key]['files']: |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 283 | d.appendVar('FILES:' + pypackage, ' ' + value) |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 284 | |
| 285 | # Add cached files |
| 286 | if include_pycs == '1': |
| 287 | for value in python_manifest[key]['cached']: |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 288 | d.appendVar('FILES:' + pypackage, ' ' + value) |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 289 | |
| 290 | for value in python_manifest[key]['rdepends']: |
| 291 | # Make it work with or without $PN |
| 292 | if '${PN}' in value: |
| 293 | value=value.split('-', 1)[1] |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 294 | d.appendVar('RDEPENDS:' + pypackage, ' ' + pn + '-' + value) |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 295 | |
| 296 | for value in python_manifest[key].get('rrecommends', ()): |
| 297 | if '${PN}' in value: |
| 298 | value=value.split('-', 1)[1] |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 299 | d.appendVar('RRECOMMENDS:' + pypackage, ' ' + pn + '-' + value) |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 300 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 301 | d.setVar('SUMMARY:' + pypackage, python_manifest[key]['summary']) |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 302 | |
| 303 | # Prepending so to avoid python-misc getting everything |
| 304 | packages = newpackages + packages |
| 305 | d.setVar('PACKAGES', ' '.join(packages)) |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 306 | d.setVar('ALLOW_EMPTY:${PN}-modules', '1') |
| 307 | d.setVar('ALLOW_EMPTY:${PN}-pkgutil', '1') |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 308 | } |
| 309 | |
| 310 | # Files needed to create a new manifest |
| 311 | |
| 312 | do_create_manifest() { |
| 313 | # This task should be run with every new release of Python. |
| 314 | # We must ensure that PACKAGECONFIG enables everything when creating |
| 315 | # a new manifest, this is to base our new manifest on a complete |
| 316 | # native python build, containing all dependencies, otherwise the task |
| 317 | # wont be able to find the required files. |
| 318 | # e.g. BerkeleyDB is an optional build dependency so it may or may not |
| 319 | # be present, we must ensure it is. |
| 320 | |
| 321 | cd ${WORKDIR} |
| 322 | # This needs to be executed by python-native and NOT by HOST's python |
| 323 | nativepython3 create_manifest3.py ${PYTHON_MAJMIN} |
| 324 | cp python3-manifest.json.new ${THISDIR}/python3/python3-manifest.json |
| 325 | } |
| 326 | |
| 327 | # bitbake python -c create_manifest |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 328 | # 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] | 329 | addtask do_create_manifest after do_patch do_prepare_recipe_sysroot |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 330 | |
| 331 | # manual dependency additions |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 332 | RRECOMMENDS:${PN}-core:append:class-nativesdk = " nativesdk-python3-modules" |
| 333 | RRECOMMENDS:${PN}-crypt:append:class-target = " ${MLPREFIX}openssl ${MLPREFIX}ca-certificates" |
| 334 | RRECOMMENDS:${PN}-crypt:append:class-nativesdk = " ${MLPREFIX}openssl ${MLPREFIX}ca-certificates" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 335 | |
| 336 | # For historical reasons PN is empty and provided by python3-modules |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 337 | FILES:${PN} = "" |
| 338 | RPROVIDES:${PN}-modules = "${PN}" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 339 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 340 | FILES:${PN}-pydoc += "${bindir}/pydoc${PYTHON_MAJMIN} ${bindir}/pydoc3" |
| 341 | FILES:${PN}-idle += "${bindir}/idle3 ${bindir}/idle${PYTHON_MAJMIN}" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 342 | |
| 343 | # provide python-pyvenv from python3-venv |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 344 | RPROVIDES:${PN}-venv += "${MLPREFIX}python3-pyvenv" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 345 | |
| 346 | # package libpython3 |
| 347 | PACKAGES =+ "libpython3 libpython3-staticdev" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 348 | FILES:libpython3 = "${libdir}/libpython*.so.*" |
| 349 | FILES:libpython3-staticdev += "${libdir}/python${PYTHON_MAJMIN}/config-${PYTHON_MAJMIN}-*/libpython${PYTHON_MAJMIN}.a" |
| 350 | INSANE_SKIP:${PN}-dev += "dev-elf" |
| 351 | INSANE_SKIP:${PN}-ptest = "dev-deps" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 352 | |
| 353 | # catch all the rest (unsorted) |
| 354 | PACKAGES += "${PN}-misc" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 355 | RDEPENDS:${PN}-misc += "\ |
Andrew Geissler | d25ed32 | 2020-06-27 00:28:28 -0500 | [diff] [blame] | 356 | ${PN}-core \ |
| 357 | ${PN}-email \ |
| 358 | ${PN}-codecs \ |
| 359 | ${PN}-pydoc \ |
| 360 | ${PN}-pickle \ |
| 361 | ${PN}-audio \ |
| 362 | ${PN}-numbers \ |
| 363 | " |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 364 | RDEPENDS:${PN}-modules:append:class-target = " ${MLPREFIX}python3-misc" |
| 365 | RDEPENDS:${PN}-modules:append:class-nativesdk = " ${MLPREFIX}python3-misc" |
| 366 | 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] | 367 | |
| 368 | # catch manpage |
| 369 | PACKAGES += "${PN}-man" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 370 | FILES:${PN}-man = "${datadir}/man" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 371 | |
| 372 | # See https://bugs.python.org/issue18748 and https://bugs.python.org/issue37395 |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 373 | RDEPENDS:libpython3:append:libc-glibc = " libgcc" |
| 374 | RDEPENDS:${PN}-ctypes:append:libc-glibc = " ${MLPREFIX}ldconfig" |
| 375 | RDEPENDS:${PN}-ptest = "${PN}-modules ${PN}-tests ${PN}-dev unzip bzip2 libgcc tzdata-europe coreutils sed" |
| 376 | RDEPENDS:${PN}-ptest:append:libc-glibc = " locale-base-tr-tr.iso-8859-9" |
| 377 | RDEPENDS:${PN}-tkinter += "${@bb.utils.contains('PACKAGECONFIG', 'tk', 'tk tk-lib', '', d)}" |
| 378 | RDEPENDS:${PN}-idle += "${@bb.utils.contains('PACKAGECONFIG', 'tk', '${PN}-tkinter tcl', '', d)}" |
| 379 | RDEPENDS:${PN}-dev = "" |
| 380 | RDEPENDS:${PN}-pydoc += "${PN}-io" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 381 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 382 | RDEPENDS:${PN}-tests:append:class-target = " ${MLPREFIX}bash" |
| 383 | RDEPENDS:${PN}-tests:append:class-nativesdk = " ${MLPREFIX}bash" |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 384 | |
| 385 | # Python's tests contain large numbers of files we don't need in the recipe sysroots |
| 386 | SYSROOT_PREPROCESS_FUNCS += " py3_sysroot_cleanup" |
| 387 | py3_sysroot_cleanup () { |
| 388 | rm -rf ${SYSROOT_DESTDIR}${libdir}/python${PYTHON_MAJMIN}/test |
| 389 | } |