or-tools: Add Python bindings

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
This commit is contained in:
Anders Kaseorg 2018-12-11 23:54:31 -08:00
parent 373488e6f4
commit 08e9273e29
4 changed files with 27 additions and 17 deletions

View File

@ -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;

View File

@ -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"

View File

@ -21750,7 +21750,9 @@ in
nauty = callPackage ../applications/science/math/nauty {};
or-tools = callPackage ../development/libraries/science/math/or-tools {};
or-tools = callPackage ../development/libraries/science/math/or-tools {
pythonProtobuf = pythonPackages.protobuf;
};
rubiks = callPackage ../development/libraries/science/math/rubiks { };

View File

@ -551,6 +551,11 @@ in {
ordered-set = callPackage ../development/python-modules/ordered-set { };
ortools = (toPythonModule (pkgs.or-tools.override {
inherit (self) python;
pythonProtobuf = self.protobuf;
})).python;
osmnx = callPackage ../development/python-modules/osmnx { };
outcome = callPackage ../development/python-modules/outcome {};