%global srcname swiglpk Name: python-%{srcname} Version: 5.0.13 Release: 1%{?dist} Summary: Plain SWIG Python bindings for the GNU Linear Programming Kit # The sources carry the GPL v3-or-later header ("either version 3 of the # License, or (at your option) any later version") in setup.py, the SWIG # interface and the test; PyPI's metadata says only "GPL v3". License: GPL-3.0-or-later URL: https://github.com/biosustain/swiglpk Source: %{url}/archive/%{version}/%{srcname}-%{version}.tar.gz BuildRequires: gcc BuildRequires: swig BuildRequires: glpk-devel BuildRequires: python3-devel BuildRequires: pyproject-rpm-macros BuildRequires: python3-pytest %global _description %{expand: swiglpk exposes GLPK's C API to Python through SWIG with almost no wrapping: the function and structure names are the C ones (glp_create_prob, glp_simplex, glp_get_obj_val, ...). It is meant as a base for higher-level tools rather than for direct use; optlang, and through it COBRApy, call it.} %description %_description %package -n python3-%{srcname} Summary: %{summary} %description -n python3-%{srcname} %_description %prep %autosetup -p1 -n %{srcname}-%{version} # glpk.i carries two hand-written typemap lines that call PyInt_Check and # PyInt_AsLong. Python 3 has no PyInt_*; SWIG <= 4.4 supplied #defines for them # in every generated wrapper and SWIG 4.5 (Fedora 45, rawhide) removed that # block, so the wrapper no longer compiles there. PyLong_* is what the macros # expanded to. grep -q 'PyInt_Check(item)' swiglpk/glpk.i || { echo "PyInt_Check not found" >&2; exit 1; } sed -i 's/PyInt_Check(/PyLong_Check(/;s/PyInt_AsLong(/PyLong_AsLong(/' swiglpk/glpk.i %generate_buildrequires %pyproject_buildrequires %build # setup.py looks for glpk.h in /usr/include and for swig on PATH; it links the # system libglpk (libraries=['glpk']), not the static copy PyPI's wheels carry. %pyproject_wheel %install %pyproject_install %pyproject_save_files -l %{srcname} %check # Upstream's one test file (unittest, solves a small LP) against the build root. # Run from outside the source tree so the installed extension is imported, not # the unbuilt swiglpk/ directory. mkdir -p %{_builddir}/swiglpk-check cp test_swiglpk.py %{_builddir}/swiglpk-check/ cd %{_builddir}/swiglpk-check %pytest -q test_swiglpk.py %files -n python3-%{srcname} -f %{pyproject_files} %doc README.rst %changelog * Fri Oct 23 2026 Morgan Hough - 5.0.13-1 - Initial package: swiglpk 5.0.13. Net-new to Fedora; links Fedora's glpk-devel 5.0 (PyPI wheels bundle GLPK). Required by optlang, hence COBRApy. - NOT BUILT OR RUN YET. This is the only compiled package of the COBRApy chain and was written while another build occupied the machine. What was checked: setup.py and swiglpk/glpk.i read for the build inputs (glpk.h, swig, libglpk), the licence headers, and test_swiglpk.py passes against PyPI's cp314 wheel (1 passed). - Replace PyInt_Check and PyInt_AsLong with PyLong_* in glpk.i: the wrapper did not compile on Fedora 45 and rawhide, where SWIG 4.5 no longer defines them.