Merge pull request #194337 from andersk/ortools

authored by Sandro and committed by GitHub a362cc95 fdce3577

+70 -79
+67 -76
pkgs/development/libraries/science/math/or-tools/default.nix
··· 1 - { lib 2 - , stdenv 3 - , fetchFromGitHub 4 - , cmake 5 - , abseil-cpp 6 , bzip2 7 - , zlib 8 - , lsb-release 9 - , which 10 - , protobuf 11 , cbc 12 , ensureNewerSourcesForZipFilesHook 13 , python 14 , swig4 15 }: 16 17 stdenv.mkDerivation rec { 18 pname = "or-tools"; 19 - version = "9.1"; 20 - disabled = python.pythonOlder "3.6"; # not supported upstream 21 22 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 - ''; 48 49 - # 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 86 swig4 87 - which 88 - ensureNewerSourcesForZipFilesHook 89 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 105 ]; 106 107 outputs = [ "out" "python" ]; 108
··· 1 + { abseil-cpp 2 , bzip2 3 , cbc 4 + , cmake 5 + , eigen 6 , ensureNewerSourcesForZipFilesHook 7 + , fetchFromGitHub 8 + , fetchpatch 9 + , glpk 10 + , lib 11 + , pkg-config 12 + , protobuf 13 , python 14 + , re2 15 + , stdenv 16 , swig4 17 + , unzip 18 + , zlib 19 }: 20 21 stdenv.mkDerivation rec { 22 pname = "or-tools"; 23 + version = "9.4"; 24 25 src = fetchFromGitHub { 26 owner = "google"; 27 repo = "or-tools"; 28 rev = "v${version}"; 29 + sha256 = "sha256-joWonJGuxlgHhXLznRhC1MDltQulXzpo4Do9dec1bLY="; 30 }; 31 + patches = [ 32 + # Disable test that requires external input: https://github.com/google/or-tools/issues/3429 33 + (fetchpatch { 34 + url = "https://github.com/google/or-tools/commit/7072ae92ec204afcbfce17d5360a5884c136ce90.patch"; 35 + hash = "sha256-iWE+atp308q7pC1L1FD6sK8LvWchZ3ofxvXssguozbM="; 36 + }) 37 + # Fix test that broke in parallel builds: https://github.com/google/or-tools/issues/3461 38 + (fetchpatch { 39 + url = "https://github.com/google/or-tools/commit/a26602f24781e7bfcc39612568aa9f4010bb9736.patch"; 40 + hash = "sha256-gM0rW0xRXMYaCwltPK0ih5mdo3HtX6mKltJDHe4gbLc="; 41 + }) 42 + ]; 43 44 + cmakeFlags = [ 45 + "-DBUILD_DEPS=OFF" 46 + "-DBUILD_PYTHON=ON" 47 + "-DBUILD_pybind11=OFF" 48 + "-DFETCH_PYTHON_DEPS=OFF" 49 + "-DUSE_GLPK=ON" 50 + "-DUSE_SCIP=OFF" 51 ]; 52 nativeBuildInputs = [ 53 cmake 54 + ensureNewerSourcesForZipFilesHook 55 + pkg-config 56 + python 57 + python.pkgs.pip 58 swig4 59 + unzip 60 + ]; 61 + buildInputs = [ 62 + bzip2 63 + cbc 64 + eigen 65 + glpk 66 + python.pkgs.absl-py 67 + python.pkgs.mypy-protobuf 68 + python.pkgs.pybind11 69 python.pkgs.setuptools 70 python.pkgs.wheel 71 + re2 72 zlib 73 ]; 74 propagatedBuildInputs = [ 75 abseil-cpp 76 protobuf 77 python.pkgs.protobuf 78 + python.pkgs.numpy 79 + ]; 80 + checkInputs = [ 81 + python.pkgs.matplotlib 82 + python.pkgs.pandas 83 + python.pkgs.virtualenv 84 ]; 85 + 86 + doCheck = true; 87 + 88 + # This extra configure step prevents the installer from littering 89 + # $out/bin with sample programs that only really function as tests, 90 + # and disables the upstream installation of a zipped Python egg that 91 + # can’t be imported with our Python setup. 92 + installPhase = '' 93 + cmake . -DBUILD_EXAMPLES=OFF -DBUILD_PYTHON=OFF -DBUILD_SAMPLES=OFF 94 + cmake --install . 95 + pip install --prefix="$python" python/ 96 + ''; 97 98 outputs = [ "out" "python" ]; 99
+3 -3
pkgs/top-level/all-packages.nix
··· 35452 35453 or-tools = callPackage ../development/libraries/science/math/or-tools { 35454 python = python3; 35455 - # or-tools builds with -std=c++17, so abseil-cpp must 35456 # also be built that way 35457 - abseil-cpp = abseil-cpp.override { 35458 static = true; 35459 - cxxStandard = "17"; 35460 }; 35461 }; 35462
··· 35452 35453 or-tools = callPackage ../development/libraries/science/math/or-tools { 35454 python = python3; 35455 + # or-tools builds with -std=c++20, so abseil-cpp must 35456 # also be built that way 35457 + abseil-cpp = abseil-cpp_202111.override { 35458 static = true; 35459 + cxxStandard = "20"; 35460 }; 35461 }; 35462