You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cross: wrong interpreter returned when no python available #88228
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=Nonecreated_at=<Date2021-05-06.18:23:43.293>labels= ['build', '3.9', '3.10', '3.11']
title='cross: wrong interpreter returned when no python available'updated_at=<Date2021-05-06.19:06:58.698>user='https://github.com/vfazio'
When trying to cross compile python3.9, configure attempts to find a strict python 3.9 version match, however if it fails it still attempts to use python in PYTHON_FOR_BUILD instead of failing outright like the code implies it should
$/python3/targetbuild# which python3.9 python3 python
/usr/bin/python3
if test "$cross_compiling" = yes; then
AC_MSG_CHECKING([for python interpreter for cross build])
if test -z "$PYTHON_FOR_BUILD"; then
for interp in python$PACKAGE_VERSION python3 python; do
which $interp >/dev/null 2>&1 || continue
if $interp -c "import sys;sys.exit(not '.'.join(str(n) for n in sys.version_info@<:@:2@:>@) == '$PACKAGE_VERSION')"; then
break
fi
interp=
done
if test x$interp = x; then
AC_MSG_ERROR([python$PACKAGE_VERSION interpreter not found])
fi
AC_MSG_RESULT($interp)
PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/cat pybuilddir.txt:)$(srcdir)/Lib PYTHON_SYSCONFIGDATA_NAME=sysconfigdata$(ABIFLAGS)$(MACHDEP)$(MULTIARCH) '$interp
fi
elif test "$cross_compiling" = maybe; then
AC_MSG_ERROR([Cross compiling required --host=HOST-TUPLE and --build=ARCH])
else
PYTHON_FOR_BUILD='./$(BUILDPYTHON) -E'
fi
AC_SUBST(PYTHON_FOR_BUILD)
The issue is a failing edge case here:
for interp in python$PACKAGE_VERSION python3 python; do
which $interp >/dev/null 2>&1 || continue
where interp keeps it's last value doesn't trigger the empty check here:
if test x$interp = x; then
AC_MSG_ERROR([python$PACKAGE_VERSION interpreter not found])
fi
Note that there's an explicit clearing of interp when the python version isn't a match:
if $interp-c"import sys;sys.exit(not '.'.join(str(n) for n in sys.version_info@<:@:2@:>@) == '$PACKAGE_VERSION')"; thenbreakfiinterp=
The fix should be pretty straightforward:
for interp in python$PACKAGE_VERSION python3 python ''; do
adding '' as the last possible interpreter means one hasn't been found up to that point and allows configure to properly fail
$/python3/targetbuild# PYTHON_FOR_REGEN=/python3/hostbuild/python ac_cv_file__dev_ptmx=yes ac_cv_file__dev_ptc=no ac_cv_buggy_getaddrinfo=no ../configure --build=x86-linux-gnu --host=aarch64-linux-gnu --enable-loadable-sqlite-extensions --enable-option-checking=fatal --enable-shared --with-system-expat --with-system-ffi --without-ensurepip
checking build system type... x86-unknown-linux-gnu
checking host system type... aarch64-unknown-linux-gnu
checking for python3.9... /python3/hostbuild/python
checking for python interpreter for cross build... configure: error: python3.9 interpreter not found
It will continue to work when a proper interpreter is found
$/python3/targetbuild# PATH=/python3/hostbuild:$PATH PYTHON_FOR_REGEN=/python3/hostbuild/python ac_cv_file__dev_ptmx=yes ac_cv_file__dev_ptc=no ac_cv_buggy_getaddrinfo=no ../configure --build=x86-linux-gnu --host=aarch64-linux-gnu --enable-loadable-sqlite-extensions --enable-option-checking=fatal --enable-shared --with-system-expat --with-system-ffi --without-ensurepip
checking build system type... x86-unknown-linux-gnu
checking host system type... aarch64-unknown-linux-gnu
checking for python3.9... /python3/hostbuild/python
checking for python interpreter for cross build... Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
python
This should help highlight any inconsistent environment between configuring and building.
Activity
vfazio commentedon May 6, 2021
When trying to cross compile python3.9,
configureattempts to find a strict python 3.9 version match, however if it fails it still attempts to usepythonin PYTHON_FOR_BUILD instead of failing outright like the code implies it should$/python3/targetbuild# which python3.9 python3 python
/usr/bin/python3
$/python3/targetbuild# python3 --version
Python 3.7.3
$/python3/targetbuild# PYTHON_FOR_REGEN=/python3/hostbuild/python \
ac_cv_file__dev_ptmx=yes \
ac_cv_file__dev_ptc=no \
ac_cv_buggy_getaddrinfo=no \
../configure --build=x86-linux-gnu \
--host=aarch64-linux-gnu \
--enable-loadable-sqlite-extensions \
--enable-option-checking=fatal \
--enable-shared \
--with-system-expat \
--with-system-ffi \
--without-ensurepip
checking build system type... x86-unknown-linux-gnu
checking host system type... aarch64-unknown-linux-gnu
checking for python3.9... /python3/hostbuild/python
checking for python interpreter for cross build... python
...
$/python3/targetbuild# grep PYTHON_FOR_BUILD config.log
PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/
cat pybuilddir.txt:)$(srcdir)/Lib PYTHON_SYSCONFIGDATA_NAME=sysconfigdata$(ABIFLAGS)$(MACHDEP)$(MULTIARCH) python'in configure
if test "$cross_compiling" = yes; then
AC_MSG_CHECKING([for python interpreter for cross build])
if test -z "$PYTHON_FOR_BUILD"; then
for interp in python$PACKAGE_VERSION python3 python; do
which $interp >/dev/null 2>&1 || continue
if $interp -c "import sys;sys.exit(not '.'.join(str(n) for n in sys.version_info@<:@:2@:>@) == '$PACKAGE_VERSION')"; then
break
fi
interp=
done
if test x$interp = x; then
AC_MSG_ERROR([python$PACKAGE_VERSION interpreter not found])
fi
AC_MSG_RESULT($interp)
PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/
cat pybuilddir.txt:)$(srcdir)/Lib PYTHON_SYSCONFIGDATA_NAME=sysconfigdata$(ABIFLAGS)$(MACHDEP)$(MULTIARCH) '$interpfi
elif test "$cross_compiling" = maybe; then
AC_MSG_ERROR([Cross compiling required --host=HOST-TUPLE and --build=ARCH])
else
PYTHON_FOR_BUILD='./$(BUILDPYTHON) -E'
fi
AC_SUBST(PYTHON_FOR_BUILD)
The issue is a failing edge case here:
where interp keeps it's last value doesn't trigger the empty check here:
Note that there's an explicit clearing of interp when the python version isn't a match:
The fix should be pretty straightforward:
adding '' as the last possible interpreter means one hasn't been found up to that point and allows configure to properly fail
$/python3/targetbuild# PYTHON_FOR_REGEN=/python3/hostbuild/python ac_cv_file__dev_ptmx=yes ac_cv_file__dev_ptc=no ac_cv_buggy_getaddrinfo=no ../configure --build=x86-linux-gnu --host=aarch64-linux-gnu --enable-loadable-sqlite-extensions --enable-option-checking=fatal --enable-shared --with-system-expat --with-system-ffi --without-ensurepip
checking build system type... x86-unknown-linux-gnu
checking host system type... aarch64-unknown-linux-gnu
checking for python3.9... /python3/hostbuild/python
checking for python interpreter for cross build... configure: error: python3.9 interpreter not found
It will continue to work when a proper interpreter is found
$/python3/targetbuild# PATH=/python3/hostbuild:$PATH PYTHON_FOR_REGEN=/python3/hostbuild/python ac_cv_file__dev_ptmx=yes ac_cv_file__dev_ptc=no ac_cv_buggy_getaddrinfo=no ../configure --build=x86-linux-gnu --host=aarch64-linux-gnu --enable-loadable-sqlite-extensions --enable-option-checking=fatal --enable-shared --with-system-expat --with-system-ffi --without-ensurepip
checking build system type... x86-unknown-linux-gnu
checking host system type... aarch64-unknown-linux-gnu
checking for python3.9... /python3/hostbuild/python
checking for python interpreter for cross build... Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
python
This should help highlight any inconsistent environment between configuring and building.
vfazio commentedon Apr 11, 2022
This should probably be closed in favor of #90039 which was merged in #29835.
It's still an issue for versions prior to 3.11