BUG #6633: PL/Python build does not honor PYTHON on Mac OS X

Started by Clay McClurealmost 14 years ago5 messagesbugs
Jump to latest
#1Clay McClure
clay@daemons.net

The following bug has been logged on the website:

Bug reference: 6633
Logged by: Clay McClure
Email address: clay@daemons.net
PostgreSQL version: 9.1.3
Operating system: Darwin / Mac OS X 10.7.3 (Lion)
Description:

According to the installation documentation, one can set the PYTHON
environment variable to control which python is used to build PL/Python, but
this does not work correctly on Mac OS X.

The configure script correctly sets python_libspec based on the PYTHON
environment variable, but the plpython Makefile clobbers that value:

# Darwin (OS X) has its own ideas about how to do this.
ifeq ($(PORTNAME), darwin)
shared_libpython = yes
override python_libspec = -framework Python
override python_additional_libs =
endif

According to a Homebrew bug report
(https://github.com/mxcl/homebrew/issues/11162):

"You should submit a bug report to PostgreSQL as they can't assume Python is
always built as a Framework on Darwin. They should be using python-config to
get the gory details."

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Clay McClure (#1)
Re: BUG #6633: PL/Python build does not honor PYTHON on Mac OS X

clay@daemons.net writes:

According to a Homebrew bug report
(https://github.com/mxcl/homebrew/issues/11162):
"You should submit a bug report to PostgreSQL as they can't assume Python is
always built as a Framework on Darwin. They should be using python-config to
get the gory details."

Hmm ... on my Mac,

$ python-config
Usage: /usr/bin/python-config [--prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--help]

None of those options produce anything including "-framework Python".
So I think your upstream needs to clarify to us benighted database geeks
exactly how this needs to be done, in such a way that it doesn't break
the existing working cases while fixing their case.

regards, tom lane

#3Clay McClure
clay@daemons.net
In reply to: Tom Lane (#2)
Re: BUG #6633: PL/Python build does not honor PYTHON on Mac OS X

On Tue, May 8, 2012 at 1:42 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Hmm ... on my Mac,

$ python-config
Usage: /usr/bin/python-config [--prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--help]

None of those options produce anything including "-framework Python".
So I think your upstream needs to clarify to us benighted database geeks
exactly how this needs to be done, in such a way that it doesn't break
the existing working cases while fixing their case.

Thanks for your reply, Tom. I will check with the Homebrew
maintainers, but my (albeit limited) understanding of the subject is
that a framework Python is only needed for GUI applications. Unless
PL/Python is opening windows and drawing buttons, plpython.so should
work when linked against a non-framework python, whose libraries can
be found like so:

$ python-config --libs

What is interesting to me is that the top-level configure script in
the Postgres source distribution already does this, saving the result
in `python_libspec`. It's not clear to me why that is later overridden
in the plpython Makefile to build against a framework python.

I'll write back when I hear from the Homebrew folks.

Cheers,

Clay

#4Clay McClure
clay@daemons.net
In reply to: Clay McClure (#3)
Re: BUG #6633: PL/Python build does not honor PYTHON on Mac OS X

On Tue, May 8, 2012 at 11:07 AM, Clay McClure <clay@daemons.net> wrote:

Thanks for your reply, Tom. I will check with the Homebrew
maintainers, but my (albeit limited) understanding of the subject is
that a framework Python is only needed for GUI applications. Unless
PL/Python is opening windows and drawing buttons, plpython.so should
work when linked against a non-framework python, whose libraries can
be found like so:

 $ python-config --libs

What is interesting to me is that the top-level configure script in
the Postgres source distribution already does this, saving the result
in `python_libspec`. It's not clear to me why that is later overridden
in the plpython Makefile to build against a framework python.

I'll write back when I hear from the Homebrew folks.

It turns out that `python-config --libs` is only useful when you're
dealing with a unix-style (not framework) python. Since Mac OS X ships
with framework pythons, it makes sense that PostgreSQL would assume a
framework python, but it would be nice if it would also accomodate
unix-style pythons. According to the Homebrew folks, here's how to do
that:

"The gist of it is to grab python-config --prefix and store it in a
variable, say py_prefix. If the file $py_prefix/Python exists, you are
dealing with a Framework build and -framework Python is the
appropriate method of linking. Otherwise, you have a UNIX-style build
and -lpython is the appropriate method of linking."

The '-lpython' specifics are those reported by `python-config --libs`.

Cheers,

Clay

#5Peter Eisentraut
peter_e@gmx.net
In reply to: Clay McClure (#4)
Re: BUG #6633: PL/Python build does not honor PYTHON on Mac OS X

On tis, 2012-05-08 at 11:33 -0400, Clay McClure wrote:

"The gist of it is to grab python-config --prefix and store it in a
variable, say py_prefix. If the file $py_prefix/Python exists, you are
dealing with a Framework build and -framework Python is the
appropriate method of linking. Otherwise, you have a UNIX-style build
and -lpython is the appropriate method of linking."

Please try the attached patch. It's completely untested, as I don't
have that platform, but as a guidance about how it might work.

Attachments:

plpython-macosx-framework-or-not.patchtext/x-patch; charset=UTF-8; name=plpython-macosx-framework-or-not.patchDownload+20-2