From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1464720-garchives=archives.gentoo.org@lists.gentoo.org>
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 7A5F7158020
	for <garchives@archives.gentoo.org>; Tue,  6 Dec 2022 19:39:22 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id BC838E07D3;
	Tue,  6 Dec 2022 19:39:21 +0000 (UTC)
Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183])
	(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 9989FE07D3
	for <gentoo-commits@lists.gentoo.org>; Tue,  6 Dec 2022 19:39:21 +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))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id 77C90341146
	for <gentoo-commits@lists.gentoo.org>; Tue,  6 Dec 2022 19:39:20 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id 0CDB2772
	for <gentoo-commits@lists.gentoo.org>; Tue,  6 Dec 2022 19:39:19 +0000 (UTC)
From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" <sam@gentoo.org>
Message-ID: <1670355531.3478cabb5f94e9d90ae1ed9e3f7909a1146aa471.sam@gentoo>
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-lang/python/
X-VCS-Repository: repo/gentoo
X-VCS-Files: dev-lang/python/python-3.10.8_p3.ebuild dev-lang/python/python-3.11.0_p2.ebuild dev-lang/python/python-3.12.0_alpha2.ebuild dev-lang/python/python-3.8.15_p3.ebuild dev-lang/python/python-3.9.15_p3.ebuild
X-VCS-Directories: dev-lang/python/
X-VCS-Committer: sam
X-VCS-Committer-Name: Sam James
X-VCS-Revision: 3478cabb5f94e9d90ae1ed9e3f7909a1146aa471
X-VCS-Branch: master
Date: Tue,  6 Dec 2022 19:39:19 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply
X-Archives-Salt: c51f06d7-4070-4394-bde1-4a88b8d2b102
X-Archives-Hash: c46aadf11f6111c4d4721429bf17b2bb

commit:     3478cabb5f94e9d90ae1ed9e3f7909a1146aa471
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Tue Dec  6 19:35:41 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Dec  6 19:38:51 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=3478cabb

dev-lang/python: disable _ctypes, _crypt for cross (CBUILD) Python

* Use a hack to deduce libdir to nudge the build system in the right
  direction because get_libdir can't handle BROOT/CBUILD right now.

* Disable _ctypes (libffi) and _crypt (lib(x)crypt) modules for cross (CBUILD)
  Python as they're not needed and Python struggles to find the libraries
  correctly.

  This avoids an issue where setup.py can't handle deducing libdir
  (or even being passed it) for cross-compilation. Fortunately, cpython
  is migrating away from setup.py to autotools.

Note that this isn't the same as what bug 633712 would've been at the time
it was reported, but it certainly showed up the same way on more modern
Pythons since we introduced the CBUILD part a few months ago.

Bug: https://bugs.gentoo.org/633712
Bug: https://bugs.gentoo.org/794181
Bug: https://bugs.gentoo.org/864911
Signed-off-by: Sam James <sam <AT> gentoo.org>

 dev-lang/python/python-3.10.8_p3.ebuild     | 13 +++++++++++--
 dev-lang/python/python-3.11.0_p2.ebuild     | 13 +++++++++++--
 dev-lang/python/python-3.12.0_alpha2.ebuild | 13 +++++++++++--
 dev-lang/python/python-3.8.15_p3.ebuild     | 13 +++++++++++--
 dev-lang/python/python-3.9.15_p3.ebuild     | 13 +++++++++++--
 5 files changed, 55 insertions(+), 10 deletions(-)

diff --git a/dev-lang/python/python-3.10.8_p3.ebuild b/dev-lang/python/python-3.10.8_p3.ebuild
index e7125a5118a9..bb439f4a2c0e 100644
--- a/dev-lang/python/python-3.10.8_p3.ebuild
+++ b/dev-lang/python/python-3.10.8_p3.ebuild
@@ -230,6 +230,10 @@ src_configure() {
 	local -x OPT=
 
 	if tc-is-cross-compiler ; then
+		# 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)
+		append-flags "${cbuild_libdir}"
+
 		# pass system CFLAGS & LDFLAGS as _NODIST, otherwise they'll get
 		# propagated to sysconfig for built extensions
 		local -x CFLAGS_NODIST=${CFLAGS_FOR_BUILD}
@@ -241,6 +245,8 @@ src_configure() {
 		local myeconfargs_cbuild=(
 			"${myeconfargs[@]}"
 
+			--libdir="${cbuild_libdir:2}"
+
 			# As minimal as possible for the mini CBUILD Python
 			# we build just for cross.
 			--without-lto
@@ -253,7 +259,10 @@ src_configure() {
 
 		mkdir "${WORKDIR}"/${P}-${CBUILD} || die
 		pushd "${WORKDIR}"/${P}-${CBUILD} &> /dev/null || die
-		ECONF_SOURCE="${S}" econf_build "${myeconfargs_cbuild[@]}"
+		# We disable _ctypes and _crypt for CBUILD because Python's setup.py can't handle locating
+		# libdir correctly for cross.
+		PYTHON_DISABLE_MODULES="${PYTHON_DISABLE_MODULES} _ctypes _crypt" \
+			ECONF_SOURCE="${S}" econf_build "${myeconfargs_cbuild[@]}"
 
 		# Avoid as many dependencies as possible for the cross build.
 		cat >> Makefile <<-EOF || die
@@ -276,7 +285,7 @@ src_configure() {
 		# not in src_compile, because CHOST configure for Python
 		# will check the existence of the Python it was pointed to
 		# immediately.
-		emake
+		PYTHON_DISABLE_MODULES="${PYTHON_DISABLE_MODULES} _ctypes _crypt" emake
 		popd &> /dev/null || die
 	fi
 

diff --git a/dev-lang/python/python-3.11.0_p2.ebuild b/dev-lang/python/python-3.11.0_p2.ebuild
index 6888041b8060..a5b25008d1ca 100644
--- a/dev-lang/python/python-3.11.0_p2.ebuild
+++ b/dev-lang/python/python-3.11.0_p2.ebuild
@@ -219,6 +219,10 @@ src_configure() {
 	local -x OPT=
 
 	if tc-is-cross-compiler ; then
+		# 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)
+		append-flags "${cbuild_libdir}"
+
 		# pass system CFLAGS & LDFLAGS as _NODIST, otherwise they'll get
 		# propagated to sysconfig for built extensions
 		local -x CFLAGS_NODIST=${CFLAGS_FOR_BUILD}
@@ -230,6 +234,8 @@ src_configure() {
 		local myeconfargs_cbuild=(
 			"${myeconfargs[@]}"
 
+			--libdir="${cbuild_libdir:2}"
+
 			# As minimal as possible for the mini CBUILD Python
 			# we build just for cross to satisfy --with-build-python.
 			--without-lto
@@ -245,7 +251,10 @@ src_configure() {
 
 		mkdir "${WORKDIR}"/${P}-${CBUILD} || die
 		pushd "${WORKDIR}"/${P}-${CBUILD} &> /dev/null || die
-		ECONF_SOURCE="${S}" econf_build "${myeconfargs_cbuild[@]}"
+		# We disable _ctypes and _crypt for CBUILD because Python's setup.py can't handle locating
+		# libdir correctly for cross.
+		PYTHON_DISABLE_MODULES="${PYTHON_DISABLE_MODULES} _ctypes _crypt" \
+			ECONF_SOURCE="${S}" econf_build "${myeconfargs_cbuild[@]}"
 
 		# Avoid as many dependencies as possible for the cross build.
 		cat >> Makefile <<-EOF || die
@@ -268,7 +277,7 @@ src_configure() {
 		# not in src_compile, because CHOST configure for Python
 		# will check the existence of the --with-build-python value
 		# immediately.
-		emake
+		PYTHON_DISABLE_MODULES="${PYTHON_DISABLE_MODULES} _ctypes _crypt" emake
 		popd &> /dev/null || die
 	fi
 

diff --git a/dev-lang/python/python-3.12.0_alpha2.ebuild b/dev-lang/python/python-3.12.0_alpha2.ebuild
index ec1c57a29503..75b1ec9ee990 100644
--- a/dev-lang/python/python-3.12.0_alpha2.ebuild
+++ b/dev-lang/python/python-3.12.0_alpha2.ebuild
@@ -215,6 +215,10 @@ src_configure() {
 	local -x OPT=
 
 	if tc-is-cross-compiler ; then
+		# 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)
+		append-flags "${cbuild_libdir}"
+
 		# pass system CFLAGS & LDFLAGS as _NODIST, otherwise they'll get
 		# propagated to sysconfig for built extensions
 		local -x CFLAGS_NODIST=${CFLAGS_FOR_BUILD}
@@ -226,6 +230,8 @@ src_configure() {
 		local myeconfargs_cbuild=(
 			"${myeconfargs[@]}"
 
+			--libdir="${cbuild_libdir:2}"
+
 			# As minimal as possible for the mini CBUILD Python
 			# we build just for cross to satisfy --with-build-python.
 			--without-lto
@@ -241,7 +247,10 @@ src_configure() {
 
 		mkdir "${WORKDIR}"/${P}-${CBUILD} || die
 		pushd "${WORKDIR}"/${P}-${CBUILD} &> /dev/null || die
-		ECONF_SOURCE="${S}" econf_build "${myeconfargs_cbuild[@]}"
+		# We disable _ctypes and _crypt for CBUILD because Python's setup.py can't handle locating
+		# libdir correctly for cross.
+		PYTHON_DISABLE_MODULES="${PYTHON_DISABLE_MODULES} _ctypes _crypt" \
+			ECONF_SOURCE="${S}" econf_build "${myeconfargs_cbuild[@]}"
 
 		# Avoid as many dependencies as possible for the cross build.
 		cat >> Makefile <<-EOF || die
@@ -264,7 +273,7 @@ src_configure() {
 		# not in src_compile, because CHOST configure for Python
 		# will check the existence of the --with-build-python value
 		# immediately.
-		emake
+		PYTHON_DISABLE_MODULES="${PYTHON_DISABLE_MODULES} _ctypes _crypt" emake
 		popd &> /dev/null || die
 	fi
 

diff --git a/dev-lang/python/python-3.8.15_p3.ebuild b/dev-lang/python/python-3.8.15_p3.ebuild
index 5f5bccbf6686..282fad56251f 100644
--- a/dev-lang/python/python-3.8.15_p3.ebuild
+++ b/dev-lang/python/python-3.8.15_p3.ebuild
@@ -184,6 +184,10 @@ src_configure() {
 	local -x OPT=
 
 	if tc-is-cross-compiler ; then
+		# 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)
+		append-flags "${cbuild_libdir}"
+
 		# pass system CFLAGS & LDFLAGS as _NODIST, otherwise they'll get
 		# propagated to sysconfig for built extensions
 		local -x CFLAGS_NODIST=${CFLAGS_FOR_BUILD}
@@ -195,6 +199,8 @@ src_configure() {
 		local myeconfargs_cbuild=(
 			"${myeconfargs[@]}"
 
+			--libdir="${cbuild_libdir:2}"
+
 			# As minimal as possible for the mini CBUILD Python
 			# we build just for cross.
 			--without-lto
@@ -207,7 +213,10 @@ src_configure() {
 
 		mkdir "${WORKDIR}"/${P}-${CBUILD} || die
 		pushd "${WORKDIR}"/${P}-${CBUILD} &> /dev/null || die
-		ECONF_SOURCE="${S}" econf_build "${myeconfargs_cbuild[@]}"
+		# We disable _ctypes and _crypt for CBUILD because Python's setup.py can't handle locating
+		# libdir correctly for cross.
+		PYTHON_DISABLE_MODULES="${PYTHON_DISABLE_MODULES} _ctypes _crypt" \
+			ECONF_SOURCE="${S}" econf_build "${myeconfargs_cbuild[@]}"
 
 		# Avoid as many dependencies as possible for the cross build.
 		cat >> Makefile <<-EOF || die
@@ -230,7 +239,7 @@ src_configure() {
 		# not in src_compile, because CHOST configure for Python
 		# will check the existence of the Python it was pointed to
 		# immediately.
-		emake
+		PYTHON_DISABLE_MODULES="${PYTHON_DISABLE_MODULES} _ctypes _crypt" emake
 		popd &> /dev/null || die
 	fi
 

diff --git a/dev-lang/python/python-3.9.15_p3.ebuild b/dev-lang/python/python-3.9.15_p3.ebuild
index 4ab4f51b7faf..4153d0130a07 100644
--- a/dev-lang/python/python-3.9.15_p3.ebuild
+++ b/dev-lang/python/python-3.9.15_p3.ebuild
@@ -224,6 +224,10 @@ src_configure() {
 	local -x OPT=
 
 	if tc-is-cross-compiler ; then
+		# 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)
+		append-flags "${cbuild_libdir}"
+
 		# pass system CFLAGS & LDFLAGS as _NODIST, otherwise they'll get
 		# propagated to sysconfig for built extensions
 		local -x CFLAGS_NODIST=${CFLAGS_FOR_BUILD}
@@ -235,6 +239,8 @@ src_configure() {
 		local myeconfargs_cbuild=(
 			"${myeconfargs[@]}"
 
+			--libdir="${cbuild_libdir:2}"
+
 			# As minimal as possible for the mini CBUILD Python
 			# we build just for cross.
 			--without-lto
@@ -247,7 +253,10 @@ src_configure() {
 
 		mkdir "${WORKDIR}"/${P}-${CBUILD} || die
 		pushd "${WORKDIR}"/${P}-${CBUILD} &> /dev/null || die
-		ECONF_SOURCE="${S}" econf_build "${myeconfargs_cbuild[@]}"
+		# We disable _ctypes and _crypt for CBUILD because Python's setup.py can't handle locating
+		# libdir correctly for cross.
+		PYTHON_DISABLE_MODULES="${PYTHON_DISABLE_MODULES} _ctypes _crypt" \
+			ECONF_SOURCE="${S}" econf_build "${myeconfargs_cbuild[@]}"
 
 		# Avoid as many dependencies as possible for the cross build.
 		cat >> Makefile <<-EOF || die
@@ -270,7 +279,7 @@ src_configure() {
 		# not in src_compile, because CHOST configure for Python
 		# will check the existence of the Python it was pointed to
 		# immediately.
-		emake
+		PYTHON_DISABLE_MODULES="${PYTHON_DISABLE_MODULES} _ctypes _crypt" emake
 		popd &> /dev/null || die
 	fi