Unverified Commit d0753d4a authored by Someone's avatar Someone Committed by GitHub
Browse files

or-tools: 9.12 -> 9.14 (#458786)

parents 54ddfb62 ca31461f
Loading
Loading
Loading
Loading
+45 −0
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  fetchFromGitHub,
  cmake,
  gtest,
  static ? stdenv.hostPlatform.isStatic,
  cxxStandard ? null,
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "abseil-cpp";
  version = "20250512.1";

  src = fetchFromGitHub {
    owner = "abseil";
    repo = "abseil-cpp";
    tag = finalAttrs.version;
    hash = "sha256-eB7OqTO9Vwts9nYQ/Mdq0Ds4T1KgmmpYdzU09VPWOhk=";
  };

  cmakeFlags = [
    (lib.cmakeBool "ABSL_BUILD_TEST_HELPERS" true)
    (lib.cmakeBool "ABSL_USE_EXTERNAL_GOOGLETEST" true)
    (lib.cmakeBool "BUILD_SHARED_LIBS" (!static))
  ]
  ++ lib.optionals (cxxStandard != null) [
    (lib.cmakeFeature "CMAKE_CXX_STANDARD" cxxStandard)
  ];

  strictDeps = true;

  nativeBuildInputs = [ cmake ];

  buildInputs = [ gtest ];

  meta = {
    description = "Open-source collection of C++ code designed to augment the C++ standard library";
    homepage = "https://abseil.io/";
    changelog = "https://github.com/abseil/abseil-cpp/releases/tag/${finalAttrs.version}";
    license = lib.licenses.asl20;
    platforms = lib.platforms.all;
    maintainers = [ lib.maintainers.GaetanLepage ];
  };
})
+25 −6
Original line number Diff line number Diff line
From 077295f6ede59d9e2413b2d19f38cf63b64f4fec Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Br=C3=BCns?= <stefan.bruens@rwth-aachen.de>
Date: Tue, 21 Oct 2025 17:05:59 +0300
Subject: [PATCH] Do not try to copy pybind11_abseil status extension module

The module is already installed in the correct location. And even if not,
it should be done as part of the pybind11_abseil build ...
---
 cmake/python.cmake         | 5 -----
 ortools/python/setup.py.in | 4 ----
 2 files changed, 9 deletions(-)

diff --git a/cmake/python.cmake b/cmake/python.cmake
index 2112ceeb66..db15434303 100644
--- a/cmake/python.cmake
+++ b/cmake/python.cmake
@@ -322,7 +322,6 @@
@@ -326,7 +326,6 @@ file(GENERATE OUTPUT ${PYTHON_PROJECT_DIR}/init/python/__init__.py CONTENT "")
 file(GENERATE OUTPUT ${PYTHON_PROJECT_DIR}/linear_solver/__init__.py CONTENT "")
 file(GENERATE OUTPUT ${PYTHON_PROJECT_DIR}/linear_solver/python/__init__.py CONTENT "")
 if(BUILD_MATH_OPT)
@@ -8,17 +22,17 @@
   file(GENERATE OUTPUT ${PYTHON_PROJECT_DIR}/math_opt/__init__.py CONTENT "")
   file(GENERATE OUTPUT ${PYTHON_PROJECT_DIR}/math_opt/core/__init__.py CONTENT "")
   file(GENERATE OUTPUT ${PYTHON_PROJECT_DIR}/math_opt/core/python/__init__.py CONTENT "")
@@ -635,9 +634,6 @@
@@ -680,9 +679,6 @@ add_custom_command(
   COMMAND ${CMAKE_COMMAND} -E
    $<IF:$<BOOL:${BUILD_MATH_OPT}>,copy,true>
    $<TARGET_FILE:math_opt_pybind11> ${PYTHON_PROJECT}/math_opt/core/python
    $<TARGET_FILE:math_opt_io_pybind11> ${PYTHON_PROJECT}/math_opt/io/python
-  COMMAND ${CMAKE_COMMAND} -E
-   $<IF:$<BOOL:${BUILD_MATH_OPT}>,copy,true>
-   $<TARGET_FILE:status_py_extension_stub> ${PYTHON_PROJECT}/../pybind11_abseil
   COMMAND ${CMAKE_COMMAND} -E
    $<IF:$<TARGET_EXISTS:pdlp_pybind11>,copy,true>
    $<$<TARGET_EXISTS:pdlp_pybind11>:$<TARGET_FILE:pdlp_pybind11>> ${PYTHON_PROJECT}/pdlp/python
@@ -696,7 +692,6 @@
@@ -744,7 +740,6 @@ add_custom_command(
   COMMAND ${stubgen_EXECUTABLE} -p ortools.constraint_solver.pywrapcp --output .
   COMMAND ${stubgen_EXECUTABLE} -p ortools.linear_solver.pywraplp --output .
   COMMAND ${stubgen_EXECUTABLE} -p ortools.linear_solver.python.model_builder_helper --output .
@@ -26,9 +40,11 @@
   COMMAND ${stubgen_EXECUTABLE} -p ortools.math_opt.core.python.solver --output .
   COMMAND ${stubgen_EXECUTABLE} -p ortools.pdlp.python.pdlp --output .
   COMMAND ${stubgen_EXECUTABLE} -p ortools.sat.python.cp_model_helper --output .
diff --git a/ortools/python/setup.py.in b/ortools/python/setup.py.in
index 0aeaa900ef..ae4fa07815 100644
--- a/ortools/python/setup.py.in
+++ b/ortools/python/setup.py.in
@@ -83,10 +83,6 @@
@@ -83,10 +83,6 @@ setup(
             '*.pyi',
             'py.typed'
         ],
@@ -37,5 +53,8 @@
-            '*.pyi'
-        ],
         '@PYTHON_PROJECT@.math_opt':['*.pyi'],
         '@PYTHON_PROJECT@.math_opt.python':['*.pyi'],
         '@PYTHON_PROJECT@.math_opt.core.python':[
             '$<TARGET_FILE_NAME:math_opt_pybind11>',
-- 
2.51.0
+26 −0
Original line number Diff line number Diff line
From 46e7d2cccd029a2c4215ce9b0c3bf72b2f2dd398 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Br=C3=BCns?= <stefan.bruens@rwth-aachen.de>
Date: Thu, 2 Jan 2025 16:32:05 +0100
Subject: [PATCH] Fix up broken CMake rules for bundled pybind stuff

Unfortunately, upstream only uses and tests the bundled code, and the
unbundled cases are bitrotting.
---
 cmake/system_deps.cmake    | 1 +
 1 files changed, 1 insertion(+)

diff --git a/cmake/system_deps.cmake b/cmake/system_deps.cmake
index d9ae923..0c176a8 100644
--- a/cmake/system_deps.cmake
+++ b/cmake/system_deps.cmake
@@ -94,6 +94,7 @@ endif()
 
 # Check language Dependencies
 if(BUILD_PYTHON)
+  find_package(Python REQUIRED Interpreter Development.Module)
   if(NOT BUILD_pybind11 AND NOT TARGET pybind11::pybind11_headers)
     find_package(pybind11 REQUIRED)
   endif()
-- 
2.47.1
+71 −29
Original line number Diff line number Diff line
{
  abseil-cpp_202407,
  stdenv,
  lib,
  callPackage,

  abseil-cpp_202505,
  bzip2,
  cbc,
  cmake,
@@ -11,12 +15,10 @@
  gbenchmark,
  glpk,
  highs,
  lib,
  pkg-config,
  protobuf_29,
  protobuf_31,
  python3,
  re2,
  stdenv,
  swig,
  unzip,
  zlib,
@@ -30,14 +32,50 @@ let
  # protobuf. Do not un-pin these, even if you're upgrading them to
  # what might happen to be the latest version at the current moment;
  # future upgrades *will* break the build.
  abseil-cpp = abseil-cpp_202407;
  protobuf = protobuf_29.override { inherit abseil-cpp; };
  python-protobuf = python3.pkgs.protobuf5.override { inherit protobuf; };
  pybind11-protobuf = python3.pkgs.pybind11-protobuf.override { protobuf_29 = protobuf; };
  abseil-cpp' = abseil-cpp_202505;
  protobuf' = protobuf_31.override { abseil-cpp = abseil-cpp'; };
  python-protobuf' = python3.pkgs.protobuf5.override { protobuf = protobuf'; };

  pybind11' = callPackage ./pybind11-2.13.6.nix {
    inherit (python3.pkgs)
      buildPythonPackage
      cmake
      ninja
      numpy
      pytestCheckHook
      pythonOlder
      setuptools
      ;
    python = python3;
  };
  pybind11-abseil' = python3.pkgs.pybind11-abseil.override {
    pybind11 = pybind11';
    abseil-cpp = abseil-cpp';
  };
  pybind11-protobuf' = callPackage ./pybind11-protobuf.nix {
    inherit (python3.pkgs) buildPythonPackage;
    pybind11 = pybind11';
  };
  # re2 must also use the same abseil version, else these two versions will conflict during linking
  re2' = re2.override { abseil-cpp = abseil-cpp'; };

  # 77a28070b9c4c83995ac6bbfa9544722ff3342ce renamed the scip cmake target(s) differently
  # to what upstream still calls it. Apply this patch to scipopt-scip.
  scipopt-scip' = scipopt-scip.overrideAttrs (old: {
    patches = old.patches or [ ] ++ [
      # from https://github.com/google/or-tools/commit/77a28070b9c4c83995ac6bbfa9544722ff3342ce#diff-c95174a817e73db366d414af1e329c1856f70e5158ed3994d43da88765ccc98f
      ./scip.patch
    ];
    # Their patch forgets to find_package() soplex, bring it back.
    postPatch = (old.postPatch or "") + ''
      substituteInPlace CMakeLists.txt \
        --replace-fail 'message(STATUS "Finding Soplex...")' 'find_package(SOPLEX CONFIG HINTS ''${SOPLEX_DIR})'
    '';
  });

  # local revert of 58daf511687f191829238fc7f571e08dc9dedf56,
  # working around https://github.com/google/or-tools/issues/4911
  _highs = highs.overrideAttrs (old: rec {
  highs' = highs.overrideAttrs (old: rec {
    version = "1.10.0";
    src = fetchFromGitHub {
      owner = "ERGO-Code";
@@ -57,13 +95,13 @@ let
in
stdenv.mkDerivation (finalAttrs: {
  pname = "or-tools";
  version = "9.12";
  version = "9.14";

  src = fetchFromGitHub {
    owner = "google";
    repo = "or-tools";
    tag = "v${finalAttrs.version}";
    hash = "sha256-5rFeAK51+BfjIyu/5f5ptaKMD7Hd20yHa2Vj3O3PkLU=";
    hash = "sha256-FxKe3uY4L33mavwC2aanji3fY9dPqpkwVqi6PNjovSA=";
  };

  patches = [
@@ -74,16 +112,18 @@ stdenv.mkDerivation (finalAttrs: {
      url = "https://build.opensuse.org/public/source/science/google-or-tools/0001-Revert-python-Fix-python-install-on-windows-breaks-L.patch?rev=19";
      hash = "sha256-BNB3KlgjpWcZtb9e68Jkc/4xC4K0c+Iisw0eS6ltYXE=";
    })
    (fetchpatch {
      name = "0001-Fix-up-broken-CMake-rules-for-bundled-pybind-stuff.patch";
      url = "https://build.opensuse.org/public/source/science/google-or-tools/0001-Fix-up-broken-CMake-rules-for-bundled-pybind-stuff.patch?rev=19";
      hash = "sha256-r38ZbRkEW1ZvJb0Uf56c0+HcnfouZZJeEYlIK7quSjQ=";
    })
    ./0001-Fix-up-broken-CMake-rules-for-bundled-pybind-stuff.patch
    (fetchpatch {
      name = "math_opt-only-run-SCIP-tests-if-enabled.patch";
      url = "https://github.com/google/or-tools/commit/b5a2f8ac40dd4bfa4359c35570733171454ec72b.patch";
      hash = "sha256-h96zJkqTtwfBd+m7Lm9r/ks/n8uvY4iSPgxMZe8vtXI=";
    })
    # Fix tests on aarch64-linux
    # https://github.com/google/or-tools/issues/4746
    (fetchpatch {
      url = "https://github.com/google/or-tools/commit/8442c7b1c219b0c8d58ee96d266d81b7c3a19ad2.patch";
      hash = "sha256-HrV9wU3PFMdb3feGt8i5UJNgHuitMRBF9cNrH5RRENQ=";
    })
  ];

  # or-tools normally attempts to build Protobuf for the build platform when
@@ -108,6 +148,8 @@ stdenv.mkDerivation (finalAttrs: {
    (lib.cmakeFeature "CMAKE_INSTALL_INCLUDEDIR" "include")
    (lib.cmakeFeature "CMAKE_INSTALL_LIBDIR" "lib")
    (lib.cmakeBool "FETCH_PYTHON_DEPS" false)
    # not packaged in nixpkgs
    (lib.cmakeBool "USE_fuzztest" false)
    (lib.cmakeBool "USE_GLPK" true)
    (lib.cmakeBool "USE_SCIP" withScip)
    (lib.cmakeFeature "Python3_EXECUTABLE" "${python3.pythonOnBuildForHost.interpreter}")
@@ -136,37 +178,37 @@ stdenv.mkDerivation (finalAttrs: {
    mypy
  ]);
  buildInputs = [
    abseil-cpp
    abseil-cpp'
    bzip2
    cbc
    eigen
    glpk
    gbenchmark
    gtest
    _highs
    highs'
    python3.pkgs.absl-py
    python3.pkgs.pybind11
    python3.pkgs.pybind11-abseil
    pybind11-protobuf
    pybind11'
    pybind11-abseil'
    pybind11-protobuf'
    python3.pkgs.pytest
    python3.pkgs.scipy
    python3.pkgs.setuptools
    python3.pkgs.wheel
    re2
    re2'
    zlib
  ];
  propagatedBuildInputs = [
    abseil-cpp
    _highs
    protobuf
    python-protobuf
    abseil-cpp'
    highs'
    protobuf'
    python-protobuf'
    python3.pkgs.immutabledict
    python3.pkgs.numpy
    python3.pkgs.pandas
  ]
  ++ lib.optionals withScip [
    # Needed for downstream cmake consumers to not need to set SCIP_ROOT explicitly
    scipopt-scip
    scipopt-scip'
  ];

  nativeCheckInputs = [
@@ -178,8 +220,8 @@ stdenv.mkDerivation (finalAttrs: {
    python3.pkgs.virtualenv
  ];

  # some tests fail on aarch64-linux and hang on darwin
  doCheck = stdenv.hostPlatform.isx86_64 && stdenv.hostPlatform.isLinux;
  # some tests hang on darwin
  doCheck = stdenv.hostPlatform.isLinux;

  preCheck = ''
    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH''${LD_LIBRARY_PATH:+:}$PWD/lib
Loading