| 1 | # Contributor: Sheila Aman <[email protected]> |
| 2 | # Maintainer: Natanael Copa <[email protected]> |
| 3 | pkgname=python3 |
| 4 | # python3-extra's pkgver needs to be synchronized with this. |
| 5 | pkgver=3.14.8 |
| 6 | _basever="${pkgver%.*}" |
| 7 | pkgrel=0 |
| 8 | pkgdesc="High-level scripting language" |
| 9 | url="https://www.python.org/" |
| 10 | arch="all" |
| 11 | license="PSF-2.0" |
| 12 | # pyc0 comes last because the files are named without a unique substring |
| 13 | subpackages=" |
| 14 | $pkgname-dbg |
| 15 | $pkgname-dev |
| 16 | $pkgname-doc |
| 17 | $pkgname-idle::noarch |
| 18 | $pkgname-tests::noarch |
| 19 | $pkgname-pyc:_default_pyc |
| 20 | $pkgname-pycache-pyc2 |
| 21 | $pkgname-pycache-pyc1 |
| 22 | $pkgname-pycache-pyc0 |
| 23 | pyc:_pyc_meta:noarch |
| 24 | " |
| 25 | # explicit expat>=2.8 dependency for hash flooding protection |
| 26 | # https://github.com/python/cpython/issues/149018 |
| 27 | depends="libssl3>=3.3.0 libexpat>=2.8.0" |
| 28 | makedepends=" |
| 29 | !gettext-dev |
| 30 | bluez-headers |
| 31 | bzip2-dev |
| 32 | expat-dev>=2.8.0 |
| 33 | libffi-dev |
| 34 | linux-headers |
| 35 | mpdecimal-dev |
| 36 | musl-libintl |
| 37 | ncurses-dev |
| 38 | openssl-dev |
| 39 | readline-dev |
| 40 | sqlite-dev |
| 41 | tcl-dev |
| 42 | xz-dev |
| 43 | zlib-dev |
| 44 | " |
| 45 | source="https://www.python.org/ftp/python/$pkgver/Python-$pkgver.tar.xz |
| 46 | idle.desktop |
| 47 | externally-managed |
| 48 | musl-find_library.patch |
| 49 | " |
| 50 | options="net" # Required for tests |
| 51 | builddir="$srcdir/Python-$pkgver" |
| 52 | |
| 53 | # secfixes: |
| 54 | # 3.14.8-r0: |
| 55 | # - CVE-2026-15310 |
| 56 | # - CVE-2026-15806 |
| 57 | # - CVE-2026-17084 |
| 58 | # - CVE-2026-19445 |
| 59 | # - CVE-2026-19553 |
| 60 | # - CVE-2026-19672 |
| 61 | # - CVE-2026-82049 |
| 62 | # 3.14.7-r0: |
| 63 | # - CVE-2025-15366 |
| 64 | # - CVE-2026-0864 |
| 65 | # - CVE-2026-3276 |
| 66 | # - CVE-2026-4360 |
| 67 | # - CVE-2026-6879 |
| 68 | # - CVE-2026-7210 |
| 69 | # - CVE-2026-7774 |
| 70 | # - CVE-2026-8328 |
| 71 | # - CVE-2026-9669 |
| 72 | # - CVE-2026-11940 |
| 73 | # - CVE-2026-11972 |
| 74 | # - CVE-2026-15308 |
| 75 | # 3.14.5-r0: |
| 76 | # - CVE-2026-2297 |
| 77 | # - CVE-2026-3644 |
| 78 | # - CVE-2026-4224 |
| 79 | # 3.12.11-r0: |
| 80 | # - CVE-2024-12718 |
| 81 | # - CVE-2025-4138 |
| 82 | # - CVE-2025-4330 |
| 83 | # - CVE-2025-4517 |
| 84 | # 3.12.10-r1: |
| 85 | # - CVE-2025-4516 |
| 86 | # 3.12.9-r0: |
| 87 | # - CVE-2025-0938 |
| 88 | # 3.12.8-r1: |
| 89 | # - CVE-2024-12254 |
| 90 | # 3.12.8-r0: |
| 91 | # - CVE-2024-9287 |
| 92 | # 3.12.6-r0: |
| 93 | # - CVE-2015-2104 |
| 94 | # - CVE-2023-27043 |
| 95 | # - CVE-2024-4032 |
| 96 | # - CVE-2024-6232 |
| 97 | # - CVE-2024-7592 |
| 98 | # 3.12.5-r1: |
| 99 | # - CVE-2024-8088 |
| 100 | # 3.12.5-r0: |
| 101 | # - CVE-2024-6923 |
| 102 | # 3.11.5-r0: |
| 103 | # - CVE-2023-40217 |
| 104 | # 3.11.1-r0: |
| 105 | # - CVE-2022-45061 |
| 106 | # 3.10.5-r0: |
| 107 | # - CVE-2015-20107 |
| 108 | # 3.9.5-r0: |
| 109 | # - CVE-2021-29921 |
| 110 | # 3.9.4-r0: |
| 111 | # - CVE-2021-3426 |
| 112 | # 3.8.8-r0: |
| 113 | # - CVE-2021-23336 |
| 114 | # 3.8.7-r2: |
| 115 | # - CVE-2021-3177 |
| 116 | # 3.8.5-r0: |
| 117 | # - CVE-2019-20907 |
| 118 | # 3.8.4-r0: |
| 119 | # - CVE-2020-14422 |
| 120 | # 3.8.2-r0: |
| 121 | # - CVE-2020-8315 |
| 122 | # - CVE-2020-8492 |
| 123 | # 3.7.5-r0: |
| 124 | # - CVE-2019-16056 |
| 125 | # - CVE-2019-16935 |
| 126 | # 3.6.8-r1: |
| 127 | # - CVE-2019-5010 |
| 128 | |
| 129 | # was briefly present, and is in 3.16 |
| 130 | provides="pythonispython3=$pkgver-r$pkgrel" |
| 131 | |
| 132 | prepare() { |
| 133 | default_prepare |
| 134 | |
| 135 | # force system libs |
| 136 | rm -r Modules/expat |
| 137 | } |
| 138 | |
| 139 | build() { |
| 140 | # set thread stack size to 2MB so we don't segfault before we hit |
| 141 | # sys.getrecursionlimit() |
| 142 | # note: raised from 1 as we ran into some stack limit on x86_64 too |
| 143 | # sometimes, but not recursion |
| 144 | local stacksize=0x200000 |
| 145 | |
| 146 | # we want -O2 here for more speed for such a large interpreter. |
| 147 | export CFLAGS_NODIST="$CFLAGS -O2 -DTHREAD_STACK_SIZE=$stacksize" |
| 148 | export CXXFLAGS_NODIST="$CXXFLAGS -O2" |
| 149 | export LDFLAGS_NODIST="$LDFLAGS -Wl,-z,stack-size=$stacksize" |
| 150 | |
| 151 | case "$CARCH" in |
| 152 | ppc64le) |
| 153 | # FIXME: on ppc64le, the stack-clash-protection from gcc seems to segfault |
| 154 | # python.. sometimes. not sure if python or gcc bug (probably former) |
| 155 | # for an easy reproduction, run the testsuite of community/py3-lmdb |
| 156 | export CFLAGS_NODIST="${CFLAGS_NODIST/-fstack-clash-protection}" |
| 157 | export CXXFLAGS_NODIST="${CXXFLAGS_NODIST/-fstack-clash-protection}" |
| 158 | # because test_time fails in docker on ppc64le (see check()), |
| 159 | # we need to exclude that from the tests that run for PGO |
| 160 | # purposes during the build, as well |
| 161 | export PROFILE_TASK='-m test --pgo --timeout=$(TESTTIMEOUT) --exclude test_time' |
| 162 | ;; |
| 163 | esac |
| 164 | |
| 165 | |
| 166 | # we set them via NODIST to not propagate them and duplicate them to modules |
| 167 | unset LDFLAGS CFLAGS CXXFLAGS CPPFLAGS |
| 168 | |
| 169 | ./configure \ |
| 170 | --build=$CBUILD \ |
| 171 | --host=$CHOST \ |
| 172 | --prefix=/usr \ |
| 173 | --enable-ipv6 \ |
| 174 | --enable-loadable-sqlite-extensions \ |
| 175 | --enable-optimizations \ |
| 176 | --enable-shared \ |
| 177 | --with-lto \ |
| 178 | --with-computed-gotos \ |
| 179 | --with-system-expat \ |
| 180 | --with-system-libmpdec \ |
| 181 | --without-ensurepip |
| 182 | |
| 183 | make |
| 184 | } |
| 185 | |
| 186 | check() { |
| 187 | # test that we reach recursionlimit before we segfault |
| 188 | cat > test-stacksize.py <<-EOF |
| 189 | import threading |
| 190 | import sys |
| 191 | |
| 192 | def fun(i): |
| 193 | try: |
| 194 | fun(i+1) |
| 195 | except: |
| 196 | sys.exit(0) |
| 197 | |
| 198 | t = threading.Thread(target=fun, args=[1]) |
| 199 | t.start() |
| 200 | EOF |
| 201 | LD_LIBRARY_PATH=$PWD ./python test-stacksize.py |
| 202 | |
| 203 | local fail |
| 204 | local ignore |
| 205 | |
| 206 | # musl related |
| 207 | fail="test__locale" # various musl locale deficiencies |
| 208 | fail="$fail test_locale" |
| 209 | fail="$fail test_re" |
| 210 | fail="$fail test_c_locale_coercion" |
| 211 | fail="$fail test_datetime" # hangs if 'tzdata' installed |
| 212 | fail="$fail test_os" # fpathconf, ttyname errno values |
| 213 | ignore="test.test_strptime.StrptimeTests.test_date_locale2" |
| 214 | |
| 215 | # FIXME: failures needing investigation |
| 216 | fail="$fail test_ctypes" # fail on aarch64 (ctypes.test.test_win32.Structures) |
| 217 | |
| 218 | # kernel related |
| 219 | fail="$fail test_fcntl" # wants DNOTIFY, we don't have it |
| 220 | |
| 221 | # test_clock_settime returns Function not implemented instead of the |
| 222 | # expected permission error in docker (CI). Disable for now. |
| 223 | case "$CARCH" in |
| 224 | ppc64le) fail="$fail test_time";; |
| 225 | esac |
| 226 | |
| 227 | make quicktest TESTOPTS="-j${JOBS:-$(nproc)} --exclude $fail --ignore $ignore" |
| 228 | } |
| 229 | |
| 230 | package() { |
| 231 | make -j1 DESTDIR="$pkgdir" EXTRA_CFLAGS="$CFLAGS" install maninstall |
| 232 | install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE |
| 233 | |
| 234 | install -Dm644 "$srcdir"/externally-managed \ |
| 235 | "$pkgdir"/usr/lib/python$_basever/EXTERNALLY-MANAGED |
| 236 | |
| 237 | ln -s python3 "$pkgdir"/usr/bin/python |
| 238 | ln -s python3-config "$pkgdir"/usr/bin/python-config |
| 239 | |
| 240 | local size |
| 241 | for size in 16 32 48 256; do |
| 242 | local dir="$pkgdir"/usr/share/icons/hicolor/"$size"x"$size"/apps |
| 243 | install -dm755 "$dir" |
| 244 | ln -s ../../../../../lib/python3.14/idlelib/Icons/idle_$size.png "$dir"/idle.png |
| 245 | done |
| 246 | install -Dm0644 "$srcdir"/idle.desktop "$pkgdir"/usr/share/applications/idle.desktop |
| 247 | } |
| 248 | |
| 249 | dev() { |
| 250 | default_dev |
| 251 | |
| 252 | # pyconfig.h is needed runtime so we move it back |
| 253 | mkdir -p "$pkgdir"/usr/include/python$_basever |
| 254 | mv "$subpkgdir"/usr/include/python$_basever/pyconfig.h \ |
| 255 | "$pkgdir"/usr/include/python$_basever/ |
| 256 | } |
| 257 | |
| 258 | idle() { |
| 259 | pkgdesc="IDE for Python3 using Tkinter" |
| 260 | depends="$depends python3-tkinter~$pkgver" |
| 261 | |
| 262 | amove usr/bin/idle* usr/lib/python$_basever/idlelib usr/share/icons usr/share/applications |
| 263 | } |
| 264 | |
| 265 | tests() { |
| 266 | pkgdesc="The test modules from the main python package" |
| 267 | provides="python3-tkinter-tests=$pkgver-r$pkgrel" |
| 268 | |
| 269 | amove usr/lib/python$_basever/test |
| 270 | } |
| 271 | |
| 272 | _pyc_meta() { |
| 273 | pkgdesc="Meta package for pulling in all -pyc packages" |
| 274 | depends="" |
| 275 | mkdir -p "$subpkgdir" |
| 276 | } |
| 277 | |
| 278 | # python3-pyc, to install pyc by default |
| 279 | _default_pyc() { |
| 280 | pkgdesc="$pkgdesc (install .pyc cache files)" |
| 281 | install_if="$pkgname=$pkgver-r$pkgrel" |
| 282 | provides="python3-tkinter-pyc=$pkgver-r$pkgrel" |
| 283 | depends=" |
| 284 | $pkgname-pycache-pyc0=$pkgver-r$pkgrel |
| 285 | pyc |
| 286 | " |
| 287 | |
| 288 | mkdir -p "$subpkgdir" |
| 289 | } |
| 290 | |
| 291 | pyc0() { |
| 292 | pkgdesc="$pkgdesc (.pyc pycache files)" |
| 293 | depends="" |
| 294 | |
| 295 | cd "$pkgdir" |
| 296 | amove $(find usr/lib/python3* -name "*.pyc") |
| 297 | } |
| 298 | |
| 299 | pyc1() { |
| 300 | pkgdesc="$pkgdesc (.opt-1.pyc pycache files)" |
| 301 | depends="" |
| 302 | |
| 303 | cd "$pkgdir" |
| 304 | amove $(find usr/lib/python3* -name "*.opt-1.pyc") |
| 305 | } |
| 306 | |
| 307 | pyc2() { |
| 308 | pkgdesc="$pkgdesc (.opt-2.pyc pycache files)" |
| 309 | depends="" |
| 310 | |
| 311 | cd "$pkgdir" |
| 312 | amove $(find usr/lib/python3* -name "*.opt-2.pyc") |
| 313 | } |
| 314 | |
| 315 | sha512sums=" |
| 316 | f9e6809b0c45d90fcc174b8051e15058a3037981c9136c598d110a118a22cbbb8263fbd677e07b2b9d93e1aa83cd9cb835b61b6af898fd301d1080a29c2156fe Python-3.14.8.tar.xz |
| 317 | f1ecb004871dc7e0c794eebe94ca1084b211924ecc97edc57f32a7c8df5d572e9ca6cdc45d6fc08009e480eb9a2c9f3d359d46989dc72c03679eb94ad97a2916 idle.desktop |
| 318 | 46dd8230ee2ab66e9c4157c10b2bd9c414fd7f30be0bee73e21a9eea88f63fff362d47828e0fc77ddc59df097b414b21505f8b5f98bc866381115c58ae3f4862 externally-managed |
| 319 | ab8eaa2858d5109049b1f9f553198d40e0ef8d78211ad6455f7b491af525bffb16738fed60fc84e960c4889568d25753b9e4a1494834fea48291b33f07000ec2 musl-find_library.patch |
| 320 | " |