[gdal-dev] gdal swig python's setup.py not python3 compatible

Vincent Schut schut at sarvision.nl
Thu Dec 30 05:32:58 EST 2010


On 12/29/2010 06:06 PM, Even Rouault wrote:
> Vincent,
>
> you didn't mention which GDAL version you use. Since GDAL 1.7.0, the Python
> bindings work with both python 2.X and 3.X. But I see that the autoconf check
> for python isn't python3 ready indeed. So you can ignore the configure errors
> and just cd swig/python and build the buindings from there directly (make
> build; make install)

Hi Even,

I'm using svn trunk. Sorry to be a bit confusing... I know the bindings 
work for both 2 and 3, and I know that I build and install the bindings 
separately. I tend to forget to do that, though, which results in 
updated gdal bindings in my py3 site-packages, which I don't use much, 
and still an old one in my py2 site-packages, and me being confused as 
to why stuff didn't get updated... I know, it's just a matter of being 
lazy and loving convenience too much :-)
I guess my question actually boils down to: how can I specify in the 
configure phase, which python to use for the bindings? E.g. I have both 
2 and 3 on my system, and 3 is the default, but I want gdal to build and 
install the bindings for 2. Could I specify 
--with-python=/usr/bin/python2 when running configure? (Or even better, 
build and install it for both pythons in one run...)

Thanks,
Vincent.
>
> Best regards,
>
> Even
>
> Le mercredi 29 décembre 2010 14:27:09, Vincent Schut a écrit :
>> Oops, wrong conclusion. Seems more complicated than I thought, as there
>> are some python checks in configure that use python...
>>
>> Lets change this into a question:
>>
>> as I have both python2 and python3, with /usr/bin/python linking to
>> python3 (so python3 is the default), and gdal's python extension seems
>> to be not python3 compatible (at least the build/install method), what
>> would be the prefered way to have gdal's configure/make/make install use
>> python2 for everything? E.g. use /usr/bin/python2 as executable, and the
>> python2 site-packages dir for installing.
>>
>> As lots of my own scripts and other extensions I use are still not
>> really python3-ready, I don't mind using python2 myself, but I'd like to
>> keep the system default to python3 because I don't want to mess to much
>> with my system's defaults (I tend to forget stuff I change manually, etc.)
>>
>> Tia,
>> Vincent.
>>
>> On 12/29/2010 02:19 PM, Vincent Schut wrote:
>>> Hi,
>>>
>>> some time ago, Arch linux made the rather bold decision to have python3
>>> as system python default, of course with a /usr/bin/python2 alternative
>>> sitting next to it. However, as the /usr/bin/python link is pointing to
>>> /usr/bin/python3, gdal's swig python module's setup.py is being called
>>> with python3, and appears to be not python3 compatible:
>>>
>>> checking for python bindings... checking for python... python
>>> checking for location of Python Makefiles... File "<string>", line 3
>>> print sys.prefix
>>> ^
>>> SyntaxError: invalid syntax
>>> File "<string>", line 3
>>> print sys.prefix
>>> ^
>>> SyntaxError: invalid syntax
>>> File "<string>", line 3
>>> print sys.version[:3]
>>> ^
>>> SyntaxError: invalid syntax
>>> found
>>> checking where to install Python modules... /lib/python/site-packages
>>> enabled
>>> checking for python setuptools... File "<string>", line 3
>>> print 1
>>> ^
>>> SyntaxError: invalid syntax
>>> not found
>>> configure: checking whether we should include rasdaman support...
>>> rasdaman support not requested.
>>> configure: creating ./config.status
>>> config.status: creating GDALmake.opt
>>>
>>> Imho the easiest way to fix this would be to have a '#!/usr/bin/python2'
>>> as first line in setup.py; I suppose every distro has also a
>>> /usr/bin/python2 executable/link, even if there is not yet a python3 one.
>>>
>>> Regards,
>>> Vincent.
>>> _______________________________________________
>>> gdal-dev mailing list
>>> gdal-dev at lists.osgeo.org
>>> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>>
>> _______________________________________________
>> gdal-dev mailing list
>> gdal-dev at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/gdal-dev


More information about the gdal-dev mailing list