and here is the forgotten patch


Andrew Dunstan wrote:


Tom Lane wrote:
Andrew Dunstan <[EMAIL PROTECTED]> writes:
Peter Eisentraut wrote:
Ideally, we would get Python to tell us the right location, because "use lib64 if it exists" isn't the right solution.

Is this fixed somewhere post 7.4?

Yes, but it was never backported. See:
http://developer.postgresql.org/cvsweb.cgi/pgsql/config/python.m4

My recollection is that there are a number of interrelated changes going
on there, and that a backport would have to touch a lot more than just
the python stuff. So I'd recommend that it's not worth the trouble/risk.
But if you want to have a go at extracting a small patch from the CVS
history, have at it.



Patch attached - seems to work on my FC5/x86_64 box. Also contains the OSX fix backported. Not sure that it qualifies as small though :-)

Unless there's an objection I will apply this soon (when were we thinking of putting out the new point releases?)
--------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
      subscribe-nomail command to [EMAIL PROTECTED] so that your
      message can get through to the mailing list cleanly

cheers

andrew
Index: configure
===================================================================
RCS file: /projects/cvsroot/pgsql/configure,v
retrieving revision 1.310.2.24
diff -c -r1.310.2.24 configure
*** configure	21 May 2006 21:54:01 -0000	1.310.2.24
--- configure	4 Sep 2006 01:52:36 -0000
***************
*** 4405,4453 ****
  fi
  
  
! echo "$as_me:$LINENO: checking Python installation directories" >&5
! echo $ECHO_N "checking Python installation directories... $ECHO_C" >&6
! python_version=`${PYTHON} -c "import sys; print sys.version[:3]"`
! python_prefix=`${PYTHON} -c "import sys; print sys.prefix"`
! python_execprefix=`${PYTHON} -c "import sys; print sys.exec_prefix"`
! python_configdir="${python_execprefix}/lib/python${python_version}/config"
! python_includespec="-I${python_prefix}/include/python${python_version}"
! if test "$python_prefix" != "$python_execprefix"; then
!   python_includespec="-I${python_execprefix}/include/python${python_version} $python_includespec"
  fi
  
  # This should be enough of a message.
! if test "$python_prefix" != "$python_execprefix"; then
!   echo "$as_me:$LINENO: result: $python_prefix/lib/python${python_version} and $python_execprefix/lib/python${python_version}" >&5
! echo "${ECHO_T}$python_prefix/lib/python${python_version} and $python_execprefix/lib/python${python_version}" >&6
! else
!   echo "$as_me:$LINENO: result: $python_prefix/lib/python${python_version}" >&5
! echo "${ECHO_T}$python_prefix/lib/python${python_version}" >&6
! fi
  
  
  echo "$as_me:$LINENO: checking how to link an embedded Python application" >&5
  echo $ECHO_N "checking how to link an embedded Python application... $ECHO_C" >&6
  
! if test ! -f "$python_configdir/Makefile"; then
!   echo "$as_me:$LINENO: result: no" >&5
! echo "${ECHO_T}no" >&6
!   { { echo "$as_me:$LINENO: error: Python Makefile not found" >&5
! echo "$as_me: error: Python Makefile not found" >&2;}
!    { (exit 1); exit 1; }; }
! fi
  
! _python_libs=`grep '^LIBS=' $python_configdir/Makefile | sed 's/^.*=//'`
! _python_libc=`grep '^LIBC=' $python_configdir/Makefile | sed 's/^.*=//'`
! _python_libm=`grep '^LIBM=' $python_configdir/Makefile | sed 's/^.*=//'`
! _python_liblocalmod=`grep '^LOCALMODLIBS=' $python_configdir/Makefile | sed 's/^.*=//'`
! _python_libbasemod=`grep '^BASEMODLIBS=' $python_configdir/Makefile | sed 's/^.*=//'`
  
! pgac_tab="	" # tab character
! python_libspec=`echo X"-L$python_configdir $_python_libs $_python_libc $_python_libm -lpython$python_version $_python_liblocalmod $_python_libbasemod" | sed -e 's/^X//' -e "s/[ $pgac_tab][ $pgac_tab]*/ /g"`
  
! echo "$as_me:$LINENO: result: ${python_libspec}" >&5
! echo "${ECHO_T}${python_libspec}" >&6
  
  
  fi
--- 4405,4457 ----
  fi
  
  
! echo "$as_me:$LINENO: checking for Python distutils module" >&5
! echo $ECHO_N "checking for Python distutils module... $ECHO_C" >&6
! if "${PYTHON}" 2>&- -c 'import distutils'
! then
!     echo "$as_me:$LINENO: result: yes" >&5
! echo "${ECHO_T}yes" >&6
! else
!     echo "$as_me:$LINENO: result: no" >&5
! echo "${ECHO_T}no" >&6
!     { { echo "$as_me:$LINENO: error: distutils module not found" >&5
! echo "$as_me: error: distutils module not found" >&2;}
!    { (exit 1); exit 1; }; }
  fi
+ echo "$as_me:$LINENO: checking Python configuration directory" >&5
+ echo $ECHO_N "checking Python configuration directory... $ECHO_C" >&6
+ python_version=`${PYTHON} -c "import sys; print sys.version[:3]"`
+ python_configdir=`${PYTHON} -c "from distutils.sysconfig import get_python_lib as f; import os; print os.path.join(f(plat_specific=1,standard_lib=1),'config')"`
+ python_includespec=`${PYTHON} -c "import distutils.sysconfig; print '-I'+distutils.sysconfig.get_python_inc()"`
  
  # This should be enough of a message.
! echo "$as_me:$LINENO: result: $python_configdir" >&5
! echo "${ECHO_T}$python_configdir" >&6
  
  
  echo "$as_me:$LINENO: checking how to link an embedded Python application" >&5
  echo $ECHO_N "checking how to link an embedded Python application... $ECHO_C" >&6
  
! python_libdir=`${PYTHON} -c "import distutils.sysconfig,string; print string.join(filter(None,distutils.sysconfig.get_config_vars('LIBDIR')))"`
! python_ldlibrary=`${PYTHON} -c "import distutils.sysconfig,string; print string.join(filter(None,distutils.sysconfig.get_config_vars('LDLIBRARY')))"`
! python_so=`${PYTHON} -c "import distutils.sysconfig,string; print string.join(filter(None,distutils.sysconfig.get_config_vars('SO')))"`
! ldlibrary=`echo "${python_ldlibrary}" | sed "s/${python_so}$//"`
  
! if test x"${python_libdir}" != x"" -a x"${python_ldlibrary}" != x"" -a x"${python_ldlibrary}" != x"${ldlibrary}"
! then
! 	# New way: use the official shared library
! 	ldlibrary=`echo "${ldlibrary}" | sed "s/^lib//"`
! 	python_libspec="-L${python_libdir} -l${ldlibrary}"
! else
! 	# Old way: use libpython from python_configdir
! 	python_libdir="${python_configdir}"
! 	python_libspec="-L${python_libdir} -lpython${python_version}"
! fi
  
! python_additional_libs=`${PYTHON} -c "import distutils.sysconfig,string; print string.join(filter(None,distutils.sysconfig.get_config_vars('LIBS','LIBC','LIBM','LOCALMODLIBS','BASEMODLIBS')))"`
  
! echo "$as_me:$LINENO: result: ${python_libspec} ${python_additional_libs}" >&5
! echo "${ECHO_T}${python_libspec} ${python_additional_libs}" >&6
  
  
  fi
***************
*** 18361,18371 ****
  s,@perl_useshrplib@,$perl_useshrplib,;t t
  s,@perl_embed_ldflags@,$perl_embed_ldflags,;t t
  s,@PYTHON@,$PYTHON,;t t
! s,@python_prefix@,$python_prefix,;t t
! s,@python_execprefix@,$python_execprefix,;t t
  s,@python_configdir@,$python_configdir,;t t
  s,@python_includespec@,$python_includespec,;t t
  s,@python_libspec@,$python_libspec,;t t
  s,@LIBOBJS@,$LIBOBJS,;t t
  s,@HAVE_IPV6@,$HAVE_IPV6,;t t
  s,@THREAD_SUPPORT@,$THREAD_SUPPORT,;t t
--- 18365,18376 ----
  s,@perl_useshrplib@,$perl_useshrplib,;t t
  s,@perl_embed_ldflags@,$perl_embed_ldflags,;t t
  s,@PYTHON@,$PYTHON,;t t
! s,@python_version@,$python_version,;t t
  s,@python_configdir@,$python_configdir,;t t
  s,@python_includespec@,$python_includespec,;t t
+ s,@python_libdir@,$python_libdir,;t t
  s,@python_libspec@,$python_libspec,;t t
+ s,@python_additional_libs@,$python_additional_libs,;t t
  s,@LIBOBJS@,$LIBOBJS,;t t
  s,@HAVE_IPV6@,$HAVE_IPV6,;t t
  s,@THREAD_SUPPORT@,$THREAD_SUPPORT,;t t
Index: config/python.m4
===================================================================
RCS file: /projects/cvsroot/pgsql/config/python.m4,v
retrieving revision 1.6
diff -c -r1.6 python.m4
*** config/python.m4	1 Sep 2003 23:01:48 -0000	1.6
--- config/python.m4	4 Sep 2006 01:52:36 -0000
***************
*** 1,7 ****
  #
  # Autoconf macros for configuring the build of Python extension modules
  #
! # $Header: /projects/cvsroot/pgsql/config/python.m4,v 1.6 2003/09/01 23:01:48 petere Exp $
  #
  
  # PGAC_PATH_PYTHON
--- 1,7 ----
  #
  # Autoconf macros for configuring the build of Python extension modules
  #
! # $PostgreSQL: pgsql/config/python.m4,v 1.11 2004/10/11 19:32:16 tgl Exp $
  #
  
  # PGAC_PATH_PYTHON
***************
*** 18,71 ****
  
  # _PGAC_CHECK_PYTHON_DIRS
  # -----------------------
! # Determine the name of various directory of a given Python installation.
  AC_DEFUN([_PGAC_CHECK_PYTHON_DIRS],
  [AC_REQUIRE([PGAC_PATH_PYTHON])
! AC_MSG_CHECKING([Python installation directories])
! python_version=`${PYTHON} -c "import sys; print sys.version[[:3]]"`
! python_prefix=`${PYTHON} -c "import sys; print sys.prefix"`
! python_execprefix=`${PYTHON} -c "import sys; print sys.exec_prefix"`
! python_configdir="${python_execprefix}/lib/python${python_version}/config"
! python_includespec="-I${python_prefix}/include/python${python_version}"
! if test "$python_prefix" != "$python_execprefix"; then
!   python_includespec="-I${python_execprefix}/include/python${python_version} $python_includespec"
  fi
  
! AC_SUBST(python_prefix)[]dnl
! AC_SUBST(python_execprefix)[]dnl
  AC_SUBST(python_configdir)[]dnl
  AC_SUBST(python_includespec)[]dnl
  # This should be enough of a message.
! if test "$python_prefix" != "$python_execprefix"; then
!   AC_MSG_RESULT([$python_prefix/lib/python${python_version} and $python_execprefix/lib/python${python_version}])
! else
!   AC_MSG_RESULT([$python_prefix/lib/python${python_version}])
! fi
  ])# _PGAC_CHECK_PYTHON_DIRS
  
  
  # PGAC_CHECK_PYTHON_EMBED_SETUP
  # -----------------------------
! # Courtesy of the INN 2.3.1 package...
  AC_DEFUN([PGAC_CHECK_PYTHON_EMBED_SETUP],
  [AC_REQUIRE([_PGAC_CHECK_PYTHON_DIRS])
  AC_MSG_CHECKING([how to link an embedded Python application])
  
! if test ! -f "$python_configdir/Makefile"; then
!   AC_MSG_RESULT(no)
!   AC_MSG_ERROR([Python Makefile not found])
  fi
  
! _python_libs=`grep '^LIBS=' $python_configdir/Makefile | sed 's/^.*=//'`
! _python_libc=`grep '^LIBC=' $python_configdir/Makefile | sed 's/^.*=//'`
! _python_libm=`grep '^LIBM=' $python_configdir/Makefile | sed 's/^.*=//'`
! _python_liblocalmod=`grep '^LOCALMODLIBS=' $python_configdir/Makefile | sed 's/^.*=//'`
! _python_libbasemod=`grep '^BASEMODLIBS=' $python_configdir/Makefile | sed 's/^.*=//'`
! 
! pgac_tab="	" # tab character
! python_libspec=`echo X"-L$python_configdir $_python_libs $_python_libc $_python_libm -lpython$python_version $_python_liblocalmod $_python_libbasemod" | sed -e 's/^X//' -e "s/[[ $pgac_tab]][[ $pgac_tab]]*/ /g"`
  
! AC_MSG_RESULT([${python_libspec}])
  
  AC_SUBST(python_libspec)[]dnl
  ])# PGAC_CHECK_PYTHON_EMBED_SETUP
--- 18,80 ----
  
  # _PGAC_CHECK_PYTHON_DIRS
  # -----------------------
! # Determine the name of various directories of a given Python installation.
  AC_DEFUN([_PGAC_CHECK_PYTHON_DIRS],
  [AC_REQUIRE([PGAC_PATH_PYTHON])
! AC_MSG_CHECKING([for Python distutils module])
! if "${PYTHON}" 2>&- -c 'import distutils'
! then
!     AC_MSG_RESULT(yes)
! else
!     AC_MSG_RESULT(no)
!     AC_MSG_ERROR([distutils module not found])
  fi
+ AC_MSG_CHECKING([Python configuration directory])
+ python_version=`${PYTHON} -c "import sys; print sys.version[[:3]]"`
+ python_configdir=`${PYTHON} -c "from distutils.sysconfig import get_python_lib as f; import os; print os.path.join(f(plat_specific=1,standard_lib=1),'config')"`
+ python_includespec=`${PYTHON} -c "import distutils.sysconfig; print '-I'+distutils.sysconfig.get_python_inc()"`
  
! AC_SUBST(python_version)[]dnl
  AC_SUBST(python_configdir)[]dnl
  AC_SUBST(python_includespec)[]dnl
  # This should be enough of a message.
! AC_MSG_RESULT([$python_configdir])
  ])# _PGAC_CHECK_PYTHON_DIRS
  
  
  # PGAC_CHECK_PYTHON_EMBED_SETUP
  # -----------------------------
! #
! # Note: selecting libpython from python_configdir works in all Python
! # releases, but it generally finds a non-shared library, which means
! # that we are binding the python interpreter right into libplpython.so.
! # In Python 2.3 and up there should be a shared library available in
! # the main library location.
  AC_DEFUN([PGAC_CHECK_PYTHON_EMBED_SETUP],
  [AC_REQUIRE([_PGAC_CHECK_PYTHON_DIRS])
  AC_MSG_CHECKING([how to link an embedded Python application])
  
! python_libdir=`${PYTHON} -c "import distutils.sysconfig,string; print string.join(filter(None,distutils.sysconfig.get_config_vars('LIBDIR')))"`
! python_ldlibrary=`${PYTHON} -c "import distutils.sysconfig,string; print string.join(filter(None,distutils.sysconfig.get_config_vars('LDLIBRARY')))"`
! python_so=`${PYTHON} -c "import distutils.sysconfig,string; print string.join(filter(None,distutils.sysconfig.get_config_vars('SO')))"`
! ldlibrary=`echo "${python_ldlibrary}" | sed "s/${python_so}$//"`
! 
! if test x"${python_libdir}" != x"" -a x"${python_ldlibrary}" != x"" -a x"${python_ldlibrary}" != x"${ldlibrary}"
! then
! 	# New way: use the official shared library
! 	ldlibrary=`echo "${ldlibrary}" | sed "s/^lib//"`
! 	python_libspec="-L${python_libdir} -l${ldlibrary}"
! else
! 	# Old way: use libpython from python_configdir
! 	python_libdir="${python_configdir}"
! 	python_libspec="-L${python_libdir} -lpython${python_version}"
  fi
  
! python_additional_libs=`${PYTHON} -c "import distutils.sysconfig,string; print string.join(filter(None,distutils.sysconfig.get_config_vars('LIBS','LIBC','LIBM','LOCALMODLIBS','BASEMODLIBS')))"`
  
! AC_MSG_RESULT([${python_libspec} ${python_additional_libs}])
  
+ AC_SUBST(python_libdir)[]dnl
  AC_SUBST(python_libspec)[]dnl
+ AC_SUBST(python_additional_libs)[]dnl
  ])# PGAC_CHECK_PYTHON_EMBED_SETUP
Index: src/Makefile.global.in
===================================================================
RCS file: /projects/cvsroot/pgsql/src/Makefile.global.in,v
retrieving revision 1.170.2.1
diff -c -r1.170.2.1 Makefile.global.in
*** src/Makefile.global.in	19 Dec 2003 23:29:29 -0000	1.170.2.1
--- src/Makefile.global.in	4 Sep 2006 01:52:38 -0000
***************
*** 133,140 ****
--- 133,143 ----
  enable_thread_safety	= @enable_thread_safety@
  
  python_includespec	= @python_includespec@
+ python_libdir		= @python_libdir@
  python_libspec		= @python_libspec@
+ python_additional_libs	= @python_additional_libs@
  python_configdir	= @python_configdir@
+ python_version		= @python_version@
  
  krb_srvtab = @krb_srvtab@
  
Index: src/pl/plpython/Makefile
===================================================================
RCS file: /projects/cvsroot/pgsql/src/pl/plpython/Makefile,v
retrieving revision 1.11.6.1
diff -c -r1.11.6.1 Makefile
*** src/pl/plpython/Makefile	21 Jan 2004 19:25:11 -0000	1.11.6.1
--- src/pl/plpython/Makefile	4 Sep 2006 01:52:41 -0000
***************
*** 6,17 ****
  
  
  # On some platforms we can only build PL/Python if libpython is a
! # shared library.  Since there is no official way to determine this,
! # we see if there is a file that is named like a shared library.
! ifneq (,$(wildcard $(python_configdir)/libpython*$(DLSUFFIX)*))
  shared_libpython = yes
  endif
  
  # If we don't have a shared library and the platform doesn't allow it
  # to work without, we have to skip it.
  ifneq (,$(findstring yes, $(shared_libpython)$(allow_nonpic_in_shlib)))
--- 6,25 ----
  
  
  # On some platforms we can only build PL/Python if libpython is a
! # shared library.  Since there is no official way to determine this
! # (at least not in pre-2.3 Python), we see if there is a file that is
! # named like a shared library.
! ifneq (,$(wildcard $(python_libdir)/libpython*$(DLSUFFIX)*))
  shared_libpython = yes
  endif
  
+ # Darwin (OS X) has its own ideas about how to do this.
+ ifeq ($(PORTNAME), darwin)
+ shared_libpython = yes
+ override python_libspec := -framework Python
+ override python_additional_libs :=
+ endif
+ 
  # If we don't have a shared library and the platform doesn't allow it
  # to work without, we have to skip it.
  ifneq (,$(findstring yes, $(shared_libpython)$(allow_nonpic_in_shlib)))
***************
*** 24,30 ****
  SO_MINOR_VERSION = 0
  OBJS = plpython.o
  
! SHLIB_LINK = $(BE_DLLLIBS) $(python_libspec)
  
  include $(top_srcdir)/src/Makefile.shlib
  
--- 32,39 ----
  SO_MINOR_VERSION = 0
  OBJS = plpython.o
  
! SHLIB_LINK = $(BE_DLLLIBS) $(python_libspec) $(python_additional_libs)
! 
  
  include $(top_srcdir)/src/Makefile.shlib
  
---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Reply via email to