diff --git a/build/bin/sage-bootstrap-python b/build/bin/sage-bootstrap-python deleted file mode 100755 index d51ae4a751b..00000000000 --- a/build/bin/sage-bootstrap-python +++ /dev/null @@ -1,78 +0,0 @@ -#!/bin/sh - -# Run the system python. -# -# This is only for use by the build toolchain. -# -# (It has nothing to do with the python3 that configure --with-system-python3 -# is looking for in build/pkgs/python3/spkg-configure.m4.) - -if [ -z "$SAGE_ORIG_PATH" ]; then - # If not we're running from within sage-env just set the existing path - SAGE_ORIG_PATH="$PATH" -fi -IFS=':' -NEW_PATH="" -for path in $SAGE_ORIG_PATH -do - case "$path" in - */.pyenv/shims*);; - *) NEW_PATH="$NEW_PATH$path:";; - esac -done -unset IFS -SAGE_ORIG_PATH=${NEW_PATH%%':'} -# In particular, it is invoked by "bootstrap -d" for sage-download-file, -# i.e., before a configure run, and by "sage-spkg", also for sage-download-file. -# So it needs to find a python that has the urllib module. -# For example, on Debian buster, the python3-minimal package does NOT provide it. -# -# Also, Issue #20023 removed the vendored argparse library from sage_bootstrap, -# so we test that python is new enough (>= 2.7) to run it. -# -# See https://github.com/sagemath/sage/issues/29090 - -# Issue #29890: Our first choice is "python", not "python3". This is to avoid -# a defect of sage_bootstrap on macOS regarding SSL URLs. - -# Issue #30177: Also check for hashlib.sha1 to guard against broken python2 -# from old homebrew installations. Also check whether the current directory -# is accessible by this python; this is to guard on WSL against Pythons -# installed somewhere else in Windows. - -# Issue #29285: Do not accept pythons that manipulate PATH, such as -# the shims provided by pyenv. - -# Issue #30008: Make it work even if the environment tries to sabotage UTF-8 -# operation in Python 3.0.x-3.6.x by setting LC_ALL=C or similar. - -if [ "$LC_ALL" = "C" -o "$LANG" = "C" -o "$LC_CTYPE" = "C" ]; then - LC_ALL=$(locale -a | grep -E -i '^(c|en_us)[-.]utf-?8$' | head -n 1) - LANG=$LC_ALL - export LC_ALL - export LANG -fi - -PYTHONS="python python3 python3.12 python3.11 python3.10 python3.9 python3.8 python3.7 python2.7 python3.6 python2" -# Issue #32405: Prefer a Python that provides ssl with SNI, which allows developers -# to download from upstream URLs (configure --enable-download-from-upstream-url), -# in particular from PyPI, which requires SNI. -for PY in $PYTHONS; do - PYTHON="$(PATH="$SAGE_ORIG_PATH" command -v $PY)" - if [ -n "$PYTHON" ]; then - if CHECK_PATH="$PATH" "$PYTHON" -c "import argparse; import urllib; from hashlib import sha1; from ssl import HAS_SNI; assert HAS_SNI; from os import listdir, environ; listdir(\"$(pwd)\"); assert environ[\"PATH\"] == environ[\"CHECK_PATH\"];" 2>/dev/null; then - exec "$PYTHON" "$@" - fi - fi -done -# Second round, no ssl/SNI test. -for PY in $PYTHONS; do - PYTHON="$(PATH="$SAGE_ORIG_PATH" command -v $PY)" - if [ -n "$PYTHON" ]; then - if CHECK_PATH="$PATH" "$PYTHON" -c "import argparse; import urllib; from hashlib import sha1; from os import listdir, environ; listdir(\"$(pwd)\"); assert environ[\"PATH\"] == environ[\"CHECK_PATH\"];" 2>/dev/null; then - exec "$PYTHON" "$@" - fi - fi -done -echo >&2 "$0: error: none of $PYTHONS is a suitable Python" -exit 1 diff --git a/build/bin/sage-build-num-threads b/build/bin/sage-build-num-threads index 1ba165b1a21..f8b2bae7c82 100755 --- a/build/bin/sage-build-num-threads +++ b/build/bin/sage-build-num-threads @@ -1,4 +1,4 @@ -#!/usr/bin/env sage-bootstrap-python +#!/usr/bin/env python3 # # Determine the number of threads to be used by Sage. # diff --git a/build/bin/sage-download-file b/build/bin/sage-download-file index 3a369d29274..5d0e21ec9b9 100755 --- a/build/bin/sage-download-file +++ b/build/bin/sage-download-file @@ -1,4 +1,4 @@ -#!/usr/bin/env sage-bootstrap-python +#!/usr/bin/env python3 # USAGE: # diff --git a/build/bin/sage-flock b/build/bin/sage-flock index 9611cfde80b..18331e8f0b0 100755 --- a/build/bin/sage-flock +++ b/build/bin/sage-flock @@ -1,4 +1,4 @@ -#!/usr/bin/env sage-bootstrap-python +#!/usr/bin/env python3 # vim: set filetype=python: # USAGE: diff --git a/build/bin/sage-print-system-package-command b/build/bin/sage-print-system-package-command index 13bafa22dc0..47ca1d5a168 100755 --- a/build/bin/sage-print-system-package-command +++ b/build/bin/sage-print-system-package-command @@ -97,7 +97,7 @@ function print_shell_command() if [ -z "$WRAP" -o $# -lt 6 ]; then echo "${PROMPT}${quoted}" else - sage-bootstrap-python -c "import textwrap; print(' \\\\\n'.join(textwrap.wrap(r'''${quoted}''', $WRAP, initial_indent=r'''${PROMPT}''', subsequent_indent=r'''${CONTINUATION}''', break_long_words=False, break_on_hyphens=False)))" + python3 -c "import textwrap; print(' \\\\\n'.join(textwrap.wrap(r'''${quoted}''', $WRAP, initial_indent=r'''${PROMPT}''', subsequent_indent=r'''${CONTINUATION}''', break_long_words=False, break_on_hyphens=False)))" fi if [ -n "$OUTPUT_RST" ]; then echo diff --git a/build/bin/sage-spkg-installcheck b/build/bin/sage-spkg-installcheck index a8ef89ba2aa..7f1b697903e 100755 --- a/build/bin/sage-spkg-installcheck +++ b/build/bin/sage-spkg-installcheck @@ -1,4 +1,4 @@ -#!/usr/bin/env sage-bootstrap-python +#!/usr/bin/env python3 # usage: sage-spkg-installcheck [-h] PKG [SAGE_LOCAL] # diff --git a/build/bin/sage-spkg-uninstall b/build/bin/sage-spkg-uninstall index e99a914d6af..af13b527f7e 100755 --- a/build/bin/sage-spkg-uninstall +++ b/build/bin/sage-spkg-uninstall @@ -1,4 +1,4 @@ -#!/usr/bin/env sage-bootstrap-python +#!/usr/bin/env python3 # usage: sage-spkg-uninstall [-h] PKG [SAGE_LOCAL] # diff --git a/build/bin/sage-uncompress-spkg b/build/bin/sage-uncompress-spkg index 98f2c7645d1..c30c9dd4fcf 100755 --- a/build/bin/sage-uncompress-spkg +++ b/build/bin/sage-uncompress-spkg @@ -1,4 +1,4 @@ -#!/usr/bin/env sage-bootstrap-python +#!/usr/bin/env python3 # usage: sage-uncompress-spkg [-h] [-d DIR] PKG [FILE] # diff --git a/build/make/Makefile.in b/build/make/Makefile.in index b26ef0f9c05..3373e6b3d17 100644 --- a/build/make/Makefile.in +++ b/build/make/Makefile.in @@ -33,7 +33,6 @@ SPKG_INST_RELDIR = var/lib/sage/installed # Aliases for mutually exclusive standard packages selected at configure time TOOLCHAIN = @SAGE_TOOLCHAIN@ -PYTHON = python3 MP_LIBRARY = gmp BLAS = openblas @@ -221,12 +220,7 @@ ifneq ($(PYTHON_FOR_VENV),) # 3 only). $(PYTHON) is set in Makefile to python3_venv. # Thus $(inst_python3_venv) will an (order-only) dependency of every Python package. # -# TODO: If we reconfigure to build our own Python after having used the system -# Python, files installed to create the virtualenv should be *removed*. That -# could either be done here by the makefile, or in an spkg-preinst for python3 -ifeq ($(PYTHON),python3) PYTHON = python3_venv -endif inst_python3_venv = $(SAGE_VENV)/$(SPKG_INST_RELDIR)/python3_venv-3.$(PYTHON_MINOR)-$(subst /,-,$(PYTHON_FOR_VENV))$(findstring --system-site-packages,$(SAGE_VENV_FLAGS)) $(SAGE_VENV)/$(SPKG_INST_RELDIR): @@ -313,9 +307,8 @@ all-toolchain: base-toolchain PYTHON_TOOLCHAIN = setuptools pip setuptools_scm wheel flit_core hatchling python_build meson_python # Issue #32056: Avoid installed setuptools leaking into the build of python3 by uninstalling it. -# It will have to be reinstalled anyway because of its dependency on $(PYTHON). -python3-SAGE_LOCAL-no-deps: setuptools-clean -python3-SAGE_VENV-no-deps: setuptools-clean +# python3-SAGE_LOCAL-no-deps: setuptools-clean +# python3-SAGE_VENV-no-deps: setuptools-clean # Everything needed to start up Sage using "./sage". Of course, not # every part of Sage will work. It does not include Maxima for example. diff --git a/build/pkgs/appnope/spkg-install.in b/build/pkgs/appnope/spkg-install.in index 6a9ec337a12..01c5cd85806 100644 --- a/build/pkgs/appnope/spkg-install.in +++ b/build/pkgs/appnope/spkg-install.in @@ -1,7 +1,7 @@ cd src # Only install this package on OS X -if sage-bootstrap-python -c 'from sys import *; exit(0 if platform == "darwin" else 1)'; then +if python3 -c 'from sys import *; exit(0 if platform == "darwin" else 1)'; then sdh_pip_install . else echo "Not OS X, skipping installation of package 'appnope'" diff --git a/build/pkgs/database_stein_watkins_mini/spkg-install.in b/build/pkgs/database_stein_watkins_mini/spkg-install.in deleted file mode 120000 index d7005d17fc4..00000000000 --- a/build/pkgs/database_stein_watkins_mini/spkg-install.in +++ /dev/null @@ -1 +0,0 @@ -../database_stein_watkins/spkg-install.in \ No newline at end of file diff --git a/build/pkgs/database_stein_watkins_mini/spkg-install.in b/build/pkgs/database_stein_watkins_mini/spkg-install.in new file mode 100644 index 00000000000..da13b1e19cc --- /dev/null +++ b/build/pkgs/database_stein_watkins_mini/spkg-install.in @@ -0,0 +1,16 @@ +# spkg-install file for +# * database_stein_watkins +# * database_stein_watkins_mini + +if [ -z "$SAGE_SHARE" ]; then + echo >&2 "SAGE_SHARE undefined ... exiting" + echo >&2 "Maybe run 'sage --sh'?" + exit 1 +fi + +TARGET="${SAGE_SHARE}/stein_watkins" +if [ ! -d "${TARGET}" ]; then + mkdir "${TARGET}" +fi + +exec cp -R src/swdb/* "${TARGET}/" diff --git a/build/pkgs/openblas/spkg-install.in b/build/pkgs/openblas/spkg-install.in index dbfcb6c1a75..a3e33c10195 100644 --- a/build/pkgs/openblas/spkg-install.in +++ b/build/pkgs/openblas/spkg-install.in @@ -3,7 +3,7 @@ cd src # OpenBLAS does not build on 32bit Haswell. Upstream suggests to pass BINARY=32 to default to NEHALEM kernels # See https://github.com/xianyi/OpenBLAS/issues/657 # Right now this affect all 32bit CPUs. -if [ `sage-bootstrap-python -c "from __future__ import print_function; import platform; print(platform.architecture()[0])"` = "32bit" ]; then +if [ `python3 -c "from __future__ import print_function; import platform; print(platform.architecture()[0])"` = "32bit" ]; then echo >&2 "Building a 32bit version of OpenBLAS." OPENBLAS_CONFIGURE="$OPENBLAS_CONFIGURE BINARY=32" fi diff --git a/build/pkgs/openblas/write_pc_file.py b/build/pkgs/openblas/write_pc_file.py index dc5ebff6de3..0c2a16071f3 100755 --- a/build/pkgs/openblas/write_pc_file.py +++ b/build/pkgs/openblas/write_pc_file.py @@ -1,4 +1,4 @@ -#!/usr/bin/env sage-bootstrap-python +#!/usr/bin/env python3 TEMPLATE = """ diff --git a/build/pkgs/sage_docbuild/spkg-install.in b/build/pkgs/sage_docbuild/spkg-install.in deleted file mode 120000 index 428e161a850..00000000000 --- a/build/pkgs/sage_docbuild/spkg-install.in +++ /dev/null @@ -1 +0,0 @@ -../sage_setup/spkg-install.in \ No newline at end of file diff --git a/build/pkgs/sage_docbuild/spkg-install.in b/build/pkgs/sage_docbuild/spkg-install.in new file mode 100644 index 00000000000..da7d7a2870f --- /dev/null +++ b/build/pkgs/sage_docbuild/spkg-install.in @@ -0,0 +1,9 @@ +cd src +if [ "$SAGE_EDITABLE" = yes ]; then + sdh_pip_editable_install . + if [ "$SAGE_WHEELS" = yes ]; then + sdh_build_and_store_wheel --no-isolation . + fi +else + sdh_pip_install . +fi diff --git a/build/pkgs/sagemath_categories/spkg-install.in b/build/pkgs/sagemath_categories/spkg-install.in deleted file mode 120000 index d83cc631c9a..00000000000 --- a/build/pkgs/sagemath_categories/spkg-install.in +++ /dev/null @@ -1 +0,0 @@ -../sagemath_objects/spkg-install.in \ No newline at end of file diff --git a/build/pkgs/sagemath_categories/spkg-install.in b/build/pkgs/sagemath_categories/spkg-install.in new file mode 100644 index 00000000000..53c094fde04 --- /dev/null +++ b/build/pkgs/sagemath_categories/spkg-install.in @@ -0,0 +1,10 @@ +cd src + +export PIP_NO_INDEX=true +export PIP_FIND_LINKS="file://$SAGE_SPKG_WHEELS" + +# First build the sdist, then build the wheel from the sdist. +# https://pypa-build.readthedocs.io/en/latest/#python--m-build +# (Important because sagemath-objects uses MANIFEST.in for filtering.) +# Do not install the wheel. +sdh_build_and_store_wheel --sdist-then-wheel . diff --git a/build/pkgs/sagemath_environment/spkg-install.in b/build/pkgs/sagemath_environment/spkg-install.in deleted file mode 120000 index d83cc631c9a..00000000000 --- a/build/pkgs/sagemath_environment/spkg-install.in +++ /dev/null @@ -1 +0,0 @@ -../sagemath_objects/spkg-install.in \ No newline at end of file diff --git a/build/pkgs/sagemath_environment/spkg-install.in b/build/pkgs/sagemath_environment/spkg-install.in new file mode 100644 index 00000000000..53c094fde04 --- /dev/null +++ b/build/pkgs/sagemath_environment/spkg-install.in @@ -0,0 +1,10 @@ +cd src + +export PIP_NO_INDEX=true +export PIP_FIND_LINKS="file://$SAGE_SPKG_WHEELS" + +# First build the sdist, then build the wheel from the sdist. +# https://pypa-build.readthedocs.io/en/latest/#python--m-build +# (Important because sagemath-objects uses MANIFEST.in for filtering.) +# Do not install the wheel. +sdh_build_and_store_wheel --sdist-then-wheel . diff --git a/build/pkgs/sagemath_repl/spkg-install.in b/build/pkgs/sagemath_repl/spkg-install.in deleted file mode 120000 index d83cc631c9a..00000000000 --- a/build/pkgs/sagemath_repl/spkg-install.in +++ /dev/null @@ -1 +0,0 @@ -../sagemath_objects/spkg-install.in \ No newline at end of file diff --git a/build/pkgs/sagemath_repl/spkg-install.in b/build/pkgs/sagemath_repl/spkg-install.in new file mode 100644 index 00000000000..53c094fde04 --- /dev/null +++ b/build/pkgs/sagemath_repl/spkg-install.in @@ -0,0 +1,10 @@ +cd src + +export PIP_NO_INDEX=true +export PIP_FIND_LINKS="file://$SAGE_SPKG_WHEELS" + +# First build the sdist, then build the wheel from the sdist. +# https://pypa-build.readthedocs.io/en/latest/#python--m-build +# (Important because sagemath-objects uses MANIFEST.in for filtering.) +# Do not install the wheel. +sdh_build_and_store_wheel --sdist-then-wheel . diff --git a/build/sage_bootstrap/creator.py b/build/sage_bootstrap/creator.py index e16002f12f9..f083e75f3cd 100644 --- a/build/sage_bootstrap/creator.py +++ b/build/sage_bootstrap/creator.py @@ -127,9 +127,9 @@ def set_python_data_and_scripts(self, pypi_package_name=None, source='normal', d else: dependencies = '' if source == 'wheel': - dependencies_order_only = 'pip $(PYTHON)' + dependencies_order_only = 'pip' else: - dependencies_order_only = '$(PYTHON_TOOLCHAIN) $(PYTHON)' + dependencies_order_only = '$(PYTHON_TOOLCHAIN)' f.write(dependencies + ' | ' + dependencies_order_only + '\n\n') f.write('----------\nAll lines of this file are ignored except the first.\n') if source == 'normal': diff --git a/build/sage_bootstrap/expand_class.py b/build/sage_bootstrap/expand_class.py index c5bab8a313e..565e23d77ea 100644 --- a/build/sage_bootstrap/expand_class.py +++ b/build/sage_bootstrap/expand_class.py @@ -77,7 +77,7 @@ def include_recursive_dependencies(names, package_name): pkg = Package(package_name) except FileNotFoundError: # Silently ignore unknown packages, - # substitutions such as $(BLAS) $(PYTHON), + # substitutions such as $(BLAS) # and optional dependencies of the form $(find-string ...). return names.add(package_name) diff --git a/build/sage_bootstrap/flock.py b/build/sage_bootstrap/flock.py index bc95a0ecf8f..872fb7d617f 100644 --- a/build/sage_bootstrap/flock.py +++ b/build/sage_bootstrap/flock.py @@ -1,4 +1,4 @@ -#!/usr/bin/env sage-bootstrap-python +#!/usr/bin/env python3 # vim: set filetype=python: """ This script runs the given command under a file lock (similar to the flock diff --git a/build/setup.py b/build/setup.py index b05dcc386ca..16f4ccda4a3 100755 --- a/build/setup.py +++ b/build/setup.py @@ -1,4 +1,4 @@ -#!/usr/bin/env sage-bootstrap-python +#!/usr/bin/env python3 from distutils.core import setup @@ -12,7 +12,7 @@ 'sage_bootstrap.download', 'sage_bootstrap.compat' ], - scripts=['bin/sage-package', 'bin/sage-download-file', 'bin/sage-bootstrap-python'], + scripts=['bin/sage-package', 'bin/sage-download-file'], version='1.0', url='https://www.sagemath.org', ) diff --git a/build/test/runnable.py b/build/test/runnable.py index 75edc551fd6..6424725f60d 100755 --- a/build/test/runnable.py +++ b/build/test/runnable.py @@ -1,4 +1,4 @@ -#!/usr/bin/env sage-bootstrap-python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Utility to test running with different values for ``SAGE_BOOTSTRAP`` diff --git a/configure.ac b/configure.ac index da23266e19b..cad84f85348 100644 --- a/configure.ac +++ b/configure.ac @@ -353,14 +353,6 @@ SAGE_DARWIN_PKG_CONFIG_PATH= AC_CHECK_HEADER([zlib.h], [], [AC_MSG_ERROR([cannot find libz headers. $SAGE_PREREQ_URL])]) -# Check for system python (bootstrap python for build scripts) -AC_MSG_CHECKING([for Python]) -if SAGE_BOOTSTRAP_PYTHON=$(build/bin/sage-bootstrap-python -c "import sys; print(sys.executable)"); then - AC_MSG_RESULT([$SAGE_BOOTSTRAP_PYTHON]) -else - AC_MSG_ERROR([You do not have a suitable version of Python installed]) -fi - # check for liblzma PKG_CHECK_MODULES([liblzma], [liblzma], [], [ @@ -381,7 +373,7 @@ AS_IF([test x"$with_python" = x3], [ AC_MSG_NOTICE([The meaning of the option --with-python has changed in Sage 9.2. Ignoring.]) with_python='' ]) -AS_IFbuild/bin/sage-bootstrap-python([test x"$with_python" = x"no"], +AS_IF([test x"$with_python" = x"no"], [AC_MSG_ERROR([building Sage --without-python is not supported])]) ac_path_PYTHON3="$with_python" diff --git a/src/doc/en/developer/packaging.rst b/src/doc/en/developer/packaging.rst index 0ef010050a9..3d93fd8c657 100644 --- a/src/doc/en/developer/packaging.rst +++ b/src/doc/en/developer/packaging.rst @@ -325,28 +325,12 @@ Likewise for :envvar:`CXXFLAGS`, :envvar:`FCFLAGS`, and :envvar:`F77FLAGS`. code should go in a separate file (e.g. ``spkg-install.py``), and can then be executed from the real ``spkg-install.in`` like: - .. code-block:: text - - exec sage-bootstrap-python spkg-install.py - - or - .. code-block:: text exec python3 spkg-install.py - In more detail: ``sage-bootstrap-python`` runs a version of Python - pre-installed on the machine, which is a build prerequisite of Sage. - Note that ``sage-bootstrap-python`` accepts a wide range of Python - versions, Python >= 2.6 and >= 3.4, see :sage_root:`build/tox.ini` - for details. You should only use ``sage-bootstrap-python`` for - installation tasks that must be able to run before Sage has made - ``python3`` available. It must not be used for running ``pip`` or - ``setup.py`` for any package. - - ``python3`` runs the version of Python managed by Sage (either its - own installation of Python 3 from an SPKG or a venv over a system - python3. You should use this if you are installing a Python package + ``python3`` runs from the venv over a system python3. + You should use this if you are installing a Python package to make sure that the libraries are installed in the right place. Many packages currently do not separate the build and install steps and only