[bug#78443,v2] gnu: python-pulp: Update to 3.1.1.

Message ID 20250530173428.3882-1-wz@freeshell.de
State New
Headers
Series [bug#78443,v2] gnu: python-pulp: Update to 3.1.1. |

Commit Message

Wiktor Żelazny May 30, 2025, 5:34 p.m. UTC
  * gnu/packages/python-xyz.scm (python-pulp-2.4): Copy from python-pulp.
* gnu/packages/python-science.scm (snakemake): Use python-pulp-2.4.
* gnu/packages/python-science.scm (snakemake-{5,6,7}): Use python-pulp-2.4.
* gnu/packages/patches/python-pulp-exclude-solver-binaries.patch: New patch.
* gnu/local.mk (dist_patch_DATA): Register it.
* gnu/packages/python-xyz.scm (python-pulp): Update to 3.1.1.
[source]: Update the uri capitalization.
[source]: Add a snippet for skipping a failing test.
[source]: Apply the new patch.
[build-system]: Change to pyproject-build-system.
[native-inputs]: Add cbc, glpk, highs, python-setuptools, and python-wheel.
[propagated-inputs]: Remove python-amply.
[agruments]<#:phases>: Add a phase to remove solver binaries.
[agruments]<#:phases>: Test using pulptest.
[synopsis]: Change according to About in the code repository.
[description]: Extend according to README.rst in the code repository.

Change-Id: I41a7ea4066302d1195913815eb030c45dec9014d
---
 gnu/local.mk                                  |  1 +
 .../python-pulp-exclude-solver-binaries.patch | 36 ++++++++++++++++
 gnu/packages/python-science.scm               |  8 ++--
 gnu/packages/python-xyz.scm                   | 42 +++++++++++++++++++
 4 files changed, 83 insertions(+), 4 deletions(-)
 create mode 100644 gnu/packages/patches/python-pulp-exclude-solver-binaries.patch


base-commit: b750d54703d849fe58dcacf94f23d34ab85b23a2
  

Patch

diff --git a/gnu/local.mk b/gnu/local.mk
index f534768c2de..424a8d92f1d 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -2028,6 +2028,7 @@  dist_patch_DATA =						\
   %D%/packages/patches/python-matplotlib-fix-legend-loc-best-test.patch	\
   %D%/packages/patches/python-random2-getrandbits-test.patch		\
   %D%/packages/patches/python-pillow-use-zlib-1.3.patch	\
+  %D%/packages/patches/python-pulp-exclude-solver-binaries.patch	\
   %D%/packages/patches/python-pydocstyle-add-support-for-pep701.patch	\
   %D%/packages/patches/python-pyreadstat-link-libiconv.patch	\
   %D%/packages/patches/python-sip-include-dirs.patch	\
diff --git a/gnu/packages/patches/python-pulp-exclude-solver-binaries.patch b/gnu/packages/patches/python-pulp-exclude-solver-binaries.patch
new file mode 100644
index 00000000000..57e9a1421b0
--- /dev/null
+++ b/gnu/packages/patches/python-pulp-exclude-solver-binaries.patch
@@ -0,0 +1,36 @@ 
+This patch excludes solver binary executables that the project uses for
+testing. In the package definition, solvers are provided as native inputs,
+instead.
+
+This is an original patch. It was not submitted upstream.
+
+diff --git a/pyproject.toml b/pyproject.toml
+index 82f9d48..0925858 100644
+--- a/pyproject.toml
++++ b/pyproject.toml
+@@ -61,26 +61,11 @@ dev = [
+ [tool.setuptools]
+ packages = [
+         "pulp",
+-        "pulp.solverdir",
+-        "pulp.solverdir.cbc.linux.i32",
+-        "pulp.solverdir.cbc.linux.i64",
+-        "pulp.solverdir.cbc.linux.arm64",
+-        "pulp.solverdir.cbc.win.i32",
+-        "pulp.solverdir.cbc.win.i64",
+-        "pulp.solverdir.cbc.osx.i64",
+         "pulp.apis",
+         "pulp.tests"]
+ # This is a workaround for https://github.com/astral-sh/uv/issues/9513
+ license-files = []
+
+-[tool.setuptools.package-data]
+-"pulp.solverdir.cbc.linux.i32"= ["*", "*.*"]
+-"pulp.solverdir.cbc.linux.i64"= ["*", "*.*"]
+-"pulp.solverdir.cbc.linux.arm64"= ["*", "*.*"]
+-"pulp.solverdir.cbc.win.i32"= ["*", "*.*"]
+-"pulp.solverdir.cbc.win.i64"= ["*", "*.*"]
+-"pulp.solverdir.cbc.osx.i64"= ["*", "*.*"]
+-
+ [project.scripts]
+ pulptest = "pulp.tests.run_tests:pulpTestAll"
diff --git a/gnu/packages/python-science.scm b/gnu/packages/python-science.scm
index 376ae67570c..fdfa88c56c7 100644
--- a/gnu/packages/python-science.scm
+++ b/gnu/packages/python-science.scm
@@ -4976,7 +4976,7 @@  (define-public snakemake
            python-nbformat
            python-packaging
            python-psutil
-           python-pulp
+           python-pulp-2.4 ;https://github.com/snakemake/snakemake/issues/2607
            python-pyyaml
            python-requests
            python-reretry
@@ -5068,7 +5068,7 @@  (define-public snakemake-5
            python-nbformat
            python-networkx
            python-psutil
-           python-pulp
+           python-pulp-2.4 ;https://github.com/snakemake/snakemake/issues/2607
            python-pyyaml
            python-ratelimiter
            python-requests
@@ -5155,7 +5155,7 @@  (define-public snakemake-6
            python-nbformat
            python-networkx
            python-psutil
-           python-pulp
+           python-pulp-2.4 ;https://github.com/snakemake/snakemake/issues/2607
            python-pyyaml
            python-py-tes
            python-ratelimiter
@@ -5253,7 +5253,7 @@  (define-public snakemake-7
            python-nbformat
            python-networkx
            python-psutil
-           python-pulp
+           python-pulp-2.4 ;https://github.com/snakemake/snakemake/issues/2607
            python-pyyaml
            python-py-tes
            python-requests
diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
index 0058c665e3d..090b534b368 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -15041,6 +15041,48 @@  (define-public python-amply
     (license license:epl1.0)))
 
 (define-public python-pulp
+  (package
+    (name "python-pulp")
+    (version "3.1.1")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (pypi-uri "pulp" version))
+       ;; https://github.com/coin-or/pulp/issues/832
+       (modules '((guix build utils)))
+       (snippet '(substitute* "pulp/tests/test_pulp.py"
+                   (("        def test_time_limit_no_solution")
+                    "        @unittest.skip
+        def test_time_limit_no_solution")))
+       (sha256
+        (base32 "15bdjv0hpzg3lfbz25w16sf4h3gkpd4mhvysgynak73wj47362ih"))
+       (patches (search-patches "python-pulp-exclude-solver-binaries.patch"))))
+    (build-system pyproject-build-system)
+    (native-inputs (list cbc ;a solver for testing
+                         glpk ;a solver for testing
+                         highs ;a solver for testing
+                         python-setuptools
+                         python-wheel))
+    (arguments
+     `(#:phases (modify-phases %standard-phases
+                  (add-before 'build 'remove-solver-binaries
+                    (lambda _
+                      (delete-file-recursively "pulp/solverdir/")))
+                  (replace 'check
+                    (lambda* (#:key tests? #:allow-other-keys)
+                      (if tests?
+                          (invoke "pulptest")))))))
+    (home-page "https://github.com/coin-or/pulp")
+    (synopsis "Python Linear Programming API")
+    (description
+     "PuLP is an linear and mixed integer programming modeler written in
+Python.  With PuLP, it is simple to create MILP optimisation problems and solve
+them with the latest open-source (or proprietary) solvers.  PuLP can generate
+MPS or LP files and call solvers such as GLPK, COIN-OR CLP/CBC, CPLEX, GUROBI,
+MOSEK, XPRESS, CHOCO, MIPCL, HiGHS, SCIP/FSCIP.")
+    (license license:expat)))
+
+(define-public python-pulp-2.4
   (package
     (name "python-pulp")
     (version "2.4")