Path: blob/main/Sage_framework/files/patches/sage.patch
242 views
--- ../repo/sage/local/var/lib/sage/venv-python3.11.1/bin/sage 2023-03-30 15:47:171+++ sage 2022-12-09 14:04:522@@ -77,9 +77,49 @@3}45# Resolve the links in $0 so that local/bin/sage can be executed from6-# a symlink (Issue #30888).7+# a symlink (Trac #30888).8SELF=$(resolvelinks "${0}")910+#####################################################################11+# Get the installation-specific symlink12+#####################################################################13+14+SAVED_CWD="`pwd`"15+CURDIR=$(resolvelinks "`dirname $0`")16+cd "$CURDIR/../../../../../../"17+VERSION_DIR="`pwd`"18+cd "$SAVED_CWD"19+runpath_sh=$VERSION_DIR/local/var/lib/sage/runpath.sh20+if [ -x "$runpath_sh" ]; then21+ . "$runpath_sh"22+else23+ echo could not find $VERSION_DIR/local/var/lib/sage/runpath.sh24+fi25+26+# Check that the installation specific symlink points to this sage27+# root directory. If not, try to reset it. Strangely, this script28+# can get called a second time and when that happens we will have29+# $TARGET == $SAGE_SYMLINK. We had better not set the symlink to30+# point to itself!31+32+OLD_VERSION_DIR=`readlink $SAGE_SYMLINK`33+if [ "$VERSION_DIR" != "$OLD_VERSION_DIR" ] && [ "$VERSION_DIR" != "$SAGE_SYMLINK" ]; then34+ rm -f $SAGE_SYMLINK 2> /dev/null35+ if [ $? -ne 0 ]; then36+ OWNER=$(stat -f '%Su' $SAGE_SYMLINK)37+ echo38+ echo "Oh no!"39+ echo "You do not have permission to reconfigure this SageMath."40+ echo "Please ask $OWNER to open the app."41+ echo42+ read -p "The app will exit when you press a key."43+ exit44+ fi45+ if [ "$VERSION_DIR" != "$SAGE_SYMLINK" ]; then46+ ln -s "$VERSION_DIR" "$SAGE_SYMLINK"47+ fi48+fi49+50# Display the current version of Sage51# usage: sage_version [-v]52# -v display the full version banner including release date53@@ -216,20 +238,24 @@54exit 12755fi5657-# Check for '-i' etc. before sourcing sage-env: running "make"58+# Check for '-i' before sourcing sage-env: running "make"59# should be run outside of the Sage shell.60-case "$1" in61- -i|-f|-p)62- # Delegate further option handling to the non-installed sage-site script.63- # (These options become unavailable if the directory $SAGE_ROOT is removed.)64- if [ -d "$SAGE_ROOT" ]; then65- exec "$SAGE_ROOT/build/bin/sage-site" "$@"66- # fallthrough if there is no sage-site script67- fi68- echo >&2 "Error: unknown option: $1"69- exit 170- ;;71-esac72+if [ "$1" = '-f' ]; then73+ # -f is an alias for -i -f74+ set -- -i "$@"75+fi76+if [ "$1" = '-i' ]; then77+ if [ -z "$2" ]; then78+ PACKAGE="the package"79+ else80+ PACKAGE=$281+ fi82+ echo "Sorry, this binary distribution does not support installing sage packages."83+ echo "If $PACKAGE is available from pypi you may install it by running"84+ echo " %pip install $PACKAGE"85+ echo "from the sage prompt."86+ exit 187+fi8889#####################################################################90# Report information about the Sage environment91@@ -275,6 +301,18 @@92export DOT_SAGE="$HOME/.sage"93fi9495+#####################################################################96+# Special environment variables used for the macOS app to prevent97+# writing into the application bundle and breaking the signature.98+# and to block warnings about using "if x is 1" and to find the99+# Jupyter kernel.100+#####################################################################101+export PYTHONPYCACHEPREFIX="$DOT_SAGE/pycache"102+export PIP_CONFIG_FILE="$SAGE_SYMLINK/Resources/pip.conf"103+export PYTHONWARNINGS=ignore104+if ! [ -e /usr/local/share/jupyter/kernels/SageMath-"$SAGE_VERSION"/kernel.json ]; then105+ export JUPYTER_PATH=$SAGE_SYMLINK/Resources/jupyter106+fi107108#####################################################################109# Helper functions110@@ -479,13 +517,6 @@111echo " Sage documentation for \"string\"."112echo " --search_src ... -- same as --grep"113echo " --search_doc ... -- same as --grepdoc"114- echo " --fixdoctests file.py"115- echo " -- Run doctests and replace output of failing doctests"116- echo " with actual output."117- echo " --fiximports <files|dir>"118- echo " -- Replace imports from sage.PAC.KAGE.all by specific"119- echo " imports when sage.PAC.KAGE is an implicit namespace"120- echo " package"121fi122echo " --sh [...] -- run a shell with Sage environment variables"123echo " as they are set in the runtime of Sage"124@@ -981,11 +1012,6 @@125exec sage-startuptime.py "$@"126fi127128-if [ "$1" = '-fiximports' -o "$1" = '--fiximports' ]; then129- shift130- exec sage-python -m sage.misc.replace_dot_all "$@"131-fi132-133if [ "$1" = '-tox' -o "$1" = '--tox' ]; then134shift135if [ -n "$SAGE_SRC" -a -f "$SAGE_SRC/tox.ini" ]; then136137138