···1-{ lib
2-, stdenv
3-, fetchFromGitHub
4-, cmake
5-, abseil-cpp
6, bzip2
7-, zlib
8-, lsb-release
9-, which
10-, protobuf
11, cbc
0012, ensureNewerSourcesForZipFilesHook
00000013, python
0014, swig4
0015}:
1617stdenv.mkDerivation rec {
18 pname = "or-tools";
19- version = "9.1";
20- disabled = python.pythonOlder "3.6"; # not supported upstream
2122 src = fetchFromGitHub {
23 owner = "google";
24 repo = "or-tools";
25 rev = "v${version}";
26- sha256 = "sha256-dEYMPWpa3J9EqtCq3kubdUYJivNRTOKUpNDx3UC1IcQ=";
27 };
28-29- # The original build system uses cmake which does things like pull
30- # in dependencies through git and Makefile creation time. We
31- # obviously don't want to do this so instead we provide the
32- # dependencies straight from nixpkgs and use the make build method.
33-34- # Cbc is linked against bzip2 and declares this in its pkgs-config file,
35- # but this makefile doesn't use pkgs-config, so we also have to add lbz2
36- configurePhase = ''
37- substituteInPlace makefiles/Makefile.third_party.unix.mk \
38- --replace 'COINUTILS_LNK = $(STATIC_COINUTILS_LNK)' \
39- 'COINUTILS_LNK = $(STATIC_COINUTILS_LNK) -lbz2'
40-41- cat <<EOF > Makefile.local
42- UNIX_ABSL_DIR=${abseil-cpp}
43- UNIX_PROTOBUF_DIR=${protobuf}
44- UNIX_CBC_DIR=${cbc}
45- USE_SCIP=OFF
46- EOF
47- '';
4849- # Many of these 'samples' (which are really the tests) require using SCIP, and or-tools 8.1
50- # will just crash if SCIP is not found because it doesn't fall back to using one of
51- # the available solvers: https://github.com/google/or-tools/blob/b77bd3ac69b7f3bb02f55b7bab6cbb4bab3917f2/ortools/linear_solver/linear_solver.cc#L427
52- # We don't compile with SCIP because it does not have an open source license.
53- # See https://github.com/google/or-tools/issues/2395
54- preBuild = ''
55- for file in ortools/linear_solver/samples/*.cc; do
56- if grep -q SCIP_MIXED_INTEGER_PROGRAMMING $file; then
57- substituteInPlace $file --replace SCIP_MIXED_INTEGER_PROGRAMMING CBC_MIXED_INTEGER_PROGRAMMING
58- fi;
59- done
60-61- substituteInPlace ortools/linear_solver/samples/simple_mip_program.cc \
62- --replace 'SCIP' 'CBC'
63- '';
64- makeFlags = [
65- "prefix=${placeholder "out"}"
66- "PROTOBUF_PYTHON_DESC=${python.pkgs.protobuf}/${python.sitePackages}/google/protobuf/descriptor_pb2.py"
67 ];
68- buildFlags = [ "cc" "pypi_archive" ];
69-70- doCheck = true;
71- checkTarget = "test_cc";
72-73- installTargets = [ "install_cc" ];
74- # The upstream install_python target installs to $HOME.
75- postInstall = ''
76- mkdir -p "$python/${python.sitePackages}"
77- (cd temp_python/ortools; PYTHONPATH="$python/${python.sitePackages}:$PYTHONPATH" python setup.py install '--prefix=$python')
78- '';
79-80- # protobuf generation is not thread safe
81- enableParallelBuilding = false;
82-83 nativeBuildInputs = [
84 cmake
85- lsb-release
00086 swig4
87- which
88- ensureNewerSourcesForZipFilesHook
0000000089 python.pkgs.setuptools
90 python.pkgs.wheel
91- ];
92- buildInputs = [
93 zlib
94- bzip2
95- python
96 ];
97 propagatedBuildInputs = [
98 abseil-cpp
99 protobuf
100-101 python.pkgs.protobuf
102- python.pkgs.six
103- python.pkgs.absl-py
104- python.pkgs.mypy-protobuf
000105 ];
000000000000106107 outputs = [ "out" "python" ];
108