Opened 6 years ago

Closed 6 years ago

Last modified 5 years ago

#774 closed defect (fixed)

GEOS and Python3

Reported by: citibeth Owned by: geos-devel@…
Priority: major Milestone: 3.5.2
Component: Default Version: 3.5.0
Severity: Unassigned Keywords:
Cc:

Description

The GEOS Python extensions (enabled via --with-python) do not build with Python3. This is (initially, at least) due to an errant "print" statement in the configure script.

The CMake build does not seem to even attempt to build the Python extension.

Change History (12)

comment:1 by strk, 6 years ago

Patches welcome!

comment:2 by strk, 6 years ago

Milestone: 3.5.13.5.2

Ticket retargeted after milestone closed

comment:3 by andreash, 6 years ago

From what I can see, this is only caused by the print statements in the configure script.

This patch fixes these issues for me (GEOS-3.5.0):

--- configure.orig	2016-12-29 17:33:15.229294313 +0100
+++ configure	2016-12-29 18:33:27.822625611 +0100
@@ -18329,7 +18329,7 @@
 if ${am_cv_python_version+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  am_cv_python_version=`$PYTHON -c "import sys; print sys.version[:3]"`
+  am_cv_python_version=`$PYTHON -c "import sys; print(sys.version[:3])"`
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_python_version" >&5
 $as_echo "$am_cv_python_version" >&6; }
@@ -18348,7 +18348,7 @@
 if ${am_cv_python_platform+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  am_cv_python_platform=`$PYTHON -c "import sys; print sys.platform"`
+  am_cv_python_platform=`$PYTHON -c "import sys; print(sys.platform)"`
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_python_platform" >&5
 $as_echo "$am_cv_python_platform" >&6; }
@@ -18362,7 +18362,7 @@
 if ${am_cv_python_pythondir+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  am_cv_python_pythondir=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_python_lib(0,0,prefix='$PYTHON_PREFIX')" 2>/dev/null ||
+  am_cv_python_pythondir=`$PYTHON -c "from distutils import sysconfig; print(sysconfig.get_python_lib(0,0,prefix='$PYTHON_PREFIX'))" 2>/dev/null ||
      echo "$PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages"`
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_python_pythondir" >&5
@@ -18379,7 +18379,7 @@
 if ${am_cv_python_pyexecdir+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  am_cv_python_pyexecdir=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_python_lib(1,0,prefix='$PYTHON_EXEC_PREFIX')" 2>/dev/null ||
+  am_cv_python_pyexecdir=`$PYTHON -c "from distutils import sysconfig; print(sysconfig.get_python_lib(1,0,prefix='$PYTHON_EXEC_PREFIX'))" 2>/dev/null ||
      echo "${PYTHON_EXEC_PREFIX}/lib/python${PYTHON_VERSION}/site-packages"`
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_python_pyexecdir" >&5
@@ -18448,19 +18448,21 @@
         # Check for Python library path
         { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Python library path" >&5
 $as_echo_n "checking for Python library path... " >&6; }
-        for i in "$base_python_path/lib/python$PYTHON_VERSION/config/" "$base_python_path/lib/python$PYTHON_VERSION/" "$base_python_path/lib/python/config/" "$base_python_path/lib/python/" "$base_python_path/" "$base_python_path/libs/" ; do
-                python_path=`find $i -name libpython$PYTHON_VERSION.* -print 2> /dev/null | sed "1q"`
+        for i in "$base_python_path/lib/python$PYTHON_VERSION/config/" "$base_python_path/lib/python$PYTHON_VERSION/" "$base_python_path/lib/python/config/" "$base_python_path/lib/python/" "$base_python_path/" "$base_python_path/libs/" "$base_python_path/lib/" ; do
+                python_path=`find $i -name libpython$PYTHON_VERSION*.so* -print 2> /dev/null | sed "1q"`
                 if test -n "$python_path" ; then
                         break
                 fi
         done
+
+        lpython_name=`python -c "import os; print(os.path.split(\"$python_path\")[1].split(\".so\")[0].split(\"lib\")[1])"`
         python_path=`echo $python_path | sed "s,/libpython.*$,,"`
         { $as_echo "$as_me:${as_lineno-$LINENO}: result: $python_path" >&5
 $as_echo "$python_path" >&6; }
         if test -z "$python_path" ; then
                 as_fn_error $? "cannot find Python library path" "$LINENO" 5
         fi
-        PYTHON_LDFLAGS="-L$python_path -lpython$PYTHON_VERSION"
+        PYTHON_LDFLAGS="-L$python_path -l$lpython_name"
 
         #
         python_site=`echo $base_python_path | sed "s/config/site-packages/"`

Feel free to include it.

comment:4 by strk, 6 years ago

The configure script is generated from configure.ac, so patches should go there, if not in the generator (autoconf).

comment:5 by Bas Couwenberg, 6 years ago

macros/python.m4 needs to be updated to support Python 3.

comment:6 by andreash, 6 years ago

configure.ac doesn't contain any print statements. I don't know anything about autotools, but from a look at macros/python.m4 it seems that it should be enough to make the changes there?

comment:7 by strk, 6 years ago

Resolution: fixed
Status: newclosed

In 4320:

Update python m4 macro, should fix #774

comment:8 by strk, 6 years ago

Please see if r4320 fixes it, in case it shall be backported to 3.6 branch

comment:9 by strk, 6 years ago

In 4323:

Update python m4 macro, should fix #774

comment:10 by Sandro Santilli <strk@…>, 5 years ago

In 6cecfc1/git:

Update python m4 macro, should fix #774

git-svn-id: http://svn.osgeo.org/geos/trunk@4320 5242fede-7e19-0410-aef8-94bd7d2200fb

comment:11 by Sandro Santilli <strk@…>, 5 years ago

In 6cecfc1/git:

Update python m4 macro, should fix #774

git-svn-id: http://svn.osgeo.org/geos/trunk@4320 5242fede-7e19-0410-aef8-94bd7d2200fb

comment:12 by Sandro Santilli <strk@…>, 5 years ago

In 6cecfc1/git:

Update python m4 macro, should fix #774

git-svn-id: http://svn.osgeo.org/geos/trunk@4320 5242fede-7e19-0410-aef8-94bd7d2200fb

Note: See TracTickets for help on using tickets.