Skip to content

Commit 4f5f4da

Browse files
committed
On OS X, link libpython normally, ignoring the "framework" framework.
As of Xcode 5.0, Apple isn't including the Python framework as part of the SDK-level files, which means that linking to it might fail depending on whether Xcode thinks you've selected a specific SDK version. According to their Tech Note 2328, they've basically deprecated the framework method of linking to libpython and are telling people to link to the shared library normally. (I'm pretty sure this is in direct contradiction to the advice they were giving a few years ago, but whatever.) Testing says that this approach works fine at least as far back as OS X 10.4.11, so let's just rip out the framework special case entirely. We do still need a special case to decide that OS X provides a shared library at all, unfortunately (I wonder why the distutils check doesn't work ...). But this is still less of a special case than before, so it's fine. Back-patch to all supported branches, since we'll doubtless be hearing about this more as more people update to recent Xcode.
1 parent 6f11869 commit 4f5f4da

File tree

3 files changed

+10
-21
lines changed

3 files changed

+10
-21
lines changed

config/python.m4

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,9 @@ python_libdir=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(N
6868
python_ldlibrary=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('LDLIBRARY'))))"`
6969
python_so=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('SO'))))"`
7070
ldlibrary=`echo "${python_ldlibrary}" | sed "s/${python_so}$//"`
71-
python_framework=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('PYTHONFRAMEWORK'))))"`
7271
python_enable_shared=`${PYTHON} -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_vars().get('Py_ENABLE_SHARED',0))"`
7372
74-
if test -n "$python_framework"; then
75-
python_frameworkprefix=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('PYTHONFRAMEWORKPREFIX'))))"`
76-
python_libspec="-F${python_frameworkprefix} -framework $python_framework"
77-
python_enable_shared=1
78-
elif test x"${python_libdir}" != x"" -a x"${python_ldlibrary}" != x"" -a x"${python_ldlibrary}" != x"${ldlibrary}"
73+
if test x"${python_libdir}" != x"" -a x"${python_ldlibrary}" != x"" -a x"${python_ldlibrary}" != x"${ldlibrary}"
7974
then
8075
# New way: use the official shared library
8176
ldlibrary=`echo "${ldlibrary}" | sed "s/^lib//"`
@@ -91,9 +86,7 @@ else
9186
python_libspec="-L${python_libdir} -lpython${python_ldversion}"
9287
fi
9388
94-
if test -z "$python_framework"; then
95-
python_additional_libs=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('LIBS','LIBC','LIBM','BASEMODLIBS'))))"`
96-
fi
89+
python_additional_libs=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('LIBS','LIBC','LIBM','BASEMODLIBS'))))"`
9790
9891
AC_MSG_RESULT([${python_libspec} ${python_additional_libs}])
9992

configure

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7584,14 +7584,9 @@ python_libdir=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(N
75847584
python_ldlibrary=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('LDLIBRARY'))))"`
75857585
python_so=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('SO'))))"`
75867586
ldlibrary=`echo "${python_ldlibrary}" | sed "s/${python_so}$//"`
7587-
python_framework=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('PYTHONFRAMEWORK'))))"`
75887587
python_enable_shared=`${PYTHON} -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_vars().get('Py_ENABLE_SHARED',0))"`
75897588

7590-
if test -n "$python_framework"; then
7591-
python_frameworkprefix=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('PYTHONFRAMEWORKPREFIX'))))"`
7592-
python_libspec="-F${python_frameworkprefix} -framework $python_framework"
7593-
python_enable_shared=1
7594-
elif test x"${python_libdir}" != x"" -a x"${python_ldlibrary}" != x"" -a x"${python_ldlibrary}" != x"${ldlibrary}"
7589+
if test x"${python_libdir}" != x"" -a x"${python_ldlibrary}" != x"" -a x"${python_ldlibrary}" != x"${ldlibrary}"
75957590
then
75967591
# New way: use the official shared library
75977592
ldlibrary=`echo "${ldlibrary}" | sed "s/^lib//"`
@@ -7607,9 +7602,7 @@ else
76077602
python_libspec="-L${python_libdir} -lpython${python_ldversion}"
76087603
fi
76097604

7610-
if test -z "$python_framework"; then
7611-
python_additional_libs=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('LIBS','LIBC','LIBM','BASEMODLIBS'))))"`
7612-
fi
7605+
python_additional_libs=`${PYTHON} -c "import distutils.sysconfig; print(' '.join(filter(None,distutils.sysconfig.get_config_vars('LIBS','LIBC','LIBM','BASEMODLIBS'))))"`
76137606

76147607
{ $as_echo "$as_me:$LINENO: result: ${python_libspec} ${python_additional_libs}" >&5
76157608
$as_echo "${python_libspec} ${python_additional_libs}" >&6; }

src/pl/plpython/Makefile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,19 @@ include $(top_builddir)/src/Makefile.global
99
# asks Python directly. But because this has been broken in Debian
1010
# for a long time (http://bugs.debian.org/695979), and to support
1111
# older Python versions, we see if there is a file that is named like
12-
# a shared library as a fallback. (Note that this is wrong on OS X,
13-
# where DLSUFFIX is .so, but libpython is a .dylib. Python <2.5 is
14-
# therefore not supported on OS X.)
12+
# a shared library as a fallback.
1513
ifeq (1,$(python_enable_shared))
1614
shared_libpython = yes
1715
else
16+
ifeq ($(PORTNAME), darwin)
17+
# OS X does supply a .dylib even though Py_ENABLE_SHARED does not get set
18+
shared_libpython = yes
19+
else
1820
ifneq (,$(wildcard $(python_libdir)/libpython*$(DLSUFFIX)*))
1921
shared_libpython = yes
2022
endif
2123
endif
24+
endif
2225

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

0 commit comments

Comments
 (0)