--- id: swiglpk version: "5.0.13" license: GPL v3 license_treatment: copyleft maintenance: active --- # swiglpk — swiglpk - Simple swig bindings for the GNU Linear Programming Kit License: copyleft · Maintenance: active · Downloads: 89.9K/mo ## What it is and what it does swiglpk is a thin, low-level wrapper around GLPK's C API generated by SWIG. It exposes the full C interface directly to Python without abstraction, allowing you to call GLPK functions like glp_create_prob(), glp_simplex(), and glp_get_obj_val() almost exactly as you would in C. This means you work with raw arrays, manual memory management, and C-style function calls—it is not a high-level mathematical programming language. The package is useful when you need direct access to GLPK's capabilities or when you are building a higher-level abstraction on top of it. It ships with prebuilt wheels for all major platforms and Python versions, so installation typically requires only pip install with no compilation step. The trade-off is that the API is verbose and low-level; for most users, a wrapper like optlang is recommended for cleaner, more Pythonic problem formulation. Use it for: - Solve linear programming (LP) and mixed-integer programming (MIP) problems where you need direct control over the underlying GLPK solver. - Build a domain-specific optimization framework or mathematical modeling language on top of GLPK's C API. - Port existing C/C++ GLPK code to Python while keeping the same algorithmic structure and function calls. - Integrate GLPK into a scientific computing pipeline where other components also use low-level C bindings. - Access GLPK features or tuning parameters not exposed by higher-level Python wrappers. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. swiglpk provides direct Python bindings to the GNU Linear Programming Kit (GLPK) C library, enabling you to formulate and solve linear and mixed-integer optimization problems from Python code. Yes, if you need direct GLPK access and accept GPL v3 licensing. The package is actively maintained, has no known vulnerabilities, and installs cleanly via prebuilt wheels. However, if you want a Pythonic API for formulating optimization problems, use optlang or another high-level wrapper instead; swiglpk is intentionally low-level and verbose. Proprietary projects cannot use it due to GPL v3 copyleft. ## Install pip install swiglpk uv add swiglpk poetry add swiglpk ## Installing swiglpk Before you install: Installation is straightforward via pip with prebuilt wheels for Windows, macOS, and Linux across multiple Python versions (3.10–3.13 supported in current release). No compilation or external dependencies required at install time. Repository is actively maintained with recent commits. License in practice: Licensed under GPL v3 (copyleft). Any code that links swiglpk must be distributed under a compatible open-source license; proprietary or closed-source projects cannot use it without negotiating alternative licensing. Quickstart: pip install swiglpk from swiglpk import * lp = glp_create_prob() glp_set_prob_name(lp, "example") glp_set_obj_dir(lp, GLP_MAX) glp_add_rows(lp, 1) glp_add_cols(lp, 1) glp_simplex(lp, None) Z = glp_get_obj_val(lp) glp_delete_prob(lp) GLPK C library must be installed on the system; binary wheels bundle it, but source builds require GLPK headers and swig installed separately. Verify before relying: - Whether binary wheels include a bundled GLPK library or assume system installation - Exact Python version range supported (classifiers list 2.7 and 3.4, but wheels show 3.10–3.13) - Performance characteristics compared to higher-level wrappers like optlang ## Package facts - License: GPL v3 (copyleft) - Python support: unspecified - Install friction: medium - Maintenance: active - Downloads: 89.9K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags linear programming solver python, glpk python bindings, optimization library python, integer programming python, simplex solver python, constraint optimization, mathematical programming, optimization, linear-programming, glpk-bindings [View on SkillFed](https://skillfed.io/packages/swiglpk) · [View on PyPI](https://pypi.org/project/swiglpk/)