commit:     c9ce129f9f6fa05f408cb305d893d5c73045a354
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat Mar  5 10:33:40 2022 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat Mar  5 11:54:49 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c9ce129f

dev-lang/python: Backport expat test fixes to 3.10

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 dev-lang/python/Manifest                |   1 +
 dev-lang/python/python-3.10.2_p1.ebuild | 386 ++++++++++++++++++++++++++++++++
 2 files changed, 387 insertions(+)

diff --git a/dev-lang/python/Manifest b/dev-lang/python/Manifest
index a5cc8a673bd3..2e99999b179a 100644
--- a/dev-lang/python/Manifest
+++ b/dev-lang/python/Manifest
@@ -24,6 +24,7 @@ DIST python-gentoo-patches-2.7.18_p13.tar.xz 33296 BLAKE2B 
91b711458aff4f6337ee1
 DIST python-gentoo-patches-3.10.0_p1.tar.xz 10068 BLAKE2B 
1c9817b449831559f0a0b722c02a5f55d94b3dfde98e5882c1403fe24a4addf7074ab39c09b91cff6fd7ace2e4b6e8ed899d9a0b9ffd6612ce315c4c192bd309
 SHA512 
39aa41dbf17b6dc5255491c75031a3dae6962b44125e426dbfdce365a6533c5dae9856b1fff8016a189124b7cff72d2665ce99da344c2f9dff005ba685e8c2c4
 DIST python-gentoo-patches-3.10.1.tar.xz 8580 BLAKE2B 
58d165c6c21a6736787d77d5bbeb770adff7f3729a47f62d0b7c4f0982c15c6a50b326be33638f3fca5574936cbce35d26e9ce0868faa3b5a3412b30586b066a
 SHA512 
f86adf4e5195b1eb13cedbf24c1956964ce56745f0524a62b1e7c6baf74c6f1802e05cf4c08519b147579945c0526ff0a0ffc01cfb4372c0ec4f403b25e81012
 DIST python-gentoo-patches-3.10.2.tar.xz 8584 BLAKE2B 
4328b21d7b8b0e39d0d6761c3a52cb5369aff7dfa890a1496fe5c01720bd9d8ef38d915188ad6079158104f8acf5847e220d58c092a9682615aa366dce9f20d2
 SHA512 
063c53022525cea988a9a27643bf0b2b5e674259de487826ee3b3cbca50c369857908d53cee9be59adf09db7ac0dcaed65639c40204ff4519b812b215de588a6
+DIST python-gentoo-patches-3.10.2_p1.tar.xz 9860 BLAKE2B 
6343b9fa1af2763501fc67674f0ebcec9bffa340edd741c97f54b290e91056141230264221b8746447da553ced7081156d83517330b7bb3ac027d9f72fa0d62a
 SHA512 
7c8666bf47cda7647d330fff6070b9d0410dc21dc7114ff232bdbb5e5f993c02b9fc373919bae73391a2d28a8bbe096efc071f8273f2338758876a5f50b28d30
 DIST python-gentoo-patches-3.11.0a4.tar.xz 3652 BLAKE2B 
19beab7c85e93414f392f2fda89a5ec0fc0a8339bf3804cb88c349cbb57b2c2cd6338d59307a950abe387958cbe7d3b958a73004b5fc51788235660aed3dea6a
 SHA512 
97745cc7dd9c0849f1e5cc577322878f831e7af0b45ef6d23e0cee1b02879386bbf22d84ff73b8a5f70f2b193788f3dff003ddc248bd8ea19779c371fe706bdc
 DIST python-gentoo-patches-3.11.0a5.tar.xz 3652 BLAKE2B 
2460db48b01d7397e6f72f6eaf9afd8a69ca01bc7c988b34e4277406bd70656009cd524cfee374eccdd04317c4e313d32b7689706ce57233d9f4054dc3f3db52
 SHA512 
164eaa0385491e2dcd92ecdfd9acb4ea4aba69a4571073f9c95e578cfecc69f6fcac47a0dd5e3415a27977cfe7221ce214f417606c7402ec0185701306de3f98
 DIST python-gentoo-patches-3.11.0a5_p1.tar.xz 4956 BLAKE2B 
e93817dd9b0fe695b5ade52604165114f26c40a67deba08135dfff0f1fc31fa2657435dd736d8cdc053714d1042ffc1c2d52b3177186a72e74e86e67a1eeb479
 SHA512 
f2440720e715ea68859841dc4f1f7c858064d18d48e4c7515d6ae57b55c281b271dabee1506099d8343f106deff806bad9e28abf67f961acc95e7dfcdb320d21

diff --git a/dev-lang/python/python-3.10.2_p1.ebuild 
b/dev-lang/python/python-3.10.2_p1.ebuild
new file mode 100644
index 000000000000..c3d1ada324fb
--- /dev/null
+++ b/dev-lang/python/python-3.10.2_p1.ebuild
@@ -0,0 +1,386 @@
+# Copyright 1999-2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI="7"
+WANT_LIBTOOL="none"
+
+inherit autotools check-reqs flag-o-matic multiprocessing pax-utils \
+       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/";
+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 ~m68k ~mips ~ppc ~ppc64 ~riscv 
~s390 ~sparc ~x86"
+IUSE="bluetooth build examples gdbm hardened libedit lto +ncurses pgo 
+readline +sqlite +ssl test tk wininst +xml"
+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:=
+       dev-lang/python-exec[python_targets_python3_10(-)]
+       dev-libs/libffi:=
+       sys-apps/util-linux:=
+       >=sys-libs/zlib-1.1.3:=
+       virtual/libcrypt:=
+       virtual/libintl
+       gdbm? ( sys-libs/gdbm:=[berkdb] )
+       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
+       )
+       xml? ( >=dev-libs/expat-2.1:= )
+       !!<sys-apps/sandbox-2.21"
+# bluetooth requires headers from bluez
+DEPEND="${RDEPEND}
+       bluetooth? ( net-wireless/bluez )
+       test? ( app-arch/xz-utils[extra-filters(+)] )"
+# autoconf-archive needed to eautoreconf
+BDEPEND="
+       sys-devel/autoconf-archive
+       virtual/awk
+       virtual/pkgconfig
+       verify-sig? ( sec-keys/openpgp-keys-python )
+       !sys-devel/gcc[libffi(-)]"
+RDEPEND+=" !build? ( app-misc/mime-types )"
+
+VERIFY_SIG_OPENPGP_KEY_PATH=${BROOT}/usr/share/openpgp-keys/python.org.asc
+
+# large file tests involve a 2.5G file being copied (duplicated)
+CHECKREQS_DISK_BUILD=5500M
+
+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, libffi and zlib are not used.
+       rm -fr Modules/expat || die
+       rm -fr Modules/_ctypes/libffi* || die
+       rm -fr Modules/zlib || die
+
+       local PATCHES=(
+               "${WORKDIR}/${PATCHSET}"
+       )
+
+       default
+
+       sed -i -e "s:@@GENTOO_LIBDIR@@:$(get_libdir):g" \
+               setup.py || die "sed failed to replace @@GENTOO_LIBDIR@@"
+
+       # force correct number of jobs
+       # https://bugs.gentoo.org/737660
+       local jobs=$(makeopts_jobs "${MAKEOPTS}" "$(get_nproc)")
+       sed -i -e "s:-j0:-j${jobs}:" Makefile.pre.in || die
+       sed -i -e "/self\.parallel/s:True:${jobs}:" setup.py || die
+
+       eautoreconf
+}
+
+src_configure() {
+       local disable
+       # disable automagic bluetooth headers detection
+       use bluetooth || export ac_cv_header_bluetooth_bluetooth_h=no
+       use gdbm      || disable+=" gdbm"
+       use ncurses   || disable+=" _curses _curses_panel"
+       use readline  || disable+=" readline"
+       use sqlite    || disable+=" _sqlite3"
+       use ssl       || export PYTHON_DISABLE_SSL="1"
+       use tk        || disable+=" _tkinter"
+       use xml       || disable+=" _elementtree pyexpat" # _elementtree uses 
pyexpat.
+       export PYTHON_DISABLE_MODULES="${disable}"
+
+       if ! use xml; then
+               ewarn "You have configured Python without XML support."
+               ewarn "This is NOT a recommended configuration as you"
+               ewarn "may face problems parsing any XML documents."
+       fi
+
+       if [[ -n "${PYTHON_DISABLE_MODULES}" ]]; then
+               einfo "Disabled modules: ${PYTHON_DISABLE_MODULES}"
+       fi
+
+       if [[ "$(gcc-major-version)" -ge 4 ]]; then
+               append-flags -fwrapv
+       fi
+
+       filter-flags -malign-double
+
+       # https://bugs.gentoo.org/show_bug.cgi?id=50309
+       if is-flagq -O3; then
+               is-flagq -fstack-protector-all && replace-flags -O3 -O2
+               use hardened && replace-flags -O3 -O2
+       fi
+
+       # https://bugs.gentoo.org/700012
+       if is-flagq -flto || is-flagq '-flto=*'; then
+               append-cflags $(test-flags-CC -ffat-lto-objects)
+       fi
+
+       # Export CXX so it ends up in /usr/lib/python3.X/config/Makefile.
+       tc-export CXX
+
+       # Fix implicit declarations on cross and prefix builds. Bug #674070.
+       use ncurses && append-cppflags -I"${ESYSROOT}"/usr/include/ncursesw
+
+       local dbmliborder
+       if use gdbm; then
+               dbmliborder+="${dbmliborder:+:}gdbm"
+       fi
+
+       if use pgo; then
+               local jobs=$(makeopts_jobs "${MAKEOPTS}" "$(get_nproc)")
+               export PROFILE_TASK="-m test -j${jobs} --pgo-extended -x 
test_gdb -u-network"
+
+               # 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)
+               PROFILE_TASK+=" -x test_socket -x test_asyncio -x 
test_httpservers -x test_logging -x test_multiprocessing_fork -x test_xmlrpc"
+
+               if has_version "app-arch/rpm" ; then
+                       # Avoid sandbox failure (attempts to write to 
/var/lib/rpm)
+                       PROFILE_TASK+=" -x test_distutils"
+               fi
+       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
+               --with-system-expat
+               --with-system-ffi
+
+               $(use_with lto)
+               $(use_enable pgo optimizations)
+               $(use_with readline readline "$(usex libedit editline 
readline)")
+       )
+
+       # disable implicit optimization/debugging flags
+       local -x OPT=
+       # 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=
+
+       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
+}
+
+src_compile() {
+       # Ensure sed works as expected
+       # https://bugs.gentoo.org/594768
+       local -x LC_ALL=C
+       # Prevent using distutils bundled by setuptools.
+       # https://bugs.gentoo.org/823728
+       export SETUPTOOLS_USE_DISTUTILS=stdlib
+
+       if use pgo ; then
+               # bug 660358
+               local -x COLUMNS=80
+               local -x PYTHONDONTWRITEBYTECODE=
+
+               addpredict /usr/lib/python3.10/site-packages
+       fi
+
+       # also need to clear the flags explicitly here or they end up
+       # in _sysconfigdata*
+       emake CPPFLAGS= CFLAGS= LDFLAGS=
+
+       # 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
+
+       # Skip failing tests.
+       local skipped_tests="gdb"
+
+       for test in ${skipped_tests}; do
+               mv "${S}"/Lib/test/test_${test}.py "${T}"
+       done
+
+       # bug 660358
+       local -x COLUMNS=80
+       local -x PYTHONDONTWRITEBYTECODE=
+       # workaround https://bugs.gentoo.org/775416
+       addwrite /usr/lib/python3.10/site-packages
+
+       local jobs=$(makeopts_jobs "${MAKEOPTS}" "$(get_nproc)")
+
+       emake test EXTRATESTOPTS="-u-network -j${jobs}" \
+               CPPFLAGS= CFLAGS= LDFLAGS= < /dev/tty
+       local result=$?
+
+       for test in ${skipped_tests}; do
+               mv "${T}/test_${test}.py" "${S}"/Lib/test
+       done
+
+       elog "The following tests have been skipped:"
+       for test in ${skipped_tests}; do
+               elog "test_${test}.py"
+       done
+
+       elog "If you would like to run them, you may:"
+       elog "cd '${EPREFIX}/usr/lib/python${PYVER}/test'"
+       elog "and run the tests separately."
+
+       if [[ ${result} -ne 0 ]]; then
+               die "emake test failed"
+       fi
+}
+
+src_install() {
+       local libdir=${ED}/usr/lib/python${PYVER}
+
+       emake 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
+
+       use sqlite || rm -r "${libdir}/"{sqlite3,test/test_sqlite*} || die
+       use tk || rm -r "${ED}/usr/bin/idle${PYVER}" 
"${libdir}/"{idlelib,tkinter,test/test_tk*} || 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 "${S}"/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"
+
+       local -x EPYTHON=python${PYVER}
+       # if not using a cross-compiler, use the fresh binary
+       if ! tc-is-cross-compiler; then
+               local -x PYTHON=./python
+               local -x 
LD_LIBRARY_PATH=${LD_LIBRARY_PATH+${LD_LIBRARY_PATH}:}${PWD}
+       else
+               local -x PYTHON=${EPREFIX}/usr/bin/${EPYTHON}
+       fi
+
+       echo "EPYTHON='${EPYTHON}'" > epython.py || die
+       python_domodule epython.py
+
+       # python-exec wrapping support
+       local pymajor=${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
+}

Reply via email to