Unverified Commit b974faef authored by TomaSajt's avatar TomaSajt
Browse files

{python3Packages.,}monosat: modernize

parent e8586783
Loading
Loading
Loading
Loading
+22 −18
Original line number Diff line number Diff line
@@ -14,18 +14,14 @@
}:

let
  boolToCmake = x: if x then "ON" else "OFF";

  rev = "1.8.0";
  sha256 = "0q3a8x3iih25xkp2bm842sm2hxlb8hxlls4qmvj7vzwrh4lvsl7b";

  pname = "monosat";
  version = rev;
  version = "1.8.0";

  src = fetchFromGitHub {
    owner = "sambayless";
    repo = "monosat";
    inherit rev sha256;
    tag = version;
    sha256 = "0q3a8x3iih25xkp2bm842sm2hxlb8hxlls4qmvj7vzwrh4lvsl7b";
  };

  patches = [
@@ -41,7 +37,7 @@ let
  # https://github.com/sambayless/monosat/issues/33
  commonPostPatch = lib.optionalString (!stdenv.hostPlatform.isx86) ''
    substituteInPlace src/monosat/Main.cc \
      --replace 'defined(__linux__)' '0'
      --replace-fail 'defined(__linux__)' '0'
  '';

  core = stdenv.mkDerivation {
@@ -63,12 +59,11 @@ let
    ];

    cmakeFlags = [
      "-DBUILD_STATIC=OFF"
      "-DJAVA=${boolToCmake includeJava}"
      "-DGPL=${boolToCmake includeGplCode}"

      (lib.cmakeBool "BUILD_STATIC" false)
      (lib.cmakeBool "JAVA" includeJava)
      (lib.cmakeBool "GPL" includeGplCode)
      # file RPATH_CHANGE could not write new RPATH
      "-DCMAKE_SKIP_BUILD_RPATH=ON"
      (lib.cmakeBool "CMAKE_SKIP_BUILD_RPATH" true)
    ];

    postInstall = lib.optionalString includeJava ''
@@ -91,11 +86,13 @@ let
  python =
    {
      buildPythonPackage,
      setuptools,
      cython,
      pytestCheckHook,
    }:
    buildPythonPackage {
      format = "setuptools";
      pyproject = true;

      inherit
        pname
        version
@@ -103,13 +100,15 @@ let
        patches
        ;

      propagatedBuildInputs = [
        core
      build-system = [
        setuptools
        cython
      ];

      buildInputs = [ core ];

      # This tells setup.py to use cython, which should produce faster bindings
      MONOSAT_CYTHON = true;
      env.MONOSAT_CYTHON = true;

      # After patching src, move to where the actually relevant source is. This could just be made
      # the sourceRoot if it weren't for the patch.
@@ -124,7 +123,7 @@ let
          # shared lib? The current setup.py copies the .dylib/.so...
          ''
            substituteInPlace setup.py \
              --replace 'library_dir = "../../../../"' 'library_dir = "${core}/lib/"'
              --replace-fail 'library_dir = "../../../../"' 'library_dir = "${core}/lib/"'
          '';

      nativeCheckInputs = [ pytestCheckHook ];
@@ -133,6 +132,11 @@ let
        "test_assertAtMostOne"
        "test_assertEqual"
      ];

      pythonImportsCheck = [
        "monosat"
        "monosat.monosat_p"
      ];
    };
in
core
+1 −4
Original line number Diff line number Diff line
@@ -9967,10 +9967,7 @@ self: super: with self; {
  monkeytype = callPackage ../development/python-modules/monkeytype { };
  monosat = pkgs.monosat.python {
    inherit buildPythonPackage;
    inherit (self) cython pytestCheckHook;
  };
  monosat = callPackage pkgs.monosat.python { };
  monotonic = callPackage ../development/python-modules/monotonic { };