diff --git a/build/pkgs/_python3.12/distros/debian.txt b/build/pkgs/_python3.12/distros/debian.txt index 20ac50641bf..04a63409a04 100644 --- a/build/pkgs/_python3.12/distros/debian.txt +++ b/build/pkgs/_python3.12/distros/debian.txt @@ -1,4 +1,3 @@ python3.12 python3.12-dev -python3.12-distutils python3.12-venv diff --git a/build/pkgs/python3/SPKG.rst b/build/pkgs/python3/SPKG.rst index 6d9c7de71e7..8e2cb6f1360 100644 --- a/build/pkgs/python3/SPKG.rst +++ b/build/pkgs/python3/SPKG.rst @@ -8,16 +8,15 @@ By default, Sage will try to use system's ``python3`` to set up a virtual environment, a.k.a. `venv `_ rather than building a Python 3 installation from scratch. -Sage will accept versions 3.9.x to 3.10.x. +Sage will accept versions 3.9.x to 3.11.x. You can also use ``--with-python=/path/to/python3_binary`` to tell Sage to use ``/path/to/python3_binary`` to set up the venv. Note that setting up the venv requires a number of Python modules to be available within the Python in question. Currently, -as of Sage 9.7, these modules are as follows: ``sqlite3``, ``ctypes``, ``math``, -``hashlib``, ``socket``, ``zlib``, ``distutils.core``, ``ssl`` - -they will be checked for by the ``configure`` script. +as of Sage 10.3, these modules are as follows: ``sqlite3``, ``ctypes``, ``math``, +``hashlib``, ``socket``, ``zlib``, ``ssl``, ``ensurepip``. -Use the ``configure`` option ``--without-system-python3`` in case you want Python 3 +Use the ``configure`` option ``--without-system-python3`` if you want Python 3 built from scratch. diff --git a/build/pkgs/python3/distros/alpine.txt b/build/pkgs/python3/distros/alpine.txt index 596ce366935..c4fe4764a15 100644 --- a/build/pkgs/python3/distros/alpine.txt +++ b/build/pkgs/python3/distros/alpine.txt @@ -1 +1,2 @@ python3-dev +py3-setuptools diff --git a/build/pkgs/python3/distros/debian.txt b/build/pkgs/python3/distros/debian.txt index 6b3ebf766dc..71f8637f37e 100644 --- a/build/pkgs/python3/distros/debian.txt +++ b/build/pkgs/python3/distros/debian.txt @@ -1,4 +1,4 @@ python3 libpython3-dev -python3-distutils +python3-setuptools python3-venv diff --git a/build/pkgs/python3/distros/fedora.txt b/build/pkgs/python3/distros/fedora.txt index 07358a92e89..ba7b5ea9b21 100644 --- a/build/pkgs/python3/distros/fedora.txt +++ b/build/pkgs/python3/distros/fedora.txt @@ -1 +1,2 @@ python3-devel +python-setuptools diff --git a/build/pkgs/python3/distros/freebsd.txt b/build/pkgs/python3/distros/freebsd.txt index e650785f225..d7bf687a0a3 100644 --- a/build/pkgs/python3/distros/freebsd.txt +++ b/build/pkgs/python3/distros/freebsd.txt @@ -1 +1,2 @@ lang/python +devel/py-setuptools diff --git a/build/pkgs/python3/distros/homebrew.txt b/build/pkgs/python3/distros/homebrew.txt index 1054bbddaff..3ae3509605d 100644 --- a/build/pkgs/python3/distros/homebrew.txt +++ b/build/pkgs/python3/distros/homebrew.txt @@ -1,2 +1,3 @@ # This installs /usr/local/bin/python3 -> python3.9 python3 +python-setuptools diff --git a/build/pkgs/python3/distros/macports.txt b/build/pkgs/python3/distros/macports.txt index 92826c681b4..60bf435e3ce 100644 --- a/build/pkgs/python3/distros/macports.txt +++ b/build/pkgs/python3/distros/macports.txt @@ -1 +1,2 @@ python310 +py-setuptools diff --git a/build/pkgs/python3/distros/opensuse.txt b/build/pkgs/python3/distros/opensuse.txt index 760ddd76f2c..de3b7dcc464 100644 --- a/build/pkgs/python3/distros/opensuse.txt +++ b/build/pkgs/python3/distros/opensuse.txt @@ -1 +1,2 @@ python3${PYTHON_MINOR}-devel +python3${PYTHON_MINOR}-setuptools diff --git a/build/pkgs/python3/distros/void.txt b/build/pkgs/python3/distros/void.txt index 07358a92e89..ab50f2d9b07 100644 --- a/build/pkgs/python3/distros/void.txt +++ b/build/pkgs/python3/distros/void.txt @@ -1 +1,2 @@ python3-devel +python3-setuptools diff --git a/build/pkgs/python3/spkg-configure.m4 b/build/pkgs/python3/spkg-configure.m4 index 9e3d51b2e98..08aad53f36f 100644 --- a/build/pkgs/python3/spkg-configure.m4 +++ b/build/pkgs/python3/spkg-configure.m4 @@ -24,8 +24,8 @@ SAGE_SPKG_CONFIGURE([python3], [ dnl Check if we can do venv with a system python3 dnl instead of building our own copy. dnl Trac #31160: We no longer check for readline here. - check_modules="sqlite3, ctypes, math, hashlib, socket, zlib, distutils.core, ssl, ensurepip" - AC_CACHE_CHECK([for python3 >= ]MIN_VERSION[, < ]LT_VERSION[ with modules $check_modules], [ac_cv_path_PYTHON3], [ + check_modules="sqlite3, ctypes, math, hashlib, socket, zlib, ssl, ensurepip" + AC_CACHE_CHECK([for python3 >= ]MIN_VERSION[, < ]LT_VERSION[ with modules $check_modules and setuptools/distutils], [ac_cv_path_PYTHON3], [ AS_IF([test x"$ac_path_PYTHON3" != x], [dnl checking explicitly specified $with_python AC_MSG_RESULT([]) AC_PATH_PROG([ac_path_PYTHON3], [$ac_path_PYTHON3]) @@ -40,7 +40,7 @@ SAGE_SPKG_CONFIGURE([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 >= ]MIN_VERSION[, < ]LT_VERSION[ with modules $check_modules]) + AC_MSG_CHECKING([for python3 >= ]MIN_VERSION[, < ]LT_VERSION[ with modules $check_modules and setuptools/distutils]) ]) AS_IF([test -z "$ac_cv_path_PYTHON3"], [ AC_MSG_ERROR([the python3 selected using --with-python=$with_python is not suitable]) diff --git a/m4/sage_check_python_for_venv.m4 b/m4/sage_check_python_for_venv.m4 index da89e93a7ed..363f08c1138 100644 --- a/m4/sage_check_python_for_venv.m4 +++ b/m4/sage_check_python_for_venv.m4 @@ -16,11 +16,23 @@ AC_DEFUN([SAGE_CHECK_PYTHON_FOR_VENV], [ AX_COMPARE_VERSION([$python3_version], [ge], MIN_VERSION, [ AX_COMPARE_VERSION([$python3_version], [lt], LT_VERSION, [ dnl Because the system python is not used directly but rather in a venv without site-packages, - dnl we test whether the module will be available in a venv. + dnl we should test whether the module will be available in a venv. dnl Otherwise, some system site-package may be providing this module to the system python. + dnl However, on Python >= 3.12, we need setuptools to run our extension compilation tests + dnl because distutils has been removed from the standard library. + AX_COMPARE_VERSION([$python3_version], [ge], [3.12.0], [ + conftest_venv_options="--system-site-packages" + distutils_core="setuptools" + distutils_extension="setuptools.extension" + ], [ + conftest_venv_options= + distutils_core="distutils.core" + distutils_extension="distutils.extension" + ]) + all_required_modules="]REQUIRED_MODULES[, $distutils_core, $distutils_extension" 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[" 2>& ]AS_MESSAGE_LOG_FD, [ + AS_IF(["]PYTHON_EXE[" build/bin/sage-venv $conftest_venv_options conftest_venv && conftest_venv/bin/python3 -c "import $all_required_modules" 2>& ]AS_MESSAGE_LOG_FD, [ AS_VAR_SET([python3_result], [yes]) SAGE_PYTHON_CHECK_DISTUTILS([CC="$CC" CXX="$CXX" conftest_venv/bin/python3], [ SAGE_ARCHFLAGS="unset" @@ -46,7 +58,7 @@ AC_DEFUN([SAGE_CHECK_PYTHON_FOR_VENV], [ AC_MSG_RESULT([$python3_result]) ]) ], [ - AC_MSG_RESULT([no, the version is in the supported range but cannot import one of the required modules: ]REQUIRED_MODULES) + AC_MSG_RESULT([no, the version is in the supported range but cannot import one of the required modules: $all_required_modules]) ]) ], [ AC_MSG_RESULT([no, $python3_version is too recent]) @@ -123,8 +135,9 @@ PyInit_spam(void) ]) AC_LANG_POP([C]) cat > conftest.py < conftest.py <