3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/applications/science/math/sage/sage-env.nix

197 lines
4.4 KiB
Nix
Raw Normal View History

2018-04-24 22:53:36 +01:00
{ stdenv
, lib
, writeTextFile
, sagelib
, env-locations
, gfortran
, bash
, coreutils
, gnused
, gnugrep
, binutils
, pythonEnv
, python3
, pkg-config
, pari
2019-01-16 23:28:37 +00:00
, gap
2018-04-24 22:53:36 +01:00
, ecl
, maxima-ecl
, singular
, fflas-ffpack
, givaro
, gd
, libpng
, linbox
, m4ri
2018-04-24 22:53:36 +01:00
, giac
, palp
, rWrapper
, gfan
, cddlib
, jmol
, tachyon
, glpk
, eclib
, sympow
, nauty
, sqlite
, ppl
, ecm
, lcalc
, rubiks
, flintqs
, blas
, lapack
2018-04-24 22:53:36 +01:00
, flint
, gmp
, mpfr
, pynac
, zlib
, gsl
, ntl
2020-09-19 13:22:43 +01:00
, jdk8
, less
2018-04-24 22:53:36 +01:00
}:
assert (!blas.isILP64) && (!lapack.isILP64);
2018-11-12 22:28:29 +00:00
# This generates a `sage-env` shell file that will be sourced by sage on startup.
# It sets up various environment variables, telling sage where to find its
# dependencies.
2018-04-24 22:53:36 +01:00
let
2020-09-19 13:22:43 +01:00
jdk = jdk8; # TODO: remove override https://github.com/NixOS/nixpkgs/pull/89731
2018-04-24 22:53:36 +01:00
runtimepath = (lib.makeBinPath ([
"@sage-local@"
"@sage-local@/build"
pythonEnv
gfortran # for inline fortran
stdenv.cc # for cython
bash
coreutils
gnused
gnugrep
binutils.bintools
pkg-config
pari
2019-01-16 23:28:37 +00:00
gap
2018-04-24 22:53:36 +01:00
ecl
maxima-ecl
singular
giac
palp
2018-11-27 17:26:16 +00:00
# needs to be rWrapper since the default `R` doesn't include R's default libraries
2018-04-24 22:53:36 +01:00
rWrapper
gfan
cddlib
jmol
tachyon
glpk
eclib
sympow
nauty
sqlite
ppl
ecm
lcalc
rubiks
flintqs
2018-12-01 20:26:37 +00:00
jdk # only needed for `jmol` which may be replaced in the future
less # needed to prevent transient test errors until https://github.com/ipython/ipython/pull/11864 is resolved
2018-04-24 22:53:36 +01:00
]
));
in
writeTextFile rec {
name = "sage-env";
destination = "/${name}";
text = ''
export PKG_CONFIG_PATH='${lib.makeSearchPathOutput "dev" "lib/pkgconfig" [
# This should only be needed during build. However, since the doctests
# also test the cython build (for example in src/sage/misc/cython.py),
# it is also needed for the testsuite to pass. We could fix the
# testsuite instead, but since all the packages are also runtime
# dependencies it doesn't really hurt to include them here.
2018-04-24 22:53:36 +01:00
singular
blas lapack
fflas-ffpack givaro
gd
libpng zlib
gsl
linbox
m4ri
]
2018-04-24 22:53:36 +01:00
}'
2018-11-12 22:28:29 +00:00
export SAGE_ROOT='${sagelib.src}'
2020-11-30 13:09:26 +00:00
'' +
# TODO: is using pythonEnv instead of @sage-local@ here a good
# idea? there is a test in src/sage/env.py that checks if the values
# SAGE_ROOT and SAGE_LOCAL set here match the ones set in env.py.
# we fix up env.py's SAGE_ROOT in sage-src.nix (which does not
# have access to sage-with-env), but env.py autodetects
# SAGE_LOCAL to be pythonEnv.
# setting SAGE_LOCAL to pythonEnv also avoids having to create
# python3, ipython, ipython3 and jupyter symlinks in
# sage-with-env.nix.
''
export SAGE_LOCAL='${pythonEnv}'
2018-04-24 22:53:36 +01:00
export SAGE_SHARE='${sagelib}/share'
2020-11-30 13:09:26 +00:00
export SAGE_ENV_CONFIG_SOURCED=1 # sage-env complains if sage-env-config is not sourced beforehand
2018-04-24 22:53:36 +01:00
orig_path="$PATH"
export PATH='${runtimepath}'
# set dependent vars, like JUPYTER_CONFIG_DIR
2018-11-12 22:28:29 +00:00
source "${sagelib.src}/src/bin/sage-env"
2019-01-16 23:28:37 +00:00
export PATH="$RUNTIMEPATH_PREFIX:${runtimepath}:$orig_path" # sage-env messes with PATH
2018-04-24 22:53:36 +01:00
export SAGE_LOGS="$TMPDIR/sage-logs"
export SAGE_DOC="''${SAGE_DOC_OVERRIDE:-doc-placeholder}"
2018-11-12 22:28:29 +00:00
export SAGE_DOC_SRC="''${SAGE_DOC_SRC_OVERRIDE:-${sagelib.src}/src/doc}"
2018-04-24 22:53:36 +01:00
# set locations of dependencies
. ${env-locations}/sage-env-locations
# needed for cython
export CC='${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc'
# cython needs to find these libraries, otherwise will fail with `ld: cannot find -lflint` or similar
export LDFLAGS='${
lib.concatStringsSep " " (map (pkg: "-L${pkg}/lib") [
flint
2019-01-16 23:28:37 +00:00
gap
2018-04-24 22:53:36 +01:00
glpk
gmp
mpfr
pari
pynac
zlib
eclib
gsl
ntl
jmol
sympow
])
}'
export CFLAGS='${
lib.concatStringsSep " " (map (pkg: "-isystem ${pkg}/include") [
singular
gmp.dev
glpk
flint
2019-01-16 23:28:37 +00:00
gap
2018-04-24 22:53:36 +01:00
pynac
mpfr.dev
])
}'
2020-11-30 13:09:26 +00:00
export SAGE_LIB='${sagelib}/${python3.sitePackages}'
2018-04-24 22:53:36 +01:00
2020-11-30 13:09:26 +00:00
export SAGE_EXTCODE='${sagelib.src}/src/sage/ext_data'
2018-04-24 22:53:36 +01:00
2018-11-12 22:28:29 +00:00
# for find_library
export DYLD_LIBRARY_PATH="${lib.makeLibraryPath [stdenv.cc.libc singular]}''${DYLD_LIBRARY_PATH:+:}$DYLD_LIBRARY_PATH"
2018-04-24 22:53:36 +01:00
'';
2018-11-12 22:28:29 +00:00
} // {
lib = sagelib; # equivalent of `passthru`, which `writeTextFile` doesn't support
2018-04-24 22:53:36 +01:00
}