Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#4725 closed defect (fixed)

./configure does not support Python 3

Reported by: Mateusz Łoskot Owned by: warmerdam
Priority: normal Milestone: 1.10.0
Component: ConfigBuild Version: svn-trunk
Severity: normal Keywords: python3, python2, python, build, configure, linux
Cc:

Description (last modified by Mateusz Łoskot)

This problem occured to me in Linux environment where /usr/bin/python points to Python 3.x but not Python 2.x:

mloskot gdal $ python -V
Python 3.2.3
mloskot gdal $ python2 -V
Python 2.7.3

Here are the symptoms:

mloskot gdal $ ./configure --with-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
...

It also means that AM_PATH_PYTHON macro called by ./configure does not check version of Python found.

Likely, improving ./configure to support Python 3.x will involve adding new option --with-python3 to avoid ambiguities.

Attachments (1)

quick-fix-for-no-py3-support-in-configure.patch (897 bytes ) - added by Mateusz Łoskot 12 years ago.
Quick fix makes ./configure too look for python2 first, so python is not looked for in case /usr/bin/python is Python 3.x executable

Download all attachments as: .zip

Change History (4)

comment:1 by Mateusz Łoskot, 12 years ago

Description: modified (diff)

by Mateusz Łoskot, 12 years ago

Quick fix makes ./configure too look for python2 first, so python is not looked for in case /usr/bin/python is Python 3.x executable

comment:2 by Even Rouault, 12 years ago

Milestone: 2.0.0
Resolution: fixed
Status: newclosed

I've followed another route by removing a lot of old stuff that was likely needed by the old-gen python bindings. Now --with-python should work with either python 2 or 3, and it can also now accept as argument the path to / name of the wished python binary. For example --with-python=python2.7 or --with-python=python3.2

trunk r24948 : --with-python: make it work with python3, and also accept path to python binary as argument of --with-python (#4725)

comment:3 by Even Rouault, 12 years ago

r25008 "Unix configure: avoid ./configure to fail with default arguments if Python isn't available (trunk only, fix r24948, #4725)"

Note: See TracTickets for help on using tickets.