summary refs log tree commit diff
path: root/pkgs/development/libraries/science/math/or-tools/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/libraries/science/math/or-tools/default.nix')
-rw-r--r--pkgs/development/libraries/science/math/or-tools/default.nix32
1 files changed, 24 insertions, 8 deletions
diff --git a/pkgs/development/libraries/science/math/or-tools/default.nix b/pkgs/development/libraries/science/math/or-tools/default.nix
index 415e57e5d3c..ba6827bf694 100644
--- a/pkgs/development/libraries/science/math/or-tools/default.nix
+++ b/pkgs/development/libraries/science/math/or-tools/default.nix
@@ -1,15 +1,17 @@
-{ stdenv, fetchFromGitHub, cmake, google-gflags, which
-, lsb-release, glog, protobuf, cbc, zlib, python3 }:
+{ stdenv, fetchFromGitHub, cmake, abseil-cpp, google-gflags, which
+, lsb-release, glog, protobuf, cbc, zlib
+, ensureNewerSourcesForZipFilesHook, python, swig
+, pythonProtobuf }:
 
 stdenv.mkDerivation rec {
   name = "or-tools-${version}";
-  version = "v6.10";
+  version = "v7.0";
 
   src = fetchFromGitHub {
     owner = "google";
     repo = "or-tools";
     rev = version;
-    sha256 = "11k3671rpv968dsglc6bgarr9yi8ijaaqm2wq3m0rn4wy8fj7za2";
+    sha256 = "09rs2j3w4ljw9qhhnsjlvfii297njjszwvkbgj1i6kns3wnlr7cp";
   };
 
   # The original build system uses cmake which does things like pull
@@ -18,6 +20,7 @@ stdenv.mkDerivation rec {
   # dependencies straight from nixpkgs and use the make build method.
   configurePhase = ''
     cat <<EOF > Makefile.local
+    UNIX_ABSL_DIR=${abseil-cpp}
     UNIX_GFLAGS_DIR=${google-gflags}
     UNIX_GLOG_DIR=${glog}
     UNIX_PROTOBUF_DIR=${protobuf}
@@ -25,23 +28,36 @@ stdenv.mkDerivation rec {
     EOF
   '';
 
-  makeFlags = [ "prefix=${placeholder "out"}" ];
-  buildFlags = [ "cc" ];
+  makeFlags = [
+    "prefix=${placeholder "out"}"
+    "PROTOBUF_PYTHON_DESC=${pythonProtobuf}/${python.sitePackages}/google/protobuf/descriptor_pb2.py"
+  ];
+  buildFlags = [ "cc" "pypi_archive" ];
 
   checkTarget = "test_cc";
   doCheck = true;
 
   installTargets = [ "install_cc" ];
+  # The upstream install_python target installs to $HOME.
+  postInstall = ''
+    mkdir -p "$python/${python.sitePackages}"
+    (cd temp_python/ortools; PYTHONPATH="$python/${python.sitePackages}:$PYTHONPATH" python setup.py install '--prefix=$python')
+  '';
 
   nativeBuildInputs = [
-    cmake lsb-release which zlib python3
+    cmake lsb-release swig which zlib python
+    ensureNewerSourcesForZipFilesHook
+    python.pkgs.setuptools python.pkgs.wheel
   ];
   propagatedBuildInputs = [
-    google-gflags glog protobuf cbc
+    abseil-cpp google-gflags glog protobuf cbc
+    pythonProtobuf python.pkgs.six
   ];
 
   enableParallelBuilding = true;
 
+  outputs = [ "out" "python" ];
+
   meta = with stdenv.lib; {
     homepage = https://github.com/google/or-tools;
     license = licenses.asl20;