Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 5431393

Browse files
committed
Allow plpython to build on Win32.
Magnus Hagander
1 parent 4542581 commit 5431393

File tree

4 files changed

+34
-41
lines changed

4 files changed

+34
-41
lines changed

config/python.m4

Lines changed: 4 additions & 19 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.8 2004/09/16 23:30:30 joe Exp $
4+
# $PostgreSQL: pgsql/config/python.m4,v 1.9 2004/10/06 09:20:40 momjian Exp $
55
#
66

77
# PGAC_PATH_PYTHON
@@ -34,15 +34,13 @@ python_version=`${PYTHON} -c "import sys; print sys.version[[:3]]"`
3434
python_prefix=`${PYTHON} -c "import sys; print sys.prefix"`
3535
python_execprefix=`${PYTHON} -c "import sys; print sys.exec_prefix"`
3636
python_configdir=`${PYTHON} -c "from distutils.sysconfig import get_python_lib as f; import os; print os.path.join(f(plat_specific=1,standard_lib=1),'config')"`
37-
python_includespec="-I${python_prefix}/include/python${python_version}"
38-
if test "$python_prefix" != "$python_execprefix"; then
39-
python_includespec="-I${python_execprefix}/include/python${python_version} $python_includespec"
40-
fi
37+
python_includespec=`${PYTHON} -c "import distutils.sysconfig; print '-I'+distutils.sysconfig.get_python_inc()"`
4138
4239
AC_SUBST(python_prefix)[]dnl
4340
AC_SUBST(python_execprefix)[]dnl
4441
AC_SUBST(python_configdir)[]dnl
4542
AC_SUBST(python_includespec)[]dnl
43+
AC_SUBST(python_version)[]dnl
4644
# This should be enough of a message.
4745
if test "$python_prefix" != "$python_execprefix"; then
4846
AC_MSG_RESULT([$python_prefix/lib/python${python_version} and $python_execprefix/lib/python${python_version}])
@@ -54,24 +52,11 @@ fi
5452

5553
# PGAC_CHECK_PYTHON_EMBED_SETUP
5654
# -----------------------------
57-
# Courtesy of the INN 2.3.1 package...
5855
AC_DEFUN([PGAC_CHECK_PYTHON_EMBED_SETUP],
5956
[AC_REQUIRE([_PGAC_CHECK_PYTHON_DIRS])
6057
AC_MSG_CHECKING([how to link an embedded Python application])
6158
62-
if test ! -f "$python_configdir/Makefile"; then
63-
AC_MSG_RESULT(no)
64-
AC_MSG_ERROR([Python Makefile not found])
65-
fi
66-
67-
_python_libs=`grep '^LIBS=' $python_configdir/Makefile | sed 's/^.*=//'`
68-
_python_libc=`grep '^LIBC=' $python_configdir/Makefile | sed 's/^.*=//'`
69-
_python_libm=`grep '^LIBM=' $python_configdir/Makefile | sed 's/^.*=//'`
70-
_python_liblocalmod=`grep '^LOCALMODLIBS=' $python_configdir/Makefile | sed 's/^.*=//'`
71-
_python_libbasemod=`grep '^BASEMODLIBS=' $python_configdir/Makefile | sed 's/^.*=//'`
72-
73-
pgac_tab=" " # tab character
74-
python_libspec=`echo X"-L$python_configdir $_python_libs $_python_libc $_python_libm -lpython$python_version $_python_liblocalmod $_python_libbasemod" | sed -e 's/^X//' -e "s/[[ $pgac_tab]][[ $pgac_tab]]*/ /g"`
59+
python_libspec=`${PYTHON} -c "import distutils.sysconfig,string;print string.join(filter(None,distutils.sysconfig.get_config_vars('LIBS','LIBC','LIBM','LOCALMODLIBS','BASEMODLIBS')))"`
7560
7661
AC_MSG_RESULT([${python_libspec}])
7762

configure

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4241,10 +4241,7 @@ python_version=`${PYTHON} -c "import sys; print sys.version[:3]"`
42414241
python_prefix=`${PYTHON} -c "import sys; print sys.prefix"`
42424242
python_execprefix=`${PYTHON} -c "import sys; print sys.exec_prefix"`
42434243
python_configdir=`${PYTHON} -c "from distutils.sysconfig import get_python_lib as f; import os; print os.path.join(f(plat_specific=1,standard_lib=1),'config')"`
4244-
python_includespec="-I${python_prefix}/include/python${python_version}"
4245-
if test "$python_prefix" != "$python_execprefix"; then
4246-
python_includespec="-I${python_execprefix}/include/python${python_version} $python_includespec"
4247-
fi
4244+
python_includespec=`${PYTHON} -c "import distutils.sysconfig; print '-I'+distutils.sysconfig.get_python_inc()"`
42484245

42494246
# This should be enough of a message.
42504247
if test "$python_prefix" != "$python_execprefix"; then
@@ -4259,22 +4256,7 @@ fi
42594256
echo "$as_me:$LINENO: checking how to link an embedded Python application" >&5
42604257
echo $ECHO_N "checking how to link an embedded Python application... $ECHO_C" >&6
42614258

4262-
if test ! -f "$python_configdir/Makefile"; then
4263-
echo "$as_me:$LINENO: result: no" >&5
4264-
echo "${ECHO_T}no" >&6
4265-
{ { echo "$as_me:$LINENO: error: Python Makefile not found" >&5
4266-
echo "$as_me: error: Python Makefile not found" >&2;}
4267-
{ (exit 1); exit 1; }; }
4268-
fi
4269-
4270-
_python_libs=`grep '^LIBS=' $python_configdir/Makefile | sed 's/^.*=//'`
4271-
_python_libc=`grep '^LIBC=' $python_configdir/Makefile | sed 's/^.*=//'`
4272-
_python_libm=`grep '^LIBM=' $python_configdir/Makefile | sed 's/^.*=//'`
4273-
_python_liblocalmod=`grep '^LOCALMODLIBS=' $python_configdir/Makefile | sed 's/^.*=//'`
4274-
_python_libbasemod=`grep '^BASEMODLIBS=' $python_configdir/Makefile | sed 's/^.*=//'`
4275-
4276-
pgac_tab=" " # tab character
4277-
python_libspec=`echo X"-L$python_configdir $_python_libs $_python_libc $_python_libm -lpython$python_version $_python_liblocalmod $_python_libbasemod" | sed -e 's/^X//' -e "s/[ $pgac_tab][ $pgac_tab]*/ /g"`
4259+
python_libspec=`${PYTHON} -c "import distutils.sysconfig,string;print string.join(filter(None,distutils.sysconfig.get_config_vars('LIBS','LIBC','LIBM','LOCALMODLIBS','BASEMODLIBS')))"`
42784260

42794261
echo "$as_me:$LINENO: result: ${python_libspec}" >&5
42804262
echo "${ECHO_T}${python_libspec}" >&6
@@ -18778,6 +18760,7 @@ s,@python_prefix@,$python_prefix,;t t
1877818760
s,@python_execprefix@,$python_execprefix,;t t
1877918761
s,@python_configdir@,$python_configdir,;t t
1878018762
s,@python_includespec@,$python_includespec,;t t
18763+
s,@python_version@,$python_version,;t t
1878118764
s,@python_libspec@,$python_libspec,;t t
1878218765
s,@LIBOBJS@,$LIBOBJS,;t t
1878318766
s,@HAVE_IPV6@,$HAVE_IPV6,;t t

src/Makefile.global.in

Lines changed: 2 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.197 2004/10/05 19:30:19 momjian Exp $
2+
# $PostgreSQL: pgsql/src/Makefile.global.in,v 1.198 2004/10/06 09:20:41 momjian Exp $
33

44
#------------------------------------------------------------------------------
55
# All PostgreSQL makefiles include this file and use the variables it sets,
@@ -137,6 +137,7 @@ enable_thread_safety = @enable_thread_safety@
137137
python_includespec = @python_includespec@
138138
python_libspec = @python_libspec@
139139
python_configdir = @python_configdir@
140+
python_version = @python_version@
140141

141142
krb_srvtab = @krb_srvtab@
142143

src/pl/plpython/Makefile

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $PostgreSQL: pgsql/src/pl/plpython/Makefile,v 1.14 2004/09/24 20:08:42 tgl Exp $
1+
# $PostgreSQL: pgsql/src/pl/plpython/Makefile,v 1.15 2004/10/06 09:20:41 momjian Exp $
22

33
subdir = src/pl/plpython
44
top_builddir = ../../..
@@ -12,6 +12,12 @@ ifneq (,$(wildcard $(python_configdir)/libpython*$(DLSUFFIX)*))
1212
shared_libpython = yes
1313
endif
1414

15+
# Convert backslashed paths to normal slashes
16+
ifeq ($(PORTNAME), win32)
17+
shared_libpython = yes
18+
python_includespec := $(subst \,/,$(python_includespec))
19+
endif
20+
1521
# Darwin (OS X) has its own ideas about how to do this.
1622
ifeq ($(PORTNAME), darwin)
1723
shared_libpython = yes
@@ -30,6 +36,21 @@ SO_MAJOR_VERSION = 0
3036
SO_MINOR_VERSION = 0
3137
OBJS = plpython.o
3238

39+
40+
# Python on win32 ships with import libraries only for Microsoft Visual C++,
41+
# which are not compatible with mingw gcc. Therefore we need to build a
42+
# new import library to link with.
43+
ifeq ($(PORTNAME), win32)
44+
pytverstr=$(subst .,,${python_version})
45+
OBJS += libpython${pytverstr}.a
46+
libpython${pytverstr}.a: python${pytverstr}.def
47+
dlltool --dllname python${pytverstr}.dll --def python${pytverstr}.def --output-lib libpython${pytverstr}.a
48+
WD=$(subst \,/,$(WINDIR))
49+
python${pytverstr}.def: $(WD)/system32/python${pytverstr}.dll
50+
pexports $(WD)/system32/python${pytverstr}.dll > python${pytverstr}.def
51+
endif
52+
53+
3354
SHLIB_LINK = $(BE_DLLLIBS) $(python_libspec)
3455

3556
include $(top_srcdir)/src/Makefile.shlib
@@ -55,6 +76,9 @@ uninstall:
5576
clean distclean maintainer-clean: clean-lib
5677
rm -f $(OBJS)
5778
@rm -f error.diff feature.diff error.output feature.output test.log
79+
ifeq ($(PORTNAME), win32)
80+
rm -f python${pytverstr}.def
81+
endif
5882

5983
installcheck:
6084
PATH=$(bindir):$$PATH $(SHELL) $(srcdir)/test.sh

0 commit comments

Comments
 (0)