Python bindings for the Glasgow Constraint Solver
Project description
Glasgow Constraint Solver CPMpy Interface
The code in this directory creates a simple Python interface for
the Glasgow Constraint Solver, primarily intended for use by the CPMpy
modelling library. Essentially it wraps all the relevant functionality in a single
class defined in api.hh, api.cc using only standard library types, and then generates
bindings for the methods using pybind11 (submoduled in the extern
directory).
How to install
I've not entirely got the installation process streamlined yet, but the current procedure is as follows.
- Clone the whole repository, including the pybind11 submodule:
git clone --recurse-submodules https://github.com/ciaranm/glasgow-constraint-solver.git
- Build the libraries (including the python module) using CMake (the XCSP support is not required):
cd glasgow-constraint-solver
cmake -S . -B build -DGCS_ENABLE_XCSP=OFF -GCS_ENABLE_CPMPY=ON
cmake --build build
- The
cpmpy/gcspy
directory should now contain a shared library file that can be imported as a python module. Optionally this can now be tested with some simple python unit tests
cd cpmpy
python3 gcspytest.py
- To make this available system-wide, or in a virtual environment, the package can now be pip installed:
(ensure still in the
cpmpy
directory)
pip3 install .
Packaging for PyPi (untested)
I think that after doing steps 1-3 we should be able to just do:
python3 -m build
python3 -m twine upload dist/*
And then anyone should be able to install the package with simply:
pip3 install gcspy
I'm not sure about the cross-platform compatability of this though, and I haven't tested it yet.
API Functions
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.