passagemath-environment 10.4.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- passagemath_environment-10.4.1.data/scripts/sage +1140 -0
- passagemath_environment-10.4.1.data/scripts/sage-env +667 -0
- passagemath_environment-10.4.1.data/scripts/sage-num-threads.py +105 -0
- passagemath_environment-10.4.1.data/scripts/sage-python +2 -0
- passagemath_environment-10.4.1.data/scripts/sage-venv-config +42 -0
- passagemath_environment-10.4.1.data/scripts/sage-version.sh +9 -0
- passagemath_environment-10.4.1.dist-info/METADATA +76 -0
- passagemath_environment-10.4.1.dist-info/RECORD +70 -0
- passagemath_environment-10.4.1.dist-info/WHEEL +5 -0
- passagemath_environment-10.4.1.dist-info/top_level.txt +1 -0
- sage/all__sagemath_environment.py +4 -0
- sage/env.py +496 -0
- sage/features/__init__.py +981 -0
- sage/features/all.py +126 -0
- sage/features/bliss.py +85 -0
- sage/features/cddlib.py +38 -0
- sage/features/coxeter3.py +45 -0
- sage/features/csdp.py +83 -0
- sage/features/cython.py +38 -0
- sage/features/databases.py +302 -0
- sage/features/dvipng.py +40 -0
- sage/features/ecm.py +42 -0
- sage/features/ffmpeg.py +119 -0
- sage/features/four_ti_2.py +55 -0
- sage/features/fricas.py +66 -0
- sage/features/gap.py +86 -0
- sage/features/gfan.py +38 -0
- sage/features/giac.py +30 -0
- sage/features/graph_generators.py +171 -0
- sage/features/graphviz.py +117 -0
- sage/features/igraph.py +44 -0
- sage/features/imagemagick.py +138 -0
- sage/features/interfaces.py +256 -0
- sage/features/internet.py +65 -0
- sage/features/jmol.py +44 -0
- sage/features/join_feature.py +146 -0
- sage/features/kenzo.py +77 -0
- sage/features/latex.py +300 -0
- sage/features/latte.py +85 -0
- sage/features/lrs.py +164 -0
- sage/features/mcqd.py +45 -0
- sage/features/meataxe.py +46 -0
- sage/features/mip_backends.py +114 -0
- sage/features/msolve.py +68 -0
- sage/features/nauty.py +70 -0
- sage/features/normaliz.py +43 -0
- sage/features/palp.py +65 -0
- sage/features/pandoc.py +42 -0
- sage/features/pdf2svg.py +41 -0
- sage/features/phitigra.py +42 -0
- sage/features/pkg_systems.py +195 -0
- sage/features/polymake.py +43 -0
- sage/features/poppler.py +58 -0
- sage/features/rubiks.py +180 -0
- sage/features/sagemath.py +1205 -0
- sage/features/sat.py +103 -0
- sage/features/singular.py +48 -0
- sage/features/sirocco.py +45 -0
- sage/features/sphinx.py +71 -0
- sage/features/standard.py +38 -0
- sage/features/symengine_py.py +44 -0
- sage/features/tdlib.py +38 -0
- sage/features/threejs.py +75 -0
- sage/features/topcom.py +67 -0
- sage/misc/all__sagemath_environment.py +2 -0
- sage/misc/package.py +570 -0
- sage/misc/package_dir.py +621 -0
- sage/misc/temporary_file.py +546 -0
- sage/misc/viewer.py +369 -0
- sage/version.py +5 -0
@@ -0,0 +1,1140 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
# WARNING: this function is copy/pasted from both src/bin/sage-env and
|
4
|
+
# the top-level "sage" script. Please keep them synchronized.
|
5
|
+
resolvelinks() {
|
6
|
+
# $in is what still needs to be converted (normally has no starting slash)
|
7
|
+
in="$1"
|
8
|
+
# $out is the part which is converted (normally ends with trailing slash)
|
9
|
+
out="./"
|
10
|
+
|
11
|
+
# Move stuff from $in to $out
|
12
|
+
while [ -n "$in" ]; do
|
13
|
+
# Normalize $in by replacing consecutive slashes by one slash
|
14
|
+
in=$(echo "${in}" | sed 's://*:/:g')
|
15
|
+
|
16
|
+
# If $in starts with a slash, remove it and set $out to the root
|
17
|
+
in_without_slash=${in#/}
|
18
|
+
if [ "$in" != "$in_without_slash" ]; then
|
19
|
+
in=$in_without_slash
|
20
|
+
out="/"
|
21
|
+
continue
|
22
|
+
fi
|
23
|
+
|
24
|
+
# Check that the directory $out exists by trying to cd to it.
|
25
|
+
# If this fails, then cd will show an error message (unlike
|
26
|
+
# test -d "$out"), so no need to be more verbose.
|
27
|
+
( cd "$out" ) || return $?
|
28
|
+
|
29
|
+
|
30
|
+
# Get the first component of $in
|
31
|
+
f=${in%%/*}
|
32
|
+
|
33
|
+
# If it is not a symbolic link, simply move it to $out
|
34
|
+
if [ ! -L "$out$f" ]; then
|
35
|
+
in=${in#"$f"}
|
36
|
+
out="$out$f"
|
37
|
+
|
38
|
+
# If the new $in starts with a slash, move it to $out
|
39
|
+
in_without_slash=${in#/}
|
40
|
+
if [ "$in" != "$in_without_slash" ]; then
|
41
|
+
in=$in_without_slash
|
42
|
+
out="$out/"
|
43
|
+
fi
|
44
|
+
continue
|
45
|
+
fi
|
46
|
+
|
47
|
+
# Now resolve the symbolic link "$f"
|
48
|
+
f_resolved=`readlink -n "$out$f" 2>/dev/null`
|
49
|
+
status=$?
|
50
|
+
# status 127 means readlink could not be found.
|
51
|
+
if [ $status -eq 127 ]; then
|
52
|
+
# We don't have "readlink", try a stupid "ls" hack instead.
|
53
|
+
# This will fail if we have filenames like "a -> b".
|
54
|
+
fls=`ls -l "$out$f" 2>/dev/null`
|
55
|
+
status=$?
|
56
|
+
f_resolved=${fls##*-> }
|
57
|
+
|
58
|
+
# If $fls equals $f_resolved, then certainly
|
59
|
+
# something is wrong
|
60
|
+
if [ $status -eq 0 -a "$fls" = "$f_resolved" ]; then
|
61
|
+
echo >&2 "Cannot parse output from ls -l '$out$f'"
|
62
|
+
return 1
|
63
|
+
fi
|
64
|
+
fi
|
65
|
+
if [ $status -ne 0 ]; then
|
66
|
+
echo >&2 "Cannot read symbolic link '$out$f'"
|
67
|
+
return $status
|
68
|
+
fi
|
69
|
+
|
70
|
+
# In $in, replace $f by $f_resolved (leave $out alone)
|
71
|
+
in="${in#${f}}"
|
72
|
+
in="${f_resolved}${in}"
|
73
|
+
done
|
74
|
+
|
75
|
+
# Return $out
|
76
|
+
echo "$out"
|
77
|
+
}
|
78
|
+
|
79
|
+
# Resolve the links in $0 so that local/bin/sage can be executed from
|
80
|
+
# a symlink (Issue #30888).
|
81
|
+
SELF=$(resolvelinks "${0}")
|
82
|
+
|
83
|
+
# Display the current version of Sage
|
84
|
+
# usage: sage_version [-v]
|
85
|
+
# -v display the full version banner including release date
|
86
|
+
sage_version() {
|
87
|
+
if [ -f "${SELF}-version.sh" ]; then
|
88
|
+
. "${SELF}-version.sh"
|
89
|
+
else
|
90
|
+
. "$SAGE_ROOT/src/bin/sage-version.sh"
|
91
|
+
fi
|
92
|
+
|
93
|
+
if [ "$1" = "-v" ]; then
|
94
|
+
echo "${SAGE_VERSION_BANNER}"
|
95
|
+
else
|
96
|
+
echo "${SAGE_VERSION}"
|
97
|
+
fi
|
98
|
+
}
|
99
|
+
|
100
|
+
usage() {
|
101
|
+
sage_version -v
|
102
|
+
#### 1.......................26..................................................78
|
103
|
+
#### |.....................--.|...................................................|
|
104
|
+
echo
|
105
|
+
echo "Running Sage:"
|
106
|
+
if command -v sage-ipython &>/dev/null; then
|
107
|
+
echo
|
108
|
+
echo " file.[sage|py|spyx] -- run given .sage, .py or .spyx file"
|
109
|
+
echo " -c <cmd> -- evaluate cmd as sage code"
|
110
|
+
echo " --notebook=[...] -- start the Sage notebook (valid options are"
|
111
|
+
echo " 'default', 'jupyter', 'jupyterlab', and 'export')"
|
112
|
+
echo " Current default is 'jupyter'"
|
113
|
+
echo " -n, --notebook -- shortcut for --notebook=default"
|
114
|
+
echo " --nodotsage -- run Sage without using the user's .sage directory:"
|
115
|
+
echo " create and use a temporary .sage directory instead"
|
116
|
+
echo " -t [options] <--all|files|dir>"
|
117
|
+
echo " -- test examples in .py, .pyx, .sage, .tex or .rst files"
|
118
|
+
echo " selected options:"
|
119
|
+
echo " --long - include lines with the phrase 'long time'"
|
120
|
+
echo " --verbose - print debugging output during the test"
|
121
|
+
echo " --optional - controls which optional tests are run"
|
122
|
+
echo " --help - show all testing options"
|
123
|
+
else
|
124
|
+
echo " (not installed currently, "
|
125
|
+
echo " to install, run sage --pip install sagemath-repl)"
|
126
|
+
fi
|
127
|
+
echo
|
128
|
+
echo "Running external programs:"
|
129
|
+
echo
|
130
|
+
command -v gap &>/dev/null && \
|
131
|
+
echo " --gap [...] -- run Sage's Gap with given arguments"
|
132
|
+
command -v gp &>/dev/null && \
|
133
|
+
echo " --gp [...] -- run Sage's PARI/GP calculator with given arguments"
|
134
|
+
echo " --pip [...] -- invoke pip, the Python package manager"
|
135
|
+
command -v maxima &>/dev/null && \
|
136
|
+
echo " --maxima [...] -- run Sage's Maxima with given arguments"
|
137
|
+
command -v mwrank &>/dev/null && \
|
138
|
+
echo " --mwrank [...] -- run Sage's mwrank with given arguments"
|
139
|
+
echo " --python [...], --python3 [...] -- run the Python 3 interpreter"
|
140
|
+
command -v R &>/dev/null && \
|
141
|
+
echo " -R [...] -- run Sage's R with given arguments"
|
142
|
+
command -v singular &>/dev/null && \
|
143
|
+
echo " --singular [...] -- run Sage's singular with given arguments"
|
144
|
+
echo
|
145
|
+
echo "Getting help:"
|
146
|
+
echo
|
147
|
+
echo " -v, --version -- display Sage version information"
|
148
|
+
echo " -h, -?, --help -- print this help message"
|
149
|
+
echo " --advanced -- list all command line options"
|
150
|
+
if [ -d "$SAGE_ROOT" ]; then
|
151
|
+
exec "$SAGE_ROOT/build/bin/sage-site" "-h"
|
152
|
+
fi
|
153
|
+
exit 0
|
154
|
+
}
|
155
|
+
|
156
|
+
# 'usage_advanced', which prints a longer help message, is defined
|
157
|
+
# below, after sourcing sage-env.
|
158
|
+
|
159
|
+
# Determine SAGE_ROOT, SAGE_LOCAL, and SAGE_VENV.
|
160
|
+
unset SAGE_VENV
|
161
|
+
if [ -x "${SELF}-config" ]; then
|
162
|
+
# optional sage-config console script, installed by sage_conf
|
163
|
+
export SAGE_ROOT=$("${SELF}-config" SAGE_ROOT)
|
164
|
+
export SAGE_LOCAL=$("${SELF}-config" SAGE_LOCAL)
|
165
|
+
fi
|
166
|
+
if [ -f "${SELF}-src-env-config" ]; then
|
167
|
+
# Not installed script, present only in src/bin/
|
168
|
+
SAGE_SRC_ENV_CONFIG=1
|
169
|
+
. "${SELF}-src-env-config" >&2
|
170
|
+
fi
|
171
|
+
if [ -z "$SAGE_VENV" -a -x "${SELF}-venv-config" ]; then
|
172
|
+
# installed by setup.py
|
173
|
+
export SAGE_VENV=$("${SELF}-venv-config" SAGE_VENV)
|
174
|
+
fi
|
175
|
+
if [ -f "${SELF}-env-config" ]; then
|
176
|
+
# As of Issue #22731, sage-env-config is optional.
|
177
|
+
. "${SELF}-env-config" >&2
|
178
|
+
fi
|
179
|
+
|
180
|
+
#####################################################################
|
181
|
+
# Special options to be processed without sage-env
|
182
|
+
#####################################################################
|
183
|
+
|
184
|
+
# Check for '--nodotsage' before sourcing sage-env; otherwise sage-env
|
185
|
+
# will already have set some environment variables with the old
|
186
|
+
# setting for DOT_SAGE.
|
187
|
+
if [ "$1" = '--nodotsage' ]; then
|
188
|
+
export DOT_SAGE=`mktemp -d ${TMPDIR:-/tmp}/dotsageXXXXXX`
|
189
|
+
shift
|
190
|
+
command "${SELF}" "$@"
|
191
|
+
status=$?
|
192
|
+
rm -rf "$DOT_SAGE"
|
193
|
+
exit $status
|
194
|
+
fi
|
195
|
+
|
196
|
+
# build_sage, sage -b, sage -br, etc. could also be moved to
|
197
|
+
# build/bin/sage-site. See #29111; but OTOH #34627.
|
198
|
+
|
199
|
+
build_sage() {
|
200
|
+
( cd "$SAGE_ROOT" && make sagelib-no-deps ) || exit $?
|
201
|
+
}
|
202
|
+
|
203
|
+
# Check for '-i' etc. before sourcing sage-env: running "make"
|
204
|
+
# should be run outside of the Sage shell.
|
205
|
+
case "$1" in
|
206
|
+
-i|-f|-p)
|
207
|
+
# Delegate further option handling to the non-installed sage-site script.
|
208
|
+
# (These options become unavailable if the directory $SAGE_ROOT is removed.)
|
209
|
+
if [ -d "$SAGE_ROOT" ]; then
|
210
|
+
exec "$SAGE_ROOT/build/bin/sage-site" "$@"
|
211
|
+
# fallthrough if there is no sage-site script
|
212
|
+
fi
|
213
|
+
echo >&2 "Error: unknown option: $1"
|
214
|
+
exit 1
|
215
|
+
;;
|
216
|
+
-b)
|
217
|
+
build_sage
|
218
|
+
exit 0
|
219
|
+
;;
|
220
|
+
-br|--br)
|
221
|
+
build_sage
|
222
|
+
shift; set -- -r "$@" # delegate to handling of "-r" below, after sourcing sage-env
|
223
|
+
;;
|
224
|
+
-bn|--build-and-notebook)
|
225
|
+
build_sage
|
226
|
+
shift; set -- -n "$@" # delegate to handling of "-n" below, after sourcing sage-env
|
227
|
+
;;
|
228
|
+
-ba)
|
229
|
+
( cd "$SAGE_ROOT" && make sagelib-clean )
|
230
|
+
build_sage
|
231
|
+
exit 0
|
232
|
+
;;
|
233
|
+
-bt*)
|
234
|
+
build_sage
|
235
|
+
switch_without_b=-${1#-b}
|
236
|
+
shift; set -- $switch_without_b "$@" # delegate to handling of "-t...." below, after sourcing sage-env
|
237
|
+
;;
|
238
|
+
esac
|
239
|
+
|
240
|
+
#####################################################################
|
241
|
+
# Report information about the Sage environment
|
242
|
+
#####################################################################
|
243
|
+
|
244
|
+
if [ "$1" = '-dumpversion' -o "$1" = '--dumpversion' ]; then
|
245
|
+
sage_version
|
246
|
+
exit 0
|
247
|
+
fi
|
248
|
+
|
249
|
+
if [ "$1" = '-v' -o "$1" = '-version' -o "$1" = '--version' ]; then
|
250
|
+
sage_version -v
|
251
|
+
exit 0
|
252
|
+
fi
|
253
|
+
|
254
|
+
if [ "$1" = '-root' -o "$1" = '--root' ]; then
|
255
|
+
echo "$SAGE_ROOT"
|
256
|
+
exit 0
|
257
|
+
fi
|
258
|
+
|
259
|
+
|
260
|
+
#####################################################################
|
261
|
+
# Source sage-env ($SELF is the name of this "sage" script, so we can just
|
262
|
+
# append -env to that). We redirect stdout to stderr, which is safer
|
263
|
+
# for scripts.
|
264
|
+
#####################################################################
|
265
|
+
if [ -f "${SELF}-env" ]; then
|
266
|
+
. "${SELF}-env" >&2
|
267
|
+
if [ $? -ne 0 ]; then
|
268
|
+
echo >&2 "Error setting environment variables by sourcing '${SELF}-env';"
|
269
|
+
echo >&2 "possibly contact sage-devel (see http://groups.google.com/group/sage-devel)."
|
270
|
+
exit 1
|
271
|
+
fi
|
272
|
+
fi
|
273
|
+
|
274
|
+
if [ -f "${SELF}-src-env-config.in" ]; then
|
275
|
+
# The sage script is being run out of SAGE_ROOT/src/bin.
|
276
|
+
# In this case, put this directory in the front of the PATH.
|
277
|
+
export PATH="$SAGE_SRC/bin:$PATH"
|
278
|
+
fi
|
279
|
+
|
280
|
+
if [ -z "$DOT_SAGE" ]; then
|
281
|
+
export DOT_SAGE="$HOME/.sage"
|
282
|
+
fi
|
283
|
+
|
284
|
+
|
285
|
+
#####################################################################
|
286
|
+
# Helper functions
|
287
|
+
#####################################################################
|
288
|
+
|
289
|
+
# Prepare for running Sage, either interactively or non-interactively.
|
290
|
+
sage_setup() {
|
291
|
+
# Check that we're not in a source tarball which hasn't been built yet (#13561).
|
292
|
+
if [ "$SAGE_SRC_ENV_CONFIG" = 1 ] && [ ! -z "$SAGE_VENV" ] && [ ! -x "$SAGE_VENV/bin/sage" ]; then
|
293
|
+
echo >&2 '************************************************************************'
|
294
|
+
echo >&2 'It seems that you are attempting to run Sage from an unpacked source'
|
295
|
+
echo >&2 'tarball, but you have not compiled it yet (or maybe the build has not'
|
296
|
+
echo >&2 'finished). You should run `make` in the SAGE_ROOT directory first.'
|
297
|
+
echo >&2 'If you did not intend to build Sage from source, you should download'
|
298
|
+
echo >&2 'a binary tarball instead. Read README.txt for more information.'
|
299
|
+
echo >&2 '************************************************************************'
|
300
|
+
exit 1
|
301
|
+
fi
|
302
|
+
|
303
|
+
if [ ! -d "$IPYTHONDIR" ]; then
|
304
|
+
# make sure that $DOT_SAGE exists so that ipython will happily
|
305
|
+
# create its config directories there. If DOT_SAGE doesn't
|
306
|
+
# exist, ipython complains.
|
307
|
+
mkdir -p -m 700 "$DOT_SAGE"
|
308
|
+
fi
|
309
|
+
sage-cleaner &>/dev/null &
|
310
|
+
}
|
311
|
+
|
312
|
+
|
313
|
+
# Start an interactive Sage session, this function never returns.
|
314
|
+
interactive_sage() {
|
315
|
+
sage_setup
|
316
|
+
exec sage-ipython "$@" -i
|
317
|
+
}
|
318
|
+
|
319
|
+
#####################################################################
|
320
|
+
# sage --advanced
|
321
|
+
#####################################################################
|
322
|
+
|
323
|
+
usage_advanced() {
|
324
|
+
sage_version -v
|
325
|
+
#### 1.......................26..................................................78
|
326
|
+
#### |.....................--.|...................................................|
|
327
|
+
echo
|
328
|
+
if command -v sage-ipython &>/dev/null; then
|
329
|
+
echo "Running Sage, the most common options:"
|
330
|
+
echo
|
331
|
+
echo " file.[sage|py|spyx] -- run given .sage, .py or .spyx file"
|
332
|
+
echo " -c cmd -- evaluate cmd as sage code. For example,"
|
333
|
+
echo " \"sage -c 'print(factor(35))'\" will"
|
334
|
+
echo " print \"5 * 7\"."
|
335
|
+
echo
|
336
|
+
echo "Running Sage, other options:"
|
337
|
+
echo
|
338
|
+
echo " --preparse file.sage -- preparse \"file.sage\", and produce"
|
339
|
+
echo " the corresponding Python file"
|
340
|
+
echo " \"file.sage.py\""
|
341
|
+
echo " -q -- quiet; start with no banner"
|
342
|
+
echo " --min -- do not populate global namespace"
|
343
|
+
echo " (must be first option)"
|
344
|
+
echo " --nodotsage -- run Sage without using the user's"
|
345
|
+
echo " .sage directory: create and use a temporary"
|
346
|
+
echo " .sage directory instead."
|
347
|
+
echo " --gthread, --qthread, --q4thread, --wthread, --pylab"
|
348
|
+
echo " -- pass the option through to IPython"
|
349
|
+
echo " --simple-prompt -- pass the option through to IPython: use"
|
350
|
+
echo " this option with sage-shell mode in emacs"
|
351
|
+
echo " --gdb -- run Sage under the control of gdb"
|
352
|
+
echo " --lldb -- run Sage under the control of lldb"
|
353
|
+
else
|
354
|
+
echo "Running Sage:"
|
355
|
+
echo " (not installed currently, "
|
356
|
+
echo " to install, run sage --pip install sagemath-repl)"
|
357
|
+
fi
|
358
|
+
echo
|
359
|
+
echo "Running external programs:"
|
360
|
+
echo
|
361
|
+
echo " --cython [...] -- run Cython with the given arguments"
|
362
|
+
command -v cython &>/dev/null || \
|
363
|
+
echo " (not installed, run sage --pip install cython)"
|
364
|
+
echo " --ecl [...], --lisp [...] -- run Sage's copy of ECL (Embeddable"
|
365
|
+
echo " Common Lisp) with the given arguments"
|
366
|
+
echo " --gap [...] -- run Sage's Gap with the given arguments"
|
367
|
+
echo " --gap3 [...] -- run Sage's Gap3 with the given arguments"
|
368
|
+
command -v gap3 &>/dev/null || \
|
369
|
+
echo " (not installed currently, run sage -i gap3)"
|
370
|
+
echo " --git [...] -- run Sage's Git with the given arguments"
|
371
|
+
echo " --gp [...] -- run Sage's PARI/GP calculator with the"
|
372
|
+
echo " given arguments"
|
373
|
+
echo " --ipython [...], --ipython3 [...]"
|
374
|
+
echo " -- run Sage's IPython using the default"
|
375
|
+
echo " environment (not Sage), passing additional"
|
376
|
+
echo " additional options to IPython"
|
377
|
+
echo " --jupyter [...] -- run Sage's Jupyter with given arguments"
|
378
|
+
echo " --kash [...] -- run Sage's Kash with the given arguments"
|
379
|
+
command -v kash &>/dev/null || \
|
380
|
+
echo " (not installed currently, run sage -i kash)"
|
381
|
+
echo " --M2 [...] -- run Sage's Macaulay2 with the given arguments"
|
382
|
+
command -v M2 &>/dev/null || \
|
383
|
+
echo " (not installed currently, run sage -i macaulay2)"
|
384
|
+
echo " --maxima [...] -- run Sage's Maxima with the given arguments"
|
385
|
+
echo " --mwrank [...] -- run Sage's mwrank with the given arguments"
|
386
|
+
echo " --pip [...] -- invoke pip, the Python package manager"
|
387
|
+
echo " --polymake [...] -- run Sage's Polymake with given arguments"
|
388
|
+
command -v polymake &>/dev/null || \
|
389
|
+
echo " (not installed currently, run sage -i polymake)"
|
390
|
+
echo " --python [...], --python3 [...]"
|
391
|
+
echo " -- run the Python 3 interpreter"
|
392
|
+
echo " -R [...] -- run Sage's R with the given arguments"
|
393
|
+
echo " --singular [...] -- run Sage's singular with the given arguments"
|
394
|
+
echo " --sqlite3 [...] -- run Sage's sqlite3 with given arguments"
|
395
|
+
echo
|
396
|
+
echo "Running the notebook:"
|
397
|
+
echo
|
398
|
+
echo " -n [...], --notebook=[...]"
|
399
|
+
echo " -- start the notebook; valid options include"
|
400
|
+
echo " 'default', 'jupyter', 'jupyterlab', and 'export'."
|
401
|
+
echo " Current default is 'jupyter'."
|
402
|
+
echo " Run \"sage --notebook --help\" for more details."
|
403
|
+
echo
|
404
|
+
#### 1.......................26..................................................78
|
405
|
+
#### |.....................--.|...................................................|
|
406
|
+
echo "Testing files:"
|
407
|
+
echo
|
408
|
+
if command -v sage-runtests &>/dev/null; then
|
409
|
+
echo " -t [options] <files|dir> -- test examples in .py, .pyx, .sage"
|
410
|
+
echo " or .tex files. Options:"
|
411
|
+
echo " --long -- include lines with the phrase 'long time'"
|
412
|
+
echo " --verbose -- print debugging output during the test"
|
413
|
+
echo " --all -- test all files"
|
414
|
+
echo " --optional -- also test all examples labeled \"# optional\""
|
415
|
+
echo " --only-optional[=tags]"
|
416
|
+
echo " -- if no 'tags' are specified, only run"
|
417
|
+
echo " blocks of tests containing a line labeled"
|
418
|
+
echo " \"# optional\". If a comma-separated"
|
419
|
+
echo " list of tags is specified, only run block"
|
420
|
+
echo " containing a line labeled \"# optional tag\""
|
421
|
+
echo " for any of the tags given, and in these blocks"
|
422
|
+
echo " only run the lines which are unlabeled or"
|
423
|
+
echo " labeled \"# optional\" or labeled"
|
424
|
+
echo " \"# optional tag\" for any of the tags given."
|
425
|
+
echo " --randorder[=seed] -- randomize order of tests"
|
426
|
+
echo " --random-seed[=seed] -- random seed (integer) for fuzzing doctests"
|
427
|
+
echo " --new -- only test files modified since last commit"
|
428
|
+
echo " --initial -- only show the first failure per block"
|
429
|
+
echo " --debug -- drop into PDB after an unexpected error"
|
430
|
+
echo " --failed -- only test files that failed last test"
|
431
|
+
echo " --warn-long [timeout] -- warning if doctest is slow"
|
432
|
+
echo " --only-errors -- only output failures, not successes"
|
433
|
+
echo " --gc=GC -- control garbarge collection (ALWAYS:"
|
434
|
+
echo " collect garbage before every test; NEVER:"
|
435
|
+
echo " disable gc; DEFAULT: Python default)"
|
436
|
+
echo " --short[=secs] -- run as many doctests as possible in about 300"
|
437
|
+
echo " seconds (or the number of seconds given.) This runs"
|
438
|
+
echo " the tests for each module from the top of the file"
|
439
|
+
echo " and skips tests once it exceeds the budget"
|
440
|
+
echo " allocated for that file."
|
441
|
+
echo " --help -- show all doctesting options"
|
442
|
+
echo " --tnew [...] -- equivalent to -t --new"
|
443
|
+
echo " -tp <N> [...] -- like -t above, but tests in parallel using"
|
444
|
+
echo " N threads, with 0 interpreted as min(8, cpu_count())"
|
445
|
+
echo " --testall [options] -- equivalent to -t --all"
|
446
|
+
echo
|
447
|
+
echo " --coverage <files> -- give information about doctest coverage of files"
|
448
|
+
echo " --coverageall -- give summary info about doctest coverage of"
|
449
|
+
echo " all files in the Sage library"
|
450
|
+
echo " --startuptime [module] -- display how long each component of Sage takes to"
|
451
|
+
echo " start up; optionally specify a module to get more"
|
452
|
+
echo " details about that particular module"
|
453
|
+
else
|
454
|
+
echo " -t [options] <files|dir> -- test examples in .py, .pyx, .sage"
|
455
|
+
echo " or .tex files."
|
456
|
+
echo " (not installed currently, to install,"
|
457
|
+
echo " run sage --pip install sagemath-repl)"
|
458
|
+
fi
|
459
|
+
if [ -n "$SAGE_SRC" -a -f "$SAGE_SRC/tox.ini" ]; then
|
460
|
+
echo " --tox [options] <files|dirs> -- general entry point for testing"
|
461
|
+
echo " and linting of the Sage library"
|
462
|
+
echo " -e <envlist> -- run specific test environments; default:"
|
463
|
+
echo " $(echo $(tox -c "$SAGE_SRC" --listenvs 2>/dev/null) | sed 's/ /,/g;')"
|
464
|
+
tox -c "$SAGE_SRC" --listenvs-all -v 2>/dev/null | sed -n '/->/s/^/ /;s/(/\
|
465
|
+
(/;s/->/ --/p;'
|
466
|
+
echo " -p auto -- run test environments in parallel"
|
467
|
+
echo " --help -- show tox help"
|
468
|
+
command -v tox &>/dev/null || \
|
469
|
+
echo " (not installed currently, run sage -i tox)"
|
470
|
+
echo " --pytest [options] <files|dirs> -- run pytest on the Sage library"
|
471
|
+
command -v pytest &>/dev/null || \
|
472
|
+
echo " (not installed currently, run sage -i pytest)"
|
473
|
+
echo " --help -- show pytest help"
|
474
|
+
fi
|
475
|
+
echo
|
476
|
+
echo "Some developer utilities:"
|
477
|
+
echo
|
478
|
+
if [ -n "$SAGE_SRC" -a -d "$SAGE_SRC" ]; then
|
479
|
+
echo " --grep [options] <string>"
|
480
|
+
echo " -- regular expression search through the Sage"
|
481
|
+
echo " library for \"string\". Any options will"
|
482
|
+
echo " get passed to the \"grep\" command."
|
483
|
+
echo " --grepdoc [options] <string>"
|
484
|
+
echo " -- regular expression search through the"
|
485
|
+
echo " Sage documentation for \"string\"."
|
486
|
+
echo " --search_src ... -- same as --grep"
|
487
|
+
echo " --search_doc ... -- same as --grepdoc"
|
488
|
+
echo " --fixdoctests file.py"
|
489
|
+
echo " -- Run doctests and replace output of failing doctests"
|
490
|
+
echo " with actual output."
|
491
|
+
echo " --fiximports <files|dirs>"
|
492
|
+
echo " -- Replace imports from sage.PAC.KAGE.all by specific"
|
493
|
+
echo " imports when sage.PAC.KAGE is an implicit namespace"
|
494
|
+
echo " package"
|
495
|
+
echo " --fixdistributions <files|dirs>"
|
496
|
+
echo " -- Check or update '# sage_setup: distribution'"
|
497
|
+
echo " directives in source files"
|
498
|
+
fi
|
499
|
+
echo " --sh [...] -- run a shell with Sage environment variables"
|
500
|
+
echo " as they are set in the runtime of Sage"
|
501
|
+
echo " --cleaner -- run the Sage cleaner. This cleans up after Sage,"
|
502
|
+
echo " removing temporary directories and spawned processes."
|
503
|
+
echo " (This gets run by Sage automatically, so it is usually"
|
504
|
+
echo " not necessary to run it separately.)"
|
505
|
+
#### 1.......................26..................................................78
|
506
|
+
#### |.....................--.|...................................................|
|
507
|
+
echo "File conversion:"
|
508
|
+
echo
|
509
|
+
echo " --rst2ipynb [...] -- Generates Jupyter notebook (.ipynb) from standalone"
|
510
|
+
echo " reStructuredText source."
|
511
|
+
command -v rst2ipynb &>/dev/null || \
|
512
|
+
echo " (not installed currently, run sage -i rst2ipynb)"
|
513
|
+
echo " --ipynb2rst [...] -- Generates a reStructuredText source file from"
|
514
|
+
echo " a Jupyter notebook (.ipynb)."
|
515
|
+
echo " --sws2rst <sws doc> -- Generates a reStructuredText source file from"
|
516
|
+
echo " a Sage worksheet (.sws) document."
|
517
|
+
command -v sage-sws2rst >&/dev/null || \
|
518
|
+
echo " (not installed currently, run sage -i sage_sws2rst)"
|
519
|
+
echo
|
520
|
+
#### 1.......................26..................................................78
|
521
|
+
#### |.....................--.|...................................................|
|
522
|
+
echo "Valgrind memory debugging:"
|
523
|
+
echo
|
524
|
+
echo " --cachegrind -- run Sage using Valgrind's cachegrind tool. The log"
|
525
|
+
echo " files are named sage-cachegrind.PID can be found in"
|
526
|
+
echo " \$DOT_SAGE"
|
527
|
+
echo " --callgrind -- run Sage using Valgrind's callgrind tool. The log"
|
528
|
+
echo " files are named sage-callgrind.PID can be found in"
|
529
|
+
echo " \$DOT_SAGE"
|
530
|
+
echo " --massif -- run Sage using Valgrind's massif tool. The log"
|
531
|
+
echo " files are named sage-massif.PID can be found in"
|
532
|
+
echo " \$DOT_SAGE"
|
533
|
+
echo " --memcheck -- run Sage using Valgrind's memcheck tool. The log"
|
534
|
+
echo " files are named sage-memcheck.PID can be found in"
|
535
|
+
echo " \$DOT_SAGE"
|
536
|
+
echo " --omega -- run Sage using Valgrind's omega tool. The log"
|
537
|
+
echo " files are named sage-omega.PID can be found in"
|
538
|
+
echo " \$DOT_SAGE"
|
539
|
+
echo " --valgrind -- this is an alias for --memcheck"
|
540
|
+
echo
|
541
|
+
echo "Getting help:"
|
542
|
+
echo
|
543
|
+
echo " -v, --version -- display Sage version information"
|
544
|
+
echo " --dumpversion -- print brief Sage version"
|
545
|
+
echo " -h, -?, --help -- print a short help message"
|
546
|
+
echo " --advanced -- list all command line options"
|
547
|
+
if [ -d "$SAGE_ROOT" ]; then
|
548
|
+
exec "$SAGE_ROOT/build/bin/sage-site" "--advanced"
|
549
|
+
fi
|
550
|
+
echo
|
551
|
+
exit 0
|
552
|
+
}
|
553
|
+
|
554
|
+
if [ $# -gt 0 ]; then
|
555
|
+
if [ "$1" = '-h' -o "$1" = '-?' -o "$1" = '-help' -o "$1" = '--help' ]; then
|
556
|
+
usage
|
557
|
+
fi
|
558
|
+
if [ "$1" = "-advanced" -o "$1" = "--advanced" ]; then
|
559
|
+
usage_advanced
|
560
|
+
fi
|
561
|
+
fi
|
562
|
+
|
563
|
+
|
564
|
+
#####################################################################
|
565
|
+
# Running Sage
|
566
|
+
#####################################################################
|
567
|
+
|
568
|
+
if [ "$1" = '-min' -o "$1" = '--min' ]; then
|
569
|
+
shift
|
570
|
+
export SAGE_IMPORTALL=no
|
571
|
+
fi
|
572
|
+
|
573
|
+
if [ "$1" = '-q' ]; then
|
574
|
+
shift
|
575
|
+
export SAGE_BANNER=no
|
576
|
+
fi
|
577
|
+
|
578
|
+
if [ $# -eq 0 ]; then
|
579
|
+
interactive_sage
|
580
|
+
fi
|
581
|
+
|
582
|
+
#####################################################################
|
583
|
+
# Other basic options
|
584
|
+
#####################################################################
|
585
|
+
|
586
|
+
if [ "$1" = '-c' ]; then
|
587
|
+
shift
|
588
|
+
sage_setup
|
589
|
+
unset TERM # See Issue #12263
|
590
|
+
exec sage-eval "$@"
|
591
|
+
fi
|
592
|
+
|
593
|
+
if [ "$1" = '-preparse' -o "$1" = "--preparse" ]; then
|
594
|
+
shift
|
595
|
+
exec sage-preparse "$@"
|
596
|
+
fi
|
597
|
+
|
598
|
+
if [ "$1" = '-cleaner' -o "$1" = '--cleaner' ]; then
|
599
|
+
exec sage-cleaner
|
600
|
+
fi
|
601
|
+
|
602
|
+
#####################################################################
|
603
|
+
# Run Sage's versions of Python, pip, IPython, Jupyter.
|
604
|
+
#####################################################################
|
605
|
+
|
606
|
+
if [ "$1" = '-pip' -o "$1" = '--pip' -o "$1" = "--pip3" ]; then
|
607
|
+
shift
|
608
|
+
exec python3 -m pip --disable-pip-version-check "$@"
|
609
|
+
fi
|
610
|
+
|
611
|
+
if [ "$1" = '-python' -o "$1" = '--python' -o "$1" = '-python3' -o "$1" = '--python3' ]; then
|
612
|
+
shift
|
613
|
+
exec python3 "$@"
|
614
|
+
fi
|
615
|
+
|
616
|
+
if [ "$1" = '-ipython' -o "$1" = '--ipython' -o "$1" = '-ipython3' -o "$1" = '--ipython3' ]; then
|
617
|
+
shift
|
618
|
+
exec ipython3 "$@"
|
619
|
+
fi
|
620
|
+
|
621
|
+
if [ "$1" = '-jupyter' -o "$1" = '--jupyter' ]; then
|
622
|
+
shift
|
623
|
+
exec jupyter "$@"
|
624
|
+
fi
|
625
|
+
|
626
|
+
#####################################################################
|
627
|
+
# Run Sage's versions of its component packages
|
628
|
+
#####################################################################
|
629
|
+
|
630
|
+
if [ "$1" = "-cython" -o "$1" = '--cython' -o "$1" = '-pyrex' -o "$1" = "--pyrex" ]; then
|
631
|
+
shift
|
632
|
+
exec cython "$@"
|
633
|
+
fi
|
634
|
+
|
635
|
+
if [ "$1" = '-gap' -o "$1" = '--gap' ]; then
|
636
|
+
shift
|
637
|
+
# Use "-A" to avoid warnings about missing packages. The gap
|
638
|
+
# interface and libgap within sage both already do this.
|
639
|
+
exec gap -A "$@"
|
640
|
+
fi
|
641
|
+
|
642
|
+
if [ "$1" = '-gap3' -o "$1" = '--gap3' ]; then
|
643
|
+
shift
|
644
|
+
exec gap3 "$@"
|
645
|
+
fi
|
646
|
+
|
647
|
+
if [ "$1" = '-gp' -o "$1" = '--gp' ]; then
|
648
|
+
shift
|
649
|
+
exec gp "$@"
|
650
|
+
fi
|
651
|
+
|
652
|
+
if [ "$1" = '-polymake' -o "$1" = '--polymake' ]; then
|
653
|
+
shift
|
654
|
+
exec polymake "$@"
|
655
|
+
fi
|
656
|
+
|
657
|
+
if [ "$1" = '-singular' -o "$1" = '--singular' ]; then
|
658
|
+
shift
|
659
|
+
exec Singular "$@"
|
660
|
+
fi
|
661
|
+
|
662
|
+
if [ "$1" = '-sqlite3' -o "$1" = '--sqlite3' ]; then
|
663
|
+
shift
|
664
|
+
exec sqlite3 "$@"
|
665
|
+
fi
|
666
|
+
|
667
|
+
if [ "$1" = '-ecl' -o "$1" = '--ecl' ]; then
|
668
|
+
shift
|
669
|
+
exec ecl "$@"
|
670
|
+
fi
|
671
|
+
|
672
|
+
if [ "$1" = '-lisp' -o "$1" = '--lisp' ]; then
|
673
|
+
shift
|
674
|
+
exec ecl "$@"
|
675
|
+
fi
|
676
|
+
|
677
|
+
if [ "$1" = '-kash' -o "$1" = '--kash' ]; then
|
678
|
+
shift
|
679
|
+
exec kash "$@"
|
680
|
+
fi
|
681
|
+
|
682
|
+
if [ "$1" = '-maxima' -o "$1" = '--maxima' ]; then
|
683
|
+
shift
|
684
|
+
maxima_cmd=$(sage-config MAXIMA 2>/dev/null)
|
685
|
+
if [ -z "${maxima_cmd}" ]; then
|
686
|
+
maxima_cmd="maxima"
|
687
|
+
fi
|
688
|
+
exec $maxima_cmd "$@"
|
689
|
+
fi
|
690
|
+
|
691
|
+
if [ "$1" = '-mwrank' -o "$1" = '--mwrank' ]; then
|
692
|
+
shift
|
693
|
+
exec mwrank "$@"
|
694
|
+
fi
|
695
|
+
|
696
|
+
if [ "$1" = '-M2' -o "$1" = '--M2' ]; then
|
697
|
+
shift
|
698
|
+
exec M2 "$@"
|
699
|
+
fi
|
700
|
+
|
701
|
+
if [ "$1" = '-R' -o "$1" = '--R' ]; then
|
702
|
+
shift
|
703
|
+
exec R "$@"
|
704
|
+
fi
|
705
|
+
|
706
|
+
if [ "$1" = '-git' -o "$1" = '--git' ]; then
|
707
|
+
shift
|
708
|
+
exec git "$@"
|
709
|
+
fi
|
710
|
+
|
711
|
+
#####################################################################
|
712
|
+
# sage --sh and sage --buildsh
|
713
|
+
#####################################################################
|
714
|
+
|
715
|
+
if [ "$1" = '-sh' -o "$1" = '--sh' -o "$1" = '-buildsh' -o "$1" = '--buildsh' ]; then
|
716
|
+
# AUTHORS:
|
717
|
+
# - Carl Witty and William Stein: initial version
|
718
|
+
# - Craig Citro: add options for not loading profile
|
719
|
+
# - Martin Albrecht: fix zshell prompt (#11866)
|
720
|
+
# - John Palmieri: shorten the prompts, and don't print messages if
|
721
|
+
# there are more arguments to 'sage -sh' (#11790)
|
722
|
+
if [ -z "$SAGE_SHPROMPT_PREFIX" ]; then
|
723
|
+
SAGE_SHPROMPT_PREFIX=sage-sh
|
724
|
+
fi
|
725
|
+
if [ "$1" = '-buildsh' -o "$1" = '--buildsh' ]; then
|
726
|
+
if [ ! -r "$SAGE_ROOT"/build/bin/sage-build-env-config ]; then
|
727
|
+
echo "error: '$SAGE_ROOT' does not contain build/bin/sage-build-env-config. Run configure first."
|
728
|
+
exit 1
|
729
|
+
fi
|
730
|
+
. "$SAGE_ROOT"/build/bin/sage-build-env-config || (echo "error: Error sourcing $SAGE_ROOT/build/bin/sage-build-env-config"; exit 1)
|
731
|
+
. "$SAGE_ROOT"/build/bin/sage-build-env || (echo "error: Error sourcing $SAGE_ROOT/build/bin/sage-build-env"; exit 1)
|
732
|
+
export SAGE_SHPROMPT_PREFIX=sage-buildsh
|
733
|
+
# We export it so that recursive invocation of 'sage-sh' from a sage-buildsh shows the sage-buildsh prompt;
|
734
|
+
# this makes sense because all environment variables set in build/bin/sage-build-env-config
|
735
|
+
# and build/bin/sage-build-env are exported.
|
736
|
+
fi
|
737
|
+
shift
|
738
|
+
# If $SHELL is unset, default to bash
|
739
|
+
if [ -z "$SHELL" ]; then
|
740
|
+
export SHELL=bash
|
741
|
+
fi
|
742
|
+
# We must start a new shell with no .profile or .bashrc files
|
743
|
+
# processed, so that we know our path is correct
|
744
|
+
SHELL_NAME=`basename "$SHELL"`
|
745
|
+
# Check for SAGE_SHPROMPT. If defined, use for the prompt. If
|
746
|
+
# not, check for already-defined $PS1, and if defined use that.
|
747
|
+
# $PS1 should only be available if it is defined in
|
748
|
+
# $DOT_SAGE/sagerc.
|
749
|
+
if [ -n "$SAGE_SHPROMPT" ]; then
|
750
|
+
oldPS1=$SAGE_SHPROMPT
|
751
|
+
elif [ -n "$PS1" ]; then
|
752
|
+
oldPS1=$PS1
|
753
|
+
fi
|
754
|
+
# Set the default prompt. If available, use reverse video to
|
755
|
+
# highlight the string "(sage-sh)".
|
756
|
+
if tput rev &>/dev/null; then
|
757
|
+
color_prompt=yes
|
758
|
+
fi
|
759
|
+
case "$SHELL_NAME" in
|
760
|
+
bash)
|
761
|
+
SHELL_OPTS="--norc"
|
762
|
+
if [ "$color_prompt" = yes ]; then
|
763
|
+
PS1="\[$(tput rev)\]($SAGE_SHPROMPT_PREFIX)\[$(tput sgr0)\] \u@\h:\W\$ "
|
764
|
+
else
|
765
|
+
PS1="($SAGE_SHPROMPT_PREFIX) \u@\h:\w\$ "
|
766
|
+
fi
|
767
|
+
export PS1
|
768
|
+
;;
|
769
|
+
csh)
|
770
|
+
# csh doesn't seem to allow the specification of a different
|
771
|
+
# .cshrc file, and the prompt can only be set in this file, so
|
772
|
+
# don't bother changing the prompt.
|
773
|
+
SHELL_OPTS="-f"
|
774
|
+
;;
|
775
|
+
ksh)
|
776
|
+
SHELL_OPTS="-p"
|
777
|
+
if [ "$color_prompt" = yes ] ; then
|
778
|
+
PS1="$(tput rev)($SAGE_SHPROMPT_PREFIX)$(tput sgr0) $USER@`hostname -s`:\${PWD##*/}$ "
|
779
|
+
else
|
780
|
+
PS1="($SAGE_SHPROMPT_PREFIX) $USER@`hostname -s`:\${PWD##*/}$ "
|
781
|
+
fi
|
782
|
+
export PS1
|
783
|
+
;;
|
784
|
+
sh)
|
785
|
+
# We don't really know which shell "sh" is (it could be
|
786
|
+
# bash, but this is not guaranteed), so we don't set
|
787
|
+
# SHELL_OPTS.
|
788
|
+
if [ "$color_prompt" = yes ] ; then
|
789
|
+
PS1="$(tput rev)($SAGE_SHPROMPT_PREFIX)$(tput sgr0) $USER@`hostname -s`:\${PWD##*/}$ "
|
790
|
+
else
|
791
|
+
PS1="($SAGE_SHPROMPT_PREFIX) $USER@`hostname -s`:\${PWD}$ "
|
792
|
+
fi
|
793
|
+
export PS1
|
794
|
+
;;
|
795
|
+
tcsh)
|
796
|
+
# tcsh doesn't seem to allow the specification of a different
|
797
|
+
# .tcshrc file, and the prompt can only be set in this file, so
|
798
|
+
# don't bother changing the prompt.
|
799
|
+
SHELL_OPTS="-f"
|
800
|
+
;;
|
801
|
+
zsh)
|
802
|
+
PS1="%S($SAGE_SHPROMPT_PREFIX)%s %n@%m:%~$ "
|
803
|
+
# In zsh, the system /etc/zshenv is *always* run,
|
804
|
+
# and this may change the path (like on OSX), so we'll
|
805
|
+
# create a temporary .zshenv to reset the path
|
806
|
+
ZDOTDIR=$DOT_SAGE && export ZDOTDIR
|
807
|
+
cat >"$ZDOTDIR/.zshenv" <<EOF
|
808
|
+
PATH="$PATH" && export PATH
|
809
|
+
EOF
|
810
|
+
SHELL_OPTS=" -d"
|
811
|
+
export PS1
|
812
|
+
;;
|
813
|
+
*)
|
814
|
+
export PS1='($SAGE_SHPROMPT_PREFIX) $ '
|
815
|
+
;;
|
816
|
+
esac
|
817
|
+
if [ -n "$oldPS1" ]; then
|
818
|
+
PS1="$oldPS1"
|
819
|
+
export PS1
|
820
|
+
fi
|
821
|
+
if [ $# -eq 0 ]; then
|
822
|
+
# No arguments, so print informative message...
|
823
|
+
echo >&2
|
824
|
+
echo >&2 "Starting subshell with Sage environment variables set. Don't forget"
|
825
|
+
echo >&2 "to exit when you are done. Beware:"
|
826
|
+
echo >&2 " * Do not do anything with other copies of Sage on your system."
|
827
|
+
echo >&2 " * Do not use this for installing Sage packages using \"sage -i\" or for"
|
828
|
+
echo >&2 " running \"make\" at Sage's root directory. These should be done"
|
829
|
+
echo >&2 " outside the Sage shell."
|
830
|
+
echo >&2
|
831
|
+
if [ -n "$SHELL_OPTS" ]; then
|
832
|
+
echo >&2 "Bypassing shell configuration files..."
|
833
|
+
echo >&2
|
834
|
+
fi
|
835
|
+
echo >&2 "Note: SAGE_ROOT=$SAGE_ROOT"
|
836
|
+
"$SHELL" $SHELL_OPTS "$@"
|
837
|
+
status=$?
|
838
|
+
echo "Exited Sage subshell." 1>&2
|
839
|
+
else
|
840
|
+
exec "$SHELL" $SHELL_OPTS "$@"
|
841
|
+
# If 'exec' returns, an error occurred:
|
842
|
+
status=$?
|
843
|
+
echo >&2 "Fatal error: 'exec \"$SHELL\" \"$@\"' failed!"
|
844
|
+
fi
|
845
|
+
exit $status
|
846
|
+
fi
|
847
|
+
|
848
|
+
#####################################################################
|
849
|
+
# File conversion
|
850
|
+
#####################################################################
|
851
|
+
|
852
|
+
if [ "$1" = '-rst2ipynb' -o "$1" = '--rst2ipynb' ]; then
|
853
|
+
shift
|
854
|
+
rst2ipynb --kernel=sagemath "$@"
|
855
|
+
status="${?}"
|
856
|
+
if [ "${status}" -eq "127" ] ; then echo 'rst2ipynb is not installed, please run "sage -i rst2ipynb"' ; fi
|
857
|
+
exit ${status}
|
858
|
+
fi
|
859
|
+
|
860
|
+
if [ "$1" = '-ipynb2rst' -o "$1" = '--ipynb2rst' ]; then
|
861
|
+
shift
|
862
|
+
exec sage-ipynb2rst "$@"
|
863
|
+
fi
|
864
|
+
|
865
|
+
if [ "$1" = '-sws2rst' -o "$1" = '--sws2rst' ]; then
|
866
|
+
shift
|
867
|
+
exec sage-sws2rst "$@"
|
868
|
+
fi
|
869
|
+
|
870
|
+
#####################################################################
|
871
|
+
# The notebook, grep, building Sage, testing Sage
|
872
|
+
#####################################################################
|
873
|
+
|
874
|
+
|
875
|
+
if [[ "$1" =~ ^--notebook=.* || "$1" =~ ^-n=.* || "$1" =~ ^-notebook=.* ]] ; then
|
876
|
+
sage-cleaner &>/dev/null &
|
877
|
+
exec sage-notebook "$@"
|
878
|
+
fi
|
879
|
+
|
880
|
+
if [ "$1" = "-notebook" -o "$1" = '--notebook' -o "$1" = '-n' ]; then
|
881
|
+
sage-cleaner &>/dev/null &
|
882
|
+
exec sage-notebook "$@"
|
883
|
+
fi
|
884
|
+
|
885
|
+
if [ "$1" = "-bn" -o "$1" = "--build-and-notebook" ]; then
|
886
|
+
shift
|
887
|
+
build_sage
|
888
|
+
sage-cleaner &>/dev/null &
|
889
|
+
exec sage-notebook --notebook=default "$@"
|
890
|
+
fi
|
891
|
+
|
892
|
+
if [ -n "$SAGE_SRC" -a -d "$SAGE_SRC" ]; then
|
893
|
+
# Source inspection facilities, supported on sage-the-distribution and on distributions
|
894
|
+
# that package the Sage sources.
|
895
|
+
if [ "$1" = '-grep' -o "$1" = "--grep" -o "$1" = "-search_src" -o "$1" = "--search_src" ]; then
|
896
|
+
shift
|
897
|
+
sage-grep "$@"
|
898
|
+
exit 0
|
899
|
+
fi
|
900
|
+
|
901
|
+
if [ "$1" = '-grepdoc' -o "$1" = "--grepdoc" -o "$1" = "-search_doc" -o "$1" = "--search_doc" ]; then
|
902
|
+
shift
|
903
|
+
sage-grepdoc "$@"
|
904
|
+
exit 0
|
905
|
+
fi
|
906
|
+
fi
|
907
|
+
|
908
|
+
if [ "$1" = '-r' ]; then
|
909
|
+
shift
|
910
|
+
interactive_sage
|
911
|
+
fi
|
912
|
+
|
913
|
+
exec-runtests() {
|
914
|
+
sage_setup
|
915
|
+
export PYTHONIOENCODING="utf-8" # Fix encoding for doctests
|
916
|
+
exec sage-runtests "$@"
|
917
|
+
}
|
918
|
+
|
919
|
+
if [ "$1" = '-t' -o "$1" = '-tp' ]; then
|
920
|
+
if [ "$1" = '-tp' ]; then
|
921
|
+
shift
|
922
|
+
exec-runtests -p "$@"
|
923
|
+
else
|
924
|
+
shift
|
925
|
+
exec-runtests "$@"
|
926
|
+
fi
|
927
|
+
fi
|
928
|
+
|
929
|
+
if [ "$1" = '-tnew' ]; then
|
930
|
+
shift
|
931
|
+
exec-runtests --new "$@"
|
932
|
+
fi
|
933
|
+
|
934
|
+
if [ "$1" = '-testall' -o "$1" = "--testall" ]; then
|
935
|
+
shift
|
936
|
+
exec-runtests -a "$@"
|
937
|
+
fi
|
938
|
+
|
939
|
+
if [ "$1" = '-fixdoctests' -o "$1" = '--fixdoctests' ]; then
|
940
|
+
shift
|
941
|
+
exec sage-fixdoctests "$@"
|
942
|
+
fi
|
943
|
+
|
944
|
+
if [ "$1" = "-coverage" -o "$1" = "--coverage" ]; then
|
945
|
+
shift
|
946
|
+
exec sage-coverage "$@"
|
947
|
+
fi
|
948
|
+
|
949
|
+
if [ "$1" = "-coverageall" -o "$1" = "--coverageall" ]; then
|
950
|
+
shift
|
951
|
+
exec sage-coverage --all "$@"
|
952
|
+
fi
|
953
|
+
|
954
|
+
if [ "$1" = '-startuptime' -o "$1" = '--startuptime' ]; then
|
955
|
+
exec sage-startuptime.py "$@"
|
956
|
+
fi
|
957
|
+
|
958
|
+
if [ "$1" = '-fiximports' -o "$1" = '--fiximports' ]; then
|
959
|
+
shift
|
960
|
+
exec sage-python -m sage.misc.replace_dot_all "$@"
|
961
|
+
fi
|
962
|
+
|
963
|
+
if [ "$1" = '-fixdistributions' -o "$1" = '--fixdistributions' ]; then
|
964
|
+
shift
|
965
|
+
exec sage-python -m sage.misc.package_dir "$@"
|
966
|
+
fi
|
967
|
+
|
968
|
+
if [ "$1" = '-tox' -o "$1" = '--tox' ]; then
|
969
|
+
shift
|
970
|
+
if [ -n "$SAGE_SRC" -a -f "$SAGE_SRC/tox.ini" ]; then
|
971
|
+
if command -v tox >/dev/null ; then
|
972
|
+
exec tox -c "$SAGE_SRC" "$@"
|
973
|
+
else
|
974
|
+
echo "Run 'sage -i tox' to install"
|
975
|
+
exit 1
|
976
|
+
fi
|
977
|
+
else
|
978
|
+
echo >&2 "error: Sage source directory or tox.ini not available"
|
979
|
+
exit 1
|
980
|
+
fi
|
981
|
+
fi
|
982
|
+
|
983
|
+
if [ "$1" = '-pytest' -o "$1" = '--pytest' ]; then
|
984
|
+
shift
|
985
|
+
if [ -n "$SAGE_SRC" -a -f "$SAGE_SRC/tox.ini" ]; then
|
986
|
+
if command -v pytest >/dev/null ; then
|
987
|
+
# If no non-option arguments are given, provide one
|
988
|
+
for a in $*; do
|
989
|
+
case $a in
|
990
|
+
-*) ;;
|
991
|
+
*) exec pytest --rootdir="$SAGE_SRC" --doctest "$@"
|
992
|
+
esac
|
993
|
+
done
|
994
|
+
exec pytest --rootdir="$SAGE_SRC" --doctest "$@" "$SAGE_SRC"
|
995
|
+
else
|
996
|
+
echo "Run 'sage -i pytest' to install"
|
997
|
+
exit 1
|
998
|
+
fi
|
999
|
+
else
|
1000
|
+
echo >&2 "error: Sage source directory or tox.ini not available"
|
1001
|
+
exit 1
|
1002
|
+
fi
|
1003
|
+
fi
|
1004
|
+
|
1005
|
+
#####################################################################
|
1006
|
+
# Building the Sage documentation
|
1007
|
+
#####################################################################
|
1008
|
+
|
1009
|
+
if [ "$1" = "-docbuild" -o "$1" = "--docbuild" ]; then
|
1010
|
+
shift
|
1011
|
+
|
1012
|
+
# Issue #30002: ensure an English locale so that it is possible to
|
1013
|
+
# scrape out warnings by pattern matching.
|
1014
|
+
export LANG=C
|
1015
|
+
export LANGUAGE=C
|
1016
|
+
|
1017
|
+
# See #30351: bugs in macOS implementations of openblas/libgopm can cause
|
1018
|
+
# docbuild to hang if multiple OpenMP threads are allowed.
|
1019
|
+
if [ `uname` = 'Darwin' ]; then
|
1020
|
+
export OMP_NUM_THREADS=1
|
1021
|
+
fi
|
1022
|
+
|
1023
|
+
# Issue #33650: Make sure that user configuration of Jupyter does not
|
1024
|
+
# shadow our sagemath kernel when jupyter-sphinx is invoked
|
1025
|
+
export JUPYTER_CONFIG_DIR=/doesnotexist
|
1026
|
+
export JUPYTER_CONFIG_PATH=/doesnotexist
|
1027
|
+
export JUPYTER_DATA_DIR=/doesnotexist
|
1028
|
+
export JUPYTER_PATH=/doesnotexist
|
1029
|
+
|
1030
|
+
# Redirect stdin from /dev/null. This helps with running TeX which
|
1031
|
+
# tends to ask interactive questions if something goes wrong. These
|
1032
|
+
# cause the build to hang. If stdin is /dev/null, TeX just aborts.
|
1033
|
+
exec sage-python -m sage_docbuild "$@" </dev/null
|
1034
|
+
fi
|
1035
|
+
|
1036
|
+
#####################################################################
|
1037
|
+
# Creating and handling Sage distributions
|
1038
|
+
#####################################################################
|
1039
|
+
|
1040
|
+
# The following could be moved to build/bin/sage-site. See #29111.
|
1041
|
+
|
1042
|
+
if [ "$1" = '--location' ]; then
|
1043
|
+
# Ignore
|
1044
|
+
exit 0
|
1045
|
+
fi
|
1046
|
+
|
1047
|
+
if [ "$1" = '-installed' -o "$1" = "--installed" ]; then
|
1048
|
+
shift
|
1049
|
+
exec sage-list-packages all --installed-only $@
|
1050
|
+
fi
|
1051
|
+
|
1052
|
+
if [ "$1" = '-sdist' -o "$1" = "--sdist" ]; then
|
1053
|
+
shift
|
1054
|
+
exec sage-sdist "$@"
|
1055
|
+
fi
|
1056
|
+
|
1057
|
+
#####################################################################
|
1058
|
+
# Debugging tools
|
1059
|
+
#####################################################################
|
1060
|
+
|
1061
|
+
if [ "$1" = '-gdb' -o "$1" = "--gdb" ]; then
|
1062
|
+
shift
|
1063
|
+
sage_setup
|
1064
|
+
if [ "$SAGE_DEBUG" != "yes" ]; then
|
1065
|
+
gdb --eval-command "run" \
|
1066
|
+
-args python "${SELF}-ipython" "$@" -i
|
1067
|
+
else
|
1068
|
+
sage_dir=$(sage-python -c 'import os, sage; print(os.path.dirname(sage.__file__))')
|
1069
|
+
cygdb "$sage_dir" "$SAGE_SRC/sage" \
|
1070
|
+
-- --eval-command "run" \
|
1071
|
+
-args python "${SELF}-ipython" "$@" -i
|
1072
|
+
fi
|
1073
|
+
exit $?
|
1074
|
+
fi
|
1075
|
+
|
1076
|
+
if [ "$1" = '-lldb' -o "$1" = "--lldb" ]; then
|
1077
|
+
shift
|
1078
|
+
sage_setup
|
1079
|
+
lldb --one-line "process launch --tty" --one-line "cont" -- python "${SELF}-ipython" "$@"
|
1080
|
+
fi
|
1081
|
+
|
1082
|
+
if [ "$1" = '-valgrind' -o "$1" = "--valgrind" -o "$1" = '-memcheck' -o "$1" = "--memcheck" ]; then
|
1083
|
+
shift
|
1084
|
+
sage_setup
|
1085
|
+
exec sage-valgrind "$@"
|
1086
|
+
fi
|
1087
|
+
|
1088
|
+
if [ "$1" = '-massif' -o "$1" = "--massif" ]; then
|
1089
|
+
shift
|
1090
|
+
sage_setup
|
1091
|
+
exec sage-massif "$@"
|
1092
|
+
fi
|
1093
|
+
|
1094
|
+
if [ "$1" = '-cachegrind' -o "$1" = "--cachegrind" ]; then
|
1095
|
+
shift
|
1096
|
+
sage_setup
|
1097
|
+
exec sage-cachegrind "$@"
|
1098
|
+
fi
|
1099
|
+
|
1100
|
+
if [ "$1" = '-callgrind' -o "$1" = "--callgrind" ]; then
|
1101
|
+
shift
|
1102
|
+
sage_setup
|
1103
|
+
exec sage-callgrind "$@"
|
1104
|
+
fi
|
1105
|
+
|
1106
|
+
if [ "$1" = '-omega' -o "$1" = "--omega" ]; then
|
1107
|
+
shift
|
1108
|
+
sage_setup
|
1109
|
+
exec sage-omega "$@"
|
1110
|
+
fi
|
1111
|
+
|
1112
|
+
if [ "$1" = '-gthread' -o "$1" = '-qthread' -o "$1" = '-q4thread' -o "$1" = '-wthread' -o "$1" = '-pylab' -o "$1" = '--simple-prompt' -o "$1" = '-simple-prompt' ]; then
|
1113
|
+
# Intentionally no "shift" here
|
1114
|
+
interactive_sage "$@"
|
1115
|
+
fi
|
1116
|
+
|
1117
|
+
case "$1" in
|
1118
|
+
-*)
|
1119
|
+
# Delegate further option handling to the non-installed sage-site script.
|
1120
|
+
# (These options become unavailable if the directory $SAGE_ROOT is removed.)
|
1121
|
+
if [ -d "$SAGE_ROOT" ]; then
|
1122
|
+
exec "$SAGE_ROOT/build/bin/sage-site" "$@"
|
1123
|
+
# fallthrough if there is no sage-site script
|
1124
|
+
fi
|
1125
|
+
echo "Error: unknown option: $1"
|
1126
|
+
exit 1
|
1127
|
+
;;
|
1128
|
+
esac
|
1129
|
+
|
1130
|
+
if [ $# -ge 1 ]; then
|
1131
|
+
T=`echo "$1" | sed -e "s/.*\.//"`
|
1132
|
+
if [ "$T" = "spkg" ]; then
|
1133
|
+
echo "Error: Installing old-style SPKGs is no longer supported."
|
1134
|
+
exit 1
|
1135
|
+
fi
|
1136
|
+
sage_setup
|
1137
|
+
unset TERM # See Issue #12263
|
1138
|
+
# sage-run rejects all command line options as the first argument.
|
1139
|
+
exec sage-run "$@"
|
1140
|
+
fi
|