From b974faef7c9870adc62fce714c0d93dcd1e4bc47 Mon Sep 17 00:00:00 2001 From: TomaSajt <62384384+TomaSajt@users.noreply.github.com> Date: Fri, 18 Jul 2025 21:37:59 +0200 Subject: [PATCH] {python3Packages.,}monosat: modernize --- pkgs/by-name/mo/monosat/package.nix | 40 ++++++++++++++++------------- pkgs/top-level/python-packages.nix | 5 +--- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/pkgs/by-name/mo/monosat/package.nix b/pkgs/by-name/mo/monosat/package.nix index e45a9925f300..7744afd0eb1c 100644 --- a/pkgs/by-name/mo/monosat/package.nix +++ b/pkgs/by-name/mo/monosat/package.nix @@ -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 diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index cc6849e4cf16..89139edb4bad 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -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 { };