This repository has been archived by the owner on Jan 30, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add spkg-configure.m4 for Python 3 to detect and use a system Python 3.
If a working system Python 3 is detected, the environment variable SAGE_SYSTEM_PYTHON is set to the path of the Python interpreter executable in sage-env-config. Furthermore, if a system Python 3 is used, Sage Makefile will convert SAGE_LOCAL into a virtualenv by using the Python 3 venv package--it installs copies (should we change this to symlinks?) of the system Python, and a pyvenv.cfg file to indicate to Python that SAGE_LOCAL is an alternate virtualenv. We use the venv module to do this rather than the venv CLI, because this does not install the venv activation scripts--we don't need these because sage-env already serves the same purpose.
- Loading branch information
Showing
5 changed files
with
130 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
SAGE_SPKG_CONFIGURE([python3], [ | ||
SAGE_SPKG_DEPCHECK([sqlite libpng bzip2 xz libffi], [ | ||
check_modules="sqlite3, ctypes, math, hashlib, crypt, readline, socket, zlib, distutils.core" | ||
AC_CACHE_CHECK([for python3 >= 3.7, < 3.8 with sqlite3 module], [ac_cv_path_PYTHON3], [ | ||
AC_MSG_RESULT([]) | ||
AC_PATH_PROGS_FEATURE_CHECK([PYTHON3], [python3.7 python3], [ | ||
AC_MSG_CHECKING([... whether $ac_path_PYTHON3 is good]) | ||
python3_version=`"$ac_path_PYTHON3" --version 2>&1 \ | ||
| $SED -n -e 's/\([[0-9]]*\.[[0-9]]*\.[[0-9]]*\).*/\1/p'` | ||
AS_IF([test -n "$python3_version"], [ | ||
AX_COMPARE_VERSION([$python3_version], [ge], [3.7.0], [ | ||
AX_COMPARE_VERSION([$python3_version], [lt], [3.8.0], [ | ||
AS_IF(["$ac_path_PYTHON3" -S -c "import $check_modules"], [ | ||
AC_LANG_PUSH([C]) | ||
AC_LANG_CONFTEST([ | ||
AC_LANG_SOURCE([[ | ||
#define PY_SSIZE_T_CLEAN | ||
#include <Python.h> | ||
static PyMethodDef SpamMethods[] = { | ||
{NULL, NULL, 0, NULL} /* Sentinel */ | ||
}; | ||
static struct PyModuleDef spammodule = { | ||
PyModuleDef_HEAD_INIT, | ||
"spam", /* name of module */ | ||
NULL, /* module documentation, may be NULL */ | ||
-1, /* size of per-interpreter state of the module, | ||
or -1 if the module keeps state in global variables. */ | ||
SpamMethods | ||
}; | ||
PyMODINIT_FUNC | ||
PyInit_spam(void) | ||
{ | ||
PyObject *m; | ||
m = PyModule_Create(&spammodule); | ||
return m; | ||
} | ||
]]) | ||
]) | ||
AC_LANG_POP([C]) | ||
cat > conftest.py <<EOF | ||
from distutils.core import setup | ||
from distutils.extension import Extension | ||
from sys import exit | ||
modules = list((Extension("config_check_distutils", list(("conftest.c",))),)) | ||
setup(name="config_check_distutils", ext_modules=modules) | ||
exit(0) | ||
EOF | ||
AS_IF([$ac_path_PYTHON3 -S conftest.py --quiet build --build-base=conftest.dir], [ | ||
ac_cv_path_PYTHON3="$ac_path_PYTHON3" | ||
ac_path_PYTHON3_found=: | ||
AC_MSG_RESULT([yes]) | ||
dnl introduction for AC_MSG_RESULT printed by AC_CACHE_CHECK | ||
AC_MSG_CHECKING([for python3 >= 3.7, < 3.8 with modules $check_modules]) | ||
], [ | ||
AC_MSG_RESULT([no, the version is in the supported range, and the modules can be imported, but distutils cannot build an extension]) | ||
]) | ||
], [ | ||
AC_MSG_RESULT([no, the version is in the supported range but cannot import one of the required modules: $check_modules]) | ||
]) | ||
], [ | ||
AC_MSG_RESULT([no, $python3_version is too recent]) | ||
]) | ||
], [ | ||
AC_MSG_RESULT([no, $python3_version is too old]) | ||
]) | ||
], [ | ||
AC_MSG_RESULT([no, "$ac_path_PYTHON3 --version" does not work]) | ||
]) | ||
]) | ||
]) | ||
AS_IF([test -z "$ac_cv_path_PYTHON3"], | ||
[sage_spkg_install_python3=yes]) | ||
]) | ||
],,,[ | ||
AS_IF([test x$sage_spkg_install_python3 = xno], [SAGE_SYSTEM_PYTHON="$ac_cv_path_PYTHON3"]) | ||
AC_SUBST(SAGE_SYSTEM_PYTHON) | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters