Re: [HACKERS] unable to build postgres-9.4 in os x 10.9 with python - Mailing list pgsql-general

From Tom Lane
Subject Re: [HACKERS] unable to build postgres-9.4 in os x 10.9 with python
Date
Msg-id 9364.1401481917@sss.pgh.pa.us
Whole thread Raw
In response to Re: unable to build postgres-9.4 in os x 10.9 with python  (Adrian Klaver <adrian.klaver@aklaver.com>)
Responses Re: [HACKERS] unable to build postgres-9.4 in os x 10.9 with python  (Adrian Klaver <adrian.klaver@aklaver.com>)
List pgsql-general
Adrian Klaver <adrian.klaver@aklaver.com> writes:
> On 05/30/2014 11:52 AM, Tom Lane wrote:
>> If you do the ld call by hand without the -syslibroot option, it works.
>> AFAICS it could never have worked with such an option, so I'm thinking
>> this is some new misbehavior in the latest version of Xcode.

> There is and the SO thread that goes into detail on this is here:
> http://stackoverflow.com/questions/19555395/python-framework-is-missing-from-os-x-10-9-sdk-why-also-workaround
> The Apple document referenced in above is:
> https://developer.apple.com/library/ios/technotes/tn2328/_index.html

Fun.  So after all these years of catering to Apple's preferred weirdness
in this regard, they reverse course and tell us to do it like everywhere
else.

I experimented with just diking out the python_framework case in
configure, and that *almost* works; but for some reason distutils doesn't
admit to having a shared library, so you also have to override that test.

The attached patch fixes this and also removes a long-obsolete comment
claiming that we don't work with Python < 2.5 on OSX (see prairiedog
for evidence to the contrary).

I've tested this successfully on my 10.9.3 laptop as well as on dromedary
and prairiedog, so I'm thinking we should patch not only HEAD but all the
back branches.  Any objections?

            regards, tom lane

PS: why aren't any of the buildfarm members using 10.9 building
--with-python?  We should have known about this months ago, ISTM.

diff --git a/config/python.m4 b/config/python.m4
index 5cb2854..7012c53 100644
*** a/config/python.m4
--- b/config/python.m4
*************** python_libdir=`${PYTHON} -c "import dist
*** 68,81 ****
  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'))))"`
  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 -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
      # New way: use the official shared library
      ldlibrary=`echo "${ldlibrary}" | sed "s/^lib//"`
--- 68,76 ----
  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'))))"`
  ldlibrary=`echo "${python_ldlibrary}" | sed "s/${python_so}$//"`
  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}"
  then
      # New way: use the official shared library
      ldlibrary=`echo "${ldlibrary}" | sed "s/^lib//"`
*************** else
*** 91,99 ****
      python_libspec="-L${python_libdir} -lpython${python_ldversion}"
  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'))))"`
! fi

  AC_MSG_RESULT([${python_libspec} ${python_additional_libs}])

--- 86,92 ----
      python_libspec="-L${python_libdir} -lpython${python_ldversion}"
  fi

! python_additional_libs=`${PYTHON} -c "import distutils.sysconfig; print('
'.join(filter(None,distutils.sysconfig.get_config_vars('LIBS','LIBC','LIBM','BASEMODLIBS'))))"`

  AC_MSG_RESULT([${python_libspec} ${python_additional_libs}])

diff --git a/src/pl/plpython/Makefile b/src/pl/plpython/Makefile
index 46d2030..020861a 100644
*** a/src/pl/plpython/Makefile
--- b/src/pl/plpython/Makefile
*************** include $(top_builddir)/src/Makefile.glo
*** 9,24 ****
  # asks Python directly.  But because this has been broken in Debian
  # for a long time (http://bugs.debian.org/695979), and to support
  # 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)*))
  shared_libpython = yes
  endif
  endif

  # Windows needs to convert backslashed paths to normal slashes,
  # and we have to remove -lpython from the link since we are building our own
--- 9,27 ----
  # asks Python directly.  But because this has been broken in Debian
  # for a long time (http://bugs.debian.org/695979), and to support
  # older Python versions, we see if there is a file that is named like
! # a shared library as a fallback.
  ifeq (1,$(python_enable_shared))
  shared_libpython = yes
  else
+ ifeq ($(PORTNAME), darwin)
+ # OS X does supply a .dylib even though Py_ENABLE_SHARED does not get set
+ shared_libpython = yes
+ else
  ifneq (,$(wildcard $(python_libdir)/libpython*$(DLSUFFIX)*))
  shared_libpython = yes
  endif
  endif
+ endif

  # Windows needs to convert backslashed paths to normal slashes,
  # and we have to remove -lpython from the link since we are building our own

pgsql-general by date:

Previous
From: David G Johnston
Date:
Subject: Re: Fwd: libpq: indefinite block on poll during network problems
Next
From: Dmitry Samonenko
Date:
Subject: Re: libpq: indefinite block on poll during network problems