Bug 773

Summary: Non-standard Python location build failure with pyunbound
Product: unbound Reporter: matt
Component: serverAssignee: unbound team <unbound-team>
Status: RESOLVED FIXED    
Severity: normal CC: cathya, matt, wouter
Priority: P5    
Version: 1.5.8   
Hardware: Other   
OS: other   

Description matt 2016-06-07 03:30:14 CEST
Hey all,

When trying to build Unbound 1.5.8, I'm getting the following error after defining the path to the appropriate Python installation:

Could not link test program to Python. Maybe the main Python library has been
 installed in some non-standard library path. If so, pass it to configure,
 via the LDFLAGS environment variable.
 Example: ./configure LDFLAGS="-L/usr/non-standard-path/python/lib"
 ============================================================================
  ERROR!
  You probably have to install the development version of the Python package
  for your distribution.  The exact name of this package varies among them.
 ============================================================================

When running configure for Unbound 1.5.8 I'm seeing the following in config.log:

configure:16579: checking for python
configure:16609: result: /Users/mdavid/virtualenvs/netki/bin/python
configure:16630: checking for the distutils Python package
configure:16634: result: yes
configure:16648: checking for Python include path
configure:16658: result: -I/Users/mdavid/python/2.7.11/include/python2.7
configure:16665: checking for Python library path
configure:16671: result: libpython2.7.a

This then fails.

When running configure for Unbound 1.4.22 I'm seeing the following in config.log:

configure:16579: checking for python
configure:16609: result: /Users/mdavid/virtualenvs/netki/bin/python
configure:16630: checking for the distutils Python package
configure:16634: result: yes
configure:16648: checking for Python include path
configure:16658: result: -I/Users/mdavid/python/2.7.11/include/python2.7
configure:16665: checking for Python library path
configure:16671: result: -L/Users/mdavid/python/2.7.11/lib/python2.7 -L/Users/mdavid/python/2.7.11/lib -lpython2.7

This compile correctly. Then, when I set PYTHON_LDFLAGS to the library value in the 1.4.22 config.log and then re-run ./configure it configures and compiles correctly. It looks like the Python library determination code was changed at some point. I just wanted to let you know that this wasn't working for me (on El Capitan) at least with a custom Python install location.

Thanks all!
Comment 1 Wouter Wijngaards 2016-06-07 10:17:42 CEST
Hi Matt,

This must have broken during the python2 to python3 fixes to that part of the code.  The issues are in acx_python.m4.

If I revert to the 1.4.22 version we'll get the python3 issues back...  Does this patch fix the issue?  It is also commited to the source repo.

Index: acx_python.m4
===================================================================
--- acx_python.m4	(revision 3762)
+++ acx_python.m4	(working copy)
@@ -54,7 +54,7 @@
         AC_MSG_CHECKING([for Python library path])
         if test -z "$PYTHON_LDFLAGS"; then
                 PYTHON_LDFLAGS=`$PYTHON -c "from distutils.sysconfig import *; \
-                        print(get_config_var('BLDLIBRARY'));"`
+                        print('-L'+get_config_var('LIBDIR')+' -L'+get_config_var('LIBDEST')+' '+get_config_var('BLDLIBRARY'));"`
         fi
         AC_MSG_RESULT([$PYTHON_LDFLAGS])
         AC_SUBST([PYTHON_LDFLAGS])
Index: configure
===================================================================
--- configure	(revision 3762)
+++ configure	(working copy)
@@ -16714,7 +16714,7 @@
 $as_echo_n "checking for Python library path... " >&6; }
         if test -z "$PYTHON_LDFLAGS"; then
                 PYTHON_LDFLAGS=`$PYTHON -c "from distutils.sysconfig import *; \
-                        print(get_config_var('BLDLIBRARY'));"`
+                        print('-L'+get_config_var('LIBDIR')+' -L'+get_config_var('LIBDEST')+' '+get_config_var('BLDLIBRARY'));"`
         fi
         { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON_LDFLAGS" >&5
 $as_echo "$PYTHON_LDFLAGS" >&6; }
Comment 2 Wouter Wijngaards 2016-06-07 11:27:08 CEST
Hi Matt,

I think this fixes it, so I am closing the bug.  If it is still wrong, please let us know.

Thanks for the report!  Those python2 to python3 changes keep making issues.

Best regards, Wouter
Comment 3 matt 2016-06-07 18:28:33 CEST
Hey Wouter,

Thanks for the fix! I'll test it out shortly, but it looks like it'll work. Will this be included in the 1.5.9 release?

Thanks again,

-- Matt
Comment 4 Wouter Wijngaards 2016-06-08 16:00:11 CEST
Hi Matt,

No, it is for a later release.  Getting latest acx_python.m4 from the code repository and rerunning autoconf should make it work for older versions.

Best regards, Wouter