Some concerns about our postgresql and plpython ports

Ruslan Mahmatkhanov cvs-src at
Tue Aug 16 15:20:39 UTC 2011

Hi there.

We have databases/postgresql-plpython, that is marked as broken with
this message: "Does not configure without threaded Python", but this is
totally wrong - it actually does. I checked the internets and found
this: [1] and [2]. People are actually had problems when building it 
WITH threaded python (that is built with threads support by default).
Rebuilding python w/o threads support do the trick actually. But if you
will try to build this port with threads-aware python, you'll get this
error message:

checking whether Python is compiled with thread support... yes
configure: error: threaded Python not supported on this platform

But the funny thing that it actually builds and works fine with threaded
python too :). We just need to apply this patch to postgresqlXX-server's 

-  openbsd*|freebsd*)
+  openbsd*)

And then there is no error:

checking whether Python is compiled with thread support... yes
checking for main in -lm... yes

So what i did - i have tested the build and runtime of 8.4, 9.0, 9.1b3.
both with threads-aware python and threadless python (version 2.7.2,
runtime is tested only on 9-CURRENT, but with all the three PostgreSQL
And all of this configurations works well. For testing i'm used sample
function (pymax.sql) from PosgreSQL manual and simple script 
(, that adds/removes and runs the function:

[mrk at smeshariki2 plpython]> cat pymax.sql
CREATE FUNCTION pymax (a integer, b integer)
   RETURNS integer
AS $$
   if a > b:
     return a
   return b
$$ LANGUAGE plpythonu;

[mrk at smeshariki2 plpython]> cat

createlang -U pgsql plpythonu test
psql -U pgsql test -f pymax.sql
psql -U pgsql test -c "select pymax(1,2)"
psql -U pgsql test -c "drop function pymax(a integer, b integer)"
droplang -U pgsql plpythonu test

To build databases/postgresql-plpython with PostgreSQL 9.1b3 i've used
patch from [4] by Martin Neubauer <mn at shodan dot homeunix dot net>,
it is also included into my patch [3]. Updated regexp also working
fine with 8.4 and 9.0.

plpython module for 9.0 and 9.1 was renamed to, but there
is also symlink in 9.0 that points to 9.1 also
installs some extension files, so i fixed pkg-plists accordingly.

Since 9.0 PostgreSQL guys use docbook for building all the 
documentation, including man-pages. They ever listed all the 
dependencies needed on FreeBSD to make it build. See [5]. But because 
our postgresql-client ports didn't include needed dependencies, their 
build are broken. In particular:

postgresql91-client is broken on FreeBSD-8.2
postgresql90-client is broken on FreeBSD-7.4
postgresql91-client is broken on FreeBSD-7.4

So i have fixed this too by adding this deps to the ports. And i'm not
see another solution. We need man-pages for postgresql9x-client, and
man-pages needs all that docbook stuff.

To make lang/python27 build without threads  under tinderbox, i was
forced to fix it's plist. Please see patch [6]. Probably similar patch
should be applied against other python versions.

The plpython port is unmantained, so please commit this anybody.
Below are build logs of various configurations.

Threads-aware python:

Threadless python:

To sum up what is included into patch [3]:
- databases/postgresql-plpython no more marked as broken, since it
   builds both with threaded and threaless python on all supported
   FreeBSD versions with three major PostgreSQL branches
- added configure patch for PostgreSQL 8.4, 9.0, 9.1 to make it able to
   build plpython threads-aware python
- merge changed regexp to make plpython built with 9.1b3 from [4]
- fix plists for postgresql9x-server/pkg-plist-plpython (
   and extensions)
- fix build of postgresql9x-client (docbook related deps added)
- portrevisions for -client and -plpython bumped

I know that 8.2 and 8.3 are still supported branches, but i'm not much
interested in them, so hadn't ever tried them, but believe that the same 
fixes applies.
Please let me know if anybody actually need them, so i'll take a look
at it in my spare time.

Sorry for the long letter and my engrish :)


python -c "import sys; print(int('thread' in sys.builtin_module_names))"
postmaster -V | sed -n 
pg_config --version | sed -n 


More information about the freebsd-ports mailing list