summary refs log tree commit diff
path: root/pkgs/development/libraries
diff options
context:
space:
mode:
authorAnders Kaseorg <andersk@mit.edu>2018-12-11 23:54:31 -0800
committerAnders Kaseorg <andersk@mit.edu>2019-03-26 17:04:03 -0700
commit08e9273e29ef087950078c75b068b053d5838141 (patch)
tree75f6f9159aa384ff4d364705518c91d80fd900ec /pkgs/development/libraries
parent373488e6f4c3dc3bb51cabcb959e4a70eb5d7b2c (diff)
downloadnixpkgs-08e9273e29ef087950078c75b068b053d5838141.tar
nixpkgs-08e9273e29ef087950078c75b068b053d5838141.tar.gz
nixpkgs-08e9273e29ef087950078c75b068b053d5838141.tar.bz2
nixpkgs-08e9273e29ef087950078c75b068b053d5838141.tar.lz
nixpkgs-08e9273e29ef087950078c75b068b053d5838141.tar.xz
nixpkgs-08e9273e29ef087950078c75b068b053d5838141.tar.zst
nixpkgs-08e9273e29ef087950078c75b068b053d5838141.zip
or-tools: Add Python bindings
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
Diffstat (limited to 'pkgs/development/libraries')
-rw-r--r--pkgs/development/libraries/science/math/or-tools/default.nix23
-rw-r--r--pkgs/development/libraries/science/math/or-tools/gflags-include.patch12
2 files changed, 19 insertions, 16 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..71960c64a98 100644
--- a/pkgs/development/libraries/science/math/or-tools/default.nix
+++ b/pkgs/development/libraries/science/math/or-tools/default.nix
@@ -1,5 +1,7 @@
 { stdenv, fetchFromGitHub, cmake, google-gflags, which
-, lsb-release, glog, protobuf, cbc, zlib, python3 }:
+, lsb-release, glog, protobuf, cbc, zlib
+, ensureNewerSourcesForZipFilesHook, python, swig
+, pythonProtobuf }:
 
 stdenv.mkDerivation rec {
   name = "or-tools-${version}";
@@ -25,23 +27,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
+    pythonProtobuf python.pkgs.six
   ];
 
   enableParallelBuilding = true;
 
+  outputs = [ "out" "python" ];
+
   meta = with stdenv.lib; {
     homepage = https://github.com/google/or-tools;
     license = licenses.asl20;
diff --git a/pkgs/development/libraries/science/math/or-tools/gflags-include.patch b/pkgs/development/libraries/science/math/or-tools/gflags-include.patch
deleted file mode 100644
index 08f76180638..00000000000
--- a/pkgs/development/libraries/science/math/or-tools/gflags-include.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff --git a/ortools/data/jobshop_scheduling_parser.cc b/ortools/data/jobshop_scheduling_parser.cc
-index cb0a360b..c2f055eb 100644
---- a/ortools/data/jobshop_scheduling_parser.cc
-+++ b/ortools/data/jobshop_scheduling_parser.cc
-@@ -14,6 +14,7 @@
- #include "ortools/data/jobshop_scheduling_parser.h"
- 
- #include <cmath>
-+#include <gflags/gflags.h>
- 
- #include "google/protobuf/wrappers.pb.h"
- #include "ortools/base/filelineiter.h"