1
0
mirror of https://github.com/postgres/postgres.git synced 2025-04-20 00:42:27 +03:00

PL/Python: Make build on OS X more flexible

The PL/Python build on OS X was previously hardcoded to use the system
installation of Python, ignoring whatever was specified to configure.
Except that it would use the header files from configure, which could
lead to mismatches.  It was not possible to build against a custom
Python installation.

Now, we check in configure how the specified Python installation was
built and use that, supporting framework and non-framework builds.
This commit is contained in:
Peter Eisentraut 2013-01-05 08:56:14 -05:00
parent 7e938e3c56
commit fc8745070a
4 changed files with 34 additions and 18 deletions

View File

@ -48,7 +48,6 @@ AC_MSG_RESULT([$python_includespec])
AC_SUBST(python_majorversion)[]dnl AC_SUBST(python_majorversion)[]dnl
AC_SUBST(python_version)[]dnl AC_SUBST(python_version)[]dnl
AC_SUBST(python_configdir)[]dnl
AC_SUBST(python_includespec)[]dnl AC_SUBST(python_includespec)[]dnl
])# _PGAC_CHECK_PYTHON_DIRS ])# _PGAC_CHECK_PYTHON_DIRS
@ -69,8 +68,14 @@ python_libdir=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(N
python_ldlibrary=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('LDLIBRARY'))))"` python_ldlibrary=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('LDLIBRARY'))))"`
python_so=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('SO'))))"` python_so=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('SO'))))"`
ldlibrary=`echo "${python_ldlibrary}" | sed "s/${python_so}$//"` ldlibrary=`echo "${python_ldlibrary}" | sed "s/${python_so}$//"`
python_framework=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('PYTHONFRAMEWORK'))))"`
python_enable_shared=`${PYTHON} -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_vars().get('Py_ENABLE_SHARED',0))"`
if test x"${python_libdir}" != x"" -a x"${python_ldlibrary}" != x"" -a x"${python_ldlibrary}" != x"${ldlibrary}" if test -n "$python_framework"; then
python_frameworkprefix=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('PYTHONFRAMEWORKPREFIX'))))"`
python_libspec="-F $python_frameworkprefix -framework $python_framework"
python_enable_shared=1
elif test x"${python_libdir}" != x"" -a x"${python_ldlibrary}" != x"" -a x"${python_ldlibrary}" != x"${ldlibrary}"
then then
# New way: use the official shared library # New way: use the official shared library
ldlibrary=`echo "${ldlibrary}" | sed "s/^lib//"` ldlibrary=`echo "${ldlibrary}" | sed "s/^lib//"`
@ -86,13 +91,16 @@ else
python_libspec="-L${python_libdir} -lpython${python_ldversion}" python_libspec="-L${python_libdir} -lpython${python_ldversion}"
fi fi
if test -z "$python_framework"; then
python_additional_libs=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('LIBS','LIBC','LIBM','BASEMODLIBS'))))"` python_additional_libs=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('LIBS','LIBC','LIBM','BASEMODLIBS'))))"`
fi
AC_MSG_RESULT([${python_libspec} ${python_additional_libs}]) AC_MSG_RESULT([${python_libspec} ${python_additional_libs}])
AC_SUBST(python_libdir)[]dnl AC_SUBST(python_libdir)[]dnl
AC_SUBST(python_libspec)[]dnl AC_SUBST(python_libspec)[]dnl
AC_SUBST(python_additional_libs)[]dnl AC_SUBST(python_additional_libs)[]dnl
AC_SUBST(python_enable_shared)[]dnl
# threaded python is not supported on OpenBSD # threaded python is not supported on OpenBSD
AC_MSG_CHECKING(whether Python is compiled with thread support) AC_MSG_CHECKING(whether Python is compiled with thread support)

12
configure vendored
View File

@ -672,11 +672,11 @@ HAVE_IPV6
LIBOBJS LIBOBJS
OSSP_UUID_LIBS OSSP_UUID_LIBS
ZIC ZIC
python_enable_shared
python_additional_libs python_additional_libs
python_libspec python_libspec
python_libdir python_libdir
python_includespec python_includespec
python_configdir
python_version python_version
python_majorversion python_majorversion
PYTHON PYTHON
@ -7446,8 +7446,14 @@ python_libdir=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(N
python_ldlibrary=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('LDLIBRARY'))))"` python_ldlibrary=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('LDLIBRARY'))))"`
python_so=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('SO'))))"` python_so=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('SO'))))"`
ldlibrary=`echo "${python_ldlibrary}" | sed "s/${python_so}$//"` ldlibrary=`echo "${python_ldlibrary}" | sed "s/${python_so}$//"`
python_framework=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('PYTHONFRAMEWORK'))))"`
python_enable_shared=`${PYTHON} -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_vars().get('Py_ENABLE_SHARED',0))"`
if test x"${python_libdir}" != x"" -a x"${python_ldlibrary}" != x"" -a x"${python_ldlibrary}" != x"${ldlibrary}" if test -n "$python_framework"; then
python_frameworkprefix=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('PYTHONFRAMEWORKPREFIX'))))"`
python_libspec="-F $python_frameworkprefix -framework $python_framework"
python_enable_shared=1
elif test x"${python_libdir}" != x"" -a x"${python_ldlibrary}" != x"" -a x"${python_ldlibrary}" != x"${ldlibrary}"
then then
# New way: use the official shared library # New way: use the official shared library
ldlibrary=`echo "${ldlibrary}" | sed "s/^lib//"` ldlibrary=`echo "${ldlibrary}" | sed "s/^lib//"`
@ -7463,7 +7469,9 @@ else
python_libspec="-L${python_libdir} -lpython${python_ldversion}" python_libspec="-L${python_libdir} -lpython${python_ldversion}"
fi fi
if test -z "$python_framework"; then
python_additional_libs=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('LIBS','LIBC','LIBM','BASEMODLIBS'))))"` python_additional_libs=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('LIBS','LIBC','LIBM','BASEMODLIBS'))))"`
fi
{ $as_echo "$as_me:$LINENO: result: ${python_libspec} ${python_additional_libs}" >&5 { $as_echo "$as_me:$LINENO: result: ${python_libspec} ${python_additional_libs}" >&5
$as_echo "${python_libspec} ${python_additional_libs}" >&6; } $as_echo "${python_libspec} ${python_additional_libs}" >&6; }

View File

@ -175,11 +175,11 @@ enable_dtrace = @enable_dtrace@
enable_coverage = @enable_coverage@ enable_coverage = @enable_coverage@
enable_thread_safety = @enable_thread_safety@ enable_thread_safety = @enable_thread_safety@
python_enable_shared = @python_enable_shared@
python_includespec = @python_includespec@ python_includespec = @python_includespec@
python_libdir = @python_libdir@ python_libdir = @python_libdir@
python_libspec = @python_libspec@ python_libspec = @python_libspec@
python_additional_libs = @python_additional_libs@ python_additional_libs = @python_additional_libs@
python_configdir = @python_configdir@
python_majorversion = @python_majorversion@ python_majorversion = @python_majorversion@
python_version = @python_version@ python_version = @python_version@

View File

@ -5,13 +5,20 @@ top_builddir = ../../..
include $(top_builddir)/src/Makefile.global include $(top_builddir)/src/Makefile.global
# On some platforms we can only build PL/Python if libpython is a # We need libpython as a shared library. In Python >=2.5, configure
# shared library. Since there is no official way to determine this # asks Python directly. But because this has been broken in Debian
# (at least not in pre-2.3 Python), we see if there is a file that is # for a long time (http://bugs.debian.org/695979), and to support
# named like a shared library. # older Python versions, we see if there is a file that is named like
# a shared library as a fallback. (Note that this is wrong on OS X,
# where DLSUFFIX is .so, but libpython is a .dylib. Python <2.5 is
# therefore not supported on OS X.)
ifeq (1,$(python_enable_shared))
shared_libpython = yes
else
ifneq (,$(wildcard $(python_libdir)/libpython*$(DLSUFFIX)*)) ifneq (,$(wildcard $(python_libdir)/libpython*$(DLSUFFIX)*))
shared_libpython = yes shared_libpython = yes
endif endif
endif
# Windows needs to convert backslashed paths to normal slashes, # Windows needs to convert backslashed paths to normal slashes,
# and we have to remove -lpython from the link since we are building our own # and we have to remove -lpython from the link since we are building our own
@ -21,13 +28,6 @@ python_includespec := $(subst \,/,$(python_includespec))
override python_libspec = override python_libspec =
endif 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, we have to skip it. # If we don't have a shared library, we have to skip it.
ifeq ($(shared_libpython),yes) ifeq ($(shared_libpython),yes)