Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
3-manifolds
GitHub Repository: 3-manifolds/Sage_macOS
Path: blob/main/Sage_framework/files/patches/sage.patch
242 views
1
--- ../repo/sage/local/var/lib/sage/venv-python3.11.1/bin/sage 2023-03-30 15:47:17
2
+++ sage 2022-12-09 14:04:52
3
@@ -77,9 +77,49 @@
4
}
5
6
# Resolve the links in $0 so that local/bin/sage can be executed from
7
-# a symlink (Issue #30888).
8
+# a symlink (Trac #30888).
9
SELF=$(resolvelinks "${0}")
10
11
+#####################################################################
12
+# Get the installation-specific symlink
13
+#####################################################################
14
+
15
+SAVED_CWD="`pwd`"
16
+CURDIR=$(resolvelinks "`dirname $0`")
17
+cd "$CURDIR/../../../../../../"
18
+VERSION_DIR="`pwd`"
19
+cd "$SAVED_CWD"
20
+runpath_sh=$VERSION_DIR/local/var/lib/sage/runpath.sh
21
+if [ -x "$runpath_sh" ]; then
22
+ . "$runpath_sh"
23
+else
24
+ echo could not find $VERSION_DIR/local/var/lib/sage/runpath.sh
25
+fi
26
+
27
+# Check that the installation specific symlink points to this sage
28
+# root directory. If not, try to reset it. Strangely, this script
29
+# can get called a second time and when that happens we will have
30
+# $TARGET == $SAGE_SYMLINK. We had better not set the symlink to
31
+# point to itself!
32
+
33
+OLD_VERSION_DIR=`readlink $SAGE_SYMLINK`
34
+if [ "$VERSION_DIR" != "$OLD_VERSION_DIR" ] && [ "$VERSION_DIR" != "$SAGE_SYMLINK" ]; then
35
+ rm -f $SAGE_SYMLINK 2> /dev/null
36
+ if [ $? -ne 0 ]; then
37
+ OWNER=$(stat -f '%Su' $SAGE_SYMLINK)
38
+ echo
39
+ echo "Oh no!"
40
+ echo "You do not have permission to reconfigure this SageMath."
41
+ echo "Please ask $OWNER to open the app."
42
+ echo
43
+ read -p "The app will exit when you press a key."
44
+ exit
45
+ fi
46
+ if [ "$VERSION_DIR" != "$SAGE_SYMLINK" ]; then
47
+ ln -s "$VERSION_DIR" "$SAGE_SYMLINK"
48
+ fi
49
+fi
50
+
51
# Display the current version of Sage
52
# usage: sage_version [-v]
53
# -v display the full version banner including release date
54
@@ -216,20 +238,24 @@
55
exit 127
56
fi
57
58
-# Check for '-i' etc. before sourcing sage-env: running "make"
59
+# Check for '-i' before sourcing sage-env: running "make"
60
# should be run outside of the Sage shell.
61
-case "$1" in
62
- -i|-f|-p)
63
- # Delegate further option handling to the non-installed sage-site script.
64
- # (These options become unavailable if the directory $SAGE_ROOT is removed.)
65
- if [ -d "$SAGE_ROOT" ]; then
66
- exec "$SAGE_ROOT/build/bin/sage-site" "$@"
67
- # fallthrough if there is no sage-site script
68
- fi
69
- echo >&2 "Error: unknown option: $1"
70
- exit 1
71
- ;;
72
-esac
73
+if [ "$1" = '-f' ]; then
74
+ # -f is an alias for -i -f
75
+ set -- -i "$@"
76
+fi
77
+if [ "$1" = '-i' ]; then
78
+ if [ -z "$2" ]; then
79
+ PACKAGE="the package"
80
+ else
81
+ PACKAGE=$2
82
+ fi
83
+ echo "Sorry, this binary distribution does not support installing sage packages."
84
+ echo "If $PACKAGE is available from pypi you may install it by running"
85
+ echo " %pip install $PACKAGE"
86
+ echo "from the sage prompt."
87
+ exit 1
88
+fi
89
90
#####################################################################
91
# Report information about the Sage environment
92
@@ -275,6 +301,18 @@
93
export DOT_SAGE="$HOME/.sage"
94
fi
95
96
+#####################################################################
97
+# Special environment variables used for the macOS app to prevent
98
+# writing into the application bundle and breaking the signature.
99
+# and to block warnings about using "if x is 1" and to find the
100
+# Jupyter kernel.
101
+#####################################################################
102
+export PYTHONPYCACHEPREFIX="$DOT_SAGE/pycache"
103
+export PIP_CONFIG_FILE="$SAGE_SYMLINK/Resources/pip.conf"
104
+export PYTHONWARNINGS=ignore
105
+if ! [ -e /usr/local/share/jupyter/kernels/SageMath-"$SAGE_VERSION"/kernel.json ]; then
106
+ export JUPYTER_PATH=$SAGE_SYMLINK/Resources/jupyter
107
+fi
108
109
#####################################################################
110
# Helper functions
111
@@ -479,13 +517,6 @@
112
echo " Sage documentation for \"string\"."
113
echo " --search_src ... -- same as --grep"
114
echo " --search_doc ... -- same as --grepdoc"
115
- echo " --fixdoctests file.py"
116
- echo " -- Run doctests and replace output of failing doctests"
117
- echo " with actual output."
118
- echo " --fiximports <files|dir>"
119
- echo " -- Replace imports from sage.PAC.KAGE.all by specific"
120
- echo " imports when sage.PAC.KAGE is an implicit namespace"
121
- echo " package"
122
fi
123
echo " --sh [...] -- run a shell with Sage environment variables"
124
echo " as they are set in the runtime of Sage"
125
@@ -981,11 +1012,6 @@
126
exec sage-startuptime.py "$@"
127
fi
128
129
-if [ "$1" = '-fiximports' -o "$1" = '--fiximports' ]; then
130
- shift
131
- exec sage-python -m sage.misc.replace_dot_all "$@"
132
-fi
133
-
134
if [ "$1" = '-tox' -o "$1" = '--tox' ]; then
135
shift
136
if [ -n "$SAGE_SRC" -a -f "$SAGE_SRC/tox.ini" ]; then
137
138