Hi,

On 2020/06/01 0:27, Lev Serebryakov wrote:
> Hello Users,
> 
>    Documentation says, that SWIG is optional to build Python/Perl/Ruby/Java
>   bindings. I'm trying to build python bindings, with python 3.7.7
>   installed, but without SWIG.
> 
>    I get this error:
> 
> --- .swig_py_checked ---
> --- 
> /usr/home/lev/FreeBSD/ports/devel/py-subversion/work-py37/subversion-1.14.0/subversion/bindings/swig/python/libsvn
>  ---
> --- subversion/bindings/swig/python/svn_client.lo ---
> --- subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.lo ---
> --- .swig_py_checked ---
> SWIG python disabled at configure time: SWIG version is not suitable
> *** [.swig_py_checked] Error code 1
> 
> make[1]: stopped in 
> /usr/home/lev/FreeBSD/ports/devel/py-subversion/work-py37/subversion-1.14.0
> 
>  Configure stage looks like this:
> 
> configure: Configuring python swig binding
> checking for Python includes... -I/usr/local/include/python3.7m
> checking Python.h usability... yes
> checking Python.h presence... yes
> checking for Python.h... yes
> configure: py3c library configuration via pkg-config
> checking for py3c library... yes
> checking for compiling Python extensions... cc -pthread -fPIC
> checking for linking Python extensions... cc -pthread -shared 
> -L/usr/local/lib -fstack-protector-strong
> checking for linking Python libraries... -L/usr/local/lib
> checking for Python >= 3... yes
> test: : bad number
> configure: WARNING: Subversion Python bindings for Python 3 require SWIG 
> 3.0.10 or newer
> test: : bad number

We are sorry, this is a bug of configure, which is fixed in trunk but
is not back ported to 1.14.x yet.

If there is no swig executable, or there exist swig executable which version
is 3.0.10 or newer in the PATH, then it can be avoid without passing
--without-swig option to configure.

If there is swig executable in the PATH and its version is not 3.0.10 or
newer, it is need to make fake executable like:
[[[
#!/bin/sh
echo Version 3.0.12
]]]
and explicitly specify it by --with-swig=/path/to/fake-script.

Or alternatively, apply attached patch, and pass --without-swig option
to configure.

Cheers,
-- 
Yasuhito FUTATSUKI <futat...@yf.bsclub.org>
Index: build/ac-macros/swig.m4
===================================================================
--- build/ac-macros/swig.m4     (revision 1876661)
+++ build/ac-macros/swig.m4     (revision 1876662)
@@ -151,38 +151,44 @@
           ])
           SWIG_PY_LIBS="`SVN_REMOVE_STANDARD_LIB_DIRS($ac_cv_python_libs)`"
 
-          AC_CACHE_CHECK([for Python >= 3], [ac_cv_python_is_py3],[
-            ac_cv_python_is_py3="no"
-            $PYTHON -c 'import sys; sys.exit(0x3000000 > sys.hexversion)' && \
-               ac_cv_python_is_py3="yes"
-          ])
-
-          if test "$ac_cv_python_is_py3" = "yes"; then
-            if test "$SWIG_VERSION" -ge "300010"; then
-              dnl SWIG Python bindings successfully configured, clear the 
error message dnl
-              SWIG_PY_ERRMSG=""
-            else
-              SWIG_PY_ERRMSG="SWIG version is not suitable"
-              AC_MSG_WARN([Subversion Python bindings for Python 3 require 
SWIG 3.0.10 or newer])
-            fi
-            if test "$SWIG_VERSION" -lt "400000"; then
-              SWIG_PY_OPTS="-python -py3 -nofastunpack -modern"
-            else
-              SWIG_PY_OPTS="-python -py3 -nofastunpack"
-            fi
+          if test "$SWIG" = "none"; then
+            SWIG_PY_ERRMSG=""
           else
-            if test "$SWIG_VERSION" -lt "400000"; then
-              SWIG_PY_OPTS="-python -classic"
-              dnl SWIG Python bindings successfully configured, clear the 
error message dnl
-              SWIG_PY_ERRMSG=""
+            # Look more closely at the SWIG and Python versions to
+            # determine SWIG_PY_OPTS. We can skip this if we already
+            # have the SWIG-generated files.
+            AC_CACHE_CHECK([for Python >= 3], [ac_cv_python_is_py3],[
+              ac_cv_python_is_py3="no"
+              $PYTHON -c 'import sys; sys.exit(0x3000000 > sys.hexversion)' && 
\
+                 ac_cv_python_is_py3="yes"
+            ])
+  
+            if test "$ac_cv_python_is_py3" = "yes"; then
+              if test "$SWIG_VERSION" -ge "300010"; then
+                dnl SWIG Python bindings successfully configured, clear the 
error message dnl
+                SWIG_PY_ERRMSG=""
+              else
+                SWIG_PY_ERRMSG="SWIG version is not suitable"
+                AC_MSG_WARN([Subversion Python bindings for Python 3 require 
SWIG 3.0.10 or newer])
+              fi
+              if test "$SWIG_VERSION" -lt "400000"; then
+                SWIG_PY_OPTS="-python -py3 -nofastunpack -modern"
+              else
+                SWIG_PY_OPTS="-python -py3 -nofastunpack"
+              fi
             else
-              SWIG_PY_OPTS="-python -nofastunpack"
-              SWIG_PY_ERRMSG="SWIG version is not suitable"
-              AC_MSG_WARN([Subversion Python bindings for Python 2 require 
1.3.24 <= SWIG < 4.0.0])
+              if test "$SWIG_VERSION" -lt "400000"; then
+                SWIG_PY_OPTS="-python -classic"
+                dnl SWIG Python bindings successfully configured, clear the 
error message dnl
+                SWIG_PY_ERRMSG=""
+              else
+                SWIG_PY_OPTS="-python -nofastunpack"
+                SWIG_PY_ERRMSG="SWIG version is not suitable"
+                AC_MSG_WARN([Subversion Python bindings for Python 2 require 
1.3.24 <= SWIG < 4.0.0])
+              fi
             fi
           fi
         fi
-            
       fi
     fi
 

Reply via email to