Thread: PL/Python Postgresql 7.1.1 under Cygwin

PL/Python Postgresql 7.1.1 under Cygwin

From
"Ernesto Revilla"
Date:
Hi,
me again... this is what I wrote:
> I tried to build also the plpython so I could write my trigger functions
in
> Python. But the Makefile is not very adapted. I don't know how to call
> dlltool, etc. I'll try to copy the tcl one and adapt it. I hope it'll
help.

now I did it, so I wanted to ask
1. if somebody could merge my makefile with the original one
2. put the plpython into the postgres source tree 'pl' (as experimental or
whatever)

I have not much experience with Makefiles.

The attached Makefile is the one I used. The other file is the complete
plpython package I picked up I don't remember where.

Notes of my makefile:
1. the 2nd and third overrides may to seem necessarry. I think ./configure
could create this makefile. We need to know the Includedir and python
version.
2. The first override (CFLAGS) removes a lot of compiler warnings. So I
leave it in.
3. I don't know what the -fPIC is for. Under Win32 it is ignored.
4. In the SHLIB_LINK line the -lpython2.1 could be created with ./configure
again. I had to add the -L/usr/bin because under cygwin 1.31 I have the
libpython2.1.dll in the /usr/bin directory no the /usr/lib.
5. I still didn't try the dll so perhaps it doesn't work.


Best regards,
Erny
Spain




Attachment

Re: PL/Python Postgresql 7.1.1 under Cygwin (with attachment)

From
Jason Tishler
Date:
Erny,

[OK, let's try again with the attachment this time...]

On Fri, May 11, 2001 at 03:54:06AM +0200, Ernesto Revilla wrote:
> now I did it, so I wanted to ask
> 1. if somebody could merge my makefile with the original one
> 2. put the plpython into the postgres source tree 'pl' (as experimental or
> whatever)

It appears that plpython was recently (i.e., 2001/05/09) added to
PostgreSQL CVS.  So the above is not necessary.

However, a small patch is necessary for plpython to build cleanly under
Cygwin.  Please get the latest PostgreSQL from CVS and apply the
attached patch.  I ran the supplied test.sh and all tests passed with
the exception of the oid related ones (which is to be expected).

I would be very interested to hear if plpython works for you in a real
application, so please let me know.

I intend improve my patch as follows:

1. add -DUSE_DL_IMPORT to CPPFLAGS in a cleaner way
2. deal with the different socket module name in Python 1.5.x and 2.x,
if possible

I will also test it out on a non-Cygwin platform to make sure that I
didn't break anything on a UNIX platform.

Once the above is completed, I will submit the patch to pgsql-patches
for consideration.

Thanks,
Jason

--
Jason Tishler
Director, Software Engineering       Phone: +1 (732) 264-8770 x235
Dot Hill Systems Corp.               Fax:   +1 (732) 264-8798
82 Bethany Road, Suite 7             Email: Jason.Tishler@dothill.com
Hazlet, NJ 07730 USA                 WWW:   http://www.dothill.com

Attachment

Re: PL/Python Postgresql 7.1.1 under Cygwin

From
Jason Tishler
Date:
Erny,

On Fri, May 11, 2001 at 03:54:06AM +0200, Ernesto Revilla wrote:
> now I did it, so I wanted to ask
> 1. if somebody could merge my makefile with the original one
> 2. put the plpython into the postgres source tree 'pl' (as experimental or
> whatever)

It appears that plpython was recently (i.e., 2001/05/09) added to
PostgreSQL CVS.  So the above is not necessary.

However, a small patch is necessary for plpython to build cleanly under
Cygwin.  Please get the latest PostgreSQL from CVS and apply the
attached patch.  I ran the supplied test.sh and all tests passed with
the exception of the oid related ones (which is to be expected).

I would be very interested to hear if plpython works for you in a real
application, so please let me know.

I intend improve my patch as follows:

1. add -DUSE_DL_IMPORT to CPPFLAGS in a cleaner way
2. deal with the different socket module name in Python 1.5.x and 2.x,
if possible

I will also test it out on a non-Cygwin platform to make sure that I
didn't break anything on a UNIX platform.

Once the above is completed, I will submit the patch to pgsql-patches
for consideration.

Thanks,
Jason

--
Jason Tishler
Director, Software Engineering       Phone: +1 (732) 264-8770 x235
Dot Hill Systems Corp.               Fax:   +1 (732) 264-8798
82 Bethany Road, Suite 7             Email: Jason.Tishler@dothill.com
Hazlet, NJ 07730 USA                 WWW:   http://www.dothill.com

Cygwin plpython patch

From
Jason Tishler
Date:
See attached for a small patch that enables plpython to build cleanly
under Cygwin.  This patch together with my previous Python patch:

    http://postgresql.readysetnet.com/mhonarc/pgsql-patches/2001-05/msg00075.html

enables full Python support (i.e., configure --with-python) for Cygwin
PostgreSQL.

See below for some more details and one issue.

On Mon, May 14, 2001 at 10:26:39AM -0400, Jason Tishler wrote:
> On Fri, May 11, 2001 at 03:54:06AM +0200, Ernesto Revilla wrote:
> > now I did it, so I wanted to ask
> > 1. if somebody could merge my makefile with the original one
> > 2. put the plpython into the postgres source tree 'pl' (as experimental or
> > whatever)
>
> It appears that plpython was recently (i.e., 2001/05/09) added to
> PostgreSQL CVS.  So the above is not necessary.
>
> However, a small patch is necessary for plpython to build cleanly under
> Cygwin.  Please get the latest PostgreSQL from CVS and apply the
> attached patch.  I ran the supplied test.sh and all tests passed with
> the exception of the oid related ones (which is to be expected).
>
> I would be very interested to hear if plpython works for you in a real
> application, so please let me know.
>
> I intend improve my patch as follows:
>
> 1. add -DUSE_DL_IMPORT to CPPFLAGS in a cleaner way

I moved this hunk from src/pl/plpython/Makefile to
src/makefiles/Makefile.win to help keep all (well most) of the Win32
crud in one place.

> 2. deal with the different socket module name in Python 1.5.x and 2.x,
> if possible

My patch contains a hunk for src/pl/plpython/feature.expected since
Python 2.1's underlying socket (shared extension) module is "_socket"
instead of "socket".  I guess one could have two different
feature.expected files, one for each version, but I wasn't sure that it
was worth the effort.

> I will also test it out on a non-Cygwin platform to make sure that I
> didn't break anything on a UNIX platform.

I tested the patch under Linux without any ill effects.

> Once the above is completed, I will submit the patch to pgsql-patches
> for consideration.

Thanks,
Jason

--
Jason Tishler
Director, Software Engineering       Phone: +1 (732) 264-8770 x235
Dot Hill Systems Corp.               Fax:   +1 (732) 264-8798
82 Bethany Road, Suite 7             Email: Jason.Tishler@dothill.com
Hazlet, NJ 07730 USA                 WWW:   http://www.dothill.com

Attachment

Re: Cygwin plpython patch

From
Jason Tishler
Date:
Erny,

On Wed, May 16, 2001 at 01:27:15AM +0200, Ernesto Revilla wrote:
> 1. I downloaded all plpython files from CVS, including Makefile
> 2.     "  and installed the global Makefile (Makefile.global) and the
> configure script.
> 3.     "  and installed the Win.h of the src/backend/port/dynloader and
> other files
> this all is under 7.1.1 CVS version
>
> When I do a make, plpython does not compile, because:
> 1. plpython is not automatically included in the make process

The automatic building of plpython is not enabled yet.  From
src/pl/Makefile, we have:

    # Doesn't build portably yet.
    #ifeq ($(with_python), yes)
    #DIRS += plpython
    #endif

Hence, you will have to cd to src/pl/plpython and run make manually.

> 2. for strange reasons -lpostgres is not included in the dllwrap command
> line. (I did a new ./configure --with-python and make clean before
> beginning).
> 3. dllwrap (or dlltool) complains that there are references to unknown
> symbols: _Py_NoneStruct, _Py_TrueStruct, PyString_Type, PyType_type, and 2
> others. This is because it uses /usr/lib/python2.1/config/libpython2.1.dll.a
> which seems not to define these symbols. So I change this and link it
> against /bin/libpython.2.1.dll (this is where it is installed by default).
> Now the linker runs fine, without any error or warning.
>
> 4. When I create the language (absolute reference to /lib/plpython.dll) and
> I run a testproc something like 'CREATE FUNCION kk() RETURNS int4 AS 'return
> 1' LANGUAGE 'plpython'; the server process crashes.
>
> Any ideas?

Did you forget to apply my patch?  I have only submitted it to
pgsql-patches, it has not been accepted into CVS.  Without my patch you
would get errors like the above.  With my patch, plpython should build
OOTB -- you should not have to do unrecommended things like #3 above.

Jason

--
Jason Tishler
Director, Software Engineering       Phone: +1 (732) 264-8770 x235
Dot Hill Systems Corp.               Fax:   +1 (732) 264-8798
82 Bethany Road, Suite 7             Email: Jason.Tishler@dothill.com
Hazlet, NJ 07730 USA                 WWW:   http://www.dothill.com

Re: [PATCHES] Cygwin plpython patch

From
Bruce Momjian
Date:
Due to time constraints, I do not directly answer general PostgreSQL
questions.  For assistance, please join the appropriate mailing list and
post your question:

    http://postgresql.org/users-lounge

You can also try the #postgresql IRC channel.  See the PostgreSQL FAQ
for more information.

> See attached for a small patch that enables plpython to build cleanly
> under Cygwin.  This patch together with my previous Python patch:
>
>     http://postgresql.readysetnet.com/mhonarc/pgsql-patches/2001-05/msg00075.html
>
> enables full Python support (i.e., configure --with-python) for Cygwin
> PostgreSQL.
>
> See below for some more details and one issue.
>
> On Mon, May 14, 2001 at 10:26:39AM -0400, Jason Tishler wrote:
> > On Fri, May 11, 2001 at 03:54:06AM +0200, Ernesto Revilla wrote:
> > > now I did it, so I wanted to ask
> > > 1. if somebody could merge my makefile with the original one
> > > 2. put the plpython into the postgres source tree 'pl' (as experimental or
> > > whatever)
> >
> > It appears that plpython was recently (i.e., 2001/05/09) added to
> > PostgreSQL CVS.  So the above is not necessary.
> >
> > However, a small patch is necessary for plpython to build cleanly under
> > Cygwin.  Please get the latest PostgreSQL from CVS and apply the
> > attached patch.  I ran the supplied test.sh and all tests passed with
> > the exception of the oid related ones (which is to be expected).
> >
> > I would be very interested to hear if plpython works for you in a real
> > application, so please let me know.
> >
> > I intend improve my patch as follows:
> >
> > 1. add -DUSE_DL_IMPORT to CPPFLAGS in a cleaner way
>
> I moved this hunk from src/pl/plpython/Makefile to
> src/makefiles/Makefile.win to help keep all (well most) of the Win32
> crud in one place.
>
> > 2. deal with the different socket module name in Python 1.5.x and 2.x,
> > if possible
>
> My patch contains a hunk for src/pl/plpython/feature.expected since
> Python 2.1's underlying socket (shared extension) module is "_socket"
> instead of "socket".  I guess one could have two different
> feature.expected files, one for each version, but I wasn't sure that it
> was worth the effort.
>
> > I will also test it out on a non-Cygwin platform to make sure that I
> > didn't break anything on a UNIX platform.
>
> I tested the patch under Linux without any ill effects.
>
> > Once the above is completed, I will submit the patch to pgsql-patches
> > for consideration.
>
> Thanks,
> Jason
>
> --
> Jason Tishler
> Director, Software Engineering       Phone: +1 (732) 264-8770 x235
> Dot Hill Systems Corp.               Fax:   +1 (732) 264-8798
> 82 Bethany Road, Suite 7             Email: Jason.Tishler@dothill.com
> Hazlet, NJ 07730 USA                 WWW:   http://www.dothill.com

[ Attachment, skipping... ]

>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Re: [PATCHES] Cygwin plpython patch

From
Bruce Momjian
Date:
Patch applied.  Thanks.

> See attached for a small patch that enables plpython to build cleanly
> under Cygwin.  This patch together with my previous Python patch:
>
>     http://postgresql.readysetnet.com/mhonarc/pgsql-patches/2001-05/msg00075.html
>
> enables full Python support (i.e., configure --with-python) for Cygwin
> PostgreSQL.
>
> See below for some more details and one issue.
>
> On Mon, May 14, 2001 at 10:26:39AM -0400, Jason Tishler wrote:
> > On Fri, May 11, 2001 at 03:54:06AM +0200, Ernesto Revilla wrote:
> > > now I did it, so I wanted to ask
> > > 1. if somebody could merge my makefile with the original one
> > > 2. put the plpython into the postgres source tree 'pl' (as experimental or
> > > whatever)
> >
> > It appears that plpython was recently (i.e., 2001/05/09) added to
> > PostgreSQL CVS.  So the above is not necessary.
> >
> > However, a small patch is necessary for plpython to build cleanly under
> > Cygwin.  Please get the latest PostgreSQL from CVS and apply the
> > attached patch.  I ran the supplied test.sh and all tests passed with
> > the exception of the oid related ones (which is to be expected).
> >
> > I would be very interested to hear if plpython works for you in a real
> > application, so please let me know.
> >
> > I intend improve my patch as follows:
> >
> > 1. add -DUSE_DL_IMPORT to CPPFLAGS in a cleaner way
>
> I moved this hunk from src/pl/plpython/Makefile to
> src/makefiles/Makefile.win to help keep all (well most) of the Win32
> crud in one place.
>
> > 2. deal with the different socket module name in Python 1.5.x and 2.x,
> > if possible
>
> My patch contains a hunk for src/pl/plpython/feature.expected since
> Python 2.1's underlying socket (shared extension) module is "_socket"
> instead of "socket".  I guess one could have two different
> feature.expected files, one for each version, but I wasn't sure that it
> was worth the effort.
>
> > I will also test it out on a non-Cygwin platform to make sure that I
> > didn't break anything on a UNIX platform.
>
> I tested the patch under Linux without any ill effects.
>
> > Once the above is completed, I will submit the patch to pgsql-patches
> > for consideration.
>
> Thanks,
> Jason
>
> --
> Jason Tishler
> Director, Software Engineering       Phone: +1 (732) 264-8770 x235
> Dot Hill Systems Corp.               Fax:   +1 (732) 264-8798
> 82 Bethany Road, Suite 7             Email: Jason.Tishler@dothill.com
> Hazlet, NJ 07730 USA                 WWW:   http://www.dothill.com

[ Attachment, skipping... ]

>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026