aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula/postgresql.rb
diff options
context:
space:
mode:
authorSamuel John2013-01-21 10:33:56 +0100
committerSamuel John2013-06-03 17:29:43 +0200
commit0b50110107ea2998e65011ec31ce45931b446dab (patch)
tree9f28d410bcd3ac3bbd547bc1220919dbc8e5c39d /Library/Formula/postgresql.rb
parent35c46b417c781864d1b772ed7f8b77504605f4ad (diff)
downloadhomebrew-0b50110107ea2998e65011ec31ce45931b446dab.tar.bz2
Python 2.x and 3.x support
New `depends_on :python` Dependency. New `depends_on :python3` Dependency. To avoid having multiple formulae with endings -py2 and -py3, we will handle support for different pythons (2.x vs. 3.x) in the same formula. Further brewed vs. external python will be transparently supported. The formula also gets a new object `python`, which is false if no Python is available or the user has disabled it. Otherwise it is defined and provides several support methods: python.site_packages # the site-packages in the formula's Cellar python.global_site_packages python.binary # the full path to the python binary python.prefix python.version python.version.major python.version.minor python.xy # => e.g. "python2.7" python.incdir # includes of python python.libdir # the python dylib library python.pkg_config_path # used internally by brew python.from_osx? python.framework? python.universal? python.pypy? python.standard_caveats # Text to set PYTHONPATH for python.from_osx? python.if3then3 # => "" for 2.x and to "3" for 3.x. Further, to avoid code duplication, `python` takes an optional block that is run twice if the formula defines depends_on :python AND :python3. python do system python, 'setup.py', "--prefix=#{prefix}" end Read more in the Homebrew wiki.
Diffstat (limited to 'Library/Formula/postgresql.rb')
-rw-r--r--Library/Formula/postgresql.rb53
1 files changed, 23 insertions, 30 deletions
diff --git a/Library/Formula/postgresql.rb b/Library/Formula/postgresql.rb
index d1a2e77b9..6466c254a 100644
--- a/Library/Formula/postgresql.rb
+++ b/Library/Formula/postgresql.rb
@@ -8,12 +8,12 @@ class Postgresql < Formula
depends_on 'readline'
depends_on 'libxml2' if MacOS.version == :leopard # Leopard libxml is too old
depends_on 'ossp-uuid' => :recommended
+ depends_on :python => :recommended
conflicts_with 'postgres-xc',
:because => 'postgresql and postgres-xc install the same binaries.'
option '32-bit'
- option 'no-python', 'Build without Python support'
option 'no-perl', 'Build without Perl support'
option 'enable-dtrace', 'Build with DTrace support'
@@ -46,7 +46,7 @@ class Postgresql < Formula
]
args << "--with-ossp-uuid" if build.with? 'ossp-uuid'
- args << "--with-python" unless build.include? 'no-python'
+ args << "--with-python" if build.with? 'python'
args << "--with-perl" unless build.include? 'no-perl'
args << "--enable-dtrace" if build.include? 'enable-dtrace'
@@ -56,7 +56,7 @@ class Postgresql < Formula
ENV.append 'LIBS', `uuid-config --libs`.strip
end
- if not build.build_32_bit? and MacOS.prefer_64_bit? and not build.include? 'no-python'
+ if not build.build_32_bit? and MacOS.prefer_64_bit? and build.with? 'python'
args << "ARCHFLAGS='-arch x86_64'"
check_python_arch
end
@@ -71,27 +71,25 @@ class Postgresql < Formula
end
def check_python_arch
- # On 64-bit systems, we need to look for a 32-bit Framework Python.
- # The configure script prefers this Python version, and if it doesn't
- # have 64-bit support then linking will fail.
- framework_python = Pathname.new "/Library/Frameworks/Python.framework/Versions/Current/Python"
- return unless framework_python.exist?
- unless (archs_for_command framework_python).include? :x86_64
- opoo "Detected a framework Python that does not have 64-bit support in:"
- puts <<-EOS.undent
- #{framework_python}
-
- The configure script seems to prefer this version of Python over any others,
- so you may experience linker problems as described in:
- http://osdir.com/ml/pgsql-general/2009-09/msg00160.html
-
- To fix this issue, you may need to either delete the version of Python
- shown above, or move it out of the way before brewing PostgreSQL.
-
- Note that a framework Python in /Library/Frameworks/Python.framework is
- the "MacPython" version, and not the system-provided version which is in:
- /System/Library/Frameworks/Python.framework
- EOS
+ # On 64-bit systems, we need to avoid a 32-bit Framework Python.
+ if python.framework?
+ unless archs_for_command(python.binary).include? :x86_64
+ opoo "Detected a framework Python that does not have 64-bit support in:"
+ puts <<-EOS.undent
+ #{python.prefix}
+
+ The configure script seems to prefer this version of Python over any others,
+ so you may experience linker problems as described in:
+ http://osdir.com/ml/pgsql-general/2009-09/msg00160.html
+
+ To fix this issue, you may need to either delete the version of Python
+ shown above, or move it out of the way before brewing PostgreSQL.
+
+ Note that a framework Python in /Library/Frameworks/Python.framework is
+ the "MacPython" version, and not the system-provided version which is in:
+ /System/Library/Frameworks/Python.framework
+ EOS
+ end
end
end
@@ -103,11 +101,6 @@ class Postgresql < Formula
you may need to remove the previous version first. See:
https://github.com/mxcl/homebrew/issues/issue/2510
- To build plpython against a specific Python, set PYTHON prior to brewing:
- PYTHON=/usr/local/bin/python brew install postgresql
- See:
- http://www.postgresql.org/docs/9.2/static/install-procedure.html
-
# Create/Upgrade a Database
If this is your first install, create a database with:
@@ -118,7 +111,7 @@ class Postgresql < Formula
# Loading Extensions
- By default, Homebrew builds all available Contrib extensions. To see a list of all
+ By default, Homebrew builds all available Contrib extensions. To see a list of all
available extensions, from the psql command line, run:
SELECT * FROM pg_available_extensions;