This repository has been archived by the owner. It is now read-only.

Fix PL/Python build (fixes #11162) #12134

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
4 participants
@claymation
Contributor

claymation commented May 7, 2012

Bug report #6633 opened with PostgreSQL—should appear here after being approved by the list moderator:

http://archives.postgresql.org/pgsql-bugs/2012-05/threads.php

I have tested the Makefile patch under these scenarios:

$ PYTHON=/usr/local/bin/python brew install postgresql
$ PYTHON=/usr/bin/python brew install postgresql    
$ brew install postgresql

In the first case, the homebrew (or other custom-built) python is used. In the second case, the system python is used. In the third case, whichever python appears first on PATH is used.

@adamv

This comment has been minimized.

Show comment Hide comment
@adamv

adamv May 7, 2012

Contributor

+1

Contributor

adamv commented May 7, 2012

+1

@2bits

This comment has been minimized.

Show comment Hide comment
@2bits

2bits May 7, 2012

Contributor

Did you try this using Homebrew python built with and without --framework? Just curious.

Contributor

2bits commented May 7, 2012

Did you try this using Homebrew python built with and without --framework? Just curious.

@diek

This comment has been minimized.

Show comment Hide comment
@diek

diek May 8, 2012

Again watching, and I will ask, is this something a newbie should be delving into or should I go elsewhere?

diek commented May 8, 2012

Again watching, and I will ask, is this something a newbie should be delving into or should I go elsewhere?

@claymation

This comment has been minimized.

Show comment Hide comment
@claymation

claymation May 8, 2012

Contributor

@2bits I did, I think, by passing PYTHON=/usr/bin/python, which is the stock (framework) python. I don't know what the -framework Python flag does or how it differs from a simple -lpython, but I can say that a simple PL/Python stored procedure did work when I built PostgreSQL as:

PYTHON=/usr/bin/python brew install postgresql

@diek, most newbies don't write Python stored procedures, so I would say that either you're trying to do the wrong thing (i.e., you really have no use for PL/Python), or that you've moved beyond newbie territory and it's time to learn how the technology you use actually works :)

Contributor

claymation commented May 8, 2012

@2bits I did, I think, by passing PYTHON=/usr/bin/python, which is the stock (framework) python. I don't know what the -framework Python flag does or how it differs from a simple -lpython, but I can say that a simple PL/Python stored procedure did work when I built PostgreSQL as:

PYTHON=/usr/bin/python brew install postgresql

@diek, most newbies don't write Python stored procedures, so I would say that either you're trying to do the wrong thing (i.e., you really have no use for PL/Python), or that you've moved beyond newbie territory and it's time to learn how the technology you use actually works :)

@diek

This comment has been minimized.

Show comment Hide comment
@diek

diek May 8, 2012

I am ready to dig in. I am on my summer break, and I have several learning objectives for the spring/summer, python/django/postgresql, data structures and algorithms in C++ and toss in some math for good measure. I don't plan on being an expert but I want to have a solid understanding of the objectives before I go back in Sept.

diek commented May 8, 2012

I am ready to dig in. I am on my summer break, and I have several learning objectives for the spring/summer, python/django/postgresql, data structures and algorithms in C++ and toss in some math for good measure. I don't plan on being an expert but I want to have a solid understanding of the objectives before I go back in Sept.

@2bits

This comment has been minimized.

Show comment Hide comment
@2bits

2bits May 9, 2012

Contributor

I control the Python I'm using by having /usr/local/bin before /usr/bin in my PATH.
If I have Homebrew Python installed, then it will be used automatically.
Homebrew Python can be built as a framework or as a loose bunch of files using the --framework option or not:

brew install --framework python
or
brew install python

So there are three distinct cases that formulas need to support, plus another possibility where the user installs their own Python somewhere else. So I was just curious if the PostgreSQL build scripts were smart enough to detect and support all those with the small changes you made to the formula. Other apps need a lot more help.

Contributor

2bits commented May 9, 2012

I control the Python I'm using by having /usr/local/bin before /usr/bin in my PATH.
If I have Homebrew Python installed, then it will be used automatically.
Homebrew Python can be built as a framework or as a loose bunch of files using the --framework option or not:

brew install --framework python
or
brew install python

So there are three distinct cases that formulas need to support, plus another possibility where the user installs their own Python somewhere else. So I was just curious if the PostgreSQL build scripts were smart enough to detect and support all those with the small changes you made to the formula. Other apps need a lot more help.

@claymation

This comment has been minimized.

Show comment Hide comment
@claymation

claymation May 9, 2012

Contributor

I can't say that I fully understand the difference between a --framework python and a non-framework python, but I can tell you that, with my patch applied, the PostgreSQL Makefile was able to link plpython.so against both my homebrew Python (built non-framework) and my system Python (which ships as a framework build), depending on how I set PYTHON. Without setting PYTHON, I presume the build scripts will use the first Python that appears on the PATH, as you mentioned. So it appears that it is possible to link against framework Pythons by using -lpython instead of --framework Python. If some functionality is lost by doing so, it doesn't seem to affect PL/Python, as my (albeit simple) stored procedure worked in both cases (framework and non-framework Python).

Contributor

claymation commented May 9, 2012

I can't say that I fully understand the difference between a --framework python and a non-framework python, but I can tell you that, with my patch applied, the PostgreSQL Makefile was able to link plpython.so against both my homebrew Python (built non-framework) and my system Python (which ships as a framework build), depending on how I set PYTHON. Without setting PYTHON, I presume the build scripts will use the first Python that appears on the PATH, as you mentioned. So it appears that it is possible to link against framework Pythons by using -lpython instead of --framework Python. If some functionality is lost by doing so, it doesn't seem to affect PL/Python, as my (albeit simple) stored procedure worked in both cases (framework and non-framework Python).

@adamv

This comment has been minimized.

Show comment Hide comment
@adamv

adamv May 12, 2012

Contributor

On 10.6, using this patch, I see that plpython2.so is linked against system Python (which is a Framework.)

If someone points me to an example Python SPROC, I can verify that it actually works.

Contributor

adamv commented May 12, 2012

On 10.6, using this patch, I see that plpython2.so is linked against system Python (which is a Framework.)

If someone points me to an example Python SPROC, I can verify that it actually works.

@claymation

This comment has been minimized.

Show comment Hide comment
@claymation

claymation May 17, 2012

Contributor

Here's the one I used:

CREATE FUNCTION pypath ()                                                                                               
  RETURNS text
AS $$
import sys
return str(sys.path)
$$ LANGUAGE plpythonu;

Running the query select * from pypath(); will return Python's library path, which should indicate which installation of Python plpython.so is linked against.

Contributor

claymation commented May 17, 2012

Here's the one I used:

CREATE FUNCTION pypath ()                                                                                               
  RETURNS text
AS $$
import sys
return str(sys.path)
$$ LANGUAGE plpythonu;

Running the query select * from pypath(); will return Python's library path, which should indicate which installation of Python plpython.so is linked against.

@claymation

This comment has been minimized.

Show comment Hide comment
@claymation

claymation May 17, 2012

Contributor

If you haven't created a plpython stored procedure before, you'll want to do this first:

CREATE LANGUAGE plpythonu;

and you'll want to be a database superuser, since plpythonu is an untrusted language and plpythonu functions cannot be created by mere mortals.

Contributor

claymation commented May 17, 2012

If you haven't created a plpython stored procedure before, you'll want to do this first:

CREATE LANGUAGE plpythonu;

and you'll want to be a database superuser, since plpythonu is an untrusted language and plpythonu functions cannot be created by mere mortals.

@adamv adamv closed this in f6b13f4 Jun 8, 2012

eproxus added a commit to eproxus/homebrew that referenced this pull request Jul 18, 2012

postgresql: fix PL/Python build
Fixes #11162
Closes #12134

Signed-off-by: Adam Vandenberg <flangy@gmail.com>

Sharpie pushed a commit to Sharpie/homebrew that referenced this pull request Sep 12, 2012

postgresql: fix PL/Python build
Fixes #11162
Closes #12134

Signed-off-by: Adam Vandenberg <flangy@gmail.com>

snakeyroc3 pushed a commit to snakeyroc3/homebrew that referenced this pull request Dec 17, 2012

postgresql: fix PL/Python build
Fixes #11162
Closes #12134

Signed-off-by: Adam Vandenberg <flangy@gmail.com>

@xu-cheng xu-cheng locked and limited conversation to collaborators Feb 16, 2016

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.