[gdal-dev] Building GDAL 1.7.3 Python bindings

Christopher Barker Chris.Barker at noaa.gov
Mon Dec 6 12:14:58 EST 2010


On 12/3/10 6:26 PM, Brian Wilson wrote:
> Greetings, I am looking for some suggestions on how to build the
> python bindings for the latest gdal sources (1.7.3) for Windows.

I haven't done it for a while, but a few notes that might help get you 
moving:

> Environment: Windows 7, Visual Studio 2010, Python 2.5

I'm pretty sure the standard (python,org) build of python 2.5 was build 
with  Visual Studio 2003, and you need to build extensions with that 
same compiler version (or at least the same run-time libraries). So you 
need either VS2003 or you can also do it with mingw, with a few tweaks 
-- do a bit of googling to see how.

If you're using the python provided by ESRI, I have no idea, but it 
seems likely that it's the python,org build.

> I set up nmake.opt including PYDIR and PY_INST_DIR. I can't see
> anywhere those are USED but I followed docs and set them
> appropriately.  (C:\Python25)

In general, you want to build python extensions with python's distutils, 
which means using:

python setup.py build

The setup.py file is in "swig\python"

The idea here is that python's distutils knows how python was built, and 
will set up the compiler to build your extension in a compatible way.

> I looked at I looked at http://pypi.python.org/pypi/GDAL/ which has
> lovely and usable Linux instructions but I am currently trapped in a
> Windows world at my otherwise wonderful day job.

it's worth reading those anyway -- distutils is pretty much the same on 
all platforms.

> I suspect I need to do something with swig, which I downloaded and
> installed, but the "Windows" notes basically say "you should never
> have to do this".

the swig-generated bindings should be delivered with the source, so 
that's right, you shouldn't ahve to run swig unless you are changin the 
source and need to re-generate the binding code.

> I am sorry this email is long, but I have had plenty of time to work
> on building GDAL today while waiting for fragile and slow ESRI tools
> to run, really motivating me to try to use GDAL + Python.

I hope you get it working.

The state of Windows binaries has been a bit of a mess for a while, but 
what with all the different python versions, compiler versions and 
semi-proprietary drivers, it's a difficult problem!


HTH,

-Chris



-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov


More information about the gdal-dev mailing list