From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 5F3C9158004 for ; Fri, 7 Jun 2024 01:59:38 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D5FFE2BC01E; Fri, 7 Jun 2024 01:59:36 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id ACF7B2BC01E for ; Fri, 7 Jun 2024 01:59:36 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 0749D340C7B for ; Fri, 7 Jun 2024 01:59:35 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 3F0A31C72 for ; Fri, 7 Jun 2024 01:59:33 +0000 (UTC) From: "Michał Górny" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Michał Górny" Message-ID: <1717724107.9be1c9debac2be4dbf3b5f5ad48bb1234c7a01a7.mgorny@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: dev-lang/python/ X-VCS-Repository: repo/gentoo X-VCS-Files: dev-lang/python/Manifest dev-lang/python/python-3.12.4.ebuild X-VCS-Directories: dev-lang/python/ X-VCS-Committer: mgorny X-VCS-Committer-Name: Michał Górny X-VCS-Revision: 9be1c9debac2be4dbf3b5f5ad48bb1234c7a01a7 X-VCS-Branch: master Date: Fri, 7 Jun 2024 01:59:33 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: cca96477-82ec-4392-9155-80dfb3bf18c3 X-Archives-Hash: f17199cb562ab6b43b7fb05ba3829ef9 commit: 9be1c9debac2be4dbf3b5f5ad48bb1234c7a01a7 Author: Michał Górny gentoo org> AuthorDate: Fri Jun 7 01:00:17 2024 +0000 Commit: Michał Górny gentoo org> CommitDate: Fri Jun 7 01:35:07 2024 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=9be1c9de dev-lang/python: Bump to 3.12.4 Signed-off-by: Michał Górny gentoo.org> dev-lang/python/Manifest | 3 + dev-lang/python/python-3.12.4.ebuild | 571 +++++++++++++++++++++++++++++++++++ 2 files changed, 574 insertions(+) diff --git a/dev-lang/python/Manifest b/dev-lang/python/Manifest index bc9619ec875d..31aa270c00c6 100644 --- a/dev-lang/python/Manifest +++ b/dev-lang/python/Manifest @@ -6,6 +6,8 @@ DIST Python-3.11.9.tar.xz 20175816 BLAKE2B 4e7cd2c42ee39b5ef9624ebd1798320957e94 DIST Python-3.11.9.tar.xz.asc 833 BLAKE2B fa29f632bae0bee7db946038ee3529bc3bfbe1b2e755b21394f67a3c80911ce8079aaab43a16d88e614a8bfc01fb5105ce3f61c59a5ca44470b0f59787c707b3 SHA512 b18b50e7168b2ca5376a1fa75e50e8baae2026d4f11d4cf613d758f3f17df4610fe4653fb2ac0c5c4ec0f6e630dc6490ad1ff32a2fd0ebd60f9f3bd136207ffc DIST Python-3.12.3.tar.xz 20625068 BLAKE2B fc4f57ae50183db4c8cb37d94c37a7e58da5d031e03866841a678b986f01bbb8afdefb38124ba82b0a4988445b647214be43338dea13b0f063d3c2bf81c48c0b SHA512 4a2213b108e7f1f1525baa8348e68b2a2336d925e60d0a59f0225fc470768a2c8031edafc0b8243f94dbae18afda335ee5adf2785328c2218fd64cbb439f13a4 DIST Python-3.12.3.tar.xz.asc 963 BLAKE2B f9668dde210793f8da0e0bb026b8ec3e0b4bc3abc58e72732f8faf356b19ca88a59b9d89b4b10f77b3602d9a967f0f2f44a0f091d698bc28ba9bad8049e5e006 SHA512 c291ec5b5e4f8deba867cc517624dd9a174745f04061ef737e58f3d52b9b30318264aec350e339fe88ccb493809ca1a90a378e86d86b8ec4a4f578b1a5843624 +DIST Python-3.12.4.tar.xz 20659356 BLAKE2B 4255171ef8ee1777bab829be7bbaf28a9d5073985b3b1309a41694dda5f6b4ad599df4534a1ce83ec65b357d42416cc18722ca94b4227a45ebd90e2c1df90945 SHA512 750132ee6369196096130a924f4ddb78b9a55804133e5d136a70b9280928822974d1aa559d844486df02e89155fb0d8117871e1ac532abc18174309ca4b08369 +DIST Python-3.12.4.tar.xz.asc 963 BLAKE2B d4f62dca1de5f4e4b2581fc49ca55b1d87abe7c4ceb2c9087efe4b92d9e9b3bdd25949bbf82fd771b4b60bc3690be982c2f25b810d87592665f0728fbe08be9d SHA512 1102b17f395e0ec5de5368d04a4dceb8cc98dd408b68b53998071cf129eb9a6c259316a416128f1dfa37a739f86e599507502a98430348da2272442ce1b7059e DIST Python-3.13.0b1.tar.xz 21054240 BLAKE2B fba108b2971fe188a05340753a48379c9a829ce680f13dc50d95d889ef5ee833b82be157d1b011ba841c149d633e8eb64b07098bf03a2adcf711b3f688465050 SHA512 81cc1d8691bfcc8f8bb232ea15c18039d0df036f5cbc1667fec3b6c34cdf198bed97418ec775c037778c250b7bc4f35bd5fb938dd478cc17fc48c74b8a2b2d19 DIST Python-3.13.0b1.tar.xz.asc 963 BLAKE2B 1b038d2b73fdbe11a1ada18ceab4a174ae52aab68ae9c3a9952ee60a16ce3e08e54c13e0c47264442415f70bd39a06c2b0f97c3cef31330f51102dad6d4a837b SHA512 c10832b5016ad9a9588b7efd29a35272c1c07b444df116c397fed82d66f30150687d68a6853637094be2fe1d8ed0928a9cd151617c91d9eb9938ba1385bd7143 DIST Python-3.13.0b2.tar.xz 21089692 BLAKE2B 3cc77e9b7abcd8c9797a40b2a1f5ff6562a1841dd44c4785a57941b1eb4d70d20a3dc5bcf8cbfe3d1b2c7f846d7da7fd89758e113542820945da996d2c6a68af SHA512 3a37c8137958a6ebaf06f5a03b28c7817f359f346d820a9989932b1a716478647e8d1b94c1a08197bcabf68cd90443a08ab9454af9151eace52401d8b60d0c35 @@ -18,6 +20,7 @@ DIST python-gentoo-patches-2.7.18_p16.tar.xz 35448 BLAKE2B 0139c0944f62f9cdd236f DIST python-gentoo-patches-3.10.14_p1.tar.xz 15836 BLAKE2B a850e4ad4f025fa9d38ccba937f1b3ee8443ed186c22ede58b4c7324a8541cf724590686671a9aa9194662303ce75bc80aac8ee6f9da34b793876817b6f593ff SHA512 5d969f5e5126ee675a062924a5f403de142fc5bfe4a931fd3576bcc6298a855419d305d4b1ffedacb429783a05324b36eef4c45c861c47bada0bdd840de2bca3 DIST python-gentoo-patches-3.11.9.tar.xz 8456 BLAKE2B 4e62837f17c1d056460df417b056a79ad78dbcdd3454761c7cda68ffe6faf8f4d4f04d5539e0ba94332fe19a751f7d5ff2c35ff969a6aa09a2c72d2ce5efbff1 SHA512 a288aa8d1d15e906e0f1762602a2122f9dc91bbd6b72123ac5d00ce55b3af324a4e8280b600fc0fb630e489e57ee1547d7595a4ede7a70e4b26d6686a8414997 DIST python-gentoo-patches-3.12.3.tar.xz 6028 BLAKE2B 7953a48a1d95a6a33bd88060fbcac463a5469371aa0c882c3945f1fea64a63c4d45fca8451f51f4eaeea00a04267ad2e54e4cc720c95e8bb5a3477e00263b80a SHA512 4779bab2b24e59e4a77987ce3e9611d99e87c9c4d016309758c26a65fe2e11ef04d48d5af628c02b1552dc1f31b768f87448f8e19e716b4fe372941e6dacac3f +DIST python-gentoo-patches-3.12.4.tar.xz 6056 BLAKE2B 8e8caa52f5725aaed08e8442609bec45b11c63d5f29f8fdb302416716bf77ef1bb7fe5e9d14bab12517dabd01dc06172fe11b176326291b19785a8b1d74ee9b9 SHA512 d2fd747f81a3812f5d4a0d281ac336a43961abcf4a4e503564fa3b5d33c0312a6c7148c6f516f5c4c917432c63488615161a847ccb6539a457406b82f1661a24 DIST python-gentoo-patches-3.13.0b1_p1.tar.xz 5480 BLAKE2B 830370b56bd662b10dd4423f1e758da79c61d535a18b35496e09d864642873449a13738da8e042b94c58e8e300ac7c003088be69e27467dd024daf54b6a34c22 SHA512 d696c96263ca51f611d508ee644f7254d2607236e829946c35dc6a6977eafa98748fa807b36d40d5e32f278db3493876b2214b4e2bb1ceb4deaa1fbb8fb2c052 DIST python-gentoo-patches-3.13.0b1_p2.tar.xz 9300 BLAKE2B 63179b01623c6677363c4d1c2f7890e81defd4ca451259b66eff79c92bee68a92a0a33893801fabd8af2e9f07fe1bbd985a494a9ac3fe4662f9db6dc346db418 SHA512 29b29975571abe7dc4269f8b758bf825b431adc7e72bceb42eb801d35bc2eea4f11adea96c8742a0cc273b718b3a632a1051bac1d2d45e40aa419d0f624cf1f6 DIST python-gentoo-patches-3.13.0b1_p3.tar.xz 11056 BLAKE2B ef932bac59d2316ee8fe638a3d34ce247ff587915546038627674cd4c03179998a58336f8ebae45f1fcc94c8059d61ff6f22693f25ace1462bce275f50bfb48f SHA512 956e3da7376d60d7a593af50fff9842016a3b193180e93ab8298756c9eedfb2aaf8c1287bb75111e6340b5bac20a12dcb00ef51ecf0e12ef9ae5c98202fb071b diff --git a/dev-lang/python/python-3.12.4.ebuild b/dev-lang/python/python-3.12.4.ebuild new file mode 100644 index 000000000000..5ae290e1e120 --- /dev/null +++ b/dev-lang/python/python-3.12.4.ebuild @@ -0,0 +1,571 @@ +# Copyright 1999-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI="8" +WANT_LIBTOOL="none" + +inherit autotools check-reqs flag-o-matic multiprocessing pax-utils +inherit python-utils-r1 toolchain-funcs verify-sig + +MY_PV=${PV/_rc/rc} +MY_P="Python-${MY_PV%_p*}" +PYVER=$(ver_cut 1-2) +PATCHSET="python-gentoo-patches-${MY_PV}" + +DESCRIPTION="An interpreted, interactive, object-oriented programming language" +HOMEPAGE=" + https://www.python.org/ + https://github.com/python/cpython/ +" +SRC_URI=" + https://www.python.org/ftp/python/${PV%%_*}/${MY_P}.tar.xz + https://dev.gentoo.org/~mgorny/dist/python/${PATCHSET}.tar.xz + verify-sig? ( + https://www.python.org/ftp/python/${PV%%_*}/${MY_P}.tar.xz.asc + ) +" +S="${WORKDIR}/${MY_P}" + +LICENSE="PSF-2" +SLOT="${PYVER}" +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86" +IUSE=" + bluetooth build debug +ensurepip examples gdbm libedit + +ncurses pgo +readline +sqlite +ssl test tk valgrind +" +RESTRICT="!test? ( test )" + +# Do not add a dependency on dev-lang/python to this ebuild. +# If you need to apply a patch which requires python for bootstrapping, please +# run the bootstrap code on your dev box and include the results in the +# patchset. See bug 447752. + +RDEPEND=" + app-arch/bzip2:= + app-arch/xz-utils:= + app-crypt/libb2 + >=dev-libs/expat-2.1:= + dev-libs/libffi:= + dev-libs/mpdecimal:= + dev-python/gentoo-common + >=sys-libs/zlib-1.1.3:= + virtual/libcrypt:= + virtual/libintl + ensurepip? ( dev-python/ensurepip-pip ) + gdbm? ( sys-libs/gdbm:=[berkdb] ) + kernel_linux? ( sys-apps/util-linux:= ) + ncurses? ( >=sys-libs/ncurses-5.2:= ) + readline? ( + !libedit? ( >=sys-libs/readline-4.1:= ) + libedit? ( dev-libs/libedit:= ) + ) + sqlite? ( >=dev-db/sqlite-3.3.8:3= ) + ssl? ( >=dev-libs/openssl-1.1.1:= ) + tk? ( + >=dev-lang/tcl-8.0:= + >=dev-lang/tk-8.0:= + dev-tcltk/blt:= + dev-tcltk/tix + ) +" +# bluetooth requires headers from bluez +DEPEND=" + ${RDEPEND} + bluetooth? ( net-wireless/bluez ) + test? ( + app-arch/xz-utils + dev-python/ensurepip-pip + dev-python/ensurepip-setuptools + dev-python/ensurepip-wheel + ) + valgrind? ( dev-debug/valgrind ) +" +# autoconf-archive needed to eautoreconf +BDEPEND=" + dev-build/autoconf-archive + app-alternatives/awk + virtual/pkgconfig + verify-sig? ( >=sec-keys/openpgp-keys-python-20221025 ) +" +RDEPEND+=" + !build? ( app-misc/mime-types ) +" +if [[ ${PV} != *_alpha* ]]; then + RDEPEND+=" + dev-lang/python-exec[python_targets_python${PYVER/./_}(-)] + " +fi + +VERIFY_SIG_OPENPGP_KEY_PATH=/usr/share/openpgp-keys/python.org.asc + +# large file tests involve a 2.5G file being copied (duplicated) +CHECKREQS_DISK_BUILD=5500M + +QA_PKGCONFIG_VERSION=${PYVER} +# false positives -- functions specific to *BSD +QA_CONFIG_IMPL_DECL_SKIP=( chflags lchflags ) + +pkg_pretend() { + use test && check-reqs_pkg_pretend +} + +pkg_setup() { + use test && check-reqs_pkg_setup +} + +src_unpack() { + if use verify-sig; then + verify-sig_verify_detached "${DISTDIR}"/${MY_P}.tar.xz{,.asc} + fi + default +} + +src_prepare() { + # Ensure that internal copies of expat and libffi are not used. + # TODO: Makefile has annoying deps on expat headers + #rm -r Modules/expat || die + + local PATCHES=( + "${WORKDIR}/${PATCHSET}" + ) + + default + + # force the correct number of jobs + # https://bugs.gentoo.org/737660 + sed -i -e "s:-j0:-j$(makeopts_jobs):" Makefile.pre.in || die + + eautoreconf +} + +build_cbuild_python() { + # Hack to workaround get_libdir not being able to handle CBUILD, bug #794181 + local cbuild_libdir=$(unset PKG_CONFIG_PATH ; $(tc-getBUILD_PKG_CONFIG) --keep-system-libs --libs-only-L libffi) + + # pass system CFLAGS & LDFLAGS as _NODIST, otherwise they'll get + # propagated to sysconfig for built extensions + # + # -fno-lto to avoid bug #700012 (not like it matters for mini-CBUILD Python anyway) + local -x CFLAGS_NODIST="${BUILD_CFLAGS} -fno-lto" + local -x LDFLAGS_NODIST=${BUILD_LDFLAGS} + local -x CFLAGS= LDFLAGS= + local -x BUILD_CFLAGS="${CFLAGS_NODIST}" + local -x BUILD_LDFLAGS=${LDFLAGS_NODIST} + + # We need to build our own Python on CBUILD first, and feed it in. + # bug #847910 + local myeconfargs_cbuild=( + "${myeconfargs[@]}" + + --prefix="${BROOT}"/usr + --libdir="${cbuild_libdir:2}" + + # Avoid needing to load the right libpython.so. + --disable-shared + + # As minimal as possible for the mini CBUILD Python + # we build just for cross to satisfy --with-build-python. + --without-lto + --without-readline + --disable-optimizations + ) + + mkdir "${WORKDIR}"/${P}-${CBUILD} || die + pushd "${WORKDIR}"/${P}-${CBUILD} &> /dev/null || die + + # Avoid as many dependencies as possible for the cross build. + mkdir Modules || die + cat > Modules/Setup.local <<-EOF || die + *disabled* + nis + _dbm _gdbm + _sqlite3 + _hashlib _ssl + _curses _curses_panel + readline + _tkinter + pyexpat + zlib + # We disabled these for CBUILD because Python's setup.py can't handle locating + # libdir correctly for cross. This should be rechecked for the pure Makefile approach, + # and uncommented if needed. + #_ctypes _crypt + EOF + + ECONF_SOURCE="${S}" econf_build "${myeconfargs_cbuild[@]}" + + # Unfortunately, we do have to build this immediately, and + # not in src_compile, because CHOST configure for Python + # will check the existence of the --with-build-python value + # immediately. + emake + popd &> /dev/null || die +} + +src_configure() { + # disable automagic bluetooth headers detection + if ! use bluetooth; then + local -x ac_cv_header_bluetooth_bluetooth_h=no + fi + + append-flags -fwrapv + filter-flags -malign-double + + # Export CXX so it ends up in /usr/lib/python3.X/config/Makefile. + # PKG_CONFIG needed for cross. + tc-export CXX PKG_CONFIG + + local dbmliborder= + if use gdbm; then + dbmliborder+="${dbmliborder:+:}gdbm" + fi + + if use pgo; then + local profile_task_flags=( + -m test + "-j$(makeopts_jobs)" + --pgo-extended + -u-network + + # We use a timeout because of how often we've had hang issues + # here. It also matches the default upstream PROFILE_TASK. + --timeout 1200 + + -x test_gdb + -x test_dtrace + + # All of these seem to occasionally hang for PGO inconsistently + # They'll even hang here but be fine in src_test sometimes. + # bug #828535 (and related: bug #788022) + -x test_asyncio + -x test_concurrent_futures + -x test_httpservers + -x test_logging + -x test_multiprocessing_fork + -x test_socket + -x test_xmlrpc + + # Hangs (actually runs indefinitely executing itself w/ many cpython builds) + # bug #900429 + -x test_tools + ) + + # musl-specific skips + use elibc_musl && profile_task_flags+=( + # various musl locale deficiencies + -x test__locale + -x test_c_locale_coercion + -x test_locale + -x test_re + + # known issues with find_library on musl + # https://bugs.python.org/issue21622 + -x test_ctypes + + # fpathconf, ttyname errno values + -x test_os + ) + + if has_version "app-arch/rpm" ; then + # Avoid sandbox failure (attempts to write to /var/lib/rpm) + profile_task_flags+=( + -x test_distutils + ) + fi + local -x PROFILE_TASK="${profile_task_flags[*]}" + fi + + local myeconfargs=( + # glibc-2.30 removes it; since we can't cleanly force-rebuild + # Python on glibc upgrade, remove it proactively to give + # a chance for users rebuilding python before glibc + ac_cv_header_stropts_h=no + + --enable-shared + --without-static-libpython + --enable-ipv6 + --infodir='${prefix}/share/info' + --mandir='${prefix}/share/man' + --with-computed-gotos + --with-dbmliborder="${dbmliborder}" + --with-libc= + --enable-loadable-sqlite-extensions + --without-ensurepip + --without-lto + --with-system-expat + --with-system-libmpdec + --with-platlibdir=lib + --with-pkg-config=yes + --with-wheel-pkg-dir="${EPREFIX}"/usr/lib/python/ensurepip + + $(use_with debug assertions) + $(use_enable pgo optimizations) + $(use_with readline readline "$(usex libedit editline readline)") + $(use_with valgrind) + ) + + # https://bugs.gentoo.org/700012 + if tc-is-lto; then + append-cflags $(test-flags-CC -ffat-lto-objects) + myeconfargs+=( + --with-lto + ) + fi + + # Force-disable modules we don't want built. + # See Modules/Setup for docs on how this works. Setup.local contains our local deviations. + cat > Modules/Setup.local <<-EOF || die + *disabled* + nis + $(usev !gdbm '_gdbm _dbm') + $(usev !sqlite '_sqlite3') + $(usev !ssl '_hashlib _ssl') + $(usev !ncurses '_curses _curses_panel') + $(usev !readline 'readline') + $(usev !tk '_tkinter') + EOF + + # disable implicit optimization/debugging flags + local -x OPT= + + if tc-is-cross-compiler ; then + build_cbuild_python + myeconfargs+=( + # Point the imminent CHOST build to the Python we just + # built for CBUILD. + --with-build-python="${WORKDIR}"/${P}-${CBUILD}/python + ) + fi + + # pass system CFLAGS & LDFLAGS as _NODIST, otherwise they'll get + # propagated to sysconfig for built extensions + local -x CFLAGS_NODIST=${CFLAGS} + local -x LDFLAGS_NODIST=${LDFLAGS} + local -x CFLAGS= LDFLAGS= + + # Fix implicit declarations on cross and prefix builds. Bug #674070. + if use ncurses; then + append-cppflags -I"${ESYSROOT}"/usr/include/ncursesw + fi + + econf "${myeconfargs[@]}" + + if grep -q "#define POSIX_SEMAPHORES_NOT_ENABLED 1" pyconfig.h; then + eerror "configure has detected that the sem_open function is broken." + eerror "Please ensure that /dev/shm is mounted as a tmpfs with mode 1777." + die "Broken sem_open function (bug 496328)" + fi + + # install epython.py as part of stdlib + echo "EPYTHON='python${PYVER}'" > Lib/epython.py || die +} + +src_compile() { + # Ensure sed works as expected + # https://bugs.gentoo.org/594768 + local -x LC_ALL=C + export PYTHONSTRICTEXTENSIONBUILD=1 + + # Save PYTHONDONTWRITEBYTECODE so that 'has_version' doesn't + # end up writing bytecode & violating sandbox. + # bug #831897 + local -x _PYTHONDONTWRITEBYTECODE=${PYTHONDONTWRITEBYTECODE} + + if use pgo ; then + # bug 660358 + local -x COLUMNS=80 + local -x PYTHONDONTWRITEBYTECODE= + + addpredict "/usr/lib/python${PYVER}/site-packages" + fi + + # also need to clear the flags explicitly here or they end up + # in _sysconfigdata* + emake CPPFLAGS= CFLAGS= LDFLAGS= + + # Restore saved value from above. + local -x PYTHONDONTWRITEBYTECODE=${_PYTHONDONTWRITEBYTECODE} + + # Work around bug 329499. See also bug 413751 and 457194. + if has_version dev-libs/libffi[pax-kernel]; then + pax-mark E python + else + pax-mark m python + fi +} + +src_test() { + # Tests will not work when cross compiling. + if tc-is-cross-compiler; then + elog "Disabling tests due to crosscompiling." + return + fi + + # this just happens to skip test_support.test_freeze that is broken + # without bundled expat + # TODO: get a proper skip for it upstream + local -x LOGNAME=buildbot + + local test_opts=( + -u-network + -j "$(makeopts_jobs)" + + # fails + -x test_concurrent_futures + -x test_gdb + ) + + if use sparc ; then + # bug #788022 + test_opts+=( + -x test_multiprocessing_fork + -x test_multiprocessing_forkserver + ) + fi + + # musl-specific skips + use elibc_musl && test_opts+=( + # various musl locale deficiencies + -x test__locale + -x test_c_locale_coercion + -x test_locale + -x test_re + + # known issues with find_library on musl + # https://bugs.python.org/issue21622 + -x test_ctypes + + # fpathconf, ttyname errno values + -x test_os + ) + + # workaround docutils breaking tests + cat > Lib/docutils.py <<-EOF || die + raise ImportError("Thou shalt not import!") + EOF + + # bug 660358 + local -x COLUMNS=80 + local -x PYTHONDONTWRITEBYTECODE= + # workaround https://bugs.gentoo.org/775416 + addwrite "/usr/lib/python${PYVER}/site-packages" + + nonfatal emake -Onone test EXTRATESTOPTS="${test_opts[*]}" \ + CPPFLAGS= CFLAGS= LDFLAGS= < /dev/tty + local ret=${?} + + rm Lib/docutils.py || die + + [[ ${ret} -eq 0 ]] || die "emake test failed" +} + +src_install() { + local libdir=${ED}/usr/lib/python${PYVER} + + # the Makefile rules are broken + # https://github.com/python/cpython/issues/100221 + mkdir -p "${libdir}"/lib-dynload || die + + # -j1 hack for now for bug #843458 + emake -j1 DESTDIR="${D}" altinstall + + # Fix collisions between different slots of Python. + rm "${ED}/usr/$(get_libdir)/libpython3.so" || die + + # Cheap hack to get version with ABIFLAGS + local abiver=$(cd "${ED}/usr/include"; echo python*) + if [[ ${abiver} != python${PYVER} ]]; then + # Replace python3.X with a symlink to python3.Xm + rm "${ED}/usr/bin/python${PYVER}" || die + dosym "${abiver}" "/usr/bin/python${PYVER}" + # Create python3.X-config symlink + dosym "${abiver}-config" "/usr/bin/python${PYVER}-config" + # Create python-3.5m.pc symlink + dosym "python-${PYVER}.pc" "/usr/$(get_libdir)/pkgconfig/${abiver/${PYVER}/-${PYVER}}.pc" + fi + + # python seems to get rebuilt in src_install (bug 569908) + # Work around it for now. + if has_version dev-libs/libffi[pax-kernel]; then + pax-mark E "${ED}/usr/bin/${abiver}" + else + pax-mark m "${ED}/usr/bin/${abiver}" + fi + + rm -r "${libdir}"/ensurepip/_bundled || die + if ! use ensurepip; then + rm -r "${libdir}"/ensurepip || die + fi + if ! use sqlite; then + rm -r "${libdir}/"sqlite3 || die + fi + if ! use tk; then + rm -r "${ED}/usr/bin/idle${PYVER}" || die + rm -r "${libdir}/"{idlelib,tkinter,test/test_tk*} || die + fi + + ln -s ../python/EXTERNALLY-MANAGED "${libdir}/EXTERNALLY-MANAGED" || die + + dodoc Misc/{ACKS,HISTORY,NEWS} + + if use examples; then + docinto examples + find Tools -name __pycache__ -exec rm -fr {} + || die + dodoc -r Tools + fi + insinto /usr/share/gdb/auto-load/usr/$(get_libdir) #443510 + local libname=$( + printf 'e:\n\t@echo $(INSTSONAME)\ninclude Makefile\n' | + emake --no-print-directory -s -f - 2>/dev/null + ) + newins Tools/gdb/libpython.py "${libname}"-gdb.py + + newconfd "${FILESDIR}/pydoc.conf" pydoc-${PYVER} + newinitd "${FILESDIR}/pydoc.init" pydoc-${PYVER} + sed \ + -e "s:@PYDOC_PORT_VARIABLE@:PYDOC${PYVER/./_}_PORT:" \ + -e "s:@PYDOC@:pydoc${PYVER}:" \ + -i "${ED}/etc/conf.d/pydoc-${PYVER}" \ + "${ED}/etc/init.d/pydoc-${PYVER}" || die "sed failed" + + # python-exec wrapping support + local pymajor=${PYVER%.*} + local EPYTHON=python${PYVER} + local scriptdir=${D}$(python_get_scriptdir) + mkdir -p "${scriptdir}" || die + # python and pythonX + ln -s "../../../bin/${abiver}" "${scriptdir}/python${pymajor}" || die + ln -s "python${pymajor}" "${scriptdir}/python" || die + # python-config and pythonX-config + # note: we need to create a wrapper rather than symlinking it due + # to some random dirname(argv[0]) magic performed by python-config + cat > "${scriptdir}/python${pymajor}-config" <<-EOF || die + #!/bin/sh + exec "${abiver}-config" "\${@}" + EOF + chmod +x "${scriptdir}/python${pymajor}-config" || die + ln -s "python${pymajor}-config" "${scriptdir}/python-config" || die + # 2to3, pydoc + ln -s "../../../bin/2to3-${PYVER}" "${scriptdir}/2to3" || die + ln -s "../../../bin/pydoc${PYVER}" "${scriptdir}/pydoc" || die + # idle + if use tk; then + ln -s "../../../bin/idle${PYVER}" "${scriptdir}/idle" || die + fi +} + +pkg_postinst() { + local v + for v in ${REPLACING_VERSIONS}; do + if ver_test "${v}" -lt 3.11.0_beta4-r2; then + ewarn "Python 3.11.0b4 has changed its module ABI. The .pyc files" + ewarn "installed previously are no longer valid and will be regenerated" + ewarn "(or ignored) on the next import. This may cause sandbox failures" + ewarn "when installing some packages and checksum mismatches when removing" + ewarn "old versions. To actively prevent this, rebuild all packages" + ewarn "installing Python 3.11 modules, e.g. using:" + ewarn + ewarn " emerge -1v /usr/lib/python3.11/site-packages" + fi + done +}