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.
Files changed (70) hide show
  1. passagemath_environment-10.4.1.data/scripts/sage +1140 -0
  2. passagemath_environment-10.4.1.data/scripts/sage-env +667 -0
  3. passagemath_environment-10.4.1.data/scripts/sage-num-threads.py +105 -0
  4. passagemath_environment-10.4.1.data/scripts/sage-python +2 -0
  5. passagemath_environment-10.4.1.data/scripts/sage-venv-config +42 -0
  6. passagemath_environment-10.4.1.data/scripts/sage-version.sh +9 -0
  7. passagemath_environment-10.4.1.dist-info/METADATA +76 -0
  8. passagemath_environment-10.4.1.dist-info/RECORD +70 -0
  9. passagemath_environment-10.4.1.dist-info/WHEEL +5 -0
  10. passagemath_environment-10.4.1.dist-info/top_level.txt +1 -0
  11. sage/all__sagemath_environment.py +4 -0
  12. sage/env.py +496 -0
  13. sage/features/__init__.py +981 -0
  14. sage/features/all.py +126 -0
  15. sage/features/bliss.py +85 -0
  16. sage/features/cddlib.py +38 -0
  17. sage/features/coxeter3.py +45 -0
  18. sage/features/csdp.py +83 -0
  19. sage/features/cython.py +38 -0
  20. sage/features/databases.py +302 -0
  21. sage/features/dvipng.py +40 -0
  22. sage/features/ecm.py +42 -0
  23. sage/features/ffmpeg.py +119 -0
  24. sage/features/four_ti_2.py +55 -0
  25. sage/features/fricas.py +66 -0
  26. sage/features/gap.py +86 -0
  27. sage/features/gfan.py +38 -0
  28. sage/features/giac.py +30 -0
  29. sage/features/graph_generators.py +171 -0
  30. sage/features/graphviz.py +117 -0
  31. sage/features/igraph.py +44 -0
  32. sage/features/imagemagick.py +138 -0
  33. sage/features/interfaces.py +256 -0
  34. sage/features/internet.py +65 -0
  35. sage/features/jmol.py +44 -0
  36. sage/features/join_feature.py +146 -0
  37. sage/features/kenzo.py +77 -0
  38. sage/features/latex.py +300 -0
  39. sage/features/latte.py +85 -0
  40. sage/features/lrs.py +164 -0
  41. sage/features/mcqd.py +45 -0
  42. sage/features/meataxe.py +46 -0
  43. sage/features/mip_backends.py +114 -0
  44. sage/features/msolve.py +68 -0
  45. sage/features/nauty.py +70 -0
  46. sage/features/normaliz.py +43 -0
  47. sage/features/palp.py +65 -0
  48. sage/features/pandoc.py +42 -0
  49. sage/features/pdf2svg.py +41 -0
  50. sage/features/phitigra.py +42 -0
  51. sage/features/pkg_systems.py +195 -0
  52. sage/features/polymake.py +43 -0
  53. sage/features/poppler.py +58 -0
  54. sage/features/rubiks.py +180 -0
  55. sage/features/sagemath.py +1205 -0
  56. sage/features/sat.py +103 -0
  57. sage/features/singular.py +48 -0
  58. sage/features/sirocco.py +45 -0
  59. sage/features/sphinx.py +71 -0
  60. sage/features/standard.py +38 -0
  61. sage/features/symengine_py.py +44 -0
  62. sage/features/tdlib.py +38 -0
  63. sage/features/threejs.py +75 -0
  64. sage/features/topcom.py +67 -0
  65. sage/misc/all__sagemath_environment.py +2 -0
  66. sage/misc/package.py +570 -0
  67. sage/misc/package_dir.py +621 -0
  68. sage/misc/temporary_file.py +546 -0
  69. sage/misc/viewer.py +369 -0
  70. sage/version.py +5 -0
@@ -0,0 +1,667 @@
1
+ # -*- shell-script -*-
2
+
3
+ ###########################################################################
4
+ #
5
+ # Set environment variables for building and/or running Sage.
6
+ #
7
+ # NOTES:
8
+ # - You must *source* this script instead of executing.
9
+ # - Use "return" instead of "exit" to signal a failure. Since this
10
+ # file is sourced, an "exit" here will actually exit src/bin/sage,
11
+ # which is probably not intended.
12
+ # - All environment variables set here should be *exported*, otherwise
13
+ # they won't be available in child programs.
14
+ # - This script has a version number such that a newer version of
15
+ # sage-env can be sourced when upgrading. See below.
16
+ #
17
+ # If you want to set all environment variables for your shell like
18
+ # they are during the build of Sage packages, type
19
+ #
20
+ # . src/bin/sage-env
21
+ #
22
+ # from the SAGE_ROOT directory.
23
+ #
24
+ # AUTHORS: William Stein, David Kirkby, Jeroen Demeyer,
25
+ # J. H. Palmieri, Leif Leonhardy and others.
26
+ #
27
+ ##########################################################################
28
+
29
+ # Resolve all symbolic links in a filename. This more or less behaves
30
+ # like "readlink -f" except that it does not convert the filename to an
31
+ # absolute path (a relative path remains relative), nor does it treat
32
+ # "." or ".." specially.
33
+ #
34
+ # AUTHOR: Jeroen Demeyer (2011-08-23): Github issues #5852 and #11704
35
+ #
36
+ resolvelinks() {
37
+ # $in is what still needs to be converted (normally has no starting slash)
38
+ in="$1"
39
+ # $out is the part which is converted (normally ends with trailing slash)
40
+ out="./"
41
+
42
+ # Move stuff from $in to $out
43
+ while [ -n "$in" ]; do
44
+ # Normalize $in by replacing consecutive slashes by one slash
45
+ in=$(echo "${in}" | sed 's://*:/:g')
46
+
47
+ # If $in starts with a slash, remove it and set $out to the root
48
+ in_without_slash=${in#/}
49
+ if [ "$in" != "$in_without_slash" ]; then
50
+ in=$in_without_slash
51
+ out="/"
52
+ continue
53
+ fi
54
+
55
+ # Check that the directory $out exists by trying to cd to it.
56
+ # If this fails, then cd will show an error message (unlike
57
+ # test -d "$out"), so no need to be more verbose.
58
+ ( cd "$out" ) || return $?
59
+
60
+
61
+ # Get the first component of $in
62
+ f=${in%%/*}
63
+
64
+ # If it is not a symbolic link, simply move it to $out
65
+ if [ ! -L "$out$f" ]; then
66
+ in=${in#"$f"}
67
+ out="$out$f"
68
+
69
+ # If the new $in starts with a slash, move it to $out
70
+ in_without_slash=${in#/}
71
+ if [ "$in" != "$in_without_slash" ]; then
72
+ in=$in_without_slash
73
+ out="$out/"
74
+ fi
75
+ continue
76
+ fi
77
+
78
+ # Now resolve the symbolic link "$f"
79
+ f_resolved=`readlink -n "$out$f" 2>/dev/null`
80
+ status=$?
81
+ # status 127 means readlink could not be found.
82
+ if [ $status -eq 127 ]; then
83
+ # We don't have "readlink", try a stupid "ls" hack instead.
84
+ # This will fail if we have filenames like "a -> b".
85
+ fls=`ls -l "$out$f" 2>/dev/null`
86
+ status=$?
87
+ f_resolved=${fls##*-> }
88
+
89
+ # If $fls equals $f_resolved, then certainly
90
+ # something is wrong
91
+ if [ $status -eq 0 -a "$fls" = "$f_resolved" ]; then
92
+ echo >&2 "Cannot parse output from ls -l '$out$f'"
93
+ return 1
94
+ fi
95
+ fi
96
+ if [ $status -ne 0 ]; then
97
+ echo >&2 "Cannot read symbolic link '$out$f'"
98
+ return $status
99
+ fi
100
+
101
+ # In $in, replace $f by $f_resolved (leave $out alone)
102
+ in="${in#${f}}"
103
+ in="${f_resolved}${in}"
104
+ done
105
+
106
+ # Return $out
107
+ echo "$out"
108
+ }
109
+
110
+ # Make sure that SAGE_ROOT is either an absolute physical directory name
111
+ # or empty.
112
+ if [ -n "$SAGE_ROOT" ]; then
113
+ export SAGE_ROOT=$(cd "$SAGE_ROOT" 2>/dev/null && pwd -P)
114
+ fi
115
+
116
+ # Don't execute the commands more than once for the same version of
117
+ # sage-env... for the same combination of SAGE_LOCAL and SAGE_VENV.
118
+ # "6" indicates the version of the format of the value of SAGE_ENV_VERSION.
119
+ SAGE_ENV_VERSION="6:$SAGE_LOCAL:$SAGE_VENV:$SAGE_SRC"
120
+ if [ "$SAGE_ENV_SOURCED" = "$SAGE_ENV_VERSION" ]; then
121
+ # Already sourced, nothing to do.
122
+ return 0
123
+ fi
124
+ # Set SAGE_ENV_SOURCED to the appropriate value at the end of this file, once
125
+ # $SAGE_LOCAL, $SAGE_VENV, $SAGE_SRC have been set.
126
+
127
+ # The compilers are set in order of priority by
128
+ # 1) environment variables
129
+ # 2) compiler installed by sage
130
+ # 3) compiler set at configuration time
131
+ if [ -z "$CC" ]; then
132
+ if [ -n "$SAGE_LOCAL" -a -x "$SAGE_LOCAL/bin/gcc" ]; then
133
+ CC=gcc
134
+ elif [ -n "$CONFIGURED_CC" ]; then
135
+ CC="$CONFIGURED_CC"
136
+ fi
137
+ export CC
138
+ fi
139
+ if [ -z "$CXX" ]; then
140
+ if [ -n "$SAGE_LOCAL" -a -x "$SAGE_LOCAL/bin/g++" ]; then
141
+ CXX=g++
142
+ elif [ -n "$CONFIGURED_CXX" ]; then
143
+ CXX="$CONFIGURED_CXX"
144
+ fi
145
+ export CXX
146
+ fi
147
+ if [ -z "$FC" ]; then
148
+ if [ -n "$SAGE_LOCAL" -a -x "$SAGE_LOCAL/bin/gfortran" ]; then
149
+ FC=gfortran
150
+ elif [ -n "$CONFIGURED_FC" ]; then
151
+ FC="$CONFIGURED_FC"
152
+ fi
153
+ export FC
154
+ fi
155
+ if [ "$UNAME" = "Darwin" ]; then
156
+ if [ -z "$OBJC" ]; then
157
+ OBJC="$CONFIGURED_OBJC"
158
+ fi
159
+ if [ -z "$OBJCXX" ]; then
160
+ OBJCXX="$CONFIGURED_OBJCXX"
161
+ fi
162
+ export OBJC OBJCXX
163
+ fi
164
+
165
+ # Set other Fortran-related compiler variables
166
+ export F77="$FC"
167
+ export F90="$FC" # Needed for SciPy
168
+ export F95="$FC"
169
+
170
+ # For ARCHFLAGS (#31227) we need to distinguish unset and empty.
171
+ # If the environment defines ARCHFLAGS, even when empty, then take that.
172
+ # Otherwise, use the configured value; but if that is "unset", do not set
173
+ # the variable at all.
174
+ if [ "${ARCHFLAGS-unset}" = "unset" ]; then
175
+ if [ "${SAGE_ARCHFLAGS-unset}" != "unset" ]; then
176
+ export ARCHFLAGS="${SAGE_ARCHFLAGS}"
177
+ fi
178
+ fi
179
+
180
+ # Call with: contains_spaces X${VAR}X
181
+ # i.e., WITHOUT quotes but some character(s) around the environment variable to test.
182
+ # (This function does return false for empty/unset variables.)
183
+ contains_spaces()
184
+ {
185
+ if [ $# -ne 1 ]; then
186
+ return 0 # true
187
+ else
188
+ return 1 # false
189
+ fi
190
+ }
191
+
192
+
193
+ if contains_spaces X${SAGE_ROOT}X ; then
194
+ echo "Error: The path to the Sage directory (\$SAGE_ROOT) MUST NOT contain spaces."
195
+ echo "It is currently \"$SAGE_ROOT\"."
196
+ echo "Please correct this by moving Sage (or renaming one or more directories) first."
197
+ echo "Exiting now..."
198
+ return 1
199
+ fi
200
+
201
+
202
+ if [ 1 = 2 ]; then
203
+ echo "The following environment variables can be set by the user"
204
+ echo "AR The archiver (e.g. ar, /usr/ccs/bin/ar or /usr/bin/ar)"
205
+ echo "AS The assembler (e.g. as, /usr/ccs/bin/as or /usr/bin/as)"
206
+ echo "CC The C compiler (e.g cc, /opt/SUNWspro/bin/cc or /usr/bin/gcc)"
207
+ echo "CFLAGS Flag(s) for the C compiler (e.g. -g -Wall -O2)"
208
+ echo " (You are advised to a some optimisation flag(s), such as -O2 or -xO2 to CFLAGS)"
209
+ echo "CXX The C++ compiler (e.g g++, /opt/SUNWspro/bin/CC or /usr/local/bin/g++)"
210
+ echo "CXXFLAGS Flag(s) for the C++ compiler (e.g. -fast -fsimple=1 -x04)"
211
+ echo "LD The linker (e.g. ld, /usr/ccs/bin/ld or /usr/bin/ld)"
212
+ echo "LDFLAGS Linker flag(s) (e.g. -D token)"
213
+ echo "LN Used to make links (e.g. ln, /usr/xpg4/bin/ln or /usr/bin/ln)"
214
+ echo "MAKE The make program (e.g. make, /usr/bin/make or /usr/local/bin/gmake)"
215
+ echo "MAKEFLAGS Flag(s) to make (e.g. -j4)."
216
+ echo "RANLIB Archiver ranlib (e.g. ranlib, /usr/ccs/bin/ranlib etc)"
217
+ echo "SHAREDFLAGS Flag(s) necessary for building a shared library (e.g. -fPIC or -xcode=pic32)"
218
+ echo "We attempt to set this to sensible values, but check below to"
219
+ echo "ensure they are OK. If you wish to override any then please use:"
220
+ echo "setenv NAME_OF_ENVIRONMENT_VARIABLE value_of_environment_variable"
221
+ echo "(if you use tcsh, csh or a similar shell) or"
222
+ echo "NAME_OF_ENVIRONMENT_VARIABLE value_of_environment_variable"
223
+ echo "export NAME_OF_ENVIRONMENT_VARIABLE"
224
+ echo "if you use sh, bash or a similar shell"
225
+ fi
226
+
227
+ # Setting Sage-related location environment variables,
228
+ # depending on SAGE_ROOT and SAGE_LOCAL which are already defined.
229
+ if [ -n "$SAGE_LOCAL" ]; then
230
+ export SAGE_SHARE="$SAGE_LOCAL/share"
231
+ export SAGE_SPKG_INST="$SAGE_LOCAL/var/lib/sage/installed" # deprecated
232
+ fi
233
+ if [ -n "$SAGE_SHARE" ]; then
234
+ export SAGE_DOC="$SAGE_SHARE/doc/sage"
235
+ fi
236
+ if [ -d "$SAGE_ROOT" ]; then
237
+ export SAGE_LOGS="$SAGE_ROOT/logs/pkgs"
238
+ export SAGE_SRC="$SAGE_ROOT/src"
239
+ fi
240
+ if [ -n "$SAGE_SRC" ]; then
241
+ export SAGE_DOC_SRC="$SAGE_SRC/doc"
242
+ fi
243
+
244
+ if [ -n "$SAGE_PKG_CONFIG_PATH" ]; then
245
+ # set up external pkg-config to look into SAGE_LOCAL/lib/pkgconfig/
246
+ # (Sage's pkgconf spkg takes care of this, if installed)
247
+ export PKG_CONFIG_PATH="$SAGE_PKG_CONFIG_PATH${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}"
248
+ fi
249
+
250
+ if [ -z "${SAGE_ORIG_PATH_SET}" ]; then
251
+ SAGE_ORIG_PATH=$PATH && export SAGE_ORIG_PATH
252
+ SAGE_ORIG_PATH_SET=True && export SAGE_ORIG_PATH_SET
253
+ fi
254
+ if [ -n "$SAGE_LOCAL" ]; then
255
+ export PATH="$SAGE_LOCAL/bin:$PATH"
256
+ fi
257
+ if [ -n "$SAGE_VENV" ]; then
258
+ export PATH="$SAGE_VENV/bin:$PATH"
259
+ fi
260
+ if [ -d "$SAGE_ROOT" ]; then
261
+ export PATH="$SAGE_ROOT/build/bin:$PATH"
262
+ fi
263
+
264
+ # We offer a toolchain option, so if $SAGE_LOCAL/toolchain/toolchain-env exists source it.
265
+ # Since the user might do something crazy we do not do any checks, but hope for the best.
266
+ if [ -n "$SAGE_LOCAL" -a -f "$SAGE_LOCAL"/toolchain/toolchain-env ]; then
267
+ source "$SAGE_LOCAL"/toolchain/toolchain-env
268
+ fi
269
+
270
+ # setting of the variable UNAME (describing the o.s.)
271
+ export UNAME=`uname`
272
+
273
+ # Mac OS X-specific setup
274
+ if [ "$UNAME" = "Darwin" ]; then
275
+ export MACOSX_VERSION=`uname -r | awk -F. '{print $1}'`
276
+ # Work around problems on recent OS X crashing with an error message
277
+ # "... may have been in progress in another thread when fork() was called"
278
+ # when objective-C functions are called after fork(). See Issue #25921.
279
+ # Most likely, these errors are false positives, so we disable them:
280
+ export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
281
+ fi
282
+
283
+ if [ -n "$SAGE_LOCAL" ]; then
284
+ # Compile-time path for libraries. This is the equivalent of
285
+ # adding the gcc option -L $SAGE_LOCAL/lib.
286
+ [ -z "$LIBRARY_PATH" ] || LIBRARY_PATH=":${LIBRARY_PATH}"
287
+ export LIBRARY_PATH="$SAGE_LOCAL/lib${LIBRARY_PATH}"
288
+ # Compile-time path for include files. This is the equivalent of
289
+ # adding the gcc option -I $SAGE_LOCAL/include.
290
+ [ -z "$CPATH" ] || CPATH=":${CPATH}"
291
+ export CPATH="$SAGE_LOCAL/include${CPATH}"
292
+ fi
293
+
294
+ if [ -n "$SAGE_LOCAL" ]; then
295
+ # Ensure that there is a colon at the end of $INFOPATH by
296
+ # stripping the existing one (if it exists), and then adding a new
297
+ # one. This forces the "info" program to check various default
298
+ # system locations when the user does not have $INFOPATH set. This
299
+ # is necessary to find some *.info files installed by system
300
+ # packages when "info" from the SPKG is used.
301
+ export INFOPATH="${SAGE_LOCAL}/share/info:${INFOPATH%:}:"
302
+ fi
303
+
304
+ if [ -z "$SAGE_REPO_ANONYMOUS" ]; then
305
+ SAGE_REPO_ANONYMOUS="https://github.com/sagemath/sage.git"
306
+ export SAGE_REPO_ANONYMOUS
307
+ fi
308
+ if [ -z "$SAGE_REPO_AUTHENTICATED" ]; then
309
+ SAGE_REPO_AUTHENTICATED="https://github.com/sagemath/sage.git"
310
+ export SAGE_REPO_AUTHENTICATED
311
+ fi
312
+
313
+ if [ -d "$SAGE_ROOT" ]; then
314
+ if [ -z "$SAGE_DISTFILES" ]; then
315
+ SAGE_DISTFILES="$SAGE_ROOT/upstream"
316
+ export SAGE_DISTFILES
317
+ fi
318
+ fi
319
+
320
+ # Check that $HOME exists
321
+ if [ "$HOME" = "" ]; then
322
+ echo >&2 'Error: environment variable $HOME is not set.'
323
+ return 1
324
+ fi
325
+ if ! [ -d "$HOME" ]; then
326
+ echo >&2 "Error: HOME directory '$HOME' does not exist."
327
+ return 1
328
+ fi
329
+
330
+ if [ "$DOT_SAGE" = "" ]; then
331
+ # It is *not* an error if this directory does not exist, it will
332
+ # be created in src/bin/sage or src/sage/misc/misc.py.
333
+ # This also works if $HOME/.sage is a symbolic link to a
334
+ # non-existing directory.
335
+ DOT_SAGE=`resolvelinks "$HOME/.sage"`
336
+
337
+ # In theory, DOT_SAGE is not required to have a trailing slash.
338
+ # But since there are some issues (#11924, maybe #12221),
339
+ # we add a slash for safety.
340
+ DOT_SAGE="${DOT_SAGE}/"
341
+ export DOT_SAGE
342
+ fi
343
+
344
+ if [ "$SAGE_STARTUP_FILE" = "" ]; then
345
+ SAGE_STARTUP_FILE="$DOT_SAGE/init.sage"
346
+ export SAGE_STARTUP_FILE
347
+ fi
348
+
349
+ if [ "$PYTHON_EGG_CACHE" = "" ]; then
350
+ PYTHON_EGG_CACHE="$DOT_SAGE/.python-eggs"
351
+ export PYTHON_EGG_CACHE
352
+ fi
353
+
354
+ # Set PYTHONUSERBASE to avoid picking up non-Sage versions of
355
+ # Matplotlib, numpy, etc. See https://github.com/sagemath/sage/issues/19612.
356
+ #
357
+ # For more history (it used to be PYTHONNOUSERSITE=yes which killed
358
+ # the ability to do "sage -pip install PACKAGE --user"), see
359
+ # https://github.com/sagemath/sage/issues/14243 and
360
+ # https://github.com/sagemath/sage/issues/18955.
361
+
362
+ if [ "$PYTHONUSERBASE" = "" ]; then
363
+ PYTHONUSERBASE="$DOT_SAGE/local"
364
+ export PYTHONUSERBASE
365
+ fi
366
+
367
+ if [ -n "$PYTHONHOME" ]; then
368
+ >&2 echo "Warning: PYTHONHOME must not be set when running Sage, clearing env..."
369
+ unset PYTHONHOME
370
+ fi
371
+
372
+ if [ -n "$SAGE_LOCAL" ]; then
373
+ # Construct and export LDFLAGS
374
+ if [ "$UNAME" = "Darwin" ]; then
375
+ LDFLAGS="-L$SAGE_LOCAL/lib $LDFLAGS"
376
+ # On OS X, use the old linker if it is available.
377
+ # if "ld-classic" is present in the selected XCode
378
+ # toolchain, add "-Wl,-ld_classic" to LDFLAGS (see #36599) unless
379
+ # LD is already set, as it will be with conda on macOS. When the
380
+ # selected toolchain is in the Xcode app the output of "xcode-select -p"
381
+ # is "/Applications/Xcode.app/Contents/Developer", but "ld-classic" is
382
+ # not in the subdirectory "usr/bin/" but rather in the subdirectory
383
+ # "Toolchains/XcodeDefault.xctoolchain/usr/bin/". (See #37237.)
384
+ if [ -z "$LD" ]; then
385
+ # Running xcode-select on a system with no toolchain writes an
386
+ # error message to stderr, so redirect stderr to /dev/null.
387
+ XCODE_PATH=$(/usr/bin/xcode-select -p 2> /dev/null)
388
+ if [ -n $XCODE_PATH ]; then
389
+ if [ -x "$XCODE_PATH/usr/bin/ld-classic" -o \
390
+ -x "$XCODE_PATH/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld-classic" ]; then
391
+ LDFLAGS="$LDFLAGS -Wl,-ld_classic"
392
+ fi
393
+ else
394
+ # On a macOS system with no toolchain we don't want this script
395
+ # to call gcc because that will also print an error message to
396
+ # stderr. We can avoid this by setting AS and LD to their
397
+ # default values.
398
+ AS=as
399
+ LD=ld
400
+ fi
401
+ fi
402
+ fi
403
+ if [ "$UNAME" = "Linux" ]; then
404
+ LDFLAGS="-L$SAGE_LOCAL/lib -Wl,-rpath,$SAGE_LOCAL/lib $LDFLAGS"
405
+ LDFLAGS="-Wl,-rpath-link,$SAGE_LOCAL/lib $LDFLAGS"
406
+ fi
407
+ export LDFLAGS
408
+ fi
409
+
410
+ if [ -z "$IPYTHONDIR" ]; then
411
+ # We hardcode a version number in the directory name. The idea is
412
+ # that we keep using the same version number as long as that is
413
+ # possible. Only when some future IPython version really requires
414
+ # a new structure for the $IPYTHONDIR should this version number be
415
+ # changed to the new IPython version.
416
+ export IPYTHONDIR="$DOT_SAGE/ipython-5.0.0"
417
+ fi
418
+
419
+ if [ -z "$JUPYTER_CONFIG_DIR" ]; then
420
+ # We hardcode a version number in the directory name. The idea is
421
+ # that we keep using the same version number as long as that is
422
+ # possible. Only when some future Jupyter version really requires
423
+ # a new structure for the $JUPYTER_CONFIG_DIR should this version
424
+ # number be changed to the new jupyter_core version.
425
+ export JUPYTER_CONFIG_DIR="$DOT_SAGE/jupyter-4.1"
426
+ fi
427
+
428
+ if [ -z "$MPLCONFIGDIR" ]; then
429
+ # We hardcode a version number in the directory name. The idea is
430
+ # that we keep using the same version number as long as that is
431
+ # possible. Only when some future Matplotlib version really requires
432
+ # a new structure for the $MPLCONFIGDIR should this version
433
+ # number be changed to the new matplotlib version.
434
+ export MPLCONFIGDIR="$DOT_SAGE/matplotlib-1.5.1"
435
+ fi
436
+
437
+ # Make sure that a system-wide R installation does not interfere
438
+ unset R_HOME
439
+ unset R_PROFILE
440
+ # Do not use the global Makevars.site and ~/.R/Makevars when installing R packages
441
+ # Provide empty files to appease some R packages' installation scripts.
442
+ if [ -n "$SAGE_LOCAL" -a -d "$SAGE_LOCAL/lib/R/share" ] ; then
443
+ R_MAKEVARS_SITE="$SAGE_LOCAL/lib/R/share/Makevars.site" && export R_MAKEVARS_SITE
444
+ if ! [ -f "$R_MAKEVARS_SITE" ] ; then
445
+ if ! [ -e "$R_MAKEVARS_SITE" ] ; then
446
+ echo "## Empty site-wide Makevars file for Sage's R" > "$R_MAKEVARS_SITE"
447
+ else
448
+ >&2 echo "Warning: $R_MAKEVARS_SITE exists and is not a file : trouble ahead..."
449
+ fi
450
+ fi
451
+ fi
452
+ if [ -d "$DOT_SAGE" ] ; then
453
+ if ! [ -d "$DOT_SAGE/R" ] ; then
454
+ if ! [ -e "$DOT_SAGE/R" ] ; then
455
+ mkdir -p "$DOT_SAGE/R"
456
+ else
457
+ >&2 echo "Warning: $DOT_SAGE/R exists and is not a directory : trouble ahead..."
458
+ fi
459
+ fi
460
+ R_MAKEVARS_USER="$DOT_SAGE/R/Makevars.user" && export R_MAKEVARS_USER
461
+ if ! [ -f "$R_MAKEVARS_USER" ] ; then
462
+ if ! [ -e "$R_MAKEVARS_USER" ] ; then
463
+ echo "## Empty user-specific Makevars file for Sage's R" > "$R_MAKEVARS_USER"
464
+ else
465
+ >&2 echo "Warning: $R_MAKEVARS_USER exists and is not a file : trouble ahead..."
466
+ fi
467
+ fi
468
+ fi
469
+
470
+ export MAXIMA_USERDIR="$DOT_SAGE/maxima"
471
+
472
+ if [ -n "$SAGE_LOCAL" ]; then
473
+ PERL5LIB="$SAGE_LOCAL/lib/perl5:$PERL5LIB" && export PERL5LIB
474
+ fi
475
+
476
+ # Allow SAGE_BROWSER to override BROWSER (Issue #22449)
477
+ if [ -n "$SAGE_BROWSER" ]; then
478
+ export BROWSER="$SAGE_BROWSER"
479
+ fi
480
+
481
+ ############ compilation flags
482
+
483
+ # Setting Sage-related compilation flags.
484
+ # This could be used in code to make special changes only when
485
+ # code is being built as part of Sage.
486
+ export __sage__=""
487
+
488
+ # Setup env varariables if ccache is installed
489
+ if [ -n "$SAGE_LOCAL" -a -d "$SAGE_LOCAL/libexec/ccache" ]; then
490
+ PATH="$SAGE_LOCAL/libexec/ccache:$PATH"
491
+ fi
492
+ if [ -d "$SAGE_ROOT" -a -z "$CCACHE_BASEDIR" ]; then
493
+ export CCACHE_BASEDIR="$SAGE_ROOT"
494
+ fi
495
+
496
+ # Set AS to assembler used by $CC ("as" by default)
497
+ if [ "$AS" = "" ]; then
498
+ CC_as=`$CC -print-prog-name=as 2>/dev/null`
499
+ if command -v $CC_as >/dev/null 2>/dev/null; then
500
+ AS="$CC_as"
501
+ fi
502
+ if [ "$AS" = "" ]; then
503
+ AS=as
504
+ fi
505
+ fi
506
+ export AS
507
+
508
+ # Set LD to linker used by $CC ("ld" by default)
509
+ if [ "$LD" = "" ]; then
510
+ CC_ld=`$CC -print-prog-name=ld 2>/dev/null`
511
+ if command -v $CC_ld >/dev/null 2>/dev/null; then
512
+ LD="$CC_ld"
513
+ fi
514
+ if [ "$LD" = "" ]; then
515
+ LD=ld
516
+ fi
517
+ fi
518
+ export LD
519
+
520
+
521
+ if [ "$AR" = "" ]; then
522
+ AR="ar" && export AR
523
+ fi
524
+
525
+ if [ "$LDFLAGS" = "" ]; then
526
+ LDFLAGS="" && export LDFLAGS
527
+ fi
528
+
529
+ if [ -z "$CFLAGS" ]; then
530
+ unset CFLAGS
531
+ fi
532
+
533
+ if [ -z "$CXXFLAGS" ]; then
534
+ unset CXXFLAGS
535
+ fi
536
+
537
+ if [ -n "$CFLAGS" -a -z "$CXXFLAGS" ]; then
538
+ export CXXFLAGS="$CFLAGS"
539
+ fi
540
+
541
+ if [ "$CP" = "" ]; then
542
+ CP="cp" && export CP
543
+ fi
544
+
545
+ if [ "$MV" = "" ]; then
546
+ MV="mv" && export MV
547
+ fi
548
+
549
+ if [ "$RANLIB" = "" ]; then
550
+ RANLIB="ranlib" && export RANLIB
551
+ fi
552
+
553
+ if [ "$LN" = "" ]; then
554
+ LN="ln" && export LN
555
+ fi
556
+
557
+ if [ "$MKDIR" = "" ]; then
558
+ MKDIR="mkdir" && export MKDIR
559
+ fi
560
+
561
+ if [ "$CHMOD" = "" ]; then
562
+ CHMOD="chmod" && export CHMOD
563
+ fi
564
+
565
+ if [ "$TOUCH" = "" ]; then
566
+ TOUCH="touch" && export TOUCH
567
+ fi
568
+
569
+ # Handle parallel building/testing/...
570
+ case "$SAGE_NUM_THREADS,$SAGE_NUM_THREADS_PARALLEL" in
571
+ [1-9][0-9]*,[1-9][0-9]*)
572
+ # Variables are set to positive values already,
573
+ # sage-num-threads.py would just recompute them
574
+ ;;
575
+ *)
576
+ # See Issue Ticket #12016
577
+ # First, figure out the right values for SAGE_NUM_THREADS (default
578
+ # number of threads) and SAGE_NUM_THREADS_PARALLEL (default number of
579
+ # threads when parallel execution is asked explicitly).
580
+ sage_num_threads_array=$(sage-num-threads.py 2>/dev/null || echo 1 2 1)
581
+ sage_num_threads_array="${sage_num_threads_array% *}" # strip third item
582
+ SAGE_NUM_THREADS="${sage_num_threads_array% *}" # keep first item
583
+ SAGE_NUM_THREADS_PARALLEL="${sage_num_threads_array#* }" # keep second item
584
+ export SAGE_NUM_THREADS
585
+ export SAGE_NUM_THREADS_PARALLEL
586
+ ;;
587
+ esac
588
+
589
+ # Multithreading in OpenBLAS does not seem to play well with Sage's attempts to
590
+ # spawn new processes, see #26118. Apparently, OpenBLAS sets the thread
591
+ # affinity and, e.g., parallel doctest jobs, remain on the same core.
592
+ # Disabling that thread-affinity with OPENBLAS_MAIN_FREE=1 leads to hangs in
593
+ # some computations.
594
+ # So we disable OpenBLAS' threading completely; we might loose some performance
595
+ # here but strangely the opposite seems to be the case. Note that callers such
596
+ # as LinBox use a single-threaded OpenBLAS anyway.
597
+ export OPENBLAS_NUM_THREADS=1
598
+
599
+ if [ "$MAKE" = "" ]; then
600
+ MAKE="make"
601
+ fi
602
+
603
+ # If MAKEFLAGS exists, assume it got set by make.
604
+ # Therefore, remove all flags from $MAKE
605
+ if [ "${MAKEFLAGS-__unset__}" != "__unset__" ]; then
606
+ MAKE=`echo "$MAKE" | sed 's/ .*//'`
607
+ fi
608
+ export MAKE
609
+
610
+ # Set the cysignals crash logs directory
611
+ if [ -z "$CYSIGNALS_CRASH_LOGS" ]; then
612
+ export CYSIGNALS_CRASH_LOGS="$DOT_SAGE/crash_logs"
613
+ export CYSIGNALS_CRASH_DAYS=7 # keep logs for 7 days
614
+ fi
615
+
616
+ # You can set environment variables in $SAGE_RC_FILE
617
+ # (by default, this is the file $DOT_SAGE/sagerc). For example,
618
+ # setting PS1 there will set your prompt when you run "sage --sh".
619
+ if [ -z "$SAGE_RC_FILE" ]; then
620
+ SAGE_RC_FILE="$DOT_SAGE/sagerc"
621
+ fi
622
+
623
+ if [ -r "$SAGE_RC_FILE" ]; then
624
+ source "$SAGE_RC_FILE"
625
+ if [ $? -ne 0 ]; then
626
+ echo >&2 "Error sourcing $SAGE_RC_FILE"
627
+ exit 1
628
+ fi
629
+ fi
630
+
631
+ if [ -n "$SAGE_LOCAL" ]; then
632
+ # If we move the Sage tree then ncurses cannot find terminfo, hence, we
633
+ # tell it where to find it. See Issue Ticket #15091
634
+ export TERMINFO="$SAGE_LOCAL/share/terminfo"
635
+
636
+ # If nodejs is installed, activate the nodeenv containing it.
637
+
638
+ nodeenv_activate="$SAGE_LOCAL/share/nodejs/activate"
639
+
640
+ if [ -f "$nodeenv_activate" ]; then
641
+ # symlinked into nodeenv for specific version of nodejs installed
642
+ # The activate script needs to be sourced using its actual path.
643
+ nodeenv_activate=`resolvelinks "$nodeenv_activate"`
644
+
645
+ # Don't let nodeenv wipe out the sage-sh/sage-buildsh prompt.
646
+ NODE_VIRTUAL_ENV_DISABLE_PROMPT=1 . "$nodeenv_activate"
647
+
648
+ if [ $? -ne 0 ]; then
649
+ echo >&2 "Warning: failed to activate the nodeenv containing nodejs"
650
+ fi
651
+ elif [ -L "$nodeenv_activate" ]; then
652
+ echo >&2 "Warning: the nodeenv activation symlink for nodejs is broken"
653
+ fi
654
+
655
+ fi
656
+
657
+
658
+ # Newer versions of debugpy come with a bundled pydevd that complains
659
+ # about >=python-3.11's core modules being frozen (and therefore not
660
+ # breakpoint-able). This workaround simply hides the warning to keep
661
+ # our doctests predictable (which was the status quo with earlier
662
+ # versions of debugpy).
663
+ export PYDEVD_DISABLE_FILE_VALIDATION=1
664
+
665
+ # Finally, set SAGE_ENV_SOURCED as evidence that this script has been
666
+ # run successfully.
667
+ export SAGE_ENV_SOURCED="6:$SAGE_LOCAL:$SAGE_VENV:$SAGE_SRC"