Skip to content

Commit 5c75f22

Browse files
author
James William Pye
committed
Initial pg-python commit.
Slightly refactored from the plpython3 patch posted to -hackers.
0 parents  commit 5c75f22

132 files changed

Lines changed: 39529 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

GNUmakefile

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
all: src/module.py.cfrag $(MODULE_big)
2+
3+
# built by configure by build/tools/config.py
4+
include build/cache/python.mk
5+
6+
MODULE_big := python
7+
8+
OBJS = src/pl.o \
9+
src/do.o \
10+
src/python.o src/postgres.o \
11+
src/module.o \
12+
src/stateful.o \
13+
src/errordata.o src/triggerdata.o \
14+
src/ist.o src/xact.o \
15+
src/error.o \
16+
src/tupledesc.o src/function.o src/statement.o src/cursor.o \
17+
src/type/type.o \
18+
src/type/object.o \
19+
src/type/pseudo.o \
20+
src/type/record.o \
21+
src/type/array.o \
22+
src/type/system.o \
23+
src/type/string.o \
24+
src/type/numeric.o \
25+
src/type/timewise.o \
26+
src/type/bitwise.o
27+
28+
REGRESS = init io srf function trigger xact error domain enum ifmod array composite spi polymorphic materialize_cursor lo bytea pytypes timewise stateful type typmod do preload tupledesc corners environment oid cache
29+
30+
# PGXS built by the configure script
31+
include build/cache/postgres.mk
32+
33+
# This is a developer option that enables some unexpected elog()'s
34+
ifeq ($(PLPY_STRANGE_THINGS), 1)
35+
override CPPFLAGS := -DPLPY_STRANGE_THINGS $(CPPFLAGS)
36+
endif
37+
38+
override CPPFLAGS := '-DPL_UUID="$(uuid)"' $(python_cflags) $(CPPFLAGS) -I./include
39+
override SHLIB_LINK := $(python_ldflags) $(CPPFLAGS) $(SHLIB_LINK)
40+
41+
# Convert the characters in the file into a comma separated list of
42+
# ASCII character codes. (See src/module.c for where it's included)
43+
src/module.py.cfrag: src/module.py
44+
$(python) src/module.py.cfrag.py <$? >$@
45+
46+
.PHONY: html
47+
48+
html:
49+
mkdir -p src/sphinx/html/doctrees
50+
cp src/documentation/*.txt src/sphinx/
51+
cp src/sphinx/index.rst src/sphinx/index.txt
52+
cd src/sphinx && sphinx-build -E -b html -d html/doctrees . html
53+
@cd src/sphinx/html && pwd

LICENSE

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
BSD Licensed Software
2+
3+
Unless stated otherwise, the contained software is
4+
copyright 2004-2010, James Williame Pye.
5+
For more information: http://python.projects.postgresql.org/backend
6+
7+
8+
Redistribution and use in source and binary forms,
9+
with or without modification, are permitted provided
10+
that the following conditions are met:
11+
12+
Redistributions of source code must retain the above copyright
13+
notice, this list of conditions and the following disclaimer.
14+
15+
Redistributions in binary form must reproduce the above
16+
copyright notice, this list of conditions and the following
17+
disclaimer in the documentation and/or other materials provided
18+
with the distribution.
19+
20+
Neither the name of the James William Pye nor the names of [its]
21+
contributors may be used to endorse or promote products derived
22+
from this software without specific prior written permission.
23+
24+
25+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28+
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
29+
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
30+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
31+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
34+
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
35+
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36+
POSSIBILITY OF SUCH DAMAGE.

README

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pg-python is a Python procedural language extension for PostgreSQL.
2+
3+
See src/documentation/admin.txt for installation information.

build/tools/config.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import sys
2+
import os.path
3+
import uuid
4+
try:
5+
import distutils.sysconfig as sysconfig
6+
except ImportError:
7+
try:
8+
import sysconfig
9+
except ImportError:
10+
sys.stderr.write("ERROR: no sysconfig module available\n")
11+
sys.stderr.write("HINT: Try installing a Python 'dev' package.\n")
12+
sys.exit(1)
13+
14+
format = "{0} = {1!s}\n".format
15+
def emit(name, value):
16+
sys.stdout.write(format(name, value))
17+
18+
if sys.platform in ('win32', 'win64'):
19+
emit('target_system', 'msw')
20+
else:
21+
# ASSume.
22+
emit('target_system', 'posix')
23+
24+
emit('uuid', str(uuid.uuid1()))
25+
emit('python', sys.executable)
26+
emit('python_version', str(sys.version_info[0]) + str(sys.version_info[1]))
27+
emit('python_ref', 'python' + str(sys.version_info[0]) + str(sys.version_info[1]))
28+
29+
emit('python_cflags', ' '.join([
30+
'-I' + sysconfig.get_python_inc(),
31+
]
32+
))
33+
34+
emit('python_ldflags', ' '.join([
35+
'-L' + sysconfig.get_config_vars('LIBDIR')[0],
36+
'-lpython' + sysconfig.get_config_vars('VERSION')[0],
37+
] + sysconfig.get_config_vars('SHLIBS', 'SYSLIBS', 'LDFLAGS')
38+
))

configure

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/sh
2+
##
3+
# configure the pg_python build. This script builds the build/cache for
4+
# the GNUmakefile.
5+
##
6+
7+
if test -e build/cache
8+
then
9+
if test -e build/cache/__pg_python_build_cache__
10+
then
11+
echo >&2 "removing previous build/cache"
12+
rm -rf build/cache
13+
else
14+
echo >&2 "ERROR: build/cache does not appear to be from pg-python"
15+
echo >&2 "HINT: The __pg_python_build_cache__ file did not exist in that directory."
16+
echo >&2 " This file is used to validate that the directory is the pg-python"
17+
echo >&2 " build/cache directory."
18+
exit 2
19+
fi
20+
fi
21+
22+
mkdir -p build/cache
23+
touch build/cache/__pg_python_build_cache__
24+
25+
echo >&2 "building Makefile includes for PGXS build"
26+
pg_config 2>/dev/null >/dev/null || ! echo >&2 "ERROR: could not find 'pg_config' executable" || exit 1
27+
28+
echo >&2 "LOG: caching postgres.mk. derived from $(pg_config --bindir)/pg_config"
29+
echo "PGXS := $(pg_config --pgxs)" >build/cache/postgres.mk
30+
cat "$(pg_config --pgxs)" >>build/cache/postgres.mk
31+
echo "pg_bindir := $(pg_config --bindir)" >>build/cache/postgres.mk
32+
33+
python3 -c 'pass' || ! echo >&2 "ERROR: could not find 'python3' executable" || exit 1
34+
echo >&2 "LOG: caching python.mk. derived from $(python3 -c 'import sys; print(sys.executable)')"
35+
python3 build/tools/config.py >build/cache/python.mk

0 commit comments

Comments
 (0)