summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2004-10-11 19:32:19 +0000
committerTom Lane2004-10-11 19:32:19 +0000
commit340fe4a5b491b522904823d30dca1d06c85ed974 (patch)
tree398471c9bba34a3318757e97dd5dd354df165f2b
parent004cf98eac793797daa7eae52e4026759a22ba9c (diff)
Another try at making plpython autoconfiguration work correctly. Use a
-L spec rather than assuming libpython is in the standard search path (this returns to the way 7.4 did it). But check the distutils output to see if it looks like Python has built a shared library, and if so link with that instead of the probably-not-shared library found in configdir.
-rw-r--r--config/python.m430
-rwxr-xr-xconfigure24
-rw-r--r--src/Makefile.global.in2
-rw-r--r--src/pl/plpython/Makefile14
4 files changed, 58 insertions, 12 deletions
diff --git a/config/python.m4 b/config/python.m4
index 1bb53d026f..d6f5434275 100644
--- a/config/python.m4
+++ b/config/python.m4
@@ -18,7 +18,7 @@ fi
# _PGAC_CHECK_PYTHON_DIRS
# -----------------------
-# Determine the name of various directory of a given Python installation.
+# 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])
@@ -44,13 +44,37 @@ AC_MSG_RESULT([$python_configdir])
# 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_libspec=`${PYTHON} -c "import distutils.sysconfig,string; print '-lpython${python_version} '+string.join(filter(None,distutils.sysconfig.get_config_vars('LIBS','LIBC','LIBM','LOCALMODLIBS','BASEMODLIBS')))"`
+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}])
+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
diff --git a/configure b/configure
index e1a3057ba9..cbe7d901ca 100755
--- a/configure
+++ b/configure
@@ -4249,10 +4249,26 @@ 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_libspec=`${PYTHON} -c "import distutils.sysconfig,string; print '-lpython${python_version} '+string.join(filter(None,distutils.sysconfig.get_config_vars('LIBS','LIBC','LIBM','LOCALMODLIBS','BASEMODLIBS')))"`
+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}$//"`
-echo "$as_me:$LINENO: result: ${python_libspec}" >&5
-echo "${ECHO_T}${python_libspec}" >&6
+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
@@ -18893,7 +18909,9 @@ 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,@acx_pthread_config@,$acx_pthread_config,;t t
diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index 0781c6586a..8cc1d46075 100644
--- a/src/Makefile.global.in
+++ b/src/Makefile.global.in
@@ -135,7 +135,9 @@ enable_debug = @enable_debug@
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@
diff --git a/src/pl/plpython/Makefile b/src/pl/plpython/Makefile
index c238a65a3e..69835cdaca 100644
--- a/src/pl/plpython/Makefile
+++ b/src/pl/plpython/Makefile
@@ -6,24 +6,26 @@ include $(top_builddir)/src/Makefile.global
# 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 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
# Windows needs to convert backslashed paths to normal slashes,
-# and we have to remove -lpython from libspec since we are building our own
+# and we have to remove -lpython from the link since we are building our own
ifeq ($(PORTNAME), win32)
shared_libpython = yes
python_includespec := $(subst \,/,$(python_includespec))
-python_libspec := $(subst -lpython$(python_version),,$(python_libspec))
+override python_libspec :=
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
@@ -53,7 +55,7 @@ python${pytverstr}.def: $(WD)/system32/python${pytverstr}.dll
endif
-SHLIB_LINK = $(BE_DLLLIBS) $(python_libspec)
+SHLIB_LINK = $(BE_DLLLIBS) $(python_libspec) $(python_additional_libs)
include $(top_srcdir)/src/Makefile.shlib