[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-glpk] [Fwd: PyGLPK or python-glpk]

From: Xypron
Subject: Re: [Help-glpk] [Fwd: PyGLPK or python-glpk]
Date: Tue, 25 Jan 2011 21:00:17 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv: Gecko/20101123 SeaMonkey/2.0.11

Hello Kevin,

Python-GLPK from
uses SWIG for building.

This is what it takes to build on Debian:

#install SWIG
sudo apt-get install swig
#Download the source
# unzip
tar -xzf python-glpk_0.4.43.orig.tar.gz
# goto source directory
cd python-glpk-0.4.43/src
# make and install
sudo make install
# move to examples
cd ../examples
# run an example

Building on OS X will require to modify src/swig/Makefile.

You will have to change the following line
gcc -Wall -shared glpkpi.o  glpkpi_wrap.o -lm -lglpk  -o

The following page contains some useful information on using SWIG on OS X.

In src/ you may have to change pathes.

In src/Makefile rework the clean section.

If you are successful, please, post a message with your Makefiles.

In Python-GLPK the following is missing:
- handling API errors without aborting
- callbacks

If you look at GLPK for Java you can get an idea off the effort to build a language binding with SWIG that handles these.

The official documentation for extending Python can be found at:

The following book has a useful chapter on extending Python:
Mark Lutz, Programming Python, O'Reilly Media, ISBN 0596158106

Best regards


Nigel Galloway wrote:

You may wish to try building the bindings using SWIG, see:


SWIG is well documented and included with most recent linux distributions. It 
is the technology used for glpk-java. Unfortuanately the files I used for 
Python are no longer on the web. but they can be recovered and I will assist 
you if you find difficulties.

The only difficulty I have experienced is that 'in' and 'out' are reseved words 
in Python and glpk uses them as procedure names. SWIG has a default work around 
for this.

Good Luck


reply via email to

[Prev in Thread] Current Thread [Next in Thread]