diff --git a/pkgs/development/libraries/sundials/3.x.nix b/pkgs/development/libraries/sundials/3.x.nix new file mode 100644 index 000000000000..879f13e8bf53 --- /dev/null +++ b/pkgs/development/libraries/sundials/3.x.nix @@ -0,0 +1,52 @@ +{ stdenv +, cmake +, fetchurl +, python +, liblapack +, gfortran +, lapackSupport ? true }: + +let liblapackShared = liblapack.override { + shared = true; +}; + +in stdenv.mkDerivation rec { + pname = "sundials"; + version = "3.2.1"; + + buildInputs = [ python ] ++ stdenv.lib.optionals (lapackSupport) [ gfortran ]; + nativeBuildInputs = [ cmake ]; + + src = fetchurl { + url = "https://computation.llnl.gov/projects/${pname}/download/${pname}-${version}.tar.gz"; + sha256 = "0238r1qnwqz13wcjzfsbcfi8rfnlxcjjmxq2vpf2qf5jgablvna7"; + }; + + patches = [ + (fetchurl { + # https://github.com/LLNL/sundials/pull/19 + url = "https://github.com/LLNL/sundials/commit/1350421eab6c5ab479de5eccf6af2dcad1eddf30.patch"; + sha256 = "0g67lixp9m85fqpb9rzz1hl1z8ibdg0ldwq5z6flj5zl8a7cw52l"; + }) + ]; + + cmakeFlags = [ + "-DEXAMPLES_INSTALL_PATH=${placeholder "out"}/share/examples" + ] ++ stdenv.lib.optionals (lapackSupport) [ + "-DSUNDIALS_INDEX_TYPE=int32_t" + "-DLAPACK_ENABLE=ON" + "-DLAPACK_LIBRARIES=${liblapackShared}/lib/liblapack${stdenv.hostPlatform.extensions.sharedLibrary};${liblapackShared}/lib/libblas${stdenv.hostPlatform.extensions.sharedLibrary}" + ]; + + # flaky tests, and patch in https://github.com/LLNL/sundials/pull/21 doesn't apply cleanly for sundials_3 + doCheck = false; + checkPhase = "make test"; + + meta = with stdenv.lib; { + description = "Suite of nonlinear differential/algebraic equation solvers"; + homepage = https://computation.llnl.gov/projects/sundials; + platforms = platforms.all; + maintainers = with maintainers; [ flokli idontgetoutmuch ]; + license = licenses.bsd3; + }; +} diff --git a/pkgs/development/libraries/sundials/default.nix b/pkgs/development/libraries/sundials/default.nix index abe444c63c32..4bc066df32e2 100644 --- a/pkgs/development/libraries/sundials/default.nix +++ b/pkgs/development/libraries/sundials/default.nix @@ -1,28 +1,58 @@ -{ cmake, fetchurl, python, stdenv }: +{ stdenv +, cmake +, fetchurl +, python +, liblapack +, gfortran +, lapackSupport ? true }: -stdenv.mkDerivation rec { +let liblapackShared = liblapack.override { + shared = true; +}; +in stdenv.mkDerivation rec { pname = "sundials"; version = "4.1.0"; + buildInputs = [ python ] ++ stdenv.lib.optionals (lapackSupport) [ gfortran ]; + nativeBuildInputs = [ cmake ]; + src = fetchurl { url = "https://computation.llnl.gov/projects/${pname}/download/${pname}-${version}.tar.gz"; sha256 = "19ca4nmlf6i9ijqcibyvpprxzsdfnackgjs6dw51fq13gg1f2398"; }; - preConfigure = '' - export cmakeFlags="-DCMAKE_INSTALL_PREFIX=$out -DEXAMPLES_INSTALL_PATH=$out/share/examples $cmakeFlags" - ''; + patches = [ + (fetchurl { + # https://github.com/LLNL/sundials/pull/19 + url = "https://github.com/LLNL/sundials/commit/1350421eab6c5ab479de5eccf6af2dcad1eddf30.patch"; + sha256 = "0g67lixp9m85fqpb9rzz1hl1z8ibdg0ldwq5z6flj5zl8a7cw52l"; + }) + (fetchurl { + # https://github.com/LLNL/sundials/pull/20 + url = "https://github.com/LLNL/sundials/pull/20/commits/2d951bbe1ff7842fcd0dafa28c61b0aa94015f66.patch"; + sha256 = "0lcr6m4lk14yqrxah4rdscpczny5l7m1zpfsjh8bgspadfsgk512"; + }) + # https://github.com/LLNL/sundials/pull/21 + ./tests-parallel.patch + ]; - nativeBuildInputs = [ cmake ]; - buildInputs = [ python ]; + cmakeFlags = [ + "-DEXAMPLES_INSTALL_PATH=${placeholder "out"}/share/examples" + ] ++ stdenv.lib.optionals (lapackSupport) [ + "-DSUNDIALS_INDEX_TYPE=int32_t" + "-DLAPACK_ENABLE=ON" + "-DLAPACK_LIBRARIES=${liblapackShared}/lib/liblapack${stdenv.hostPlatform.extensions.sharedLibrary};${liblapackShared}/lib/libblas${stdenv.hostPlatform.extensions.sharedLibrary}" + ]; + + doCheck = true; + checkPhase = "make test"; meta = with stdenv.lib; { description = "Suite of nonlinear differential/algebraic equation solvers"; homepage = https://computation.llnl.gov/projects/sundials; platforms = platforms.all; - maintainers = [ maintainers.idontgetoutmuch ]; + maintainers = with maintainers; [ flokli idontgetoutmuch ]; license = licenses.bsd3; }; - } diff --git a/pkgs/development/libraries/sundials/tests-parallel.patch b/pkgs/development/libraries/sundials/tests-parallel.patch new file mode 100644 index 000000000000..a785a1dade9b --- /dev/null +++ b/pkgs/development/libraries/sundials/tests-parallel.patch @@ -0,0 +1,45 @@ +diff --git a/config/SundialsAddTest.cmake b/config/SundialsAddTest.cmake +index e965fed..a7fb1d2 100644 +--- a/config/SundialsAddTest.cmake ++++ b/config/SundialsAddTest.cmake +@@ -70,7 +70,7 @@ MACRO(SUNDIALS_ADD_TEST NAME EXECUTABLE) + "--verbose" + "--testname=${NAME}" + "--executablename=$" +- "--outputdir=${CMAKE_BINARY_DIR}/Testing/output" ++ "--outputdir=${TEST_OUTPUT_DIR}" + ) + + # do not diff the output and answer files +diff --git a/config/SundialsTesting.cmake b/config/SundialsTesting.cmake +index 815576a..d91801a 100644 +--- a/config/SundialsTesting.cmake ++++ b/config/SundialsTesting.cmake +@@ -29,6 +29,13 @@ IF(SUNDIALS_DEVTESTS) + ENDIF() + ENDIF() + ++ # Directory for test output ++ SET(TEST_OUTPUT_DIR ${PROJECT_BINARY_DIR}/Testing/output) ++ ++ IF(NOT EXISTS ${TEST_OUTPUT_DIR}) ++ FILE(MAKE_DIRECTORY ${TEST_OUTPUT_DIR}) ++ ENDIF() ++ + # look for the testRunner script in the test directory + FIND_PROGRAM(TESTRUNNER testRunner PATHS test) + HIDE_VARIABLE(TESTRUNNER) +diff --git a/test/testRunner b/test/testRunner +index f450ec2..f1c8deb 100755 +--- a/test/testRunner ++++ b/test/testRunner +@@ -106,7 +106,8 @@ def main(): + + # create output directory if necessary + if not os.path.exists(outDir): +- os.makedirs(outDir) ++ error("Output directory does not exist, it must be created.", outDir) ++ sys.exit(1) + elif not os.path.isdir(outDir): + error("Output directory exists but is not a directory, it must be deleted.", outDir) + sys.exit(1) diff --git a/pkgs/development/python-modules/scikits-odes/default.nix b/pkgs/development/python-modules/scikits-odes/default.nix new file mode 100644 index 000000000000..89ffe334e7ff --- /dev/null +++ b/pkgs/development/python-modules/scikits-odes/default.nix @@ -0,0 +1,55 @@ +{ stdenv +, lib +, buildPythonPackage +, fetchFromGitHub +, fetchurl +, cython +, enum34 +, gfortran +, isPy3k +, numpy +, pytest +, python +, scipy +, sundials_3 +}: + +buildPythonPackage rec { + pname = "scikits.odes"; + version = "2.4.0-9-g93075ae"; + + # we fetch github instead of Pypi, as we want #104 and #105, which don't apply cleanly on 2.4.0 + src = fetchFromGitHub { + owner = "bmcage"; + repo = "odes"; + rev = "93075ae25c409f572f13ca7207fada5706f73c73"; + sha256 = "161rab7hy6r1a9xw1zby9xhnnmxi0zwdpzxfpjkw9651xn2k5xyw"; + }; + + nativeBuildInputs = [ + gfortran + cython + ]; + + propagatedBuildInputs = [ + numpy + sundials_3 + scipy + ] ++ lib.optionals (!isPy3k) [ enum34 ]; + + doCheck = true; + checkInputs = [ pytest ]; + + checkPhase = '' + cd $out/${python.sitePackages}/scikits/odes/tests + pytest + ''; + + meta = with stdenv.lib; { + description = "A scikit offering extra ode/dae solvers, as an extension to what is available in scipy"; + homepage = https://github.com/bmcage/odes; + license = licenses.bsd3; + maintainers = with maintainers; [ flokli idontgetoutmuch ]; + platforms = [ "aarch64-linux" "x86_64-linux" "x86_64-darwin" ]; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 1cea76ad3dbe..ca37025f7f31 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -13746,6 +13746,8 @@ in sundials = callPackage ../development/libraries/sundials { }; + sundials_3 = callPackage ../development/libraries/sundials/3.x.nix { }; + sutils = callPackage ../tools/misc/sutils { }; svrcore = callPackage ../development/libraries/svrcore { }; diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 2e0ff367f9e7..80e5420bf002 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -4846,6 +4846,8 @@ in { scikit-build = callPackage ../development/python-modules/scikit-build { }; + scikits-odes = callPackage ../development/python-modules/scikits-odes { }; + scikit-optimize = callPackage ../development/python-modules/scikit-optimize { }; scikit-tda = callPackage ../development/python-modules/scikit-tda { };