Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
build/pkgs/python3/spkg-configure.m4: On macOS, if the distutils test…
Browse files Browse the repository at this point in the history
… fails, try using empty ARCHFLAGS
  • Loading branch information
mkoeppe committed Jan 31, 2021
1 parent 4c1596c commit dc5e225
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
6 changes: 5 additions & 1 deletion build/pkgs/python3/spkg-configure.m4
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,14 @@ SAGE_SPKG_CONFIGURE([python3], [
dnl POST
AS_IF([test x$sage_spkg_install_python3 = xno], [
PYTHON_FOR_VENV="$ac_cv_path_PYTHON3"
AS_IF([test "$SAGE_ARCHFLAGS" != "unset"], [
ARCHFLAGS="$SAGE_ARCHFLAGS"
export ARCHFLAGS
])
AS_IF([test -n "$CFLAGS_MARCH"], [
dnl Trac #31228
AC_MSG_CHECKING([whether "$CFLAGS_MARCH" works with the C/C++ compilers configured for building extensions for $PYTHON_FOR_VENV])
SAGE_PYTHON_CHECK_DISTUTILS([CC="$CC" CXX="$CXX" ARCHFLAGS="" CFLAGS="$CFLAGS_MARCH" conftest_venv/bin/python3], [
SAGE_PYTHON_CHECK_DISTUTILS([CC="$CC" CXX="$CXX" CFLAGS="$CFLAGS_MARCH" conftest_venv/bin/python3], [
AC_MSG_RESULT([yes])
], [
AC_MSG_RESULT([no, with these flags, $reason; disabling use of "$CFLAGS_MARCH"])
Expand Down
19 changes: 17 additions & 2 deletions m4/sage_check_python_for_venv.m4
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ AC_DEFUN([SAGE_CHECK_PYTHON_FOR_VENV], [
m4_pushdef([REQUIRED_MODULES], [$4])
m4_pushdef([COMMANDS_IF_GOOD], [$5])
AC_SUBST([SAGE_ARCHFLAGS])
AC_MSG_CHECKING([... whether ]PYTHON_EXE[ is good])
python3_version=`"PYTHON_EXE" --version 2>&1 \
| $SED -n -e 's/\([[0-9]]*\.[[0-9]]*\.[[0-9]]*\).*/\1/p'`
Expand All @@ -19,10 +21,23 @@ AC_DEFUN([SAGE_CHECK_PYTHON_FOR_VENV], [
dnl m4_define([conftest_venv], [config-venv]) .... for debugging only
rm -rf conftest_venv
AS_IF(["]PYTHON_EXE[" build/bin/sage-venv conftest_venv && conftest_venv/bin/python3 -c "import ]REQUIRED_MODULES["], [
SAGE_PYTHON_CHECK_DISTUTILS([CC="$CC" CXX="$CXX" ARCHFLAGS="" conftest_venv/bin/python3], [
SAGE_PYTHON_CHECK_DISTUTILS([CC="$CC" CXX="$CXX" conftest_venv/bin/python3], [
SAGE_ARCHFLAGS="unset"
COMMANDS_IF_GOOD
], [
AC_MSG_RESULT([no, the version is in the supported range, and the modules can be imported, but $reason])
AS_CASE([$host],
[*-*-darwin*], [
dnl #31227: Try if setting ARCHFLAGS to empty fixes it
SAGE_PYTHON_CHECK_DISTUTILS([CC="$CC" CXX="$CXX" ARCHFLAGS="" conftest_venv/bin/python3], [
SAGE_ARCHFLAGS=""
COMMANDS_IF_GOOD
], [
AC_MSG_RESULT([no, the version is in the supported range, and the modules can be imported, but $reason (even with ARCHFLAGS set to empty)])
])
], [
AC_MSG_RESULT([no, the version is in the supported range, and the modules can be imported, but $reason])
]
)
])
], [
AC_MSG_RESULT([no, the version is in the supported range but cannot import one of the required modules: ]REQUIRED_MODULES)
Expand Down
6 changes: 3 additions & 3 deletions src/bin/sage-env
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,9 @@ export F95="$FC"
# If the environment defines ARCHFLAGS, even when empty, then take that.
# Otherwise, use the configured value; but if that is "unset", do not set
# the variable at all.
if [ "{$ARCHFLAGS-unset}" = "unset" ]; then
if [ "${CONFIGURED_ARCHFLAGS-unset}" != "unset" ]; then
export ARCHFLAGS="${CONFIGURED_ARCHFLAGS}"
if [ "${ARCHFLAGS-unset}" = "unset" ]; then
if [ "${SAGE_ARCHFLAGS-unset}" != "unset" ]; then
export ARCHFLAGS="${SAGE_ARCHFLAGS}"
fi
fi

Expand Down
2 changes: 1 addition & 1 deletion src/bin/sage-env-config.in
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ CONFIGURED_CXX="@CXX@"
CONFIGURED_FC="@FC@"
CONFIGURED_OBJC="@OBJC@"
CONFIGURED_OBJCXX="@OBJCXX@"
CONFIGURED_ARCHFLAGS="@ARCHFLAGS@"

#######################################
# Other configuration (exported)
Expand All @@ -51,5 +50,6 @@ CONFIGURED_ARCHFLAGS="@ARCHFLAGS@"
#######################################
# Other configuration (not exported, only used in sage-env)
#######################################
SAGE_ARCHFLAGS="@SAGE_ARCHFLAGS@"
SAGE_PKG_CONFIG_PATH="@SAGE_PKG_CONFIG_PATH@"
SAGE_MACOSX_DEPLOYMENT_TARGET="@SAGE_MACOSX_DEPLOYMENT_TARGET@"

0 comments on commit dc5e225

Please sign in to comment.