Merge pull request #58417 from andersk/ortools-7.0

or-tools: 6.10 -> 7.0, add Python bindings
This commit is contained in:
Mateusz Kowalczyk 2019-04-20 17:39:23 +09:00 committed by GitHub
commit 575d6a4826
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 58 additions and 21 deletions

View File

@ -0,0 +1,24 @@
{ stdenv, fetchFromGitHub, cmake }:
stdenv.mkDerivation rec {
name = "abseil-cpp-${version}";
date = "20190322";
rev = "eab2078b53c9e3d9d240135c09d27e3393acb50a";
version = "${date}-${rev}";
src = fetchFromGitHub {
owner = "abseil";
repo = "abseil-cpp";
rev = "${rev}";
sha256 = "1bpz44hxq5fpkv6jlgphzk7mxjiiah526jgb63ih5pd1hd2cfw1r";
};
nativeBuildInputs = [ cmake ];
meta = with stdenv.lib; {
description = "An open-source collection of C++ code designed to augment the C++ standard library";
homepage = https://abseil.io/;
license = licenses.asl20;
maintainers = [ maintainers.andersk ];
};
}

View File

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

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

@ -9570,6 +9570,8 @@ in
aalib = callPackage ../development/libraries/aalib { };
abseil-cpp = callPackage ../development/libraries/abseil-cpp { };
accountsservice = callPackage ../development/libraries/accountsservice { };
acl = callPackage ../development/libraries/acl { };
@ -22079,7 +22081,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

@ -555,6 +555,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 {};