Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit669ca7a

Browse files
committed
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 outputto see if it looks like Python has built a shared library, and if solink with that instead of the probably-not-shared library found inconfigdir.
1 parente5d3009 commit669ca7a

File tree

4 files changed

+61
-15
lines changed

4 files changed

+61
-15
lines changed

‎config/python.m4

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#
22
# Autoconf macros for configuring the build of Python extension modules
33
#
4-
# $PostgreSQL: pgsql/config/python.m4,v 1.10 2004/10/10 19:07:52 tgl Exp $
4+
# $PostgreSQL: pgsql/config/python.m4,v 1.11 2004/10/11 19:32:16 tgl Exp $
55
#
66

77
# PGAC_PATH_PYTHON
@@ -18,7 +18,7 @@ fi
1818

1919
# _PGAC_CHECK_PYTHON_DIRS
2020
# -----------------------
21-
# Determine the name of variousdirectory of a given Python installation.
21+
# Determine the name of variousdirectories of a given Python installation.
2222
AC_DEFUN([_PGAC_CHECK_PYTHON_DIRS],
2323
[AC_REQUIRE([PGAC_PATH_PYTHON])
2424
AC_MSG_CHECKING([for Python distutils module])
@@ -44,13 +44,37 @@ AC_MSG_RESULT([$python_configdir])
4444

4545
# PGAC_CHECK_PYTHON_EMBED_SETUP
4646
# -----------------------------
47+
#
48+
# Note: selecting libpython from python_configdir works in all Python
49+
# releases, but it generally finds a non-shared library, which means
50+
# that we are binding the python interpreter right into libplpython.so.
51+
# In Python 2.3 and up there should be a shared library available in
52+
# the main library location.
4753
AC_DEFUN([PGAC_CHECK_PYTHON_EMBED_SETUP],
4854
[AC_REQUIRE([_PGAC_CHECK_PYTHON_DIRS])
4955
AC_MSG_CHECKING([how to link an embedded Python application])
5056
51-
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')))"`
57+
python_libdir=`${PYTHON} -c "import distutils.sysconfig,string; print string.join(filter(None,distutils.sysconfig.get_config_vars('LIBDIR')))"`
58+
python_ldlibrary=`${PYTHON} -c "import distutils.sysconfig,string; print string.join(filter(None,distutils.sysconfig.get_config_vars('LDLIBRARY')))"`
59+
python_so=`${PYTHON} -c "import distutils.sysconfig,string; print string.join(filter(None,distutils.sysconfig.get_config_vars('SO')))"`
60+
ldlibrary=`echo "${python_ldlibrary}" | sed "s/${python_so}$//"`
61+
62+
if test x"${python_libdir}" != x"" -a x"${python_ldlibrary}" != x"" -a x"${python_ldlibrary}" != x"${ldlibrary}"
63+
then
64+
# New way: use the official shared library
65+
ldlibrary=`echo "${ldlibrary}" | sed "s/^lib//"`
66+
python_libspec="-L${python_libdir} -l${ldlibrary}"
67+
else
68+
# Old way: use libpython from python_configdir
69+
python_libdir="${python_configdir}"
70+
python_libspec="-L${python_libdir} -lpython${python_version}"
71+
fi
72+
73+
python_additional_libs=`${PYTHON} -c "import distutils.sysconfig,string; print string.join(filter(None,distutils.sysconfig.get_config_vars('LIBS','LIBC','LIBM','LOCALMODLIBS','BASEMODLIBS')))"`
5274
53-
AC_MSG_RESULT([${python_libspec}])
75+
AC_MSG_RESULT([${python_libspec} ${python_additional_libs}])
5476
77+
AC_SUBST(python_libdir)[]dnl
5578
AC_SUBST(python_libspec)[]dnl
79+
AC_SUBST(python_additional_libs)[]dnl
5680
])# PGAC_CHECK_PYTHON_EMBED_SETUP

‎configure

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4249,10 +4249,26 @@ echo "${ECHO_T}$python_configdir" >&6
42494249
echo "$as_me:$LINENO: checking how to link an embedded Python application" >&5
42504250
echo $ECHO_N "checking how to link an embedded Python application... $ECHO_C" >&6
42514251

4252-
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')))"`
4252+
python_libdir=`${PYTHON} -c "import distutils.sysconfig,string; print string.join(filter(None,distutils.sysconfig.get_config_vars('LIBDIR')))"`
4253+
python_ldlibrary=`${PYTHON} -c "import distutils.sysconfig,string; print string.join(filter(None,distutils.sysconfig.get_config_vars('LDLIBRARY')))"`
4254+
python_so=`${PYTHON} -c "import distutils.sysconfig,string; print string.join(filter(None,distutils.sysconfig.get_config_vars('SO')))"`
4255+
ldlibrary=`echo "${python_ldlibrary}" | sed "s/${python_so}$//"`
42534256

4254-
echo "$as_me:$LINENO: result: ${python_libspec}" >&5
4255-
echo "${ECHO_T}${python_libspec}" >&6
4257+
if test x"${python_libdir}" != x"" -a x"${python_ldlibrary}" != x"" -a x"${python_ldlibrary}" != x"${ldlibrary}"
4258+
then
4259+
# New way: use the official shared library
4260+
ldlibrary=`echo "${ldlibrary}" | sed "s/^lib//"`
4261+
python_libspec="-L${python_libdir} -l${ldlibrary}"
4262+
else
4263+
# Old way: use libpython from python_configdir
4264+
python_libdir="${python_configdir}"
4265+
python_libspec="-L${python_libdir} -lpython${python_version}"
4266+
fi
4267+
4268+
python_additional_libs=`${PYTHON} -c "import distutils.sysconfig,string; print string.join(filter(None,distutils.sysconfig.get_config_vars('LIBS','LIBC','LIBM','LOCALMODLIBS','BASEMODLIBS')))"`
4269+
4270+
echo "$as_me:$LINENO: result: ${python_libspec} ${python_additional_libs}" >&5
4271+
echo "${ECHO_T}${python_libspec} ${python_additional_libs}" >&6
42564272

42574273

42584274
fi
@@ -18893,7 +18909,9 @@ s,@PYTHON@,$PYTHON,;t t
1889318909
s,@python_version@,$python_version,;t t
1889418910
s,@python_configdir@,$python_configdir,;t t
1889518911
s,@python_includespec@,$python_includespec,;t t
18912+
s,@python_libdir@,$python_libdir,;t t
1889618913
s,@python_libspec@,$python_libspec,;t t
18914+
s,@python_additional_libs@,$python_additional_libs,;t t
1889718915
s,@LIBOBJS@,$LIBOBJS,;t t
1889818916
s,@HAVE_IPV6@,$HAVE_IPV6,;t t
1889918917
s,@acx_pthread_config@,$acx_pthread_config,;t t

‎src/Makefile.global.in

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*-makefile-*-
2-
# $PostgreSQL: pgsql/src/Makefile.global.in,v 1.200 2004/10/06 15:14:13 momjian Exp $
2+
# $PostgreSQL: pgsql/src/Makefile.global.in,v 1.201 2004/10/11 19:32:19 tgl Exp $
33

44
#------------------------------------------------------------------------------
55
# All PostgreSQL makefiles include this file and use the variables it sets,
@@ -135,7 +135,9 @@ enable_debug= @enable_debug@
135135
enable_thread_safety= @enable_thread_safety@
136136

137137
python_includespec= @python_includespec@
138+
python_libdir= @python_libdir@
138139
python_libspec= @python_libspec@
140+
python_additional_libs= @python_additional_libs@
139141
python_configdir= @python_configdir@
140142
python_version= @python_version@
141143

‎src/pl/plpython/Makefile

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
1-
# $PostgreSQL: pgsql/src/pl/plpython/Makefile,v 1.16 2004/10/10 19:07:55 tgl Exp $
1+
# $PostgreSQL: pgsql/src/pl/plpython/Makefile,v 1.17 2004/10/11 19:32:19 tgl Exp $
22

33
subdir = src/pl/plpython
44
top_builddir = ../../..
55
include$(top_builddir)/src/Makefile.global
66

77

88
# On some platforms we can only build PL/Python if libpython is a
9-
# shared library. Since there is no official way to determine this,
10-
# we see if there is a file that is named like a shared library.
11-
ifneq (,$(wildcard$(python_configdir)/libpython*$(DLSUFFIX)*))
9+
# shared library. Since there is no official way to determine this
10+
# (at least not in pre-2.3 Python), we see if there is a file that is
11+
# named like a shared library.
12+
ifneq (,$(wildcard$(python_libdir)/libpython*$(DLSUFFIX)*))
1213
shared_libpython = yes
1314
endif
1415

1516
# Windows needs to convert backslashed paths to normal slashes,
16-
# and we have to remove -lpython fromlibspec since we are building our own
17+
# and we have to remove -lpython fromthe link since we are building our own
1718
ifeq ($(PORTNAME), win32)
1819
shared_libpython = yes
1920
python_includespec :=$(subst \,/,$(python_includespec))
20-
python_libspec :=$(subst -lpython$(python_version),,$(python_libspec))
21+
overridepython_libspec :=
2122
endif
2223

2324
# Darwin (OS X) has its own ideas about how to do this.
2425
ifeq ($(PORTNAME), darwin)
2526
shared_libpython = yes
2627
overridepython_libspec := -framework Python
28+
overridepython_additional_libs :=
2729
endif
2830

2931
# 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
5355
endif
5456

5557

56-
SHLIB_LINK =$(BE_DLLLIBS)$(python_libspec)
58+
SHLIB_LINK =$(BE_DLLLIBS)$(python_libspec)$(python_additional_libs)
5759

5860
include$(top_srcdir)/src/Makefile.shlib
5961

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp