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
 

Reply via email to