diff --git a/pkgs/by-name/sy/symengine/package.nix b/pkgs/by-name/sy/symengine/package.nix index 5c71dfc1d5cb..5b55cbe4a867 100644 --- a/pkgs/by-name/sy/symengine/package.nix +++ b/pkgs/by-name/sy/symengine/package.nix @@ -2,25 +2,43 @@ lib, stdenv, fetchFromGitHub, + fetchpatch2, cmake, gmp, flint, mpfr, libmpc, - withShared ? true, + withShared ? !stdenv.hostPlatform.isStatic, }: -stdenv.mkDerivation rec { +stdenv.mkDerivation (finalAttrs: { pname = "symengine"; version = "0.14.0"; src = fetchFromGitHub { owner = "symengine"; repo = "symengine"; - rev = "v${version}"; + rev = "v${finalAttrs.version}"; hash = "sha256-WriVcYt3fkObR2U4J6a4KGGc2HgyyFyFpdrwxBD+AHA="; }; + outputs = [ + "out" + "dev" + ]; + + # upgrade supported cmake version in SymEngineConfig.cmake + patches = [ + (fetchpatch2 { + url = "https://github.com/symengine/symengine/commit/c149b874b8ff947e51e8e58670a0d37daf588f86.patch?full_index=1"; + hash = "sha256-LqkJRPdsbE8OE8G6AkpWX9B+GqnOQjUNPHpKKIcCL3Q="; + }) + (fetchpatch2 { + url = "https://github.com/symengine/symengine/commit/186f72e208220efd12362c336a49378076f63f30.patch?full_index=1"; + hash = "sha256-CuQra9K3MTxm8M0bt3LooJz9HgW0/Jy6ydRBCvEgkO4="; + }) + ]; + nativeBuildInputs = [ cmake ]; buildInputs = [ @@ -31,28 +49,22 @@ stdenv.mkDerivation rec { ]; cmakeFlags = [ - "-DWITH_FLINT=ON" - "-DINTEGER_CLASS=flint" - "-DWITH_SYMENGINE_THREAD_SAFE=yes" - "-DWITH_MPC=yes" - "-DBUILD_FOR_DISTRIBUTION=yes" - ] - ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [ - # error: unrecognized instruction mnemonic, did you mean: bit, cnt, hint, ins, not? - "-DBUILD_TESTS=OFF" - ] - ++ lib.optionals withShared [ - "-DBUILD_SHARED_LIBS=ON" + (lib.cmakeBool "WITH_FLINT" true) + (lib.cmakeFeature "INTEGER_CLASS" "flint") + (lib.cmakeBool "WITH_SYMENGINE_THREAD_SAFE" true) + (lib.cmakeBool "WITH_MPC" true) + (lib.cmakeBool "BUILD_FOR_DISTRIBUTION" true) + (lib.cmakeBool "BUILD_TESTS" finalAttrs.finalPackage.doCheck) + (lib.cmakeBool "BUILD_SHARED_LIBS" withShared) ]; doCheck = true; - meta = with lib; { + meta = { description = "Fast symbolic manipulation library"; homepage = "https://github.com/symengine/symengine"; - platforms = platforms.unix ++ platforms.windows; - license = licenses.bsd3; - maintainers = [ maintainers.costrouc ]; + platforms = with lib.platforms; unix ++ windows; + license = lib.licenses.bsd3; + maintainers = with lib.maintainers; [ costrouc ]; }; - -} +}) diff --git a/pkgs/development/python-modules/symengine/default.nix b/pkgs/development/python-modules/symengine/default.nix index 9b5a0b4fd9ec..0033cc62d303 100644 --- a/pkgs/development/python-modules/symengine/default.nix +++ b/pkgs/development/python-modules/symengine/default.nix @@ -3,19 +3,17 @@ buildPythonPackage, fetchFromGitHub, cython, + setuptools, cmake, symengine, pytest, sympy, python, - setuptools, }: buildPythonPackage rec { pname = "symengine"; version = "0.14.1"; - - build-system = [ setuptools ]; pyproject = true; src = fetchFromGitHub { @@ -25,19 +23,24 @@ buildPythonPackage rec { hash = "sha256-adzODm7gAqwAf7qzfRQ1AG8mC3auiXM4OsV/0h+ZmUg="; }; - env = { - SymEngine_DIR = "${symengine}"; - }; - postPatch = '' substituteInPlace setup.py \ --replace-fail "'cython>=0.29.24'" "'cython'" ''; + build-system = [ + cython + setuptools + ]; + dontUseCmakeConfigure = true; + nativeBuildInputs = [ cmake - cython + ]; + + buildInputs = [ + symengine ]; nativeCheckInputs = [ @@ -47,15 +50,17 @@ buildPythonPackage rec { checkPhase = '' runHook preCheck + mkdir empty && cd empty ${python.interpreter} ../bin/test_python.py + runHook postCheck ''; - meta = with lib; { + meta = { description = "Python library providing wrappers to SymEngine"; homepage = "https://github.com/symengine/symengine.py"; - license = licenses.mit; + license = lib.licenses.mit; maintainers = [ ]; }; }