2010-09-20 16:08:53 -04:00
|
|
|
# src/pl/plpython/Makefile
|
2001-05-09 15:54:38 -04:00
|
|
|
|
2001-05-11 21:30:30 -04:00
|
|
|
subdir = src/pl/plpython
|
|
|
|
|
top_builddir = ../../..
|
|
|
|
|
include $(top_builddir)/src/Makefile.global
|
2001-05-09 15:54:38 -04:00
|
|
|
|
|
|
|
|
|
2013-01-05 08:56:14 -05:00
|
|
|
# We need libpython as a shared library. In Python >=2.5, configure
|
|
|
|
|
# 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
|
2005-08-12 17:44:51 -04:00
|
|
|
ifneq (,$(wildcard $(python_libdir)/libpython*$(DLSUFFIX)*))
|
2001-08-26 20:29:49 -04:00
|
|
|
shared_libpython = yes
|
|
|
|
|
endif
|
2013-01-05 08:56:14 -05:00
|
|
|
endif
|
2001-08-26 20:29:49 -04:00
|
|
|
|
2004-10-10 15:07:55 -04:00
|
|
|
# Windows needs to convert backslashed paths to normal slashes,
|
2004-10-11 15:32:19 -04:00
|
|
|
# and we have to remove -lpython from the link since we are building our own
|
2004-10-06 05:20:41 -04:00
|
|
|
ifeq ($(PORTNAME), win32)
|
|
|
|
|
shared_libpython = yes
|
2007-02-09 23:26:24 -05:00
|
|
|
python_includespec := $(subst \,/,$(python_includespec))
|
2007-02-09 10:56:00 -05:00
|
|
|
override python_libspec =
|
2004-10-06 05:20:41 -04:00
|
|
|
endif
|
|
|
|
|
|
2012-12-18 01:13:59 -05:00
|
|
|
# If we don't have a shared library, we have to skip it.
|
|
|
|
|
ifeq ($(shared_libpython),yes)
|
2001-08-26 20:29:49 -04:00
|
|
|
|
2011-02-28 21:31:39 -05:00
|
|
|
override CPPFLAGS := -I. -I$(srcdir) $(python_includespec) $(CPPFLAGS)
|
2004-11-19 14:23:01 -05:00
|
|
|
|
|
|
|
|
rpathdir = $(python_libdir)
|
2001-05-25 11:48:33 -04:00
|
|
|
|
2009-12-15 17:59:55 -05:00
|
|
|
NAME = plpython$(python_majorversion)
|
2011-03-04 21:51:14 -05:00
|
|
|
|
2011-12-18 14:14:16 -05:00
|
|
|
OBJS = \
|
|
|
|
|
plpy_cursorobject.o \
|
|
|
|
|
plpy_elog.o \
|
|
|
|
|
plpy_exec.o \
|
|
|
|
|
plpy_main.o \
|
|
|
|
|
plpy_planobject.o \
|
|
|
|
|
plpy_plpymodule.o \
|
|
|
|
|
plpy_procedure.o \
|
|
|
|
|
plpy_resultobject.o \
|
|
|
|
|
plpy_spi.o \
|
|
|
|
|
plpy_subxactobject.o \
|
|
|
|
|
plpy_typeio.o \
|
|
|
|
|
plpy_util.o
|
2001-05-09 15:54:38 -04:00
|
|
|
|
2011-11-09 14:43:04 -05:00
|
|
|
DATA = $(NAME)u.control $(NAME)u--1.0.sql $(NAME)u--unpackaged--1.0.sql
|
|
|
|
|
ifeq ($(python_majorversion),2)
|
|
|
|
|
DATA += plpythonu.control plpythonu--1.0.sql plpythonu--unpackaged--1.0.sql
|
|
|
|
|
endif
|
2011-03-04 21:51:14 -05:00
|
|
|
|
2004-10-06 05:20:41 -04:00
|
|
|
|
|
|
|
|
# Python on win32 ships with import libraries only for Microsoft Visual C++,
|
|
|
|
|
# which are not compatible with mingw gcc. Therefore we need to build a
|
|
|
|
|
# new import library to link with.
|
|
|
|
|
ifeq ($(PORTNAME), win32)
|
2014-02-14 11:31:35 -05:00
|
|
|
|
2004-10-06 05:20:41 -04:00
|
|
|
pytverstr=$(subst .,,${python_version})
|
2014-02-14 11:31:35 -05:00
|
|
|
PYTHONDLL=$(subst \,/,$(WINDIR))/system32/python${pytverstr}.dll
|
|
|
|
|
|
2004-10-06 05:20:41 -04:00
|
|
|
OBJS += libpython${pytverstr}.a
|
2014-02-14 11:31:35 -05:00
|
|
|
|
2004-10-06 05:20:41 -04:00
|
|
|
libpython${pytverstr}.a: python${pytverstr}.def
|
2014-02-14 11:31:35 -05:00
|
|
|
dlltool --dllname python${pytverstr}.dll --def python${pytverstr}.def --output-lib libpython${pytverstr}.a
|
|
|
|
|
|
|
|
|
|
python${pytverstr}.def: $(PYTHONDLL)
|
|
|
|
|
pexports $^ > $@
|
|
|
|
|
|
|
|
|
|
endif # win32
|
2004-10-06 05:20:41 -04:00
|
|
|
|
|
|
|
|
|
2009-01-15 08:49:57 -05:00
|
|
|
SHLIB_LINK = $(python_libspec) $(python_additional_libs) $(filter -lintl,$(LIBS))
|
2001-05-12 13:49:32 -04:00
|
|
|
|
2009-12-15 17:59:55 -05:00
|
|
|
REGRESS_OPTS = --dbname=$(PL_TESTDB)
|
|
|
|
|
# Only load plpythonu with Python 2. The test files themselves load
|
|
|
|
|
# the versioned language plpython(2|3)u.
|
|
|
|
|
ifeq ($(python_majorversion),2)
|
2011-03-04 21:51:14 -05:00
|
|
|
REGRESS_OPTS += --load-extension=plpythonu
|
2009-12-15 17:59:55 -05:00
|
|
|
endif
|
2011-03-05 15:13:15 -05:00
|
|
|
|
2009-08-12 12:37:26 -04:00
|
|
|
REGRESS = \
|
|
|
|
|
plpython_schema \
|
|
|
|
|
plpython_populate \
|
|
|
|
|
plpython_test \
|
2010-01-22 10:45:15 -05:00
|
|
|
plpython_do \
|
2009-08-12 12:37:26 -04:00
|
|
|
plpython_global \
|
|
|
|
|
plpython_import \
|
|
|
|
|
plpython_spi \
|
|
|
|
|
plpython_newline \
|
|
|
|
|
plpython_void \
|
|
|
|
|
plpython_params \
|
|
|
|
|
plpython_setof \
|
|
|
|
|
plpython_record \
|
|
|
|
|
plpython_trigger \
|
2009-08-14 09:42:16 -04:00
|
|
|
plpython_types \
|
2009-08-12 12:37:26 -04:00
|
|
|
plpython_error \
|
|
|
|
|
plpython_unicode \
|
2011-02-22 16:33:44 -05:00
|
|
|
plpython_quote \
|
2011-02-26 09:53:11 -05:00
|
|
|
plpython_composite \
|
2011-02-27 10:09:56 -05:00
|
|
|
plpython_subtransaction \
|
2009-08-12 12:37:26 -04:00
|
|
|
plpython_drop
|
2011-03-05 15:13:15 -05:00
|
|
|
|
PL/Python: Improve Python 3 regression test setup
Currently, we are making mangled copies of plpython/{expected,sql} to
plpython/python3/{expected,sql}, and run the tests in
plpython/python3. This has the disadvantage that the regression.diffs
file, if any, ends up in plpython/python3, which is not the normal
location. If we instead make the mangled copies in
plpython/{expected,sql}/python3/, we can run the tests from the normal
directory, regression.diffs ends up the normal place, and the
pg_regress invocation also becomes a lot simpler. It's also more
obvious at run time what's going on, because the tests end up being
named "python3/something" in the test output.
2012-09-16 22:26:33 -04:00
|
|
|
REGRESS_PLPYTHON3_MANGLE := $(REGRESS)
|
|
|
|
|
|
2006-07-20 20:24:04 -04:00
|
|
|
# where to find psql for running the tests
|
|
|
|
|
PSQLDIR = $(bindir)
|
2005-05-14 13:55:22 -04:00
|
|
|
|
2001-05-11 21:30:30 -04:00
|
|
|
include $(top_srcdir)/src/Makefile.shlib
|
2001-05-09 15:54:38 -04:00
|
|
|
|
2001-05-11 21:30:30 -04:00
|
|
|
all: all-lib
|
2001-05-09 15:54:38 -04:00
|
|
|
|
2011-03-04 21:51:14 -05:00
|
|
|
|
2011-03-05 18:32:06 -05:00
|
|
|
install: all install-lib install-data
|
2001-05-09 15:54:38 -04:00
|
|
|
|
2008-04-07 10:15:58 -04:00
|
|
|
installdirs: installdirs-lib
|
2011-03-04 21:51:14 -05:00
|
|
|
$(MKDIR_P) '$(DESTDIR)$(datadir)/extension'
|
2001-05-09 15:54:38 -04:00
|
|
|
|
2011-03-04 21:51:14 -05:00
|
|
|
uninstall: uninstall-lib uninstall-data
|
2001-05-09 15:54:38 -04:00
|
|
|
|
2011-03-05 18:32:06 -05:00
|
|
|
install-data: installdirs
|
2011-05-01 17:37:07 -04:00
|
|
|
$(INSTALL_DATA) $(addprefix $(srcdir)/, $(DATA)) '$(DESTDIR)$(datadir)/extension/'
|
2011-03-04 21:51:14 -05:00
|
|
|
|
|
|
|
|
uninstall-data:
|
|
|
|
|
rm -f $(addprefix '$(DESTDIR)$(datadir)/extension'/, $(notdir $(DATA)))
|
|
|
|
|
|
|
|
|
|
.PHONY: install-data uninstall-data
|
|
|
|
|
|
|
|
|
|
|
2009-12-15 17:59:55 -05:00
|
|
|
ifeq ($(python_majorversion),3)
|
|
|
|
|
# Adjust regression tests for Python 3 compatibility
|
PL/Python: Improve Python 3 regression test setup
Currently, we are making mangled copies of plpython/{expected,sql} to
plpython/python3/{expected,sql}, and run the tests in
plpython/python3. This has the disadvantage that the regression.diffs
file, if any, ends up in plpython/python3, which is not the normal
location. If we instead make the mangled copies in
plpython/{expected,sql}/python3/, we can run the tests from the normal
directory, regression.diffs ends up the normal place, and the
pg_regress invocation also becomes a lot simpler. It's also more
obvious at run time what's going on, because the tests end up being
named "python3/something" in the test output.
2012-09-16 22:26:33 -04:00
|
|
|
#
|
|
|
|
|
# Mention those regression test files that need to be mangled in the
|
|
|
|
|
# variable REGRESS_PLPYTHON3_MANGLE. They will be copied to a
|
|
|
|
|
# subdirectory python3/ and have their Python syntax and other bits
|
|
|
|
|
# adjusted to work with Python 3.
|
|
|
|
|
|
|
|
|
|
# Note that the order of the tests needs to be preserved in this
|
|
|
|
|
# expression.
|
|
|
|
|
REGRESS := $(foreach test,$(REGRESS),$(if $(filter $(test),$(REGRESS_PLPYTHON3_MANGLE)),python3/$(test),$(test)))
|
|
|
|
|
|
|
|
|
|
.PHONY: pgregress-python3-mangle
|
|
|
|
|
pgregress-python3-mangle:
|
|
|
|
|
$(MKDIR_P) sql/python3 expected/python3 results/python3
|
|
|
|
|
for file in $(patsubst %,$(srcdir)/sql/%.sql,$(REGRESS_PLPYTHON3_MANGLE)) $(patsubst %,$(srcdir)/expected/%*.out,$(REGRESS_PLPYTHON3_MANGLE)); do \
|
2009-12-15 17:59:55 -05:00
|
|
|
sed -e 's/except \([[:alpha:]][[:alpha:].]*\), *\([[:alpha:]][[:alpha:]]*\):/except \1 as \2:/g' \
|
|
|
|
|
-e "s/<type 'exceptions\.\([[:alpha:]]*\)'>/<class '\1'>/g" \
|
|
|
|
|
-e "s/<type 'long'>/<class 'int'>/g" \
|
|
|
|
|
-e "s/\([0-9][0-9]*\)L/\1/g" \
|
|
|
|
|
-e 's/\([ [{]\)u"/\1"/g' \
|
|
|
|
|
-e "s/\([ [{]\)u'/\1'/g" \
|
|
|
|
|
-e "s/def next/def __next__/g" \
|
|
|
|
|
-e "s/LANGUAGE plpythonu/LANGUAGE plpython3u/g" \
|
|
|
|
|
-e "s/LANGUAGE plpython2u/LANGUAGE plpython3u/g" \
|
2011-03-04 21:51:14 -05:00
|
|
|
-e "s/EXTENSION plpythonu/EXTENSION plpython3u/g" \
|
|
|
|
|
-e "s/EXTENSION plpython2u/EXTENSION plpython3u/g" \
|
PL/Python: Improve Python 3 regression test setup
Currently, we are making mangled copies of plpython/{expected,sql} to
plpython/python3/{expected,sql}, and run the tests in
plpython/python3. This has the disadvantage that the regression.diffs
file, if any, ends up in plpython/python3, which is not the normal
location. If we instead make the mangled copies in
plpython/{expected,sql}/python3/, we can run the tests from the normal
directory, regression.diffs ends up the normal place, and the
pg_regress invocation also becomes a lot simpler. It's also more
obvious at run time what's going on, because the tests end up being
named "python3/something" in the test output.
2012-09-16 22:26:33 -04:00
|
|
|
$$file >`echo $$file | sed 's,^.*/\([^/][^/]*/\)\([^/][^/]*\)$$,\1python3/\2,'` || exit; \
|
2009-12-15 17:59:55 -05:00
|
|
|
done
|
|
|
|
|
|
PL/Python: Improve Python 3 regression test setup
Currently, we are making mangled copies of plpython/{expected,sql} to
plpython/python3/{expected,sql}, and run the tests in
plpython/python3. This has the disadvantage that the regression.diffs
file, if any, ends up in plpython/python3, which is not the normal
location. If we instead make the mangled copies in
plpython/{expected,sql}/python3/, we can run the tests from the normal
directory, regression.diffs ends up the normal place, and the
pg_regress invocation also becomes a lot simpler. It's also more
obvious at run time what's going on, because the tests end up being
named "python3/something" in the test output.
2012-09-16 22:26:33 -04:00
|
|
|
check installcheck: pgregress-python3-mangle
|
|
|
|
|
|
|
|
|
|
pg_regress_clean_files += sql/python3/ expected/python3/ results/python3/
|
2009-12-15 17:59:55 -05:00
|
|
|
|
PL/Python: Improve Python 3 regression test setup
Currently, we are making mangled copies of plpython/{expected,sql} to
plpython/python3/{expected,sql}, and run the tests in
plpython/python3. This has the disadvantage that the regression.diffs
file, if any, ends up in plpython/python3, which is not the normal
location. If we instead make the mangled copies in
plpython/{expected,sql}/python3/, we can run the tests from the normal
directory, regression.diffs ends up the normal place, and the
pg_regress invocation also becomes a lot simpler. It's also more
obvious at run time what's going on, because the tests end up being
named "python3/something" in the test output.
2012-09-16 22:26:33 -04:00
|
|
|
endif # Python 3
|
2011-02-14 14:52:32 -05:00
|
|
|
|
2009-12-15 17:59:55 -05:00
|
|
|
|
2011-12-27 13:27:24 -05:00
|
|
|
check: all submake
|
2011-02-14 14:52:32 -05:00
|
|
|
$(pg_regress_check) $(REGRESS_OPTS) $(REGRESS)
|
|
|
|
|
|
2005-05-14 13:55:22 -04:00
|
|
|
installcheck: submake
|
2011-02-14 14:52:32 -05:00
|
|
|
$(pg_regress_installcheck) $(REGRESS_OPTS) $(REGRESS)
|
PL/Python: Improve Python 3 regression test setup
Currently, we are making mangled copies of plpython/{expected,sql} to
plpython/python3/{expected,sql}, and run the tests in
plpython/python3. This has the disadvantage that the regression.diffs
file, if any, ends up in plpython/python3, which is not the normal
location. If we instead make the mangled copies in
plpython/{expected,sql}/python3/, we can run the tests from the normal
directory, regression.diffs ends up the normal place, and the
pg_regress invocation also becomes a lot simpler. It's also more
obvious at run time what's going on, because the tests end up being
named "python3/something" in the test output.
2012-09-16 22:26:33 -04:00
|
|
|
|
2005-05-14 13:55:22 -04:00
|
|
|
|
|
|
|
|
.PHONY: submake
|
|
|
|
|
submake:
|
2006-07-18 22:37:00 -04:00
|
|
|
$(MAKE) -C $(top_builddir)/src/test/regress pg_regress$(X)
|
2005-05-14 13:55:22 -04:00
|
|
|
|
2011-02-28 11:41:10 -05:00
|
|
|
clean distclean: clean-lib
|
2001-05-11 21:30:30 -04:00
|
|
|
rm -f $(OBJS)
|
2011-02-14 14:52:32 -05:00
|
|
|
rm -rf $(pg_regress_clean_files)
|
2004-10-06 05:20:41 -04:00
|
|
|
ifeq ($(PORTNAME), win32)
|
|
|
|
|
rm -f python${pytverstr}.def
|
|
|
|
|
endif
|
2001-05-09 15:54:38 -04:00
|
|
|
|
2001-08-26 20:29:49 -04:00
|
|
|
else # can't build
|
|
|
|
|
|
|
|
|
|
all:
|
|
|
|
|
@echo ""; \
|
|
|
|
|
echo "*** Cannot build PL/Python because libpython is not a shared library." ; \
|
|
|
|
|
echo "*** You might have to rebuild your Python installation. Refer to"; \
|
|
|
|
|
echo "*** the documentation for details."; \
|
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
|
|
endif # can't build
|
2011-07-03 13:55:02 -04:00
|
|
|
|
|
|
|
|
# distprep and maintainer-clean rules should be run even if we can't build.
|
|
|
|
|
|
|
|
|
|
# Force this dependency to be known even without dependency info built:
|
2011-12-18 15:34:53 -05:00
|
|
|
plpy_plpymodule.o: spiexceptions.h
|
2011-07-03 13:55:02 -04:00
|
|
|
|
|
|
|
|
spiexceptions.h: $(top_srcdir)/src/backend/utils/errcodes.txt generate-spiexceptions.pl
|
|
|
|
|
$(PERL) $(srcdir)/generate-spiexceptions.pl $< > $@
|
|
|
|
|
|
|
|
|
|
distprep: spiexceptions.h
|
|
|
|
|
|
|
|
|
|
maintainer-clean: distclean
|
|
|
|
|
rm -f spiexceptions.h
|