aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Library/Formula/asymptote.rb3
-rw-r--r--Library/Formula/bazaar.rb35
-rw-r--r--Library/Formula/beecrypt.rb19
-rw-r--r--Library/Formula/boost.rb22
-rw-r--r--Library/Formula/boost149.rb18
-rw-r--r--Library/Formula/bulk_extractor.rb24
-rw-r--r--Library/Formula/bup.rb16
-rw-r--r--Library/Formula/cantera.rb1
-rw-r--r--Library/Formula/cmu-sphinxbase.rb1
-rw-r--r--Library/Formula/collectd.rb3
-rw-r--r--Library/Formula/cvs2svn.rb20
-rw-r--r--Library/Formula/denyhosts.rb13
-rw-r--r--Library/Formula/diffuse.rb5
-rw-r--r--Library/Formula/disco.rb58
-rw-r--r--Library/Formula/discodex.rb9
-rw-r--r--Library/Formula/distcc.rb18
-rw-r--r--Library/Formula/duplicity.rb19
-rw-r--r--Library/Formula/enchant.rb25
-rw-r--r--Library/Formula/fail2ban.rb17
-rw-r--r--Library/Formula/fontforge.rb54
-rw-r--r--Library/Formula/fsh.rb7
-rw-r--r--Library/Formula/gdal.rb40
-rw-r--r--Library/Formula/git-cola.rb22
-rw-r--r--Library/Formula/git.rb4
-rw-r--r--Library/Formula/glade.rb6
-rw-r--r--Library/Formula/gnome-doc-utils.rb24
-rw-r--r--Library/Formula/google-app-engine.rb2
-rw-r--r--Library/Formula/graphviz.rb2
-rw-r--r--Library/Formula/grass.rb94
-rw-r--r--Library/Formula/grc.rb3
-rw-r--r--Library/Formula/gtk-doc.rb10
-rw-r--r--Library/Formula/io.rb13
-rw-r--r--Library/Formula/ldns.rb14
-rw-r--r--Library/Formula/ledger.rb17
-rw-r--r--Library/Formula/libcaca.rb6
-rw-r--r--Library/Formula/libdnet.rb9
-rw-r--r--Library/Formula/liblunar.rb5
-rw-r--r--Library/Formula/libming.rb10
-rw-r--r--Library/Formula/libplist.rb61
-rw-r--r--Library/Formula/libpst.rb10
-rw-r--r--Library/Formula/libstfl.rb25
-rw-r--r--Library/Formula/libswiften.rb1
-rw-r--r--Library/Formula/libxml2.rb54
-rw-r--r--Library/Formula/little-cms.rb5
-rw-r--r--Library/Formula/llvm.rb32
-rw-r--r--Library/Formula/lorem.rb2
-rw-r--r--Library/Formula/macvim.rb21
-rw-r--r--Library/Formula/mapnik.rb23
-rw-r--r--Library/Formula/mapserver.rb17
-rw-r--r--Library/Formula/mercurial.rb29
-rw-r--r--Library/Formula/ninja.rb4
-rw-r--r--Library/Formula/node.rb12
-rw-r--r--Library/Formula/omniorb.rb24
-rw-r--r--Library/Formula/open-babel.rb77
-rw-r--r--Library/Formula/opencolorio.rb37
-rw-r--r--Library/Formula/orfeo.rb12
-rw-r--r--Library/Formula/oscats.rb7
-rw-r--r--Library/Formula/pil.rb34
-rw-r--r--Library/Formula/portmidi.rb31
-rw-r--r--Library/Formula/postgres-xc.rb46
-rw-r--r--Library/Formula/postgresql.rb53
-rw-r--r--Library/Formula/py2cairo.rb28
-rw-r--r--Library/Formula/pyexiv2.rb27
-rw-r--r--Library/Formula/pygobject.rb11
-rw-r--r--Library/Formula/pygtk.rb91
-rw-r--r--Library/Formula/pygtkglext.rb7
-rw-r--r--Library/Formula/pygtksourceview.rb11
-rw-r--r--Library/Formula/pyqt.rb90
-rw-r--r--Library/Formula/pyqwt.rb34
-rw-r--r--Library/Formula/pyside-tools.rb25
-rw-r--r--Library/Formula/pyside.rb59
-rw-r--r--Library/Formula/python.rb143
-rw-r--r--Library/Formula/python3.rb225
-rw-r--r--Library/Formula/qscintilla2.rb31
-rw-r--r--Library/Formula/qwt.rb6
-rw-r--r--Library/Formula/rdiff-backup.rb21
-rw-r--r--Library/Formula/rubber.rb2
-rw-r--r--Library/Formula/scons.rb13
-rw-r--r--Library/Formula/shiboken.rb65
-rw-r--r--Library/Formula/shocco.rb1
-rw-r--r--Library/Formula/sip.rb104
-rw-r--r--Library/Formula/subversion.rb18
-rw-r--r--Library/Formula/swatchbooker.rb30
-rw-r--r--Library/Formula/swig.rb2
-rw-r--r--Library/Formula/thrift.rb17
-rw-r--r--Library/Formula/treeline.rb6
-rw-r--r--Library/Formula/uwsgi.rb11
-rw-r--r--Library/Formula/vim.rb8
-rw-r--r--Library/Formula/weechat.rb41
-rw-r--r--Library/Formula/wireshark.rb2
-rw-r--r--Library/Formula/wxmac.rb16
-rw-r--r--Library/Formula/xapian.rb24
-rw-r--r--Library/Formula/yasm.rb22
-rw-r--r--Library/Formula/zookeeper.rb20
-rw-r--r--Library/Homebrew/build_options.rb15
-rw-r--r--Library/Homebrew/cmd/audit.rb68
-rw-r--r--Library/Homebrew/dependency.rb2
-rw-r--r--Library/Homebrew/dependency_collector.rb5
-rw-r--r--Library/Homebrew/download_strategy.rb1
-rw-r--r--Library/Homebrew/formula.rb19
-rw-r--r--Library/Homebrew/keg.rb8
-rw-r--r--Library/Homebrew/python_helper.rb80
-rw-r--r--Library/Homebrew/requirements.rb1
-rw-r--r--Library/Homebrew/requirements/language_module_dependency.rb4
-rw-r--r--Library/Homebrew/requirements/python_dependency.rb296
-rw-r--r--Library/Homebrew/superenv.rb23
-rw-r--r--Library/Homebrew/test/test_build_options.rb11
-rw-r--r--Library/Homebrew/test/test_python.rb1
-rw-r--r--Library/Homebrew/utils.rb2
109 files changed, 1664 insertions, 1368 deletions
diff --git a/Library/Formula/asymptote.rb b/Library/Formula/asymptote.rb
index a1d61fba0..a66a0861f 100644
--- a/Library/Formula/asymptote.rb
+++ b/Library/Formula/asymptote.rb
@@ -62,7 +62,8 @@ class Asymptote < Formula
If you wish to use xasy, you must first install the Python Imaging Library:
- easy_install http://effbot.org/downloads/Imaging-1.1.7.tar.gz
+ brew install pil
+
EOS
end
end
diff --git a/Library/Formula/bazaar.rb b/Library/Formula/bazaar.rb
index 9a54b6692..fb2500695 100644
--- a/Library/Formula/bazaar.rb
+++ b/Library/Formula/bazaar.rb
@@ -5,43 +5,18 @@ class Bazaar < Formula
url 'https://launchpad.net/bzr/2.5/2.5.1/+download/bzr-2.5.1.tar.gz'
sha1 '7e2776e3aaf8fb48828026d3fc2a3047465eea5e'
- option "system", "Install using the OS X system Python."
+ depends_on :python
def install
- ENV.j1 # Builds aren't parallel-safe
-
# Make and install man page first
system "make man1/bzr.1"
man1.install "man1/bzr.1"
- if build.include? "system"
- ENV.prepend "PATH", "/System/Library/Frameworks/Python.framework/Versions/Current/bin", ":"
- end
-
- # Find the arch for the Python we are building against.
- # We remove 'ppc' support, so we can pass Intel-optimized CFLAGS.
- if build.include? "system"
- python_cmd = "/usr/bin/python"
- else
- python_cmd = "python"
+ python do
+ # In this python block, the site-packages are already set up
+ system python, "setup.py", "install", "--prefix=#{prefix}"
+ (prefix/'man').rmtree
end
-
- archs = archs_for_command(python_cmd)
- archs.remove_ppc!
- ENV['ARCHFLAGS'] = archs.as_arch_flags
-
- system "make"
- inreplace "bzr", "#! /usr/bin/env python", "#!/usr/bin/python" if build.include? "system"
- libexec.install 'bzr', 'bzrlib'
-
- bin.install_symlink libexec+'bzr'
end
- def caveats; <<-EOS.undent
- We've built a "standalone" version of bazaar and installed its libraries to:
- #{libexec}
-
- We've specifically kept it out of your Python's "site-packages" folder.
- EOS
- end
end
diff --git a/Library/Formula/beecrypt.rb b/Library/Formula/beecrypt.rb
index 59e6c6e7f..a976f8b71 100644
--- a/Library/Formula/beecrypt.rb
+++ b/Library/Formula/beecrypt.rb
@@ -6,6 +6,7 @@ class Beecrypt < Formula
sha256 '286f1f56080d1a6b1d024003a5fa2158f4ff82cae0c6829d3c476a4b5898c55d'
depends_on "icu4c"
+ depends_on :python => :optional
def patches
# fix build with newer clang, gcc 4.7 (https://bugs.gentoo.org/show_bug.cgi?id=413951)
@@ -19,15 +20,27 @@ class Beecrypt < Formula
end
def install
- ENV.remove_from_cflags /-march=\S*/
- args = ["--prefix=#{prefix}", "--disable-openmp", "--without-java", "--without-python"]
+ ENV.remove_from_cflags(/-march=\S*/)
+ args = ["--prefix=#{prefix}", "--disable-openmp", "--without-java"]
if MacOS.prefer_64_bit?
args << "--build=x86_64-apple-darwin#{darwin_major_version}"
end
+
+ args << "--without-python" if build.without? 'python'
+
+ if python
+ # We don't want beecrypt to use get_python_lib() to install into
+ # the global site-packages. There is no option to set it.
+ # Fixing this in configure make the configure output printout correct.
+ inreplace "configure", "ac_cv_python_libdir=`$PYTHON -c 'import distutils.sysconfig; print distutils.sysconfig.get_python_lib()'`",
+ "ac_cv_python_libdir='#{python.site_packages}'"
+ end
system "./configure", *args
system "make"
- system "make check"
system "make install"
+ # We have to move the check after install (which is stupid, I know) but
+ # otherwise they fail because python bindings don't yet find the libbeecrypt
+ system "make check"
end
end
diff --git a/Library/Formula/boost.rb b/Library/Formula/boost.rb
index 3ed67e209..4fa41c24f 100644
--- a/Library/Formula/boost.rb
+++ b/Library/Formula/boost.rb
@@ -1,7 +1,7 @@
require 'formula'
class UniversalPython < Requirement
- satisfy { archs_for_command("python").universal? }
+ satisfy(:build_env => false) { archs_for_command("python").universal? }
def message; <<-EOS.undent
A universal build was requested, but Python is not a universal build
@@ -29,14 +29,14 @@ class Boost < Formula
option :universal
option 'with-mpi', 'Enable MPI support'
- option 'without-python', 'Build without Python'
- option 'with-icu', 'Build regexp engine with icu support'
+ option 'with-icu4c', 'Build regexp engine with icu support'
option 'with-c++11', 'Compile using Clang, std=c++11 and stdlib=libc++' if MacOS.version >= :lion
option 'use-system-layout', 'Use system layout instead of tagged'
- depends_on UniversalPython if build.universal? and not build.include? "without-python"
- depends_on "icu4c" if build.include? "with-icu"
- depends_on MPIDependency.new(:cc, :cxx) if build.include? "with-mpi"
+ depends_on :python => :recommended
+ depends_on UniversalPython if build.universal? and build.with? "python"
+ depends_on "icu4c" => :optional
+ depends_on MPIDependency.new(:cc, :cxx) if build.with? "mpi"
fails_with :llvm do
build 2335
@@ -69,15 +69,15 @@ class Boost < Formula
# Force boost to compile using the appropriate GCC version
open("user-config.jam", "a") do |file|
file.write "using darwin : : #{ENV.cxx} ;\n"
- file.write "using mpi ;\n" if build.include? 'with-mpi'
+ file.write "using mpi ;\n" if build.with? 'mpi'
end
# we specify libdir too because the script is apparently broken
bargs = ["--prefix=#{prefix}", "--libdir=#{lib}"]
- bargs << "--with-toolset=clang" if build.include? "with-c++11"
+ bargs << "--with-toolset=clang" if build.with? "c++11"
- if build.include? 'with-icu'
+ if build.with? 'icu4c'
icu4c_prefix = Formula.factory('icu4c').opt_prefix
bargs << "--with-icu=#{icu4c_prefix}"
else
@@ -99,7 +99,7 @@ class Boost < Formula
"threading=multi",
"install"]
- if MacOS.version >= :lion and build.include? 'with-c++11'
+ if MacOS.version >= :lion and build.with? 'c++11'
args << "toolset=clang" << "cxxflags=-std=c++11"
args << "cxxflags=-stdlib=libc++" << "cxxflags=-fPIC"
args << "cxxflags=-arch x86_64" if MacOS.prefer_64_bit? or build.universal?
@@ -111,7 +111,7 @@ class Boost < Formula
end
args << "address-model=32_64" << "architecture=x86" << "pch=off" if build.universal?
- args << "--without-python" if build.include? "without-python"
+ args << "--without-python" if build.without? 'python'
system "./bootstrap.sh", *bargs
system "./b2", *args
diff --git a/Library/Formula/boost149.rb b/Library/Formula/boost149.rb
index 1c81df650..c1c41a2d5 100644
--- a/Library/Formula/boost149.rb
+++ b/Library/Formula/boost149.rb
@@ -1,7 +1,7 @@
require 'formula'
class UniversalPython < Requirement
- satisfy { archs_for_command("python").universal? }
+ satisfy(:build_env => false) { archs_for_command("python").universal? }
def message; <<-EOS.undent
A universal build was requested, but Python is not a universal build
@@ -23,12 +23,12 @@ class Boost149 < Formula
option :universal
option 'with-mpi', 'Enable MPI support'
- option 'without-python', 'Build without Python'
- option 'with-icu', 'Build regexp engine with icu support'
+ option 'with-icu4c', 'Build regexp engine with icu support'
- depends_on UniversalPython if build.universal? and not build.include? "without-python"
- depends_on "icu4c" if build.include? "with-icu"
- depends_on MPIDependency.new(:cc, :cxx) if build.include? "with-mpi"
+ depends_on :python => :recommended
+ depends_on UniversalPython if build.universal? and build.with? "python"
+ depends_on "icu4c" => :optional
+ depends_on MPIDependency.new(:cc, :cxx) if build.with? "mpi"
fails_with :llvm do
build 2335
@@ -50,13 +50,13 @@ class Boost149 < Formula
# Force boost to compile using the appropriate GCC version
open("user-config.jam", "a") do |file|
file.write "using darwin : : #{ENV.cxx} ;\n"
- file.write "using mpi ;\n" if build.include? 'with-mpi'
+ file.write "using mpi ;\n" if build.with? 'mpi'
end
# we specify libdir too because the script is apparently broken
bargs = ["--prefix=#{prefix}", "--libdir=#{lib}"]
- if build.include? 'with-icu'
+ if build.with? 'icu4c'
icu4c_prefix = Formula.factory('icu4c').opt_prefix
bargs << "--with-icu=#{icu4c_prefix}"
else
@@ -73,7 +73,7 @@ class Boost149 < Formula
"install"]
args << "address-model=32_64" << "architecture=x86" << "pch=off" if build.universal?
- args << "--without-python" if build.include? "without-python"
+ args << "--without-python" if build.without? 'python'
system "./bootstrap.sh", *bargs
system "./bjam", *args
diff --git a/Library/Formula/bulk_extractor.rb b/Library/Formula/bulk_extractor.rb
index 7991f1d90..64a031729 100644
--- a/Library/Formula/bulk_extractor.rb
+++ b/Library/Formula/bulk_extractor.rb
@@ -7,6 +7,7 @@ class BulkExtractor < Formula
depends_on :autoconf
depends_on :automake
+ depends_on :python
depends_on 'afflib' => :optional
depends_on 'exiv2' => :optional
@@ -19,25 +20,24 @@ class BulkExtractor < Formula
end
def install
- system "./configure", "--disable-dependency-tracking",
- "--prefix=#{prefix}"
- system "make"
- system "make install"
+ python do
+ system "./configure", "--disable-dependency-tracking",
+ "--prefix=#{prefix}"
+ system "make"
+ system "make install"
- # Install documentation
- (share/'bulk_extractor/doc').install Dir['doc/*.{html,txt,pdf}']
+ # Install documentation
+ (share/'bulk_extractor/doc').install Dir['doc/*.{html,txt,pdf}']
- # Install Python utilities
- (share/'bulk_extractor/python').install Dir['python/*.py']
+ (lib/python.xy/"site-packages").install Dir['python/*.py']
+ end
# Install the GUI the Homebrew way
libexec.install 'java_gui/BEViewer.jar'
bin.write_jar_script libexec/"BEViewer.jar", "BEViewer", "-Xmx1g"
end
- def caveats; <<-EOS.undent
- You may need to add the directory containing the Python bindings to your PYTHONPATH:
- #{share}/bulk_extractor/python
- EOS
+ def caveats
+ python.standard_caveats if python
end
end
diff --git a/Library/Formula/bup.rb b/Library/Formula/bup.rb
index 3fe5f39b3..1592ada16 100644
--- a/Library/Formula/bup.rb
+++ b/Library/Formula/bup.rb
@@ -1,14 +1,16 @@
require 'formula'
class Bup < Formula
- homepage 'https://github.com/apenwarr/bup'
- url 'https://github.com/apenwarr/bup/archive/bup-0.25-rc1.tar.gz'
+ homepage 'https://github.com/bup/bup'
+ url 'https://github.com/bup/bup/archive/bup-0.25-rc1.tar.gz'
sha1 'b88bd38d6f00a646faf0bd1f561595ebc0e55b30'
- head 'https://github.com/apenwarr/bup.git', :branch => 'master'
+ head 'https://github.com/bup/bup.git', :branch => 'master'
option "run-tests", "Run unit tests after compilation"
+ depends_on :python
+
# patch to make the `--prefix` parameter work
# found at https://github.com/apenwarr/bup/pull/5
def patches
@@ -16,9 +18,11 @@ class Bup < Formula
end
def install
- ENV['PATH'] = '/usr/bin:' + ENV['PATH'] # make sure we Sytem Python
- system "./configure", "--prefix=#{prefix}"
- system "make"
+ python do
+ ohai ENV['PATH']
+ system "./configure", "--prefix=#{prefix}"
+ system "make"
+ end
system "make test" if build.include? "run-tests"
system "make install"
end
diff --git a/Library/Formula/cantera.rb b/Library/Formula/cantera.rb
index 97694e686..6ff375d77 100644
--- a/Library/Formula/cantera.rb
+++ b/Library/Formula/cantera.rb
@@ -7,6 +7,7 @@ class Cantera < Formula
head 'http://cantera.googlecode.com/svn/cantera18/trunk/'
depends_on 'numpy' => :python
+ depends_on :python
depends_on 'graphviz'
# fixes the Makefiles in Cantera/cxx/demos/ that have broken install commands
diff --git a/Library/Formula/cmu-sphinxbase.rb b/Library/Formula/cmu-sphinxbase.rb
index fc944b4df..bdc5a55ae 100644
--- a/Library/Formula/cmu-sphinxbase.rb
+++ b/Library/Formula/cmu-sphinxbase.rb
@@ -21,6 +21,7 @@ class CmuSphinxbase < Formula
sha1 'c0c4d52e143d07cd593bd6bcaeb92b9a8a5a8c8e'
depends_on 'pkg-config' => :build
+ depends_on :python
depends_on HomebrewedPython
def install
diff --git a/Library/Formula/collectd.rb b/Library/Formula/collectd.rb
index fc621ce6a..dda4f847d 100644
--- a/Library/Formula/collectd.rb
+++ b/Library/Formula/collectd.rb
@@ -9,6 +9,7 @@ class Collectd < Formula
option "java", "Enable Java 1.6 support"
depends_on 'pkg-config' => :build
+ depends_on :python
fails_with :clang do
build 318
@@ -26,7 +27,7 @@ class Collectd < Formula
--disable-dependency-tracking
--prefix=#{prefix}
--localstatedir=#{var}
- --with-python=/usr/bin]
+ --with-python=#{python}]
args << "--disable-embedded-perl" if MacOS.version == :leopard
args << "--disable-java" unless build.include? "java"
diff --git a/Library/Formula/cvs2svn.rb b/Library/Formula/cvs2svn.rb
index 1faf7dcda..6ac480266 100644
--- a/Library/Formula/cvs2svn.rb
+++ b/Library/Formula/cvs2svn.rb
@@ -3,7 +3,7 @@ require 'formula'
class PythonWithGdbm < Requirement
fatal true
- satisfy { quiet_system "python", "-c", "import gdbm" }
+ satisfy(:build_env => false) { quiet_system "python", "-c", "import gdbm" }
def message; <<-EOS.undent
The Python being used does not include gdbm support,
@@ -21,16 +21,20 @@ class Cvs2svn < Formula
url 'http://trac.macports.org/export/70472/distfiles/cvs2svn/cvs2svn-2.3.0.tar.gz'
sha1 '545237805ddb241054ba40b105b9c29b705539b8'
+ depends_on :python
depends_on PythonWithGdbm
def install
- system "python", "setup.py", "install", "--prefix=#{prefix}"
- system "make man"
- man1.install gzip('cvs2svn.1', 'cvs2git.1', 'cvs2bzr.1')
- prefix.install %w[ BUGS COMMITTERS HACKING
- cvs2bzr-example.options cvs2git-example.options cvs2hg-example.options
- cvs2svn-example.options contrib ]
-
+ python do
+ system python, "setup.py", "install", "--prefix=#{prefix}"
+ system "make man"
+ man1.install gzip('cvs2svn.1', 'cvs2git.1', 'cvs2bzr.1')
+ prefix.install %w[ BUGS COMMITTERS HACKING
+ cvs2bzr-example.options
+ cvs2git-example.options
+ cvs2hg-example.options
+ cvs2svn-example.options contrib ]
+ end
doc.install Dir['{doc,www}/*']
end
diff --git a/Library/Formula/denyhosts.rb b/Library/Formula/denyhosts.rb
index 6f3ed8f06..2d950f6c5 100644
--- a/Library/Formula/denyhosts.rb
+++ b/Library/Formula/denyhosts.rb
@@ -5,6 +5,8 @@ class Denyhosts < Formula
url 'http://downloads.sourceforge.net/project/denyhosts/denyhosts/2.6/DenyHosts-2.6.tar.gz'
sha1 '02143843cb7c37c986c222b7acc11f7b75eb7373'
+ depends_on :python
+
# Copies of daemon-control-dist & denyhosts.cfg-dist edited for OS X.
def patches; DATA; end
@@ -30,11 +32,12 @@ class Denyhosts < Formula
end
# Install mostly into libexec (a la Duplicity)
- system "python", "setup.py", "install",
- "--prefix=#{prefix}",
- "--install-lib=#{libexec}",
- "--install-scripts=#{libexec}",
- "--install-data=#{libexec}"
+ python do
+ system python, "setup.py", "install",
+ "--prefix=#{prefix}",
+ "--install-scripts=#{bin}",
+ "--install-data=#{libexec}"
+ end
libexec.install 'daemon-control'
(libexec+'daemon-control').chmod 0755
diff --git a/Library/Formula/diffuse.rb b/Library/Formula/diffuse.rb
index 0ae1d474b..bcc889eb4 100644
--- a/Library/Formula/diffuse.rb
+++ b/Library/Formula/diffuse.rb
@@ -5,13 +5,16 @@ class Diffuse < Formula
url 'http://downloads.sourceforge.net/project/diffuse/diffuse/0.4.7/diffuse-0.4.7.tar.bz2'
sha1 '9e3b906b579495027b76dc723b5df28e400d3f26'
+ depends_on :python
depends_on 'pygtk'
def install
- system "python", "./install.py",
+ python do
+ system python, "./install.py",
"--sysconfdir=#{etc}",
"--examplesdir=#{share}",
"--prefix=#{prefix}"
+ end
end
def test
diff --git a/Library/Formula/disco.rb b/Library/Formula/disco.rb
index d45bebbd3..1d077194a 100644
--- a/Library/Formula/disco.rb
+++ b/Library/Formula/disco.rb
@@ -7,6 +7,7 @@ class Disco < Formula
# Periods in the install path cause disco-worker to complain so change to underscores.
version '0_4_5'
+ depends_on :python
depends_on 'erlang'
depends_on 'simplejson' => :python if MacOS.version == :leopard
depends_on 'libcmph'
@@ -23,44 +24,31 @@ class Disco < Formula
s.change_make_var! "localstatedir", var
end
- # Support for setup.py, which is called from within the Makefile
- temp_site_packages = lib/which_python/'site-packages'
- mkdir_p temp_site_packages
- ENV['PYTHONPATH'] = temp_site_packages
- py_install_opts = "--verbose --force --install-scripts=#{bin} " +
- "--install-lib=#{temp_site_packages} --install-data=#{share} --install-headers=#{include}"
-
- # Disco's "rebar" build tool refuses to build unless it's in a git repo, so
- # make a dummy one
- system "git init && git add master/rebar && git commit -a -m 'dummy commit'"
-
- system "make"
- system "make install PY_INSTALL_OPTS='#{py_install_opts}'"
- prefix.install %w[contrib doc examples]
-
- # Fix the config file to point at the linked files, not in to cellar
- # This isn't ideal - if there's a settings.py file left over from a previous disco
- # installation, it'll issue a Warning
- inreplace "#{etc}/disco/settings.py" do |s|
- s.gsub!("Cellar/disco/"+version+"/", "")
+ python do
+ # Disco's "rebar" build tool refuses to build unless it's in a git repo, so
+ # make a dummy one
+ system "git init && git add master/rebar && git commit -a -m 'dummy commit'"
+
+ system "make"
+ system "make install"
+ prefix.install %w[contrib doc examples]
+
+ # Fix the config file to point at the linked files, not in to cellar
+ # This isn't ideal - if there's a settings.py file left over from a previous disco
+ # installation, it'll issue a Warning
+ inreplace "#{etc}/disco/settings.py" do |s|
+ s.gsub!("Cellar/disco/"+version+"/", "")
+ end
end
-
end
-
- def which_python
- # Update this once we have something like [this](https://github.com/mxcl/homebrew/issues/11204)
- "python" + `python -c 'import sys;print(sys.version[:3])'`.strip
- end
-
- def caveats; <<-EOS.undent
- Disco is a Python script. You must install homebrew's python or add the path
- #{HOMEBREW_PREFIX}/lib/python2.7/site-packages
- to your PYTHONPATH before running disco or ddfs.
-
- Please copy #{etc}/disco/settings.py to ~/.disco and edit it if necessary.
- The DDFS_*_REPLICA settings have been set to 1 assuming a single-machine install.
- Please see http://discoproject.org/doc/disco/start/install.html for further instructions.
+ def caveats
+ s = ''
+ s += python.standard_caveats if python
+ s += <<-EOS.undent
+ Please copy #{etc}/disco/settings.py to ~/.disco and edit it if necessary.
+ The DDFS_*_REPLICA settings have been set to 1 assuming a single-machine install.
+ Please see http://discoproject.org/doc/disco/start/install.html for further instructions.
EOS
end
end
diff --git a/Library/Formula/discodex.rb b/Library/Formula/discodex.rb
index bcbe498a1..44f7a8487 100644
--- a/Library/Formula/discodex.rb
+++ b/Library/Formula/discodex.rb
@@ -7,10 +7,13 @@ class Discodex < Formula
sha1 '03a9ce7a8d70c371f4dd3ce2a1e2c72cda1fc1f4'
depends_on 'disco'
+ depends_on :python
def install
- # The make target only installs python libs; must manually install the rest
- system "make", "install", "prefix=#{prefix}"
- prefix.install(%w[bin doc])
+ python do
+ # The make target only installs python libs; must manually install the rest
+ system "make", "install", "prefix=#{prefix}"
+ prefix.install(%w[bin doc])
+ end
end
end
diff --git a/Library/Formula/distcc.rb b/Library/Formula/distcc.rb
index cdc99dd10..061828c7b 100644
--- a/Library/Formula/distcc.rb
+++ b/Library/Formula/distcc.rb
@@ -2,7 +2,7 @@ require 'formula'
class PythonWithoutPPC < Requirement
fatal true
- satisfy { not archs_for_command("python").ppc? }
+ satisfy(:build_env => false) { not archs_for_command("python").ppc? }
def message
"This software will not compile if your default Python is built with PPC support."
@@ -14,18 +14,18 @@ class Distcc < Formula
url 'http://distcc.googlecode.com/files/distcc-3.2rc1.tar.gz'
sha1 '7cd46fe0926a3a859a516274e6ae59fa8ba0262d'
+ depends_on :python
depends_on PythonWithoutPPC
def install
- # Prevent distcc from finding the System Python 2.6
- ENV['PYTHON'] = which('python')
- # Make sure python stuff is put into the Cellar.
- # --root triggers a bug and installs into HOMEBREW_PREFIX/lib/python2.7/site-packages instead of the Cellar.
- inreplace 'Makefile.in', '--root="$$DESTDIR"', ""
-
- system "./configure", "--prefix=#{prefix}"
- system "make install"
+ python do
+ # Make sure python stuff is put into the Cellar.
+ # --root triggers a bug and installs into HOMEBREW_PREFIX/lib/python2.7/site-packages instead of the Cellar.
+ inreplace 'Makefile.in', '--root="$$DESTDIR"', ""
+ system "./configure", "--prefix=#{prefix}"
+ system "make install"
+ end
plist_path.write startup_plist
plist_path.chmod 0644
end
diff --git a/Library/Formula/duplicity.rb b/Library/Formula/duplicity.rb
index 5d9592f41..a5abe01fa 100644
--- a/Library/Formula/duplicity.rb
+++ b/Library/Formula/duplicity.rb
@@ -5,24 +5,17 @@ class Duplicity < Formula
url 'http://code.launchpad.net/duplicity/0.6-series/0.6.21/+download/duplicity-0.6.21.tar.gz'
sha1 '8594666f5312a7b367ab80b979d70a5c45f1145b'
+ depends_on :python
depends_on 'librsync'
depends_on 'gnupg'
option :universal
def install
- ENV.universal_binary if build.universal?
- # Install mostly into libexec
- system "python", "setup.py", "install",
- "--prefix=#{prefix}",
- "--install-lib=#{libexec}",
- "--install-scripts=#{bin}"
-
- # Shift files around to avoid needing a PYTHONPATH
- mv bin+'duplicity', bin+'duplicity.py'
- mv Dir[bin+'*'], libexec
-
- bin.install_symlink "#{libexec}/duplicity.py" => "duplicity"
- bin.install_symlink "#{libexec}/rdiffdir"
+ python do
+ ENV.universal_binary if build.universal?
+ # Install mostly into libexec
+ system python, "setup.py", "install", "--prefix=#{prefix}"
+ end
end
end
diff --git a/Library/Formula/enchant.rb b/Library/Formula/enchant.rb
index 1e85861b3..daeed7c41 100644
--- a/Library/Formula/enchant.rb
+++ b/Library/Formula/enchant.rb
@@ -1,11 +1,18 @@
require 'formula'
+class PyEnchant < Formula
+ homepage 'http://pythonhosted.org/pyenchant/'
+ url 'https://pypi.python.org/packages/source/p/pyenchant/pyenchant-1.6.5.tar.gz'
+ sha1 '6f01b8657b64e970a11945c2a9b4d6d8023997bc'
+end
+
class Enchant < Formula
homepage 'http://www.abisource.com/projects/enchant/'
url 'http://www.abisource.com/downloads/enchant/1.6.0/enchant-1.6.0.tar.gz'
sha1 '321f9cf0abfa1937401676ce60976d8779c39536'
depends_on 'pkg-config' => :build
+ depends_on :python => :recommended
depends_on 'glib'
depends_on 'aspell'
@@ -15,5 +22,23 @@ class Enchant < Formula
"--disable-ispell",
"--disable-myspell"
system "make install"
+
+ if build.with? 'python'
+ # Now we handle the python bindings from the subformulae PyEnchant
+ PyEnchant.new.brew do
+ python do
+ ENV['PYENCHANT_LIBRARY_PATH'] = lib/'libenchant.dylib'
+ system python, 'setup.py', 'install', "--prefix=#{prefix}",
+ '--single-version-externally-managed',
+ '--record=installed.txt'
+ end
+ end
+ end
+ end
+
+ def test
+ python do
+ system python, "-c", "import enchant; d=enchant.Dict('en_US'); print(d.suggest('homebrew'))"
+ end
end
end
diff --git a/Library/Formula/fail2ban.rb b/Library/Formula/fail2ban.rb
index b39cf7985..1e1aa4a8c 100644
--- a/Library/Formula/fail2ban.rb
+++ b/Library/Formula/fail2ban.rb
@@ -5,7 +5,10 @@ class Fail2ban < Formula
url 'http://cloud.github.com/downloads/fail2ban/fail2ban/fail2ban_0.8.7.1.orig.tar.gz'
sha1 'ec1a7ea1360056d5095bb9de733c1e388bd22373'
+ depends_on :python
+
def install
+ rm 'setup.cfg'
inreplace 'setup.py' do |s|
s.gsub! /\/etc/, etc
s.gsub! /\/var/, var
@@ -21,13 +24,11 @@ class Fail2ban < Formula
inreplace 'fail2ban-regex', '/etc', etc
inreplace 'fail2ban-server', '/var', var
- inreplace 'config/fail2ban.conf', '/var/run', (var + 'run')
+ inreplace 'config/fail2ban.conf', '/var/run', (var/'run')
- system "python", "setup.py", "install",
- "--prefix=#{prefix}",
- "--install-lib=#{libexec}",
- "--install-data=#{libexec}",
- "--install-scripts=#{bin}"
+ python do
+ system python, "setup.py", "install", "--prefix=#{prefix}", "--install-lib=#{libexec}"
+ end
end
plist_options :startup => true
@@ -52,7 +53,9 @@ class Fail2ban < Formula
EOS
end
- def caveats; <<-EOS.undent
+ def caveats
+ <<-EOS.undent
+ #{python.standard_caveats if python}
Before using Fail2Ban for the first time you should edit jail
configuration and enable the jails that you want to use, for instance
ssh-ipfw. Also make sure that they point to the correct configuration
diff --git a/Library/Formula/fontforge.rb b/Library/Formula/fontforge.rb
index 7a9f30e12..a7eba681d 100644
--- a/Library/Formula/fontforge.rb
+++ b/Library/Formula/fontforge.rb
@@ -7,23 +7,20 @@ class Fontforge < Formula
head 'https://github.com/fontforge/fontforge.git'
- env :std
-
- option 'without-python', 'Build without Python'
option 'with-gif', 'Build with GIF support'
- option 'with-x', 'Build with X'
depends_on 'gettext'
- depends_on :xcode # Because: #include </Developer/Headers/FlatCarbon/Files.h>
+ depends_on :python => :recommended
depends_on :libpng => :recommended
depends_on 'jpeg' => :recommended
depends_on 'libtiff' => :recommended
- depends_on :x11 if build.with? 'x'
+ depends_on :x11 => :recommended
depends_on 'giflib' if build.with? 'gif'
depends_on 'cairo' => :optional
depends_on 'pango' => :optional
depends_on 'libspiro' => :optional
+ depends_on 'fontconfig'
fails_with :llvm do
build 2336
@@ -35,29 +32,30 @@ class Fontforge < Formula
"--enable-double",
"--without-freetype-bytecode"]
- if build.without? "python"
- args << "--without-python"
- else
- python_prefix = `python-config --prefix`.strip
- python_version = `python-config --libs`.match('-lpython(\d+\.\d+)').captures.at(0)
- args << "--with-python-headers=#{python_prefix}/include/python#{python_version}"
- args << "--with-python-lib=-lpython#{python_version}"
+ args << "--without-cairo" unless build.with? "cairo"
+ args << "--without-pango" unless build.with? "pango"
+ args << "--without-x" unless build.with? 'x'
+
+ # To avoid "dlopen(/opt/local/lib/libpng.2.dylib, 1): image not found"
+ args << "--with-static-imagelibs"
+
+ if build.with? 'python'
args << "--enable-pyextension"
+ # Fix linking to correct Python library
+ ENV.prepend "LDFLAGS", "-L#{python.libdir}"
+ else
+ args << "--without-python"
end
- # Fix linking to correct Python library
- ENV.prepend "LDFLAGS", "-L#{python_prefix}/lib" unless build.without? "python"
# Fix linker error; see: http://trac.macports.org/ticket/25012
ENV.append "LDFLAGS", "-lintl"
+
# Reset ARCHFLAGS to match how we build
ENV["ARCHFLAGS"] = MacOS.prefer_64_bit? ? "-arch x86_64" : "-arch i386"
# Set up framework paths so FlatCarbon replacement paths work (see below)
- ENV.append "CFLAGS", "-F/System/Library/Frameworks/CoreServices.framework/Frameworks"
- ENV.append "CFLAGS", "-F/System/Library/Frameworks/Carbon.framework/Frameworks"
-
- args << "--without-cairo" unless build.with? "cairo"
- args << "--without-pango" unless build.with? "pango"
+ ENV.append "CFLAGS", "-F#{MacOS.sdk_path}/System/Library/Frameworks/CoreServices.framework/Frameworks"
+ ENV.append "CFLAGS", "-F#{MacOS.sdk_path}/System/Library/Frameworks/Carbon.framework/Frameworks"
system "./configure", *args
@@ -70,7 +68,7 @@ class Fontforge < Formula
# Fix install location of Python extension; see:
# http://sourceforge.net/mailarchive/message.php?msg_id=26827938
inreplace "Makefile" do |s|
- s.gsub! "python setup.py install --prefix=$(prefix) --root=$(DESTDIR)", "python setup.py install --prefix=$(prefix)"
+ s.gsub! "python setup.py install --prefix=$(prefix) --root=$(DESTDIR)", "#{python} setup.py install --prefix=$(prefix)"
end
# Replace FlatCarbon headers with the real paths
@@ -86,12 +84,9 @@ class Fontforge < Formula
system "make install"
end
- def which_python
- "python" + `python -c 'import sys;print(sys.version[:3])'`.strip
- end
-
def test
system "#{bin}/fontforge", "-version"
+ system python, "-c", "import fontforge"
end
def caveats
@@ -104,16 +99,9 @@ class Fontforge < Formula
ln -s #{opt_prefix}/FontForge.app /Applications
EOS
- python_caveats = <<-EOS.undent
-
- To use the Python extension with non-homebrew Python, you need to amend your
- PYTHONPATH like so:
- export PYTHONPATH=#{HOMEBREW_PREFIX}/lib/#{which_python}/site-packages:$PYTHONPATH
- EOS
-
s = ""
s += x_caveats if build.with? "x"
- s += python_caveats unless build.without? "python"
+ s += python.standard_caveats if python
return s
end
diff --git a/Library/Formula/fsh.rb b/Library/Formula/fsh.rb
index b16777490..f8fb5ad92 100644
--- a/Library/Formula/fsh.rb
+++ b/Library/Formula/fsh.rb
@@ -5,6 +5,8 @@ class Fsh < Formula
url 'http://www.lysator.liu.se/fsh/fsh-1.2.tar.gz'
sha1 'c2f1e923076d368fbb5504dcd1d33c74024b0d1b'
+ depends_on :python
+
def install
# FCNTL was deprecated and needs to be changed to fcntl
inreplace 'fshcompat.py', 'FCNTL', 'fcntl'
@@ -14,10 +16,5 @@ class Fsh < Formula
"--prefix=#{prefix}",
"--infodir=#{info}"
system "make install"
-
- cd bin do
- inreplace ["fsh", "fshd", "in.fshd"],
- "#! /usr/local/bin/python", "#!/usr/bin/env python"
- end
end
end
diff --git a/Library/Formula/gdal.rb b/Library/Formula/gdal.rb
index 39601e047..dd73abf8e 100644
--- a/Library/Formula/gdal.rb
+++ b/Library/Formula/gdal.rb
@@ -10,7 +10,6 @@ class Gdal < Formula
option 'complete', 'Use additional Homebrew libraries to provide more drivers.'
option 'with-postgres', 'Specify PostgreSQL as a dependency.'
option 'with-mysql', 'Specify MySQL as a dependency.'
- option 'without-python', 'Build without Python support (disables a lot of tools).'
option 'enable-opencl', 'Build with OpenCL acceleration.'
option 'enable-armadillo', 'Build with Armadillo accelerated TPS transforms.'
option 'enable-unsupported', "Allow configure to drag in any library it can find. Invoke this at your own risk."
@@ -18,6 +17,7 @@ class Gdal < Formula
# For creating up to date man pages.
depends_on 'doxygen' => :build if build.head?
+ depends_on :python => :recommended
depends_on :libpng
depends_on 'jpeg'
depends_on 'giflib'
@@ -200,18 +200,7 @@ class Gdal < Formula
system "make"
system "make install"
- unless build.include? 'without-python'
- # If setuptools happens to be installed, setup.py will cowardly refuse to
- # install to anywhere that is not on the PYTHONPATH.
- #
- # Really setuptools, we're all consenting adults here...
- python_lib = lib + which_python + 'site-packages'
- ENV.append 'PYTHONPATH', python_lib
-
- # setuptools is also apparently incapable of making the directory it's
- # self
- python_lib.mkpath
-
+ python do
# `python-config` may try to talk us into building bindings for more
# architectures than we really should.
if MacOS.prefer_64_bit?
@@ -221,7 +210,7 @@ class Gdal < Formula
end
cd 'swig/python' do
- system "python", "setup.py", "install_lib", "--install-dir=#{python_lib}"
+ system python, "setup.py", "install", "--prefix=#{prefix}", "--record=installed.txt", "--single-version-externally-managed"
bin.install Dir['scripts/*']
end
end
@@ -232,22 +221,13 @@ class Gdal < Formula
Dir[bin + '*.dox'].each { |p| rm p }
end
- def which_python
- "python" + `python -c 'import sys;print(sys.version[:3])'`.strip
- end
-
- unless build.include? 'without-python'
- def caveats
- <<-EOS
-This version of GDAL was built with Python support. In addition to providing
-modules that makes GDAL functions available to Python scripts, the Python
-binding provides ~18 additional command line tools.
-
-Unless you are using Homebrew's Python, both the bindings and the
-additional tools will be unusable unless the following directory is added to
-the PYTHONPATH:
-
- #{HOMEBREW_PREFIX}/lib/#{which_python}/site-packages
+ def caveats
+ if python
+ python.standard_caveats +
+ <<-EOS.undent
+ This version of GDAL was built with Python support. In addition to providing
+ modules that makes GDAL functions available to Python scripts, the Python
+ binding provides ~18 additional command line tools.
EOS
end
end
diff --git a/Library/Formula/git-cola.rb b/Library/Formula/git-cola.rb
index e36c65dd0..e4b979b99 100644
--- a/Library/Formula/git-cola.rb
+++ b/Library/Formula/git-cola.rb
@@ -9,6 +9,7 @@ class GitCola < Formula
option 'with-docs', "Build man pages using asciidoc and xmlto"
+ depends_on :python
depends_on 'pyqt'
if build.include? 'with-docs'
@@ -18,18 +19,17 @@ class GitCola < Formula
end
def install
- ENV.prepend 'PYTHONPATH', "#{HOMEBREW_PREFIX}/lib/#{which_python}/site-packages", ':'
- system "make", "prefix=#{prefix}", "install"
-
- if build.include? 'with-docs'
- system "make", "-C", "share/doc/git-cola",
- "-f", "Makefile.asciidoc",
- "prefix=#{prefix}",
- "install", "install-html"
+ python do
+ # The python do block creates the PYTHONPATH and temp. site-packages
+ system "make", "prefix=#{prefix}", "install"
+
+ if build.include? 'with-docs'
+ system "make", "-C", "share/doc/git-cola",
+ "-f", "Makefile.asciidoc",
+ "prefix=#{prefix}",
+ "install", "install-html"
+ end
end
end
- def which_python
- "python" + `python -c 'import sys;print(sys.version[:3])'`.strip
- end
end
diff --git a/Library/Formula/git.rb b/Library/Formula/git.rb
index 73ca95113..18e909d04 100644
--- a/Library/Formula/git.rb
+++ b/Library/Formula/git.rb
@@ -20,6 +20,7 @@ class Git < Formula
option 'with-blk-sha1', 'Compile with the block-optimized SHA1 implementation'
option 'without-completions', 'Disable bash/zsh completions from "contrib" directory'
+ depends_on :python
depends_on 'pcre' => :optional
depends_on 'gettext' => :optional
@@ -29,8 +30,9 @@ class Git < Formula
ENV['NO_DARWIN_PORTS'] = '1'
ENV['V'] = '1' # build verbosely
ENV['NO_R_TO_GCC_LINKER'] = '1' # pass arguments to LD correctly
+
ENV['PERL_PATH'] = which 'perl' # workaround for users of perlbrew
- ENV['PYTHON_PATH'] = which 'python' # python can be brewed or unbrewed
+ ENV['PYTHON_PATH'] = python.binary if python
# Clean XCode 4.x installs don't include Perl MakeMaker
ENV['NO_PERL_MAKEMAKER'] = '1' if MacOS.version >= :lion
diff --git a/Library/Formula/glade.rb b/Library/Formula/glade.rb
index 2ae80c3a8..a902676c2 100644
--- a/Library/Formula/glade.rb
+++ b/Library/Formula/glade.rb
@@ -5,19 +5,17 @@ class Glade < Formula
url 'http://ftp.gnome.org/pub/GNOME/sources/glade3/3.8/glade3-3.8.3.tar.xz'
sha256 '84bb2d7f782f203e4aab923e47db8d22529229b13e59570945261611c63941d6'
+ depends_on :python
depends_on 'pkg-config' => :build
depends_on 'xz' => :build
depends_on 'intltool' => :build
depends_on 'gettext'
depends_on 'libglade'
+ depends_on 'libxml2' # make this dep explicit
depends_on 'hicolor-icon-theme'
depends_on :x11
def install
- pydir = 'python' + `python -c 'import sys;print(sys.version[:3])'`.strip
- libxml2 = Formula.factory('libxml2')
- ENV.prepend 'PYTHONPATH', libxml2.lib/pydir/'site-packages', ':'
-
# Find our docbook catalog
ENV['XML_CATALOG_FILES'] = "#{etc}/xml/catalog"
diff --git a/Library/Formula/gnome-doc-utils.rb b/Library/Formula/gnome-doc-utils.rb
index ffb320948..a9452b124 100644
--- a/Library/Formula/gnome-doc-utils.rb
+++ b/Library/Formula/gnome-doc-utils.rb
@@ -8,6 +8,7 @@ class GnomeDocUtils < Formula
depends_on 'pkg-config' => :build
depends_on 'xz' => :build
depends_on 'intltool' => :build
+ depends_on :python
depends_on 'docbook'
depends_on 'gettext'
depends_on 'libxml2' => 'with-python'
@@ -18,20 +19,17 @@ class GnomeDocUtils < Formula
end
def install
- # TODO this should possibly be moved up into build.rb
- pydir = 'python' + `python -c 'import sys;print(sys.version[:3])'`.strip
- libxml2 = Formula.factory('libxml2')
- ENV.prepend 'PYTHONPATH', libxml2.lib/pydir/'site-packages', ':'
+ python do
+ # Find our docbook catalog
+ ENV['XML_CATALOG_FILES'] = "#{etc}/xml/catalog"
- # Find our docbook catalog
- ENV['XML_CATALOG_FILES'] = "#{etc}/xml/catalog"
+ system "./configure", "--prefix=#{prefix}",
+ "--disable-scrollkeeper",
+ "--enable-build-utils=yes"
- system "./configure", "--prefix=#{prefix}",
- "--disable-scrollkeeper",
- "--enable-build-utils=yes"
-
- # Compilation doesn't work right if we jump straight to make install
- system "make"
- system "make install"
+ # Compilation doesn't work right if we jump straight to make install
+ system "make"
+ system "make install"
+ end
end
end
diff --git a/Library/Formula/google-app-engine.rb b/Library/Formula/google-app-engine.rb
index 6ffb10d1b..fe0e46ecd 100644
--- a/Library/Formula/google-app-engine.rb
+++ b/Library/Formula/google-app-engine.rb
@@ -5,6 +5,8 @@ class GoogleAppEngine < Formula
url 'http://googleappengine.googlecode.com/files/google_appengine_1.8.0.zip'
sha1 '71b5f3ee06dce0a7d6af32d65ae27272eac038cb'
+ depends_on :python
+
def install
cd '..'
share.install 'google_appengine' => name
diff --git a/Library/Formula/graphviz.rb b/Library/Formula/graphviz.rb
index b086a66ea..25644a54c 100644
--- a/Library/Formula/graphviz.rb
+++ b/Library/Formula/graphviz.rb
@@ -10,6 +10,7 @@ class Graphviz < Formula
sha1 'a1e6ba5d9298aa87b78170e2c74f21d7e579364e'
end
+ # To find Ruby and Co.
env :std
option :universal
@@ -25,6 +26,7 @@ class Graphviz < Formula
depends_on 'pkg-config' => :build
depends_on 'pango' if build.include? 'with-pangocairo'
depends_on 'swig' if build.include? 'with-bindings'
+ depends_on :python if build.include? 'with-bindings' # this will set up python
depends_on 'gts' if build.include? 'with-gts'
depends_on :freetype if build.include? 'with-freetype' or MacOS::X11.installed?
depends_on :x11 if build.include? 'with-x' or MacOS::X11.installed?
diff --git a/Library/Formula/grass.rb b/Library/Formula/grass.rb
index 68e0d85d6..86f0d76d9 100644
--- a/Library/Formula/grass.rb
+++ b/Library/Formula/grass.rb
@@ -7,35 +7,33 @@ class Grass < Formula
head 'https://svn.osgeo.org/grass/grass/trunk'
+ option "without-gui", "Build without WxPython interface. Command line tools still available."
+
depends_on "pkg-config" => :build
+ depends_on :python
depends_on "gettext"
depends_on "readline"
depends_on "gdal"
depends_on "libtiff"
depends_on "unixodbc"
depends_on "fftw"
+ depends_on 'wxmac' => :recommended # prefer over OS X's version because of 64bit
+ depends_on 'postgres' => :optional
+ depends_on :mysql => :optional
depends_on "cairo" if MacOS.version == :leopard
- depends_on :x11
+ depends_on :x11 # needs to find at least X11/include/GL/gl.h
- # Patches ensure 32 bit system python is used for wxWidgets and that files
- # are not installed outside of the prefix.
+ # Patches that files are not installed outside of the prefix.
def patches; DATA; end
fails_with :clang do
cause "Multiple build failures while compiling GRASS tools."
end
- option "with-postgres", "specify PostgreSQL as a dependency."
- option "with-mysql", "Specify MySQL as a dependency."
- option "without-gui", "Build without WxPython interface. Command line tools still available."
-
def headless?
# The GRASS GUI is based on WxPython. Unfortunately, Lion does not include
# this module so we have to drop it.
- #
- # This restriction can be lifted once WxMac hits a stable release that is
- # 64-bit capable.
- build.include? 'without-gui' or MacOS.version >= :lion
+ build.include? 'without-gui' or MacOS.version == :lion
end
def install
@@ -44,37 +42,37 @@ class Grass < Formula
args = [
"--disable-debug", "--disable-dependency-tracking",
- "--with-libs=#{MacOS::X11.lib} #{HOMEBREW_PREFIX}/lib",
- "--with-includes=#{HOMEBREW_PREFIX}/include",
"--enable-largefile",
"--enable-shared",
"--with-cxx",
- "--with-opengl=aqua",
- "--with-x",
"--without-motif",
- "--with-python=/usr/bin/python-config",
+ "--with-python",
"--with-blas",
"--with-lapack",
"--with-sqlite",
"--with-odbc",
- "--with-geos=#{HOMEBREW_PREFIX}/bin/geos-config",
- "--with-png-includes=#{MacOS::X11.include}",
+ "--with-geos=#{Formula.factory('geos').opt_prefix}/bin/geos-config",
"--with-png",
- "--with-readline-includes=#{readline.include}",
- "--with-readline-libs=#{readline.lib}",
+ "--with-readline-includes=#{readline.opt_prefix}/include",
+ "--with-readline-libs=#{readline.opt_prefix}/lib",
"--with-readline",
- "--with-nls-includes=#{gettext.include}",
- "--with-nls-libs=#{gettext.lib}",
+ "--with-nls-includes=#{gettext.opt_prefix}/include",
+ "--with-nls-libs=#{gettext.opt_prefix}/lib",
"--with-nls",
- "--with-freetype-includes=#{MacOS::X11.include} #{MacOS::X11.include}/freetype2",
"--with-freetype",
"--without-tcltk" # Disabled due to compatibility issues with OS X Tcl/Tk
]
- if headless?
+ unless MacOS::CLT.installed?
+ # On Xcode-only systems (without the CLT), we have to help:
+ args << "--with-macosx-sdk=#{MacOS.sdk_path}"
+ args << "--with-opengl-includes=#{MacOS.sdk_path}/System/Library/Frameworks/OpenGL.framework/Headers"
+ end
+
+ if headless? or build.without? 'wxmac'
args << "--without-wxwidgets"
else
- args << "--with-wxwidgets=/usr/bin/wx-config"
+ args << "--with-wxwidgets=#{Formula.factory('wxmac').opt_prefix}/bin/wx-config"
end
if MacOS.prefer_64_bit?
@@ -96,11 +94,11 @@ class Grass < Formula
args << "--with-cairo"
# Database support
- if build.include? "with-postgres"
+ if build.with? "postgres"
args << "--with-postgres"
end
- if build.include? "with-mysql"
+ if build.with? "mysql"
mysql = Formula.factory('mysql')
args << "--with-mysql-includes=#{mysql.include + 'mysql'}"
args << "--with-mysql-libs=#{mysql.lib + 'mysql'}"
@@ -121,21 +119,22 @@ class Grass < Formula
The command line tools remain fully functional.
EOS
- else
+ elsif MacOS.version < :lion
+ # On Lion or above, we are very happy with our brewed wxwidgets.
<<-EOS.undent
GRASS is currently in a transition period with respect to GUI support.
The old Tcl/Tk GUI cannot be built using the version of Tcl/Tk provided
- by OS X. This has the unfortunate consquence of disabling the NVIZ
- visualization system. A keg-only Tcl/Tk brew or some deep hackery of
+ by OS X. This has the unfortunate consquence of disabling the NVIZ
+ visualization system. A keg-only Tcl/Tk brew or some deep hackery of
the GRASS source may be possible ways to get around this around this.
Tcl/Tk will eventually be depreciated in GRASS 7 and this version has
- been built to support the newer wxPython based GUI. However, there is
+ been built to support the newer wxPython based GUI. However, there is
a problem as wxWidgets does not compile as a 64 bit library on OS X
- which affects Snow Leopard users. In order to remedy this, the GRASS
+ which affects Snow Leopard users. In order to remedy this, the GRASS
startup script:
- #{prefix}/grass-6.4.0/etc/Init.sh
+ #{prefix}/grass-#{version}/etc/Init.sh
has been modified to use the OS X system Python and to start it in 32 bit mode.
EOS
@@ -144,35 +143,6 @@ class Grass < Formula
end
__END__
-Patch 1:
-Force 32-bit system Python to be used for the WxPython GUI.
-
-
-diff --git a/lib/init/init.sh b/lib/init/init.sh
-index 8c87fe1..2d1a2a3 100644
---- a/lib/init/init.sh
-+++ b/lib/init/init.sh
-@@ -27,6 +27,17 @@ trap "echo 'User break!' ; exit" 2 3 15
- # Set default GUI
- DEFAULT_GUI="wxpython"
-
-+
-+# Homebrew Additions:
-+#
-+# So, problem with wxWidgets is that the developers have not released a stable
-+# version that builds x86_64 for OS X. So, in order to use the nice GUI for
-+# GRASS, we have to ensure the system python is used and ensure it starts in 32
-+# bit mode.
-+export VERSIONER_PYTHON_PREFER_32_BIT=yes
-+export GRASS_PYTHON=/usr/bin/pythonw
-+
-+
- # the following is only meant to be an internal variable for debugging this script.
- # use 'g.gisenv set="DEBUG=[0-5]"' to turn GRASS debug mode on properly.
- if [ -z "$GRASS_DEBUG" ] ; then
-
-
-Patch 2:
Remove two lines of the Makefile that try to install stuff to
/Library/Documentation---which is outside of the prefix and usually fails due
to permissions issues.
diff --git a/Library/Formula/grc.rb b/Library/Formula/grc.rb
index 6b8a5ffa3..77ddb4748 100644
--- a/Library/Formula/grc.rb
+++ b/Library/Formula/grc.rb
@@ -5,10 +5,13 @@ class Grc < Formula
url 'http://korpus.juls.savba.sk/~garabik/software/grc/grc_1.4.tar.gz'
sha1 '79fd504d8291f13486d361611415ae60fa56712a'
+ depends_on :python
+
def install
#TODO we should deprefixify since it's python and thus possible
inreplace ['grc', 'grc.1'], '/etc', etc
inreplace ['grcat', 'grcat.1'], '/usr/local', prefix
+ inreplace ['grc', 'grcat'], '#! /usr/bin/python', '#!/usr/bin/env python'
etc.install 'grc.conf'
bin.install %w[grc grcat]
diff --git a/Library/Formula/gtk-doc.rb b/Library/Formula/gtk-doc.rb
index d5e3ccfd9..e0e5699cc 100644
--- a/Library/Formula/gtk-doc.rb
+++ b/Library/Formula/gtk-doc.rb
@@ -7,6 +7,7 @@ class GtkDoc < Formula
depends_on 'pkg-config' => :build
depends_on 'gnome-doc-utils' => :build
+ depends_on :python
depends_on 'gettext'
depends_on 'glib'
depends_on 'docbook'
@@ -14,13 +15,8 @@ class GtkDoc < Formula
depends_on 'libxml2'
def install
- # libxml2 must be installed with python support; this should be ensured
- # by the gnome-doc-utils dependency. However it is keg-only, so we have
- # to put its site-packages directory on the PYTHONPATH
- pydir = 'python' + `python -c 'import sys;print(sys.version[:3])'`.strip
- libxml2 = Formula.factory('libxml2')
- ENV.prepend 'PYTHONPATH', libxml2.lib/pydir/'site-packages', ':'
-
+ # libxml2 is keg_only but we installed the python bindings globally, so
+ # configure should find them.
system "./configure", "--disable-debug",
"--disable-dependency-tracking",
"--prefix=#{prefix}",
diff --git a/Library/Formula/io.rb b/Library/Formula/io.rb
index d1f1495d5..39a63a694 100644
--- a/Library/Formula/io.rb
+++ b/Library/Formula/io.rb
@@ -8,9 +8,9 @@ class Io < Formula
head 'https://github.com/stevedekorte/io.git'
option 'without-addons', 'Build without addons'
- option 'without-python', 'Build without python addon'
depends_on 'cmake' => :build
+ depends_on :python => :recommended
depends_on 'libevent'
depends_on 'libffi'
depends_on 'ossp-uuid'
@@ -40,18 +40,23 @@ class Io < Formula
def install
ENV.j1
- if build.include? 'without-addons'
+ if build.without? 'addons'
inreplace "CMakeLists.txt",
'add_subdirectory(addons)',
'#add_subdirectory(addons)'
end
- if build.include? 'without-python'
+ if build.without? 'python'
inreplace "addons/CMakeLists.txt",
'add_subdirectory(Python)',
'#add_subdirectory(Python)'
end
mkdir 'buildroot' do
- system "cmake", "..", *std_cmake_args
+ args = std_cmake_args
+ # For Xcode-only systems, the headers of system's python are inside of Xcode:
+ args << "-DPYTHON_INCLUDE_DIR='#{python.incdir}'" if python
+ # Cmake picks up the system's python dylib, even if we have a brewed one:
+ args << "-DPYTHON_LIBRARY='#{python.libdir}/lib#{python.xy}.dylib'" if python
+ system "cmake", "..", *args
system 'make'
output = %x[./_build/binaries/io ../libs/iovm/tests/correctness/run.io]
if $?.exitstatus != 0
diff --git a/Library/Formula/ldns.rb b/Library/Formula/ldns.rb
index 47e477524..fca000721 100644
--- a/Library/Formula/ldns.rb
+++ b/Library/Formula/ldns.rb
@@ -5,9 +5,8 @@ class Ldns < Formula
url 'http://nlnetlabs.nl/downloads/ldns/ldns-1.6.16.tar.gz'
sha1 '5b4fc6c5c3078cd061905c47178478cb1015c62a'
- option "python", "Build Python pydns bindings"
-
- depends_on 'swig' if build.include? 'python'
+ depends_on :python => :optional
+ depends_on 'swig' if build.with? 'python'
def install
# gost requires OpenSSL >= 1.0.0
@@ -15,12 +14,17 @@ class Ldns < Formula
--prefix=#{prefix}
--disable-gost
--with-drill
+ --with-ssl=#{MacOS.sdk_path}/usr
]
- args << "--with-pyldns" if build.include? 'python'
+
+ if build.with? 'python'
+ args << "--with-pyldns"
+ ENV['PYTHON_SITE_PKG'] = python.site_packages
+ end
system "./configure", *args
system "make"
system "make install"
- system "make install-pyldns" if build.include? 'python'
+ system "make", "install-pyldns"
end
end
diff --git a/Library/Formula/ledger.rb b/Library/Formula/ledger.rb
index 046141e67..7efeebda9 100644
--- a/Library/Formula/ledger.rb
+++ b/Library/Formula/ledger.rb
@@ -8,9 +8,9 @@ class Ledger < Formula
head 'https://github.com/ledger/ledger.git', :branch => 'master'
option 'debug', 'Build with debugging symbols enabled'
- option 'python', 'Enable Python support'
depends_on 'boost'
+ depends_on :python => :optional
if build.head?
depends_on 'cmake' => :build
depends_on 'ninja' => :build
@@ -24,14 +24,23 @@ class Ledger < Formula
end
def install
+ opoo "Homebrew: Sorry, python bindings for --HEAD seem not to install. Help us fixing this!" if build.with? 'python'
+
# find Homebrew's libpcre
ENV.append 'LDFLAGS', "-L#{HOMEBREW_PREFIX}/lib"
if build.head?
args = [((build.include? 'debug') ? 'debug' : 'opt'), "make", "-N", "-j#{ENV.make_jobs}", "--output=build"]
- args << '--python' if build.include? 'python'
- system "./acprep", *args
- system "cmake", "-D", "CMAKE_INSTALL_PREFIX=#{prefix}", "-P", "build/cmake_install.cmake"
+ if build.with? 'python'
+ args << '--python'
+ # acprep picks up system python because CMake is used
+ inreplace 'acprep', "self.configure_args = []",
+ "self.configure_args = ['-DPYTHON_INCLUDE_DIR=#{python.incdir}', '-DPYTHON_LIBRARY=#{python.libdir}/lib#{python.xy}.dylib']"
+ end
+ # Support homebrew not at /usr/local. Also support Xcode-only setups:
+ inreplace 'acprep', 'search_prefixes = [', "search_prefixes = ['#{HOMEBREW_PREFIX}','#{MacOS.sdk_path}/usr',"
+ system "./acprep", "--prefix=#{prefix}", *args
+ system "cmake", "-P", "build/cmake_install.cmake", "-DUSE_PYTHON=ON"
else
args = []
if build.with? 'libofx'
diff --git a/Library/Formula/libcaca.rb b/Library/Formula/libcaca.rb
index 1ba029fb1..99bc09ff7 100644
--- a/Library/Formula/libcaca.rb
+++ b/Library/Formula/libcaca.rb
@@ -9,6 +9,7 @@ class Libcaca < Formula
option 'with-imlib2', 'Build with Imlib2 support'
depends_on :x11 if MacOS::X11.installed? or build.include? "with-imlib2"
+ depends_on :python => :recommended
if build.include? "with-imlib2"
depends_on 'pkg-config' => :build
@@ -28,12 +29,13 @@ class Libcaca < Formula
# Don't build csharp bindings
# Don't build ruby bindings; fails for adamv w/ Homebrew Ruby 1.9.2
- # Don't build python bindings:
+
+ # Fix --destdir issue.
# ../.auto/py-compile: Missing argument to --destdir.
+ inreplace 'python/Makefile.in', '$(am__py_compile) --destdir "$(DESTDIR)"', "$(am__py_compile) --destdir \"$(cacadir)\""
system "./configure", "--disable-dependency-tracking",
"--prefix=#{prefix}",
- "--disable-python",
"--disable-doc",
"--disable-slang",
"--disable-java",
diff --git a/Library/Formula/libdnet.rb b/Library/Formula/libdnet.rb
index bd9ef3143..c220a18fb 100644
--- a/Library/Formula/libdnet.rb
+++ b/Library/Formula/libdnet.rb
@@ -5,10 +5,9 @@ class Libdnet < Formula
url 'http://libdnet.googlecode.com/files/libdnet-1.12.tgz'
sha1 '71302be302e84fc19b559e811951b5d600d976f8'
- depends_on :automake
- depends_on :libtool
-
- option 'with-python', 'Build Python module'
+ depends_on :automake => :build
+ depends_on :libtool => :build
+ depends_on :python => :optional
# Fix use of deprecated macros
# http://code.google.com/p/libdnet/issues/detail?id=27
@@ -26,7 +25,7 @@ class Libdnet < Formula
--prefix=#{prefix}
--mandir=#{man}
]
- args << "--with-python" if build.include? "with-python"
+ args << "--with-python" if build.with? "python"
system "./configure", *args
system "make install"
end
diff --git a/Library/Formula/liblunar.rb b/Library/Formula/liblunar.rb
index ff85b4fc4..89fc29ff5 100644
--- a/Library/Formula/liblunar.rb
+++ b/Library/Formula/liblunar.rb
@@ -12,14 +12,15 @@ class Liblunar < Formula
depends_on 'glib'
depends_on 'gettext'
depends_on 'vala' => :optional
- depends_on 'pygobject' if build.include? 'python'
+ depends_on :python => :optional
+ depends_on 'pygobject' if build.with? 'python'
def install
args = %W[
--disable-dependency-tracking
--prefix=#{prefix}
]
- args << '--disable-python' unless build.include? 'python'
+ args << '--disable-python' unless build.with? 'python'
system './configure', *args
system 'make install'
end
diff --git a/Library/Formula/libming.rb b/Library/Formula/libming.rb
index 37ff3df92..fe32529e7 100644
--- a/Library/Formula/libming.rb
+++ b/Library/Formula/libming.rb
@@ -5,12 +5,12 @@ class Libming < Formula
url 'http://sourceforge.net/projects/ming/files/Releases/ming-0.4.4.tar.bz2'
sha1 'e803b3b94a00a361e3415105f26112cf6f7bac81'
- option 'python', 'Build the python extension'
option 'perl', 'Build the perl extension'
option 'php', 'Build the php extension'
depends_on :libpng
depends_on :freetype
+ depends_on :python => :optional
depends_on 'giflib' => :optional
# Helps us find libgif.dylib, not libungif.dylib which is retired.
@@ -20,7 +20,7 @@ class Libming < Formula
def install
# TODO: Libming also includes scripting front-ends for Perl, Python, TCL
- # and PHP. These are disabled by default. Figure out what it would take to
+ # and PHP. These are disabled by default. Figure out what it would take to
# enable them.
# - python works if we tell it to use our giflib not ungif.
# - perl works without any change
@@ -31,9 +31,9 @@ class Libming < Formula
--disable-silent-rules
--prefix=#{prefix}
]
- args << '--enable-python' if build.include? 'python'
- args << '--enable-perl' if build.include? 'perl'
- args << '--enable-php' if build.include? 'php'
+ args << '--enable-python' if build.with? 'python'
+ args << '--enable-perl' if build.with? 'perl'
+ args << '--enable-php' if build.with? 'php'
system './configure', *args
system 'make'
diff --git a/Library/Formula/libplist.rb b/Library/Formula/libplist.rb
index ea7ebe7ae..1ad821e33 100644
--- a/Library/Formula/libplist.rb
+++ b/Library/Formula/libplist.rb
@@ -7,15 +7,12 @@ class Libplist < Formula
head 'http://git.sukimashita.com/libplist.git'
+ # Improve the default option descr. generated by `depends_on :python => :optional`
option 'with-python', 'Enable Cython Python bindings'
depends_on 'cmake' => :build
-
- if build.include? 'with-python'
- depends_on 'Cython' => :python
- # Needed to find the Cython executable
- env :userpaths
- end
+ depends_on :python => :optional
+ depends_on 'Cython' => :python if build.with? 'python'
def install
ENV.deparallelize # make fails on an 8-core Mac Pro
@@ -25,39 +22,13 @@ class Libplist < Formula
# Disable Swig Python bindings
args << "-DENABLE_SWIG='OFF'"
- if build.include? 'with-python'
- ## Taken from opencv.rb
- #
- # The CMake `FindPythonLibs` Module is dumber than a bag of hammers when
- # more than one python installation is available---for example, it clings
- # to the Header folder of the system Python Framework like a drowning
- # sailor.
- #
- # This code was cribbed from the VTK formula and uses the output to
- # `python-config` to do the job FindPythonLibs should be doing in the first
- # place.
- python_prefix = `python-config --prefix`.strip
- # Python is actually a library. The libpythonX.Y.dylib points to this lib, too.
- if File.exist? "#{python_prefix}/Python"
- # Python was compiled with --framework:
- args << "-DPYTHON_LIBRARY='#{python_prefix}/Python'"
- if !MacOS::CLT.installed? and python_prefix.start_with? '/System/Library'
- # For Xcode-only systems, the headers of system's python are inside of Xcode
- args << "-DPYTHON_INCLUDE_DIR='#{MacOS.sdk_path}/System/Library/Frameworks/Python.framework/Versions/2.7/Headers'"
- else
- args << "-DPYTHON_INCLUDE_DIR='#{python_prefix}/Headers'"
- end
- else
- python_lib = "#{python_prefix}/lib/lib#{which_python}"
- if File.exists? "#{python_lib}.a"
- args << "-DPYTHON_LIBRARY='#{python_lib}.a'"
- else
- args << "-DPYTHON_LIBRARY='#{python_lib}.dylib'"
- end
- args << "-DPYTHON_INCLUDE_DIR='#{python_prefix}/include/#{which_python}'"
- end
- else
- # Also disable Cython Python bindings if we're not building with '--python'
+ if python do
+ # For Xcode-only systems, the headers of system's python are inside of Xcode:
+ args << "-DPYTHON_INCLUDE_DIR='#{python.incdir}'"
+ # Cmake picks up the system's python dylib, even if we have a brewed one:
+ args << "-DPYTHON_LIBRARY='#{python.libdir}/lib#{python.xy}.dylib'"
+ end; else
+ # Also disable Cython Python bindings if we're not building --with-python
args << "-DENABLE_CYTHON='OFF'"
end
@@ -66,16 +37,6 @@ class Libplist < Formula
end
def caveats
- if build.include? 'with-python'
- <<-EOS.undent
- To use the Python bindings with non-homebrew Python, you need to amend your
- PYTHONPATH like so:
- export PYTHONPATH=#{HOMEBREW_PREFIX}/lib/#{which_python}/site-packages:$PYTHONPATH
- EOS
- end
- end
-
- def which_python
- "python" + `python -c 'import sys;print(sys.version[:3])'`.strip
+ python.standard_caveats if python
end
end
diff --git a/Library/Formula/libpst.rb b/Library/Formula/libpst.rb
index d143d97a5..5e2d86233 100644
--- a/Library/Formula/libpst.rb
+++ b/Library/Formula/libpst.rb
@@ -6,19 +6,19 @@ class Libpst < Formula
sha1 'c81df95509494c99222b0b603f7500dd9caceff1'
option 'pst2dii', 'Build pst2dii using gd'
- option 'python', 'Build the libpst python interface'
depends_on 'boost'
- depends_on 'gd' if build.include? 'pst2dii'
+ depends_on :python => :optional
+ depends_on 'gd' if build.with? 'pst2dii'
def install
args = %W[
--disable-dependency-tracking
--prefix=#{prefix}
]
- args << '--disable-dii' unless build.include? 'pst2dii'
- if build.include? 'python'
- ENV['PYTHON_EXTRA_LDFLAGS'] = '-u _PyMac_Error'
+ args << '--disable-dii' unless build.with? 'pst2dii'
+ if build.with? 'python'
+ # ENV['PYTHON_EXTRA_LDFLAGS'] = '-u _PyMac_Error'
args << '--enable-python' << '--with-boost-python=mt'
else
args << '--disable-python'
diff --git a/Library/Formula/libstfl.rb b/Library/Formula/libstfl.rb
index 15603a56d..6670208a8 100644
--- a/Library/Formula/libstfl.rb
+++ b/Library/Formula/libstfl.rb
@@ -5,12 +5,31 @@ class Libstfl < Formula
url 'http://www.clifford.at/stfl/stfl-0.22.tar.gz'
sha1 '226488be2b33867dfb233f0fa2dde2d066e494bd'
+ depends_on :python => :recommended
+ depends_on 'swig'
+
def patches; DATA; end
def install
- system "make", "install",
- "CC=#{ENV.cc} -pthread",
- "prefix=#{prefix}"
+ args = ["CC=#{ENV.cc} -pthread", "prefix=#{prefix}"]
+
+ args << "FOUND_RUBY = 0" unless MacOS::CLT.installed? # Ruby does not build on Xcode only. Help us fix this!
+
+ if build.with? 'python'
+ # Install into the site-packages in the Cellar (so uninstall works)
+ inreplace 'python/Makefile.snippet' do |s|
+ s.change_make_var! "PYTHON_SITEARCH", python.site_packages
+ s.gsub! 'lib-dynload/', ''
+ end
+ # Fails race condition of test:
+ # ImportError: dynamic module does not define init function (init_stfl)
+ # make: *** [python/_stfl.so] Error 1
+ ENV.deparallelize
+ else
+ args << "FOUND_PYTHON = 0"
+ end
+
+ system "make", "install", *args
end
end
diff --git a/Library/Formula/libswiften.rb b/Library/Formula/libswiften.rb
index a52d7daba..bdfb573d4 100644
--- a/Library/Formula/libswiften.rb
+++ b/Library/Formula/libswiften.rb
@@ -7,6 +7,7 @@ class Libswiften < Formula
head "git://swift.im/swift"
+ depends_on :python => :build
depends_on 'scons' => :build
depends_on 'libidn'
depends_on 'boost'
diff --git a/Library/Formula/libxml2.rb b/Library/Formula/libxml2.rb
index d3d1c1e94..1b0b1b29e 100644
--- a/Library/Formula/libxml2.rb
+++ b/Library/Formula/libxml2.rb
@@ -9,7 +9,8 @@ class Libxml2 < Formula
keg_only :provided_by_osx
option :universal
- option 'with-python', 'Compile the libxml2 Python 2.x modules'
+
+ depends_on :python => :recommended
fails_with :llvm do
build 2326
@@ -26,33 +27,40 @@ class Libxml2 < Formula
ENV.deparallelize
system "make install"
- if build.include? 'with-python'
- # Build Python bindings manually
+ python do
+ # This python do block sets up the site-packages in the Cellar.
cd 'python' do
- python_lib = lib/which_python/'site-packages'
- ENV.append 'PYTHONPATH', python_lib
- python_lib.mkpath
+ # We need to insert our include dir first
+ inreplace 'setup.py', 'includes_dir = [', "includes_dir = ['#{include}', '#{MacOS.sdk_path}/usr/include',"
+ system python, 'setup.py', "install", "--prefix=#{prefix}"
+ end
+ # This is keg_only but it makes sense to have the python bindings:
+ ohai 'Linking python bindings'
+ Dir["#{python.site_packages}/*"].each{ |f|
+ path = python.global_site_packages/(Pathname.new(f).basename)
+ puts path
+ rm path if path.exist?
+ ln_s f, path
+ }
+ end
- archs = archs_for_command("python")
- archs.remove_ppc!
- arch_flags = archs.as_arch_flags
+ end
- ENV.append 'CFLAGS', arch_flags
- ENV.append 'LDFLAGS', arch_flags
+ def caveats
+ <<-EOS.undent
+ Even if this formula is keg_only, the python bindings have been linked
+ into the global site-packages for your convenience.
+ #{python.global_site_packages}
- unless MacOS::CLT.installed?
- # We can hijack /opt/include to insert SDKROOT/usr/include
- inreplace 'setup.py', '"/opt/include",', "'#{MacOS.sdk_path}/usr/include',"
- end
+ EOS
+ end if build.with? 'python'
- system "python", "setup.py",
- "install_lib",
- "--install-dir=#{python_lib}"
- end
+ def test
+ if build.with? 'python'
+ system python, '-c', "import libxml2"
+ else
+ puts "No tests beacuse build --wtihout-python."
+ true
end
end
-
- def which_python
- "python" + `python -c 'import sys;print(sys.version[:3])'`.strip
- end
end
diff --git a/Library/Formula/little-cms.rb b/Library/Formula/little-cms.rb
index fdf565f26..69b132184 100644
--- a/Library/Formula/little-cms.rb
+++ b/Library/Formula/little-cms.rb
@@ -5,14 +5,13 @@ class LittleCms < Formula
url 'http://sourceforge.net/projects/lcms/files/lcms/1.19/lcms-1.19.tar.gz'
sha1 'd5b075ccffc0068015f74f78e4bc39138bcfe2d4'
- option 'with-python', "Build Python bindings"
-
+ depends_on :python => :optional
depends_on 'jpeg' => :optional
depends_on 'libtiff' => :optional
def install
args = ["--disable-debug", "--prefix=#{prefix}"]
- args << "--with-python" if build.include? "with-python"
+ args << "--with-python" if build.with? "python"
system "./configure", *args
system "make install"
diff --git a/Library/Formula/llvm.rb b/Library/Formula/llvm.rb
index eab3ed385..e9508e1e8 100644
--- a/Library/Formula/llvm.rb
+++ b/Library/Formula/llvm.rb
@@ -33,14 +33,20 @@ class Llvm < Formula
option :universal
option 'with-clang', 'Build Clang C/ObjC/C++ frontend'
option 'with-asan', 'Include support for -faddress-sanitizer (from compiler-rt)'
- option 'shared', 'Build LLVM as a shared library'
+ option 'disable-shared', "Don't build LLVM as a shared library"
option 'all-targets', 'Build all target backends'
option 'rtti', 'Build with C++ RTTI'
option 'disable-assertions', 'Speeds up LLVM, but provides less debug information'
+ depends_on :python => :recommended
+
env :std if build.universal?
def install
+ if build.with? 'python' and build.include? 'disable-shared'
+ raise 'The Python bindings need the shared library.'
+ end
+
Clang.new("clang").brew do
clang_dir.install Dir['*']
end if build.include? 'with-clang'
@@ -69,7 +75,7 @@ class Llvm < Formula
else
args << "--enable-targets=host"
end
- args << "--enable-shared" if build.include? 'shared'
+ args << "--enable-shared" unless build.include? 'disable-shared'
args << "--disable-assertions" if build.include? 'disable-assertions'
@@ -77,13 +83,18 @@ class Llvm < Formula
system "make install"
# install llvm python bindings
- (share/'llvm/bindings').install buildpath/'bindings/python'
+ if python
+ unless build.head?
+ inreplace buildpath/'bindings/python/llvm/common.py', 'LLVM-3.1svn', "libLLVM-#{version}svn"
+ end
+ python.site_packages.install buildpath/'bindings/python/llvm'
+ end
# install clang tools and bindings
cd clang_dir do
system 'make install'
(share/'clang/tools').install 'tools/scan-build', 'tools/scan-view'
- (share/'clang/bindings').install 'bindings/python'
+ python.site_packages.install 'bindings/python/clang' if python
end if build.include? 'with-clang'
end
@@ -91,12 +102,15 @@ class Llvm < Formula
system "#{bin}/llvm-config", "--version"
end
- def caveats; <<-EOS.undent
- Extra tools and bindings are installed in #{share}/llvm and #{share}/clang.
+ def caveats
+ s = ''
+ s += python.standard_caveats if python
+ s += <<-EOS.undent
+ Extra tools are installed in #{share}/llvm and #{share}/clang.
- If you already have LLVM installed, then "brew upgrade llvm" might not work.
- Instead, try:
- brew rm llvm && brew install llvm
+ If you already have LLVM installed, then "brew upgrade llvm" might not work.
+ Instead, try:
+ brew rm llvm && brew install llvm
EOS
end
diff --git a/Library/Formula/lorem.rb b/Library/Formula/lorem.rb
index 13f84b4fc..b13484b99 100644
--- a/Library/Formula/lorem.rb
+++ b/Library/Formula/lorem.rb
@@ -6,6 +6,8 @@ class Lorem < Formula
version '0.6.1'
sha1 'aa6ef66e5ee1151397f19b358d772af316cf333b'
+ depends_on :python
+
def install
inreplace "lorem", "!/usr/bin/python", "!/usr/bin/env python"
bin.install "lorem"
diff --git a/Library/Formula/macvim.rb b/Library/Formula/macvim.rb
index 2ab7ee02a..d10fa4d52 100644
--- a/Library/Formula/macvim.rb
+++ b/Library/Formula/macvim.rb
@@ -10,10 +10,11 @@ class Macvim < Formula
option "custom-icons", "Try to generate custom document icons"
option "override-system-vim", "Override system vim"
- option "with-python3", "Build with Python 3 scripting support"
depends_on 'cscope' => :recommended
depends_on 'lua' => :optional
+ depends_on :python => :recommended
+ depends_on :python3 => :optional # Help us! :python3 is MacVim makes the window disappear!
depends_on :xcode # For xcodebuild.
@@ -30,14 +31,16 @@ class Macvim < Formula
args = %W[
--with-features=huge
- --with-tlib=ncurses
--enable-multibyte
--with-macarchs=#{arch}
+ --with-macsdk=10.8
--enable-perlinterp
- --enable-pythoninterp
--enable-rubyinterp
--enable-tclinterp
--with-ruby-command=#{RUBY_PATH}
+ --with-tlib=ncurses
+ --with-compiledby=Homebrew
+ --with-local-dir=#{HOMEBREW_PREFIX}
]
args << "--enable-cscope" if build.with? "cscope"
@@ -47,7 +50,17 @@ class Macvim < Formula
args << "--with-lua-prefix=#{HOMEBREW_PREFIX}"
end
- args << "--enable-python3interp" if build.include? "with-python3"
+ args << "--enable-pythoninterp=dynamic" if build.with? 'python'
+ args << "--enable-python3interp=dynamic" if build.with? "python3"
+
+ unless MacOS::CLT.installed?
+ # On Xcode-only systems:
+ # Macvim cannot deal with "/Applications/Xcode.app/Contents/Developer" as
+ # it is returned by `xcode-select -print-path` and already set by
+ # Homebrew (in superenv). Instead Macvim needs the deeper dir to directly
+ # append "SDKs/...".
+ args << "--with-developer-dir=#{MacOS::Xcode.prefix}/Platforms/MacOSX.platform/Developer/"
+ end
system "./configure", *args
diff --git a/Library/Formula/mapnik.rb b/Library/Formula/mapnik.rb
index f62a5bd94..1418e3d2e 100644
--- a/Library/Formula/mapnik.rb
+++ b/Library/Formula/mapnik.rb
@@ -15,6 +15,7 @@ class Mapnik < Formula
head 'https://github.com/mapnik/mapnik.git'
depends_on 'pkg-config' => :build
+ depends_on :python
depends_on :libtool
depends_on :freetype
depends_on :libpng
@@ -46,9 +47,7 @@ class Mapnik < Formula
jobs = ENV.make_jobs.to_i
jobs /= 2 if jobs > 2
- args = [ "scons/scons.py",
- "configure",
- "CC=\"#{ENV.cc}\"",
+ args = [ "CC=\"#{ENV.cc}\"",
"CXX=\"#{ENV.cxx}\"",
"JOBS=#{jobs}",
"PREFIX=#{prefix}",
@@ -73,22 +72,16 @@ class Mapnik < Formula
args << "GDAL_CONFIG=#{Formula.factory('gdal').opt_prefix}/bin/gdal-config" if build.with? 'gdal'
args << "PG_CONFIG=#{Formula.factory('postgresql').opt_prefix}/bin/pg_config" if build.with? 'postgresql'
- system "python", *args
-
- system "python",
- "scons/scons.py",
- "install"
+ python do
+ system python, "scons/scons.py", "configure", *args
+ system python, "scons/scons.py", "install"
+ end
end
- def caveats; <<-EOS.undent
- For non-homebrew Python, you need to amend your PYTHONPATH like so:
- export PYTHONPATH=#{HOMEBREW_PREFIX}/lib/#{which_python}/site-packages:$PYTHONPATH
- EOS
+ def caveats
+ python.standard_caveats if python
end
- def which_python
- "python" + `python -c 'import sys;print(sys.version[:3])'`.strip
- end
end
__END__
diff --git a/Library/Formula/mapserver.rb b/Library/Formula/mapserver.rb
index 9206b87e7..8bbc36ddc 100644
--- a/Library/Formula/mapserver.rb
+++ b/Library/Formula/mapserver.rb
@@ -9,21 +9,21 @@ class Mapserver < Formula
option "with-geos", "Build support for GEOS spatial operations"
option "with-php", "Build PHP MapScript module"
option "with-postgresql", "Build support for PostgreSQL as a data source"
- option "with-python", "Build Python MapScript module"
- # to find custom python
env :userpaths
depends_on :freetype
depends_on :libpng
+ depends_on :python => :recommended
+ depends_on 'swig' => :build
depends_on 'giflib'
depends_on 'gd' => %w{with-freetype}
depends_on 'proj'
depends_on 'gdal'
-
depends_on 'geos' => :optional
depends_on 'postgresql' if build.include? 'with-postgresql' and not MacOS.version >= :lion
depends_on 'fcgi' if build.include? 'with-fastcgi'
+ depends_on 'cairo' => :optional
def install
args = [
@@ -47,6 +47,11 @@ class Mapserver < Formula
args << "--with-fastcgi=#{HOMEBREW_PREFIX}" if build.include? 'with-fastcgi'
+ unless MacOS::CLT.installed?
+ inreplace 'configure', "_JTOPDIR=`echo \"$_ACJNI_FOLLOWED\" | sed -e 's://*:/:g' -e 's:/[^/]*$::'`",
+ "_JTOPDIR='#{MacOS.sdk_path}/System/Library/Frameworks/JavaVM.framework/Headers'"
+ end
+
system "./configure", *args
system "make"
@@ -54,9 +59,11 @@ class Mapserver < Formula
install_args << "PHP_EXT_DIR=#{prefix}" if build.include? 'with-php'
system "make", "install", *install_args
- if build.include? 'with-python'
+ python do
cd 'mapscript/python' do
- system "python", "setup.py", "install"
+ system python, "setup.py", "install", "--prefix=#{prefix}",
+ "--single-version-externally-managed",
+ "--record=installed-files.txt"
end
end
end
diff --git a/Library/Formula/mercurial.rb b/Library/Formula/mercurial.rb
index 9bf5b20ea..15bca201f 100644
--- a/Library/Formula/mercurial.rb
+++ b/Library/Formula/mercurial.rb
@@ -7,6 +7,7 @@ class Mercurial < Formula
head 'http://selenic.com/repo/hg', :using => :hg
+ depends_on :python # its written in Python, so this is a hard dep
depends_on 'docutils' => :python if build.head? or build.include? 'doc'
option 'doc', "Build the documentation"
@@ -16,25 +17,29 @@ class Mercurial < Formula
# System-provided Python.
ENV.minimal_optimization
+ # install the completion script
bash_completion.install 'contrib/bash_completion' => 'hg-completion.bash'
- system "make doc" if build.head? or build.include? 'doc'
- system "make local"
+ python do
+ system "make doc" if build.head? or build.include? 'doc'
+ system "make local"
- libexec.install 'hg', 'mercurial', 'hgext'
+ libexec.install 'hg', 'mercurial', 'hgext'
+ # If we get it working with python3, we would need the next line instead:
+ #['hg', 'mercurial', 'hgext'].each{ |f| libexec.install "#{f}#{python.if3then3}" }
- # Symlink the hg binary into bin
- bin.install_symlink libexec/'hg'
+ # Symlink the hg binary into bin
+ bin.install_symlink libexec/"hg#{python.if3then3}"
- # Remove the hard-coded python invocation from hg
- inreplace bin/'hg', %r[^#!.*$], '#!/usr/bin/env python'
+ # Install some contribs
+ bin.install "contrib/hgk#{python.if3then3}"
+ # Install man pages
+ man1.install 'doc/hg.1'
+ man5.install 'doc/hgignore.5', 'doc/hgrc.5'
- # Install some contribs
- bin.install 'contrib/hgk'
+ system 'make clean'
+ end
- # Install man pages
- man1.install 'doc/hg.1'
- man5.install 'doc/hgignore.5', 'doc/hgrc.5'
end
def caveats
diff --git a/Library/Formula/ninja.rb b/Library/Formula/ninja.rb
index 2084a59a9..f031cadc6 100644
--- a/Library/Formula/ninja.rb
+++ b/Library/Formula/ninja.rb
@@ -5,8 +5,10 @@ class Ninja < Formula
url 'https://github.com/martine/ninja/archive/v1.3.3.tar.gz'
sha1 '1e27d85316a267afa5e98ed62b660395ab5b9851'
+ depends_on :python
+
def install
- system "./bootstrap.py"
+ system python, "./bootstrap.py"
bin.install "ninja"
bash_completion.install 'misc/bash-completion' => 'ninja-completion.sh'
end
diff --git a/Library/Formula/node.rb b/Library/Formula/node.rb
index d80e1f42f..e9e806a10 100644
--- a/Library/Formula/node.rb
+++ b/Library/Formula/node.rb
@@ -1,15 +1,5 @@
require 'formula'
-class PythonVersion < Requirement
- env :userpaths
-
- satisfy { `python -c 'import sys;print(sys.version[:3])'`.strip.to_f >= 2.6 }
-
- def message
- "Node's build system, gyp, requires Python 2.6 or newer."
- end
-end
-
class NpmNotInstalled < Requirement
fatal true
@@ -55,7 +45,7 @@ class Node < Formula
option 'without-npm', 'npm will not be installed'
depends_on NpmNotInstalled unless build.without? 'npm'
- depends_on PythonVersion
+ depends_on PythonInstalled.new("2.6") => :build
fails_with :llvm do
build 2326
diff --git a/Library/Formula/omniorb.rb b/Library/Formula/omniorb.rb
index 92390cfed..ad4d796fa 100644
--- a/Library/Formula/omniorb.rb
+++ b/Library/Formula/omniorb.rb
@@ -11,9 +11,8 @@ class Omniorb < Formula
url 'http://sourceforge.net/projects/omniorb/files/omniORB/omniORB-4.1.6/omniORB-4.1.6.tar.bz2'
sha1 '383e3b3b605188fe6358316917576e0297c4e1a6'
- option 'python', 'Enable Python mappings'
-
depends_on 'pkg-config' => :build
+ depends_on :python => :recommended
# http://www.omniorb-support.com/pipermail/omniorb-list/2012-February/031202.html
def patches
@@ -21,12 +20,12 @@ class Omniorb < Formula
end
def install
- args = ["--prefix=#{prefix}", "PYTHON=#{which 'python'}"]
+ args = ["--prefix=#{prefix}"]
system "./configure", *args
system "make"
system "make install"
- if build.include? 'python'
+ python do
OmniorbBindings.new.brew do
system "./configure", *args
system "make install"
@@ -35,25 +34,14 @@ class Omniorb < Formula
end
def caveats
- s = ''
- if build.include? 'python'
- s += <<-EOS.undent
- For non-homebrew Python, you need to amend your PYTHONPATH like so:
- export PYTHONPATH=#{HOMEBREW_PREFIX}/lib/#{which_python}/site-packages:$PYTHONPATH
- EOS
- end
- return s.empty? ? nil : s
- end
-
- def which_python
- "python" + `python -c 'import sys;print(sys.version[:3])'`.strip
+ python.standard_caveats if python
end
test do
system "#{bin}/omniidl", "-h"
- if build.include? 'python'
- system "python", "-c", %(import omniORB; print 'omniORBpy', omniORB.__version__)
+ if build.with? 'python'
+ system python, "-c", %(import omniORB; print 'omniORBpy', omniORB.__version__)
end
end
end
diff --git a/Library/Formula/open-babel.rb b/Library/Formula/open-babel.rb
index f10f88aee..6b87e1252 100644
--- a/Library/Formula/open-babel.rb
+++ b/Library/Formula/open-babel.rb
@@ -5,49 +5,30 @@ class OpenBabel < Formula
url 'http://sourceforge.net/projects/openbabel/files/openbabel/2.3.2/openbabel-2.3.2.tar.gz'
sha1 'b8831a308617d1c78a790479523e43524f07d50d'
- option 'gui', 'Build the Graphical User Interface'
- option 'png', 'Support PNG depiction'
- option 'python', 'Compile Python language bindings'
- option 'java', 'Compile Java language bindings'
+ option 'with-cairo', 'Support PNG depiction'
+ option 'with-java', 'Compile Java language bindings'
depends_on 'pkg-config' => :build
depends_on 'cmake' => :build
- depends_on 'wxmac' if build.include? 'gui'
- depends_on 'cairo' if build.include? 'png'
- depends_on 'eigen' if build.include? 'python'
- depends_on 'eigen' if build.include? 'java'
+ depends_on :python => :optional
+ depends_on 'wxmac' => :optional
+ depends_on 'cairo' => :optional
+ depends_on 'eigen' if build.with?('python') || build.with?('java')
def install
args = %W[ -DCMAKE_INSTALL_PREFIX=#{prefix} ]
- args << "-DPYTHON_BINDINGS=ON" if build.include? 'python'
- args << "-DJAVA_BINDINGS=ON" if build.include? 'java'
- args << "-DBUILD_GUI=ON" if build.include? 'gui'
+ args << "-DJAVA_BINDINGS=ON" if build.with? 'java'
+ args << "-DBUILD_GUI=ON" if build.with? 'wxmac'
args << "-DCAIRO_INCLUDE_DIRS=#{include}/cairo "\
- "-DCAIRO_LIBRARIES=#{lib}/libcairo.dylib" if build.include? 'png'
-
- # Find the right pyhton installation (code from opencv.rb)
- if build.include? 'python'
- python_prefix = `python-config --prefix`.strip
- # Python is actually a library. The libpythonX.Y.dylib points to this lib, too.
- if File.exist? "#{python_prefix}/Python"
- # Python was compiled with --framework:
- args << "-DPYTHON_LIBRARY='#{python_prefix}/Python'"
- if !MacOS::CLT.installed? and python_prefix.start_with? '/System/Library'
- # For Xcode-only systems, the headers of system's python are inside of Xcode
- args << "-DPYTHON_INCLUDE_DIR='#{MacOS.sdk_path}/System/Library/Frameworks/Python.framework/Versions/2.7/Headers'"
- else
- args << "-DPYTHON_INCLUDE_DIR='#{python_prefix}/Headers'"
- end
- else
- python_lib = "#{python_prefix}/lib/lib#{which_python}"
- if File.exists? "#{python_lib}.a"
- args << "-DPYTHON_LIBRARY='#{python_lib}.a'"
- else
- args << "-DPYTHON_LIBRARY='#{python_lib}.dylib'"
- end
- args << "-DPYTHON_INCLUDE_DIR='#{python_prefix}/include/#{which_python}'"
- end
- args << "-DPYTHON_PACKAGES_PATH='#{lib}/#{which_python}/site-packages'"
+ "-DCAIRO_LIBRARIES=#{lib}/libcairo.dylib" if build.with? 'cairo'
+
+ python do
+ args << "-DPYTHON_BINDINGS=ON"
+ # For Xcode-only systems, the headers of system's python are inside of Xcode:
+ args << "-DPYTHON_INCLUDE_DIR='#{python.incdir}'"
+ # Cmake picks up the system's python dylib, even if we have a brewed one:
+ args << "-DPYTHON_LIBRARY='#{python.libdir}/lib#{python.xy}.dylib'"
+ args << "-DPYTHON_PACKAGES_PATH='#{python.site_packages}'"
end
args << '..'
@@ -58,26 +39,18 @@ class OpenBabel < Formula
system "make install"
end
- if build.include? 'python'
- pydir = lib/which_python/'site-packages'
- pydir.install lib/'openbabel.py', lib/'pybel.py'
- cd pydir do
- `python -c 'import py_compile;py_compile.compile(\"openbabel.py\");py_compile.compile(\"pybel.py\")'`
- end
+ python do
+ python.site_packages.install lib/'openbabel.py', lib/'pybel.py', lib/'_openbabel.so'
end
end
- def caveats; <<-EOS.undent
- Python modules are installed to #{HOMEBREW_PREFIX}/lib/#{which_python}/site-packages
- so the PYTHONPATH environment variable should include the paths
- #{HOMEBREW_PREFIX}/lib/#{which_python}/site-packages:#{HOMEBREW_PREFIX}/lib
-
- Java libraries are installed to #{HOMEBREW_PREFIX}/lib so this path should be
- included in the CLASSPATH environment variable.
+ def caveats
+ s = ''
+ s += python.standard_caveats if python
+ s += <<-EOS.undent
+ Java libraries are installed to #{HOMEBREW_PREFIX}/lib so this path should be
+ included in the CLASSPATH environment variable.
EOS
end
- def which_python
- "python" + `python -c 'import sys;print(sys.version[:3])'`.strip
- end
end
diff --git a/Library/Formula/opencolorio.rb b/Library/Formula/opencolorio.rb
index f0f312b55..4b4411176 100644
--- a/Library/Formula/opencolorio.rb
+++ b/Library/Formula/opencolorio.rb
@@ -10,17 +10,17 @@ class Opencolorio < Formula
depends_on 'cmake' => :build
depends_on 'pkg-config' => :build
depends_on 'little-cms2'
+ depends_on :python => :optional
option 'with-tests', 'Verify the build with its unit tests (~1min)'
- option 'with-python', 'Build ocio with python2.7 bindings'
option 'with-java', 'Build ocio with java bindings'
option 'with-docs', 'Build the documentation'
def install
args = std_cmake_args
- args << "-DOCIO_BUILD_JNIGLUE=ON" if build.include? 'with-java'
- args << "-DOCIO_BUILD_TESTS=ON" if build.include? 'with-tests'
- args << "-DOCIO_BUILD_DOCS=ON" if build.include? 'with-docs'
+ args << "-DOCIO_BUILD_JNIGLUE=ON" if build.with? 'java'
+ args << "-DOCIO_BUILD_TESTS=ON" if build.with? 'tests'
+ args << "-DOCIO_BUILD_DOCS=ON" if build.with? 'docs'
args << "-DCMAKE_VERBOSE_MAKEFILE=OFF"
# CMake-2.8.7 + CLT + llvm + Lion => CMAKE_CXX_HAS_ISYSROOT "1"
@@ -36,31 +36,18 @@ class Opencolorio < Formula
# /usr/include
# So we just set the sysroot to /
- args << "-DCMAKE_OSX_SYSROOT=/" if ENV.compiler == :llvm and MacOS.version >= :lion
-
-
+ # args << "-DCMAKE_OSX_SYSROOT=/" if ENV.compiler == :llvm and MacOS.version >= :lion
# Python note:
# OCIO's PyOpenColorIO.so doubles as a shared library. So it lives in lib, rather
# than the usual HOMEBREW_PREFIX/lib/python2.7/site-packages per developer choice.
- if build.include? 'with-python'
- python_prefix = `python-config --prefix`.strip
- if File.exist? "#{python_prefix}/Python"
- # Python was compiled with --framework:
- args << "-DPYTHON_LIBRARY='#{python_prefix}/Python'"
- args << "-DPYTHON_INCLUDE_DIR='#{python_prefix}/Headers'"
- else
- python_version = `python-config --libs`.match('-lpython(\d+\.\d+)').captures.at(0)
- python_lib = "#{python_prefix}/lib/libpython#{python_version}"
- args << "-DPYTHON_INCLUDE_DIR='#{python_prefix}/include/python#{python_version}'"
- if File.exists? "#{python_lib}.a"
- args << "-DPYTHON_LIBRARY='#{python_lib}.a'"
- else
- args << "-DPYTHON_LIBRARY='#{python_lib}.dylib'"
- end
- end
- else
+ if python do
+ # For Xcode-only systems, the headers of system's python are inside of Xcode:
+ args << "-DPYTHON_INCLUDE_DIR='#{python.incdir}'"
+ # Cmake picks up the system's python dylib, even if we have a brewed one:
+ args << "-DPYTHON_LIBRARY='#{python.libdir}/lib#{python.xy}.dylib'"
+ end; else
args << "-DOCIO_BUILD_PYGLUE=OFF"
end
@@ -69,7 +56,7 @@ class Opencolorio < Formula
mkdir 'macbuild' do
system "cmake", *args
system "make"
- system "make test" if build.include? 'with-tests'
+ system "make test" if build.with? 'tests'
system "make install"
end
end
diff --git a/Library/Formula/orfeo.rb b/Library/Formula/orfeo.rb
index 9d3ae368c..364b391c5 100644
--- a/Library/Formula/orfeo.rb
+++ b/Library/Formula/orfeo.rb
@@ -6,12 +6,12 @@ class Orfeo < Formula
sha1 '2cdef44fc4119ef410f750001c18aabc6be3a48c'
depends_on 'cmake' => :build
+ depends_on :python => :optional
depends_on 'fltk'
depends_on 'gdal'
depends_on 'qt'
option 'examples', 'Compile and install various examples'
- option 'python', 'Enable Python support'
option 'java', 'Enable Java support'
option 'patented', 'Enable patented algorithms'
@@ -25,9 +25,17 @@ class Orfeo < Formula
]
args << '-DBUILD_EXAMPLES=' + ((build.include? 'examples') ? 'ON' : 'OFF')
- args << '-DOTB_WRAP_PYTHON=' + ((build.include? 'python') ? 'ON' : 'OFF')
args << '-DOTB_WRAP_JAVA=' + ((build.include? 'java') ? 'ON' : 'OFF')
args << '-DOTB_USE_PATENTED=' + ((build.include? 'patented') ? 'ON' : 'OFF')
+ if python do
+ args << '-DOTB_WRAP_PYTHON=ON'
+ # For Xcode-only systems, the headers of system's python are inside of Xcode:
+ args << "-DPYTHON_INCLUDE_DIR='#{python.incdir}'"
+ # Cmake picks up the system's python dylib, even if we have a brewed one:
+ args << "-DPYTHON_LIBRARY='#{python.libdir}/lib#{python.xy}.dylib'"
+ end; else
+ args << '-DOTB_WRAP_PYTHON=OFF'
+ end
mkdir 'build' do
system 'cmake', '..', *args
diff --git a/Library/Formula/oscats.rb b/Library/Formula/oscats.rb
index 3e4e5918a..68df81dbd 100644
--- a/Library/Formula/oscats.rb
+++ b/Library/Formula/oscats.rb
@@ -5,16 +5,15 @@ class Oscats < Formula
url 'http://oscats.googlecode.com/files/oscats-0.6.tar.gz'
sha1 'f57fa06ee0d842ed4c547dd7ab599fd5090d7550'
- option 'python', 'Build Python bindings'
-
depends_on 'pkg-config' => :build
+ depends_on :python => :optional
depends_on 'gsl'
depends_on 'glib'
- depends_on 'pygobject' if build.include? 'python'
+ depends_on 'pygobject' if build.with? 'python'
def install
args = ["--disable-dependency-tracking", "--prefix=#{prefix}"]
- args << "--enable-python-bindings" if build.include? 'python'
+ args << "--enable-python-bindings" if build.with? 'python'
system "./configure", *args
system "make install"
end
diff --git a/Library/Formula/pil.rb b/Library/Formula/pil.rb
index cb7e5c295..8db85de23 100644
--- a/Library/Formula/pil.rb
+++ b/Library/Formula/pil.rb
@@ -6,6 +6,7 @@ class Pil < Formula
sha1 '76c37504251171fda8da8e63ecb8bc42a69a5c81'
depends_on :freetype
+ depends_on :python
depends_on 'jpeg' => :recommended
depends_on 'little-cms' => :optional
@@ -18,7 +19,7 @@ class Pil < Formula
def install
# Find the arch for the Python we are building against.
# We remove 'ppc' support, so we can pass Intel-optimized CFLAGS.
- archs = archs_for_command("python")
+ archs = archs_for_command(python.binary)
archs.remove_ppc!
# Can't build universal on 32-bit hardware. See:
# https://github.com/mxcl/homebrew/issues/5844
@@ -44,36 +45,11 @@ class Pil < Formula
"add_directory(include_dirs, \"#{HOMEBREW_PREFIX}/include\")"
end
- # In order to install into the Cellar, the dir must exist and be in the
- # PYTHONPATH.
- temp_site_packages = lib/which_python/'site-packages'
- mkdir_p temp_site_packages
- ENV['PYTHONPATH'] = temp_site_packages
- args = [
- "--no-user-cfg",
- "--verbose",
- "install",
- "--force",
- "--install-scripts=#{share}/python",
- "--install-lib=#{temp_site_packages}",
- "--install-data=#{share}",
- "--install-headers=#{include}",
- "--record=installed-files.txt"
- ]
- system "python", "-s", "setup.py", *args
-
- end
-
- def caveats; <<-EOS.undent
- This formula installs PIL against whatever Python is first in your path.
- This Python needs to have either setuptools or distribute installed or
- the build will fail.
- EOS
+ python do
+ system python, "setup.py", "install" ,"--prefix=#{prefix}"
+ end
end
- def which_python
- "python" + `python -c 'import sys;print(sys.version[:3])'`.strip
- end
end
__END__
diff --git a/Library/Formula/portmidi.rb b/Library/Formula/portmidi.rb
index c2aae1623..8f95d25a9 100644
--- a/Library/Formula/portmidi.rb
+++ b/Library/Formula/portmidi.rb
@@ -6,10 +6,10 @@ class Portmidi < Formula
sha1 'f45bf4e247c0d7617deacd6a65d23d9fddae6117'
option 'with-java', 'Build java based app and bindings. You need the Java SDK for this.'
- option 'with-python', 'Build the pyportmidi python module.'
depends_on 'cmake' => :build
- depends_on 'Cython' => :python if build.include? 'with-python'
+ depends_on :python => :optional
+ depends_on 'Cython' => :python if build.with? 'python'
def patches
# Avoid that the Makefile.osx builds the java app and fails because: fatal error: 'jni.h' file not found
@@ -30,23 +30,7 @@ class Portmidi < Formula
system 'make -f pm_mac/Makefile.osx'
system 'make -f pm_mac/Makefile.osx install'
- if build.include? 'with-python'
- # In order to install into the Cellar, the dir must exist and be in the
- # PYTHONPATH.
- temp_site_packages = lib/which_python/'site-packages'
- mkdir_p temp_site_packages
- ENV['PYTHONPATH'] = temp_site_packages
-
- args = [
- "--no-user-cfg",
- "--verbose",
- "install",
- "--force",
- "--install-scripts=#{bin}",
- "--install-lib=#{temp_site_packages}",
- "--install-data=#{share}",
- "--install-headers=#{include}",
- ]
+ python do
cd 'pm_python' do
# There is no longer a CHANGES.txt or TODO.txt.
inreplace 'setup.py', "CHANGES = open('CHANGES.txt').read()", 'CHANGES = ""'
@@ -54,14 +38,17 @@ class Portmidi < Formula
# Provide correct dirs (that point into the Cellar)
ENV.append 'CFLAGS', "-I#{include}"
ENV.append 'LDFLAGS', "-L#{lib}"
- system "python", "-s", "setup.py", *args
+ system python, "setup.py", "install", "--prefix=#{prefix}"
end
end
end
- def which_python
- "python" + `python -c 'import sys;print(sys.version[:3])'`.strip
+ def test
+ if build.with?('python') || Tab.for_formula('portmidi').with?('python')
+ system "python", "-c", "import pyportmidi; pyportmidi.init()"
+ end
end
+
end
__END__
diff --git a/Library/Formula/postgres-xc.rb b/Library/Formula/postgres-xc.rb
index 5b303d41d..c5ea941c2 100644
--- a/Library/Formula/postgres-xc.rb
+++ b/Library/Formula/postgres-xc.rb
@@ -6,6 +6,7 @@ class PostgresXc < Formula
sha1 '76774cf32810dfa14b2174f2e939d3b28eb211a9'
depends_on :arch => :x86_64
+ depends_on :python => :recommended
depends_on 'readline'
depends_on 'libxml2' if MacOS.version == :leopard # Leopard libxml is too old
depends_on 'ossp-uuid' => :recommended
@@ -13,7 +14,6 @@ class PostgresXc < Formula
conflicts_with 'postgresql',
:because => 'postgres-xc and postgresql install the same binaries.'
- option 'no-python', 'Build without Python support'
option 'no-perl', 'Build without Perl support'
option 'enable-dtrace', 'Build with DTrace support'
@@ -44,7 +44,7 @@ class PostgresXc < Formula
"--with-libxslt"]
args << "--with-ossp-uuid" unless build.without? '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'
args << "ARCHFLAGS='-arch x86_64'"
@@ -55,7 +55,7 @@ class PostgresXc < Formula
ENV.append 'LIBS', `uuid-config --libs`.strip
end
- check_python_arch unless build.include? 'no-python'
+ check_python_arch if build.with? 'python'
system "./configure", *args
system "make install-world"
@@ -73,27 +73,25 @@ class PostgresXc < 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
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;
diff --git a/Library/Formula/py2cairo.rb b/Library/Formula/py2cairo.rb
index eb6fd3487..c9ff3dbc4 100644
--- a/Library/Formula/py2cairo.rb
+++ b/Library/Formula/py2cairo.rb
@@ -8,6 +8,7 @@ class Py2cairo < Formula
depends_on 'pkg-config' => :build
depends_on 'cairo'
depends_on :x11
+ depends_on :python
option :universal
@@ -26,23 +27,20 @@ class Py2cairo < Formula
end
end
- # waf miscompiles py2cairo on >= lion with HB python, linking the wrong
- # Python Library. So add a LINKFLAG that sets the path.
- # https://github.com/mxcl/homebrew/issues/12893
- # https://github.com/mxcl/homebrew/issues/14781
- # https://bugs.freedesktop.org/show_bug.cgi?id=51544
- ENV['LINKFLAGS'] = "-L#{%x(python-config --prefix).chomp}/lib"
- system "./waf", "configure", "--prefix=#{prefix}", "--nopyc", "--nopyo"
- system "./waf", "install"
+ python do
+ # waf miscompiles py2cairo on >= lion with HB python, linking the wrong
+ # Python Library. So add a LINKFLAG that sets the path.
+ # https://github.com/mxcl/homebrew/issues/12893
+ # https://github.com/mxcl/homebrew/issues/14781
+ # https://bugs.freedesktop.org/show_bug.cgi?id=51544
+ ENV['LINKFLAGS'] = "-L#{python.libdir}"
+ system "./waf", "configure", "--prefix=#{prefix}", "--nopyc", "--nopyo"
+ system "./waf", "install"
+ end
end
- def caveats; <<-EOS.undent
- For non-homebrew Python, you need to amend your PYTHONPATH like so:
- export PYTHONPATH=#{HOMEBREW_PREFIX}/lib/#{which_python}/site-packages:$PYTHONPATH
- EOS
+ def caveats
+ python.standard_caveats if python
end
- def which_python
- "python" + `python -c 'import sys;print(sys.version[:3])'`.strip
- end
end
diff --git a/Library/Formula/pyexiv2.rb b/Library/Formula/pyexiv2.rb
index ad73d8091..2d91fbecd 100644
--- a/Library/Formula/pyexiv2.rb
+++ b/Library/Formula/pyexiv2.rb
@@ -5,6 +5,7 @@ class Pyexiv2 < Formula
url 'http://launchpad.net/pyexiv2/0.3.x/0.3.2/+download/pyexiv2-0.3.2.tar.bz2'
sha1 'ad20ea6925571d58637830569076aba327ff56d9'
+ depends_on :python
depends_on 'scons' => :build
depends_on 'exiv2'
depends_on 'boost'
@@ -13,23 +14,19 @@ class Pyexiv2 < Formula
def patches; DATA; end
def install
- # this build script ignores CPPFLAGS, but it honors CXXFLAGS
- ENV.append "CXXFLAGS", ENV.cppflags
- system "scons BOOSTLIB=boost_python-mt"
-
- # let's install manually
- mv 'build/libexiv2python.dylib', 'build/libexiv2python.so'
- (lib + which_python + 'site-packages').install 'build/libexiv2python.so', 'src/pyexiv2'
- end
-
- def which_python
- "python" + `python -c 'import sys;print(sys.version[:3])'`.strip
+ python do
+ # this build script ignores CPPFLAGS, but it honors CXXFLAGS
+ ENV.append "CXXFLAGS", ENV.cppflags
+ system "scons BOOSTLIB=boost_python-mt"
+
+ # let's install manually
+ mv 'build/libexiv2python.dylib', 'build/libexiv2python.so'
+ python.site_packages.install 'build/libexiv2python.so', 'src/pyexiv2'
+ end
end
- def caveats; <<-EOS.undent
- For non-homebrew Python, you need to amend your PYTHONPATH like so:
- export PYTHONPATH=#{HOMEBREW_PREFIX}/lib/#{which_python}/site-packages:$PYTHONPATH
- EOS
+ def caveats
+ python.standard_caveats if python
end
end
diff --git a/Library/Formula/pygobject.rb b/Library/Formula/pygobject.rb
index 969950389..f60ebb54c 100644
--- a/Library/Formula/pygobject.rb
+++ b/Library/Formula/pygobject.rb
@@ -7,6 +7,7 @@ class Pygobject < Formula
depends_on 'pkg-config' => :build
depends_on 'glib'
+ depends_on :python
option :universal
@@ -17,9 +18,11 @@ class Pygobject < Formula
def install
ENV.universal_binary if build.universal?
- system "./configure", "--disable-dependency-tracking",
- "--prefix=#{prefix}",
- "--disable-introspection"
- system "make install"
+ python do
+ system "./configure", "--disable-dependency-tracking",
+ "--prefix=#{prefix}",
+ "--disable-introspection"
+ system "make install"
+ end
end
end
diff --git a/Library/Formula/pygtk.rb b/Library/Formula/pygtk.rb
index 2d40f9533..2aa53b22e 100644
--- a/Library/Formula/pygtk.rb
+++ b/Library/Formula/pygtk.rb
@@ -6,6 +6,7 @@ class Pygtk < Formula
sha1 '344e6a32a5e8c7e0aaeb807e0636a163095231c2'
depends_on 'pkg-config' => :build
+ depends_on :python
depends_on :x11
depends_on 'glib'
depends_on 'gtk+'
@@ -18,11 +19,13 @@ class Pygtk < Formula
option 'glade', 'Python bindigs for glade. (to `import gtk.glade`)'
def install
- ENV.append 'CFLAGS', '-ObjC'
- ENV.universal_binary if build.universal?
- system "./configure", "--disable-dependency-tracking",
- "--prefix=#{prefix}"
- system "make install"
+ python do
+ ENV.append 'CFLAGS', '-ObjC'
+ ENV.universal_binary if build.universal?
+ system "./configure", "--disable-dependency-tracking",
+ "--prefix=#{prefix}"
+ system "make install"
+ end
# Fixing the pkgconfig file to find codegen, because it was moved from
# pygtk to pygobject. But our pkgfiles point into the cellar and in the
@@ -30,55 +33,51 @@ class Pygtk < Formula
inreplace lib/'pkgconfig/pygtk-2.0.pc', 'codegendir=${datadir}/pygobject/2.0/codegen', "codegendir=#{HOMEBREW_PREFIX}/share/pygobject/2.0/codegen"
end
- def caveats; <<-EOS.undent
- For non-Homebrew Python, you need to amend your PYTHONPATH like so:
- export PYTHONPATH=#{HOMEBREW_PREFIX}/lib/#{which_python}/site-packages:$PYTHONPATH
- EOS
- end
-
- def which_python
- "python" + `python -c 'import sys;print(sys.version[:3])'`.strip
+ def caveats
+ python.standard_caveats if python
end
test do
- (testpath/'test.py').write <<-EOS.undent
- #!/usr/bin/env python
- import pygtk
- pygtk.require('2.0')
- import gtk
+ python do
+ (testpath/'test.py').write <<-EOS.undent
+ #!/usr/bin/env python
+ import pygtk
+ pygtk.require('2.0')
+ import gtk
- class HelloWorld(object):
- def hello(self, widget, data=None):
- print "Hello World"
+ class HelloWorld(object):
+ def hello(self, widget, data=None):
+ print "Hello World"
- def delete_event(self, widget, event, data=None):
- print "delete event occurred"
- return False
+ def delete_event(self, widget, event, data=None):
+ print "delete event occurred"
+ return False
- def destroy(self, widget, data=None):
- print "destroy signal occurred"
- gtk.main_quit()
+ def destroy(self, widget, data=None):
+ print "destroy signal occurred"
+ gtk.main_quit()
- def __init__(self):
- self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
- self.window.connect("delete_event", self.delete_event)
- self.window.connect("destroy", self.destroy)
- self.window.set_border_width(10)
- self.button = gtk.Button("Hello World")
- self.button.connect("clicked", self.hello, None)
- self.button.connect_object("clicked", gtk.Widget.destroy, self.window)
- self.window.add(self.button)
- self.button.show()
- self.window.show()
+ def __init__(self):
+ self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
+ self.window.connect("delete_event", self.delete_event)
+ self.window.connect("destroy", self.destroy)
+ self.window.set_border_width(10)
+ self.button = gtk.Button("Hello World")
+ self.button.connect("clicked", self.hello, None)
+ self.button.connect_object("clicked", gtk.Widget.destroy, self.window)
+ self.window.add(self.button)
+ self.button.show()
+ self.window.show()
- def main(self):
- gtk.main()
+ def main(self):
+ gtk.main()
- if __name__ == "__main__":
- hello = HelloWorld()
- hello.main()
- EOS
- chmod 0755, 'test.py'
- system "./test.py"
+ if __name__ == "__main__":
+ hello = HelloWorld()
+ hello.main()
+ EOS
+ chmod 0755, 'test.py'
+ system "./test.py"
+ end
end
end
diff --git a/Library/Formula/pygtkglext.rb b/Library/Formula/pygtkglext.rb
index 0abd885b2..92e583bf8 100644
--- a/Library/Formula/pygtkglext.rb
+++ b/Library/Formula/pygtkglext.rb
@@ -6,17 +6,22 @@ class Pygtkglext < Formula
sha1 '2ae3e87e8cdfc3318d8ff0e33b344377cb3df7cb'
depends_on 'pkg-config' => :build
+ depends_on :python
depends_on 'pygtk'
depends_on 'gtkglext'
depends_on 'pygobject'
def install
- ENV['PYGTK_CODEGEN'] = which 'pygobject-codegen-2.0'
+ ENV['PYGTK_CODEGEN'] = Formula.factory('pygobject').opt_prefix/'bin/pygobject-codegen-2.0'
system "./configure", "--disable-debug", "--disable-dependency-tracking",
"--prefix=#{prefix}"
system "make install"
end
+ def caveats
+ python.standard_caveats if python
+ end
+
test do
system "python", "-c", "import pygtk", "pygtk.require('2.0')", "import gtk.gtkgl"
end
diff --git a/Library/Formula/pygtksourceview.rb b/Library/Formula/pygtksourceview.rb
index 5e9dd1a1f..485df897f 100644
--- a/Library/Formula/pygtksourceview.rb
+++ b/Library/Formula/pygtksourceview.rb
@@ -6,6 +6,7 @@ class Pygtksourceview < Formula
sha256 'bfdde2ce4f61d461fb34dece9433cf81a73a9c9de6b62d4eb06177b8c9cec9c7'
depends_on 'pkg-config' => :build
+ depends_on :python
depends_on 'gtksourceview'
depends_on 'pygtk'
@@ -16,14 +17,8 @@ class Pygtksourceview < Formula
system "make install"
end
- def caveats; <<-EOS.undent
- For non-homebrew Python, you need to amend your PYTHONPATH like so:
- export PYTHONPATH=#{HOMEBREW_PREFIX}/lib/#{which_python}/site-packages:$PYTHONPATH
- EOS
- end
-
- def which_python
- "python" + `python -c 'import sys;print(sys.version[:3])'`.strip
+ def caveats
+ python.standard_caveats if python
end
test do
diff --git a/Library/Formula/pyqt.rb b/Library/Formula/pyqt.rb
index c36747692..20898543c 100644
--- a/Library/Formula/pyqt.rb
+++ b/Library/Formula/pyqt.rb
@@ -1,67 +1,69 @@
require 'formula'
-# Note: this project doesn't save old releases, so it breaks often as
-# downloads disappear.
-
class Pyqt < Formula
homepage 'http://www.riverbankcomputing.co.uk/software/pyqt'
url 'http://downloads.sf.net/project/pyqt/PyQt4/PyQt-4.10.1/PyQt-mac-gpl-4.10.1.tar.gz'
sha1 'cf20699c4db8d3031c19dd51df8857bba1a4956b'
- depends_on 'sip'
- depends_on 'qt'
-
- def install
- ENV.prepend 'PYTHONPATH', "#{HOMEBREW_PREFIX}/lib/#{which_python}/site-packages", ':'
+ depends_on :python => :recommended
+ depends_on :python3 => :optional
- system "python", "./configure.py", "--confirm-license",
- "--bindir=#{bin}",
- "--destdir=#{lib}/#{which_python}/site-packages",
- "--sipdir=#{share}/sip"
- system "make"
- system "make install"
- end
+ depends_on 'sip' => ['with-python3'] if build.with? 'python3'
+ depends_on 'qt' # From their site: PyQt currently supports Qt v4 and will build against Qt v5
- def caveats; <<-EOS.undent
- For non-homebrew Python, you need to amend your PYTHONPATH like so:
- export PYTHONPATH=#{HOMEBREW_PREFIX}/lib/#{which_python}/site-packages:$PYTHONPATH
- EOS
+ def install
+ python do
+ system python, "./configure.py", "--confirm-license",
+ "--bindir=#{bin}#{python.if3then3}",
+ "--destdir=#{lib}/#{python.xy}/site-packages",
+ "--sipdir=#{share}/sip#{python.if3then3}"
+ system "make"
+ system "make install"
+ system "make clean" # because this python block may be run twice
+ end
+
+ if python3
+ # These tools need a unique suffix for python3.
+ ['pyuic4', 'pyrcc4', 'pylupdate4'].each { |f| mv(prefix/"bin3/#{f}", bin/"#{f}-py3")}
+ rm_rf prefix/'bin3'
+ end
end
- def which_python
- "python" + `python -c 'import sys;print(sys.version[:3])'`.strip
+ def caveats
+ python.standard_caveats if python
end
test do
- ENV.prepend 'PYTHONPATH', "#{HOMEBREW_PREFIX}/lib/#{which_python}/site-packages", ':'
-
- # Reference: http://zetcode.com/tutorials/pyqt4/firstprograms/
- (testpath/'test.py').write <<-EOS.undent
- #!/usr/bin/env python
+ python do
+ # Todo: For brew-test-bot we need to add a timer that quits after 1 s or so.
- import sys
- from PyQt4 import QtGui, QtCore
+ # Reference: http://zetcode.com/tutorials/pyqt4/firstprograms/
+ (testpath/'test.py').write <<-EOS.undent
+ import sys
+ from PyQt4 import QtGui, QtCore
- class QuitButton(QtGui.QWidget):
- def __init__(self, parent=None):
- QtGui.QWidget.__init__(self, parent)
+ class QuitButton(QtGui.QWidget):
+ def __init__(self, parent=None):
+ QtGui.QWidget.__init__(self, parent)
- self.setGeometry(300, 300, 250, 150)
- self.setWindowTitle('Quit button')
+ self.setGeometry(300, 300, 250, 150)
+ self.setWindowTitle('Quit button')
- quit = QtGui.QPushButton('Close', self)
- quit.setGeometry(10, 10, 60, 35)
+ quit = QtGui.QPushButton('Close', self)
+ quit.setGeometry(10, 10, 60, 35)
- self.connect(quit, QtCore.SIGNAL('clicked()'),
- QtGui.qApp, QtCore.SLOT('quit()'))
+ self.connect(quit, QtCore.SIGNAL('clicked()'),
+ QtGui.qApp, QtCore.SLOT('quit()'))
- app = QtGui.QApplication(sys.argv)
- qb = QuitButton()
- qb.show()
- app.exec_()
- sys.exit(0)
- EOS
+ app = QtGui.QApplication(sys.argv)
+ qb = QuitButton()
+ qb.show()
+ app.exec_()
+ sys.exit(0)
+ EOS
- system "python", "test.py"
+ system python, "test.py"
+ rm testpath/'test.py'
+ end
end
end
diff --git a/Library/Formula/pyqwt.rb b/Library/Formula/pyqwt.rb
index a907d2ac5..57fb0e4dd 100644
--- a/Library/Formula/pyqwt.rb
+++ b/Library/Formula/pyqwt.rb
@@ -5,6 +5,7 @@ class Pyqwt < Formula
url 'http://sourceforge.net/projects/pyqwt/files/pyqwt5/PyQwt-5.2.0/PyQwt-5.2.0.tar.gz'
sha1 '797f37c63dec660272f6a8ccfd16a017df0ad640'
+ depends_on :python => :recommended
depends_on 'qt'
depends_on 'qwt'
depends_on 'sip'
@@ -13,33 +14,32 @@ class Pyqwt < Formula
def patches
# Patch to build system to allow for specific
# installation directories.
- {:p0 => DATA}
+ { :p0 => DATA }
end
def install
cd "configure" do
- system "python",
- "configure.py",
- "--module-install-path=#{lib}/#{which_python}/site-packages/PyQt4/Qwt5",
- "--sip-install-path=#{share}/sip/Qwt5",
- "--uic-install-path=#{lib}/#{which_python}/site-packages/PyQt4",
- "-Q", "../qwt-5.2"
- system "make install"
+ python do
+ system python,
+ "configure.py",
+ "--module-install-path=#{lib}/#{python.xy}/site-packages/PyQt4/Qwt5",
+ "--sip-install-path=#{share}/sip#{python.if3then3}/Qwt5",
+ "--uic-install-path=#{lib}/#{python.xy}/site-packages/PyQt4",
+ "-Q", "../qwt-5.2"
+ system "make install"
+ system 'make clean'
+ end
end
end
- def caveats; <<-EOS.undent
- For non-homebrew Python, you need to amend your PYTHONPATH like so:
- export PYTHONPATH=#{HOMEBREW_PREFIX}/lib/#{which_python}/site-packages:$PYTHONPATH
- EOS
- end
-
- def which_python
- "python" + `python -c 'import sys;print(sys.version[:3])'`.strip
+ def caveats
+ python.standard_caveats if python
end
def test
- system "python", "-c", "from PyQt4 import Qwt5 as Qwt"
+ python do
+ system python, "-c", "from PyQt4 import Qwt5 as Qwt"
+ end
end
end
diff --git a/Library/Formula/pyside-tools.rb b/Library/Formula/pyside-tools.rb
index ca1563663..5918ba2dd 100644
--- a/Library/Formula/pyside-tools.rb
+++ b/Library/Formula/pyside-tools.rb
@@ -6,15 +6,28 @@ class PysideTools < Formula
sha1 'f654553bc9bfb35dbc5673da26830969393f9fe8'
depends_on 'cmake' => :build
-
+ depends_on :python => :recommended
+ depends_on :python3 => :optional
depends_on 'pyside'
- def which_python
- "python" + `python -c 'import sys;print(sys.version[:3])'`.strip
+ def install
+ python do
+ args = std_cmake_args
+ args << "-DSITE_PACKAGE=#{lib}/#{python.xy}/site-packages"
+ # The next two lines are because pyside needs this to switch Python
+ # versions in HOMEBREW_PREFIX/lib/cmake/PySide-X.Y.Z/PySideConfig.cmake
+ args << "-DPYTHON_BASENAME=-python2.7" if python2
+ args << "-DPYTHON_BASENAME=.cpython-33m" if python3
+ # And these two lines are because the ShibokenConfig.cmake needs this to
+ # switch python versions. The price for supporting both versions:
+ args << "-DPYTHON_SUFFIX='-python2.7'" if python2
+ args << "-DPYTHON_SUFFIX='.cpython-33m'" if python3
+ system "cmake", ".", *args
+ system "make install"
+ end
end
- def install
- system "cmake", ".", "-DSITE_PACKAGE=lib/#{which_python}/site-packages", *std_cmake_args
- system "make install"
+ def caveats
+ python.standard_caveats if python
end
end
diff --git a/Library/Formula/pyside.rb b/Library/Formula/pyside.rb
index 25b8f7c1e..87d3b8d2c 100644
--- a/Library/Formula/pyside.rb
+++ b/Library/Formula/pyside.rb
@@ -7,42 +7,39 @@ class Pyside < Formula
sha1 'c0119775f2500e48efebdd50b7be7543e71b2c24'
depends_on 'cmake' => :build
- depends_on 'shiboken'
-
- def which_python
- "python" + `python -c 'import sys;print(sys.version[:3])'`.strip
- end
+ depends_on :python => :recommended
+ depends_on :python3 => :optional
+ depends_on 'shiboken' => '--with-python3' if build.with? 'python3'
+ depends_on 'qt'
def install
- # The build will be unable to find Qt headers buried inside frameworks
- # unless the folder containing those frameworks is added to the compiler
- # search path.
- qt = Formula.factory 'qt'
- ENV.append_to_cflags "-F#{qt.frameworks}"
-
- # Also need `ALTERNATIVE_QT_INCLUDE_DIR` to prevent "missing file" errors.
- # Add out of tree build because one of its deps, shiboken, itself needs an
- # out of tree build in shiboken.rb.
- args = std_cmake_args + %W[
- -DALTERNATIVE_QT_INCLUDE_DIR=#{qt.frameworks}
- -DSITE_PACKAGE=lib/#{which_python}/site-packages
- -DBUILD_TESTS=NO
- ..
- ]
- mkdir 'macbuild' do
- system 'cmake', *args
- system 'make'
- system 'make install'
+ python do
+ # Add out of tree build because one of its deps, shiboken, itself needs an
+ # out of tree build in shiboken.rb.
+ mkdir "macbuild#{python.if3then3}" do
+ args = std_cmake_args + %W[
+ -DSITE_PACKAGE=#{lib}/#{python.xy}/site-packages
+ -DALTERNATIVE_QT_INCLUDE_DIR=#{Formula.factory('qt').frameworks}
+ -DBUILD_TESTS=NO
+ ..
+ ]
+ # The next two lines are because shiboken needs them
+ args << "-DPYTHON_SUFFIX='-python2.7'" if python2
+ args << "-DPYTHON_SUFFIX='.cpython-33m'" if python3
+ system 'cmake', *args
+ system 'make'
+ system 'make install'
+ # Todo: How to deal with pyside.pc file? It doesn't support 2.x and 3.x!
+ end
end
end
- def caveats
- <<-EOS
-PySide Python modules have been linked to:
- #{HOMEBREW_PREFIX}/lib/#{which_python}/site-packages
+ def test
+ system 'python', '-c', "from PySide import QtCore" if Tab.for_formula('Pyside').with? 'python'
+ system 'python3', '-c', "from PySide import QtCore" if Tab.for_formula('Pyside').with? 'python3'
+ end
-Make sure this folder is on your PYTHONPATH. For PySide development tools,
-install the `pyside-tools` formula.
- EOS
+ def caveats
+ python.standard_caveats if python
end
end
diff --git a/Library/Formula/python.rb b/Library/Formula/python.rb
index 7cba22722..4003cd30d 100644
--- a/Library/Formula/python.rb
+++ b/Library/Formula/python.rb
@@ -49,17 +49,11 @@ class Python < Formula
HOMEBREW_PREFIX/"lib/python2.7/site-packages"
end
- # Where distribute/pip will install executable scripts.
- def scripts_folder
- HOMEBREW_PREFIX/"share/python"
- end
-
def install
opoo 'The given option --with-poll enables a somewhat broken poll() on OS X (http://bugs.python.org/issue5154).' if build.include? 'with-poll'
# Unset these so that installing pip and distribute puts them where we want
# and not into some other Python the user has installed.
- ENV['PYTHONPATH'] = nil
ENV['PYTHONHOME'] = nil
args = %W[
@@ -85,7 +79,19 @@ class Python < Formula
end
# Allow sqlite3 module to load extensions: http://docs.python.org/library/sqlite3.html#f1
- inreplace "setup.py", 'sqlite_defines.append(("SQLITE_OMIT_LOAD_EXTENSION", "1"))', ''
+ inreplace("setup.py", 'sqlite_defines.append(("SQLITE_OMIT_LOAD_EXTENSION", "1"))', '') if build.with? 'sqlite'
+
+ # Allow python modules to use ctypes.find_library to find homebrew's stuff
+ # even if homebrew is not a /usr/local/lib. Try this with:
+ # `brew install enchant && pip install pyenchant`
+ inreplace "./Lib/ctypes/macholib/dyld.py" do |f|
+ f.gsub! 'DEFAULT_LIBRARY_FALLBACK = [', "DEFAULT_LIBRARY_FALLBACK = [ '#{HOMEBREW_PREFIX}/lib',"
+ f.gsub! 'DEFAULT_FRAMEWORK_FALLBACK = [', "DEFAULT_FRAMEWORK_FALLBACK = [ '#{HOMEBREW_PREFIX}/Frameworks',"
+ end
+
+ # Fix http://bugs.python.org/issue18071
+ inreplace "./Lib/_osx_support.py", "compiler_so = list(compiler_so)",
+ "if isinstance(compiler_so, (str,unicode)): compiler_so = compiler_so.split()"
system "./configure", *args
@@ -103,89 +109,59 @@ class Python < Formula
system "make", "frameworkinstallextras", "PYTHONAPPSDIR=#{share}/python"
system "make", "quicktest" if build.include? 'quicktest'
- # Post-install, fix up the site-packages and install-scripts folders
- # so that user-installed Python software survives minor updates, such
- # as going from 2.7.0 to 2.7.1:
+ # Post-install, fix up the site-packages so that user-installed Python
+ # software survives minor updates, such as going from 2.7.0 to 2.7.1:
# Remove the site-packages that Python created in its Cellar.
site_packages_cellar.rmtree
- # Create a site-packages in HOMEBREW_PREFIX/lib/python/site-packages
+ # Create a site-packages in HOMEBREW_PREFIX/lib/python2.7/site-packages
site_packages.mkpath
# Symlink the prefix site-packages into the cellar.
ln_s site_packages, site_packages_cellar
- # Teach python not to use things from /System
- # and tell it about the correct site-package dir because we moved it
- sitecustomize = site_packages_cellar/"sitecustomize.py"
- rm sitecustomize if File.exist? sitecustomize
- sitecustomize.write <<-EOF.undent
- # This file is created by `brew install python` and is executed on each
- # python startup. Don't print from here, or else universe will collapse.
- import sys
- import site
-
- # Only do fix 1 and 2, if the currently run python is a brewed one.
- if sys.executable.startswith('#{HOMEBREW_PREFIX}'):
- # Fix 1)
- # A setuptools.pth and/or easy-install.pth sitting either in
- # /Library/Python/2.7/site-packages or in
- # ~/Library/Python/2.7/site-packages can inject the
- # /System's Python site-packages. People then report
- # "OSError: [Errno 13] Permission denied" because pip/easy_install
- # attempts to install into
- # /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
- # See: https://github.com/mxcl/homebrew/issues/14712
- sys.path = [ p for p in sys.path if not p.startswith('/System') ]
-
- # Fix 2)
- # Remove brewed Python's hard-coded site-packages
- if '#{site_packages_cellar}' in sys.path:
- sys.path.remove('#{site_packages_cellar}')
-
- # Fix 3)
- # For all Pythons: Tell about homebrew's site-packages location.
- # This is needed for Python to parse *.pth files.
- site.addsitedir('#{site_packages}')
- EOF
-
- # Install distribute and pip
- # It's important to have these installers in our bin, because some users
- # forget to put #{script_folder} in PATH, then easy_install'ing
- # into /Library/Python/X.Y/site-packages with /usr/bin/easy_install.
- mkdir_p scripts_folder unless scripts_folder.exist?
- setup_args = ["-s", "setup.py", "--no-user-cfg", "install", "--force", "--verbose", "--install-lib=#{site_packages_cellar}", "--install-scripts=#{bin}"]
- Distribute.new.brew { system "#{bin}/python", *setup_args }
- Pip.new.brew { system "#{bin}/python", *setup_args }
-
- # Tell distutils-based installers where to put scripts and python modules
- (prefix/"Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/distutils.cfg").write <<-EOF.undent
+ # Write our sitecustomize.py to tell python about the correct site-package
+ # dir because we moved it.
+ # We reuse the PythonInstalled requirement here for the sitecustomize.py
+ PythonInstalled.new("2.7").modify_build_environment
+ # We ship distribute and pip.
+ # Our modify_build_environment need the opt/python already now, so we
+ # create it temporarily
+ (HOMEBREW_PREFIX/'opt/python/bin/python2').mkpath
+ ln_s bin/'python2', HOMEBREW_PREFIX/'opt/python/bin/python2'
+ setup_args = [ "-s", "setup.py", "--no-user-cfg", "install", "--force", "--verbose",
+ "--install-scripts=#{bin}", "--install-lib=#{site_packages}" ]
+ Distribute.new.brew { system "#{bin}/python2.7", *setup_args }
+ Pip.new.brew { system "#{bin}/python2.7", *setup_args }
+ (HOMEBREW_PREFIX/'opt/python').rmtree
+
+ # And now we write the distuitsl.cfg
+ cfg = prefix/"Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/distutils.cfg"
+ cfg.delete if cfg.exist?
+ cfg.write <<-EOF.undent
+ [global]
+ verbose=1
[install]
- install-scripts=#{scripts_folder}
- install-lib=#{site_packages}
+ force=1
+ prefix=#{HOMEBREW_PREFIX}
EOF
- # Work-around this bug: http://bugs.python.org/issue18050
- inreplace "#{prefix}/Frameworks/Python.framework/Versions/2.7/lib/python2.7/re.py", 'import sys', <<-EOS.undent
- import sys
- try:
- from _sre import MAXREPEAT
- except ImportError:
- import _sre
- _sre.MAXREPEAT = 65535 # this monkey-patches all other places of "from _sre import MAXREPEAT"'
- EOS
-
- makefile = prefix/'Frameworks/Python.framework/Versions/2.7/lib/python2.7/config/Makefile'
- inreplace makefile do |s|
- unless MacOS::CLT.installed?
- s.gsub!(/^CC=.*$/, "CC=xcrun clang")
- s.gsub!(/^CXX=.*$/, "CXX=xcrun clang++")
- s.gsub!(/^AR=.*$/, "AR=xcrun ar")
- s.gsub!(/^RANLIB=.*$/, "RANLIB=xcrun ranlib")
- end
- # Should be fixed regardless of CLT (for `python-config --ldflags`)
- s.gsub!(/^PYTHONFRAMEWORKDIR=\tPython\.framework/, "PYTHONFRAMEWORKDIR= #{opt_prefix}/Frameworks/Python.framework")
- end
-
+ # Work-around this bug: http://bugs.python.org/issue18050
+ inreplace "#{prefix}/Frameworks/Python.framework/Versions/2.7/lib/python2.7/re.py", 'import sys', <<-EOS.undent
+ import sys
+ try:
+ from _sre import MAXREPEAT
+ except ImportError:
+ import _sre
+ _sre.MAXREPEAT = 65535 # this monkey-patches all other places of "from _sre import MAXREPEAT"'
+ EOS
+
+ # Write our sitecustomize.py to tell python about the correct site-package
+ # dir because we moved it. (Note, we had to install distribute and pip
+ # without the help of sitecustomize.py because HOMEBREW_PREFIX/opt/python
+ # is not yet linked)
+ # We reuse the PythonInstalled requirement here for the sitecustomize.py
+ ENV.prepend_path 'PATH', bin
+ PythonInstalled.new("2.7").modify_build_environment
end
def distutils_fix_superenv(args)
@@ -246,9 +222,6 @@ class Python < Formula
def caveats
<<-EOS.undent
- Homebrew's Python framework
- #{prefix}/Frameworks/Python.framework
-
Python demo
#{HOMEBREW_PREFIX}/share/python/Extras
@@ -265,10 +238,6 @@ class Python < Formula
They will install into the site-package directory
#{site_packages}
- Executable python scripts will be put in:
- #{scripts_folder}
- so you may want to put "#{scripts_folder}" in your PATH, too.
-
See: https://github.com/mxcl/homebrew/wiki/Homebrew-and-Python
EOS
end
diff --git a/Library/Formula/python3.rb b/Library/Formula/python3.rb
index e3e80211c..df7926625 100644
--- a/Library/Formula/python3.rb
+++ b/Library/Formula/python3.rb
@@ -15,22 +15,27 @@ class Pip < Formula
sha1 '9c70d314e5dea6f41415af814056b0f63c3ffd14'
end
-
class Python3 < Formula
homepage 'http://www.python.org/'
url 'http://python.org/ftp/python/3.3.2/Python-3.3.2.tar.bz2'
sha1 'b28c36a9752b690059dc6df4fb9b4ec9d6c5708a'
VER='3.3' # The <major>.<minor> is used so often.
+ option :universal
+ option 'quicktest', 'Run `make quicktest` after the build'
+ option 'with-brewed-openssl', "Use Homebrew's openSSL instead of the one from OS X"
+ option 'with-brewed-tk', "Use Homebrew's Tk (has optional Cocoa and threads support)"
+
depends_on 'pkg-config' => :build
depends_on 'readline' => :recommended
depends_on 'sqlite' => :recommended
depends_on 'gdbm' => :recommended
depends_on 'openssl' if build.include? 'with-brewed-openssl'
+ depends_on 'homebrew/dupes/tcl-tk' if build.include? 'with-brewed-tk'
- option :universal
- option 'quicktest', 'Run `make quicktest` after the build'
- option 'with-brewed-openssl', "Use Homebrew's openSSL instead of the one from OS X"
+ def patches
+ DATA if build.include? 'with-brewed-tk'
+ end
def site_packages_cellar
prefix/"Frameworks/Python.framework/Versions/#{VER}/lib/python#{VER}/site-packages"
@@ -41,15 +46,6 @@ class Python3 < Formula
HOMEBREW_PREFIX/"lib/python#{VER}/site-packages"
end
- # Where distribute/pip will install executable scripts.
- def scripts_folder
- HOMEBREW_PREFIX/"share/python3"
- end
-
- def effective_lib
- prefix/"Frameworks/Python.framework/Versions/#{VER}/lib"
- end
-
fails_with :llvm do
build '2336'
cause <<-EOS.undent
@@ -66,7 +62,6 @@ class Python3 < Formula
def install
# Unset these so that installing pip and distribute puts them where we want
# and not into some other Python the user has installed.
- ENV['PYTHONPATH'] = nil
ENV['PYTHONHOME'] = nil
args = %W[
@@ -78,21 +73,27 @@ class Python3 < Formula
args << '--without-gcc' if ENV.compiler == :clang
+ if superenv?
+ distutils_fix_superenv(args)
+ else
+ distutils_fix_stdenv
+ end
+
if build.universal?
ENV.universal_binary
args << "--enable-universalsdk" << "--with-universal-archs=intel"
end
- distutils_fix_superenv(args)
- distutils_fix_stdenv
-
- # Python does not need all of X11, these bundled Headers are enough
- unless MacOS::CLT.installed?
- ENV.append 'CPPFLAGS', "-I#{MacOS.sdk_path}/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers"
- end
-
# Allow sqlite3 module to load extensions: http://docs.python.org/library/sqlite3.html#f1
- inreplace "setup.py", 'sqlite_defines.append(("SQLITE_OMIT_LOAD_EXTENSION", "1"))', 'pass'
+ inreplace("setup.py", 'sqlite_defines.append(("SQLITE_OMIT_LOAD_EXTENSION", "1"))', 'pass') if build.with? 'sqlite'
+
+ # Allow python modules to use ctypes.find_library to find homebrew's stuff
+ # even if homebrew is not a /usr/local/lib. Try this with:
+ # `brew install enchant && pip install pyenchant`
+ inreplace "./Lib/ctypes/macholib/dyld.py" do |f|
+ f.gsub! 'DEFAULT_LIBRARY_FALLBACK = [', "DEFAULT_LIBRARY_FALLBACK = [ '#{HOMEBREW_PREFIX}/lib',"
+ f.gsub! 'DEFAULT_FRAMEWORK_FALLBACK = [', "DEFAULT_FRAMEWORK_FALLBACK = [ '#{HOMEBREW_PREFIX}/Frameworks',"
+ end
system "./configure", *args
@@ -122,32 +123,36 @@ class Python3 < Formula
# Symlink the prefix site-packages into the cellar.
ln_s site_packages, site_packages_cellar
- # Teach python not to use things from /System
- # and tell it about the correct site-package dir because we moved it
- sitecustomize = site_packages_cellar/"sitecustomize.py"
- rm sitecustomize if File.exist? sitecustomize
- sitecustomize.write(sitecustomize_content)
-
# "python3" and executable is forgotten for framework builds.
# Make sure homebrew symlinks it to HOMEBREW_PREFIX/bin.
ln_s "#{bin}/python#{VER}", "#{bin}/python3" unless (bin/"python3").exist?
- # Install distribute for python3 and assure there's no name clash
+ # Install distribute and pip for python3 and assure there's no name clash
# with what the python (2.x) formula installs.
- scripts_folder.mkpath
- setup_args = ["-s", "setup.py", "install", "--force", "--verbose", "--install-lib=#{site_packages_cellar}", "--install-scripts=#{bin}"]
+ ENV['PYTHONPATH'] = site_packages
+ setup_args = ["-s", "setup.py", "install", "--force", "--verbose",
+ "--install-scripts=#{bin}", "--install-lib=#{site_packages}" ]
Distribute.new.brew { system "#{bin}/python#{VER}", *setup_args }
mv bin/'easy_install', bin/'easy_install3'
Pip.new.brew { system "#{bin}/python#{VER}", *setup_args }
mv bin/'pip', bin/'pip3'
- # Tell distutils-based installers where to put scripts
- (prefix/"Frameworks/Python.framework/Versions/#{VER}/lib/python#{VER}/distutils/distutils.cfg").write <<-EOF.undent
+ # And now we write the distuitsl.cfg
+ cfg = prefix/"Frameworks/Python.framework/Versions/#{VER}/lib/python#{VER}/distutils/distutils.cfg"
+ cfg.delete if cfg.exist?
+ cfg.write <<-EOF.undent
+ [global]
+ verbose=1
[install]
- install-scripts=#{scripts_folder}
- install-lib=#{site_packages}
+ prefix=#{HOMEBREW_PREFIX}
EOF
+ # Write our sitecustomize.py and distutils.cfg to tell python about the
+ # correct site-package dir because we moved it.
+ # We reuse the PythonInstalled requirement here.
+ ENV.prepend_path 'PATH', bin
+ PythonInstalled.new(VER).modify_build_environment
+
unless MacOS::CLT.installed?
makefile = prefix/"Frameworks/Python.framework/Versions/#{VER}/lib/python#{VER}/config-#{VER}m/Makefile"
inreplace makefile do |s|
@@ -158,102 +163,64 @@ class Python3 < Formula
end
end
- # A temporary fix, until a homebrew
- # [issue on handling Frameworks](https://github.com/mxcl/homebrew/issues/15943)
- # is resolved. `brew install python python3` failed to link because both
- # provide `Python.framework`. Homebrew will need to be smarter about this,
- # since Frameworks are built to support multiple versions.
+ # A fix, because python and python3 both want to install Python.framework
+ # https://github.com/mxcl/homebrew/issues/15943
["Headers", "Python", "Resources"].each{ |f| rm(prefix/"Frameworks/Python.framework/#{f}") }
end
def distutils_fix_superenv(args)
- if superenv?
- # To allow certain Python bindings to find brewed software:
- cflags = "CFLAGS=-I#{HOMEBREW_PREFIX}/include -I#{Formula.factory('sqlite').opt_prefix}/include"
- ldflags = "LDFLAGS=-L#{HOMEBREW_PREFIX}/lib -L#{Formula.factory('sqlite').opt_prefix}/lib"
- unless MacOS::CLT.installed?
- # Help Python's build system (distribute/pip) to build things on Xcode-only systems
- # The setup.py looks at "-isysroot" to get the sysroot (and not at --sysroot)
- cflags += " -isysroot #{MacOS.sdk_path}"
- ldflags += " -isysroot #{MacOS.sdk_path}"
- # Same zlib.h-not-found-bug as in env :std (see below)
- args << "CPPFLAGS=-I#{MacOS.sdk_path}/usr/include"
+ # To allow certain Python bindings to find brewed software:
+ cflags = "CFLAGS=-I#{HOMEBREW_PREFIX}/include -I#{Formula.factory('sqlite').opt_prefix}/include"
+ ldflags = "LDFLAGS=-L#{HOMEBREW_PREFIX}/lib -L#{Formula.factory('sqlite').opt_prefix}/lib"
+ unless MacOS::CLT.installed?
+ # Help Python's build system (distribute/pip) to build things on Xcode-only systems
+ # The setup.py looks at "-isysroot" to get the sysroot (and not at --sysroot)
+ cflags += " -isysroot #{MacOS.sdk_path}"
+ ldflags += " -isysroot #{MacOS.sdk_path}"
+ # Same zlib.h-not-found-bug as in env :std (see below)
+ args << "CPPFLAGS=-I#{MacOS.sdk_path}/usr/include"
+ unless build.include? 'with-brewed-tk'
+ cflags += " -I#{MacOS.sdk_path}/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers"
end
- args << cflags
- args << ldflags
- # Avoid linking to libgcc http://code.activestate.com/lists/python-dev/112195/
- args << "MACOSX_DEPLOYMENT_TARGET=#{MacOS.version}"
- # We want our readline! This is just to outsmart the detection code,
- # superenv makes cc always find includes/libs!
- inreplace "setup.py",
- "do_readline = self.compiler.find_library_file(lib_dirs, 'readline')",
- "do_readline = '#{HOMEBREW_PREFIX}/opt/readline/lib/libhistory.dylib'"
end
+ args << cflags
+ args << ldflags
+ # Avoid linking to libgcc http://code.activestate.com/lists/python-dev/112195/
+ args << "MACOSX_DEPLOYMENT_TARGET=#{MacOS.version}"
+ # We want our readline! This is just to outsmart the detection code,
+ # superenv makes cc always find includes/libs!
+ inreplace "setup.py",
+ "do_readline = self.compiler.find_library_file(lib_dirs, 'readline')",
+ "do_readline = '#{HOMEBREW_PREFIX}/opt/readline/lib/libhistory.dylib'"
end
def distutils_fix_stdenv()
- if not superenv?
- # Python scans all "-I" dirs but not "-isysroot", so we add
- # the needed includes with "-I" here to avoid this err:
- # building dbm using ndbm
- # error: /usr/include/zlib.h: No such file or directory
- ENV.append 'CPPFLAGS', "-I#{MacOS.sdk_path}/usr/include" unless MacOS::CLT.installed?
-
- # Don't use optimizations other than "-Os" here, because Python's distutils
- # remembers (hint: `python3-config --cflags`) and reuses them for C
- # extensions which can break software (such as scipy 0.11 fails when
- # "-msse4" is present.)
- ENV.minimal_optimization
-
- # We need to enable warnings because the configure.in uses -Werror to detect
- # "whether gcc supports ParseTuple" (https://github.com/mxcl/homebrew/issues/12194)
- ENV.enable_warnings
- if ENV.compiler == :clang
- # http://docs.python.org/devguide/setup.html#id8 suggests to disable some Warnings.
- ENV.append_to_cflags '-Wno-unused-value'
- ENV.append_to_cflags '-Wno-empty-body'
- ENV.append_to_cflags '-Qunused-arguments'
- end
+ # Python scans all "-I" dirs but not "-isysroot", so we add
+ # the needed includes with "-I" here to avoid this err:
+ # building dbm using ndbm
+ # error: /usr/include/zlib.h: No such file or directory
+ ENV.append 'CPPFLAGS', "-I#{MacOS.sdk_path}/usr/include" unless MacOS::CLT.installed?
+
+ # Don't use optimizations other than "-Os" here, because Python's distutils
+ # remembers (hint: `python3-config --cflags`) and reuses them for C
+ # extensions which can break software (such as scipy 0.11 fails when
+ # "-msse4" is present.)
+ ENV.minimal_optimization
+
+ # We need to enable warnings because the configure.in uses -Werror to detect
+ # "whether gcc supports ParseTuple" (https://github.com/mxcl/homebrew/issues/12194)
+ ENV.enable_warnings
+ if ENV.compiler == :clang
+ # http://docs.python.org/devguide/setup.html#id8 suggests to disable some Warnings.
+ ENV.append_to_cflags '-Wno-unused-value'
+ ENV.append_to_cflags '-Wno-empty-body'
+ ENV.append_to_cflags '-Qunused-arguments'
end
end
- def sitecustomize_content
- <<-EOF.undent
- # This file is created by `brew install python3` and is executed on each
- # python#{VER} startup. Don't print from here, or else universe will collapse.
- import sys
- import site
-
- # Only do fix 1 and 2, if the currently run python is a brewed one.
- if sys.executable.startswith('#{HOMEBREW_PREFIX}'):
- # Fix 1)
- # A setuptools.pth and/or easy-install.pth sitting either in
- # /Library/Python/2.7/site-packages or in
- # ~/Library/Python/2.7/site-packages can inject the
- # /System's Python site-packages. People then report
- # "OSError: [Errno 13] Permission denied" because pip/easy_install
- # attempts to install into
- # /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
- # See: https://github.com/mxcl/homebrew/issues/14712
- sys.path = [ p for p in sys.path if not p.startswith('/System') ]
-
- # Fix 2)
- # Remove brewed Python's hard-coded site-packages
- sys.path.remove('#{site_packages_cellar}')
-
- # Fix 3)
- # For all Pythons: Tell about homebrew's site-packages location.
- # This is needed for Python to parse *.pth files.
- site.addsitedir('#{site_packages}')
- EOF
- end
-
def caveats
text = <<-EOS.undent
- Homebrew's Python3 framework
- #{prefix}/Frameworks/Python.framework
-
Distribute and Pip have been installed. To update them
pip3 install --upgrade distribute
pip3 install --upgrade pip
@@ -266,9 +233,6 @@ class Python3 < Formula
They will install into the site-package directory
#{site_packages}
- Executable python scripts will be put in:
- #{scripts_folder}
- so you may want to put "#{scripts_folder}" in your PATH, too.
See: https://github.com/mxcl/homebrew/wiki/Homebrew-and-Python
EOS
@@ -289,6 +253,25 @@ class Python3 < Formula
# and it can occur that building sqlite silently fails if OSX's sqlite is used.
system "#{bin}/python#{VER}", "-c", "import sqlite3"
# Check if some other modules import. Then the linked libs are working.
- system "#{bin}/python#{VER}", "-c", "import tkinter"
+ system "#{bin}/python#{VER}", "-c", "import tkinter; root = tkinter.Tk()"
end
end
+
+__END__
+diff --git a/setup.py b/setup.py
+index 9ddf2e9..60ab152 100644
+--- a/setup.py
++++ b/setup.py
+@@ -1624,9 +1624,9 @@ class PyBuildExt(build_ext):
+ # Rather than complicate the code below, detecting and building
+ # AquaTk is a separate method. Only one Tkinter will be built on
+ # Darwin - either AquaTk, if it is found, or X11 based Tk.
+- if (host_platform == 'darwin' and
+- self.detect_tkinter_darwin(inc_dirs, lib_dirs)):
+- return
++ # if (host_platform == 'darwin' and
++ # self.detect_tkinter_darwin(inc_dirs, lib_dirs)):
++ # return
+
+ # Assume we haven't found any of the libraries or include files
+ # The versions with dots are used on Unix, and the versions without
diff --git a/Library/Formula/qscintilla2.rb b/Library/Formula/qscintilla2.rb
index 32fe5ff9d..c47ba3c8f 100644
--- a/Library/Formula/qscintilla2.rb
+++ b/Library/Formula/qscintilla2.rb
@@ -7,9 +7,9 @@ class Qscintilla2 < Formula
depends_on 'pyqt'
depends_on 'sip'
+ depends_on :python
def install
- ENV.prepend 'PYTHONPATH', "#{HOMEBREW_PREFIX}/lib/#{which_python}/site-packages", ':'
cd 'Qt4Qt5' do
inreplace 'qscintilla.pro' do |s|
@@ -24,25 +24,22 @@ class Qscintilla2 < Formula
system "make", "install"
end
- cd 'Python' do
- (share/'sip').mkpath
- system 'python', 'configure.py', "-o", lib, "-n", include,
- "--apidir=#{prefix}/qsci",
- "--destdir=#{lib}/#{which_python}/site-packages/PyQt4",
- "--qsci-sipdir=#{share}/sip",
- "--pyqt-sipdir=#{HOMEBREW_PREFIX}/share/sip"
- system 'make'
- system 'make', 'install'
+ python do
+ cd 'Python' do
+ (share/"sip#{python.if3then3}").mkpath
+ system python, 'configure.py', "-o", lib, "-n", include,
+ "--apidir=#{prefix}/qsci",
+ "--destdir=#{python.site_packages}/PyQt4",
+ "--qsci-sipdir=#{share}/sip#{python.if3then3}",
+ "--pyqt-sipdir=#{HOMEBREW_PREFIX}/share/sip#{python.if3then3}"
+ system 'make'
+ system 'make', 'install'
+ end
end
end
- def caveats; <<-EOS.undent
- For non-Homebrew Python, you need to amend your PYTHONPATH like so:
- export PYTHONPATH=#{HOMEBREW_PREFIX}/lib/#{which_python}/site-packages:$PYTHONPATH
- EOS
+ def caveats
+ python.standard_caveats if python
end
- def which_python
- "python" + `python -c 'import sys;print(sys.version[:3])'`.strip
- end
end
diff --git a/Library/Formula/qwt.rb b/Library/Formula/qwt.rb
index 51ecd45b3..e8aff2b9a 100644
--- a/Library/Formula/qwt.rb
+++ b/Library/Formula/qwt.rb
@@ -17,4 +17,10 @@ class Qwt < Formula
system "make"
system "make install"
end
+
+ def caveats; <<-EOS.undent
+ The qwtmathml library contains code of the MML Widget from the Qt solutions package.
+ Beside the Qwt license you also have to take care of its license.
+ EOS
+ end
end
diff --git a/Library/Formula/rdiff-backup.rb b/Library/Formula/rdiff-backup.rb
index 24521363f..cac452961 100644
--- a/Library/Formula/rdiff-backup.rb
+++ b/Library/Formula/rdiff-backup.rb
@@ -6,20 +6,23 @@ class RdiffBackup < Formula
sha1 '14ffe4f5b46a8a96ded536c1d03ae5e85faae318'
depends_on 'librsync'
+ depends_on :python
def install
# Find the arch for the Python we are building against.
# We remove 'ppc' support, so we can pass Intel-optimized CFLAGS.
- archs = archs_for_command("python")
- archs.remove_ppc!
- archs.delete :x86_64 if Hardware.is_32_bit?
- ENV['ARCHFLAGS'] = archs.as_arch_flags
- system "python", "setup.py", "--librsync-dir=#{prefix}", "build"
+ python do
+ archs = archs_for_command(python.binary)
+ archs.remove_ppc!
+ archs.delete :x86_64 if Hardware.is_32_bit?
+ ENV['ARCHFLAGS'] = archs.as_arch_flags
+ system python, "setup.py", "--librsync-dir=#{python.site_packages}", "build"
+ python.site_packages.install Dir['build/lib.macosx*/rdiff_backup']
+ python.site_packages.install Dir['build/scripts-*/*']
+ man1.install Dir['*.1']
+ bin.install_symlink Dir["#{python.site_packages}/rdiff-backup*"]
+ end
- libexec.install Dir['build/lib.macosx*/rdiff_backup']
- libexec.install Dir['build/scripts-*/*']
- man1.install Dir['*.1']
- bin.install_symlink Dir["#{libexec}/rdiff-backup*"]
end
end
diff --git a/Library/Formula/rubber.rb b/Library/Formula/rubber.rb
index 5f88713ce..8f9e95ac5 100644
--- a/Library/Formula/rubber.rb
+++ b/Library/Formula/rubber.rb
@@ -5,6 +5,8 @@ class Rubber < Formula
url 'http://launchpad.net/rubber/trunk/1.1/+download/rubber-20100306.tar.gz'
sha1 'cd382a19cc9fc65d114456ec9d6b042dc0e65b53'
+ depends_on :python
+
def patches
# Creates missing .in files and adds them to the configure phase
# otherwise rubber modules are not found after install
diff --git a/Library/Formula/scons.rb b/Library/Formula/scons.rb
index 16e8b5f61..a0bea647e 100644
--- a/Library/Formula/scons.rb
+++ b/Library/Formula/scons.rb
@@ -5,23 +5,18 @@ class Scons < Formula
url 'http://downloads.sourceforge.net/scons/scons-2.3.0.tar.gz'
sha1 '728edf20047a9f8a537107dbff8d8f803fd2d5e3'
+ depends_on :python
+
def install
man1.install gzip('scons-time.1', 'scons.1', 'sconsign.1')
- system "/usr/bin/python", "setup.py", "install",
+ python do
+ system python, "setup.py", "install",
"--prefix=#{prefix}",
"--standalone-lib",
# SCons gets handsy with sys.path---`scons-local` is one place it
# will look when all is said and done.
- "--install-lib=#{libexec}/scons-local",
- "--install-scripts=#{bin}",
"--install-data=#{libexec}",
"--no-version-script", "--no-install-man"
-
- # Re-root scripts to libexec so they can import SCons and symlink back into
- # bin. Similar tactics are used in the duplicity formula.
- bin.children.each do |p|
- mv p, "#{libexec}/#{p.basename}.py"
- bin.install_symlink "#{libexec}/#{p.basename}.py" => p.basename
end
end
end
diff --git a/Library/Formula/shiboken.rb b/Library/Formula/shiboken.rb
index 29950a0b4..fe5128d74 100644
--- a/Library/Formula/shiboken.rb
+++ b/Library/Formula/shiboken.rb
@@ -7,48 +7,47 @@ class Shiboken < Formula
sha1 '2ffe9d47a3f536840ed9d7eff766a53040bb2a2e'
depends_on 'cmake' => :build
+ depends_on :python => :recommended
+ depends_on :python3 => :optional
depends_on 'qt'
def install
# Building the tests also runs them. Not building and running tests cuts
- # install time in half. As of 1.1.1 the install fails unless you do an
+ # install time in half. As of 1.1.1 the install fails unless you do an
# out of tree build and put the source dir last in the args.
- mkdir 'macbuild' do
- args = std_cmake_args + %W[
- -DBUILD_TESTS=OFF
- ]
-
-
- python_prefix = `python-config --prefix`.strip
- # Python is actually a library. The libpythonX.Y.dylib points to this lib, too.
- if File.exist? "#{python_prefix}/Python"
- # Python was compiled with --framework:
- args << "-DPYTHON_LIBRARY='#{python_prefix}/Python'"
- if !MacOS::CLT.installed? and python_prefix.start_with? '/System/Library'
- # For Xcode-only systems, the headers of system's python are inside of Xcode
- args << "-DPYTHON_INCLUDE_DIR='#{MacOS.sdk_path}/System/Library/Frameworks/Python.framework/Versions/2.7/Headers'"
- else
- args << "-DPYTHON_INCLUDE_DIR='#{python_prefix}/Headers'"
- end
- else
- python_version = `python-config --libs`.match('-lpython(\d+\.\d+)').captures.at(0)
- python_lib = "#{python_prefix}/lib/libpython#{python_version}"
- if File.exists? "#{python_lib}.a"
- args << "-DPYTHON_LIBRARY='#{python_lib}.a'"
- else
- args << "-DPYTHON_LIBRARY='#{python_lib}.dylib'"
- end
- args << "-DPYTHON_INCLUDE_DIR='#{python_prefix}/include/#{which_python}'"
+ python do
+ # This block will be run for each python (2.x and 3.x if requested)!
+ mkdir "macbuild#{python.if3then3}" do
+ args = std_cmake_args
+ args << "-DBUILD_TESTS=OFF"
+ # For Xcode-only systems, the headers of system's python are inside of Xcode:
+ args << "-DPYTHON#{python.if3then3}_INCLUDE_DIR='#{python.incdir}'"
+ # Cmake picks up the system's python dylib, even if we have a brewed one:
+ args << "-DPYTHON#{python.if3then3}_LIBRARY='#{python.libdir}/lib#{python.xy}.dylib'"
+ args << "-DUSE_PYTHON3=ON" if python3
+ args << '..'
+ system 'cmake', *args
+ system "make install"
+ # To support 2.x and 3.x in parallel, we have to rename shiboken.pc at first
+ mv lib/'pkgconfig/shiboken.pc', lib/"pkgconfig/shiboken-py#{python.version.major}.pc"
end
+ end
+ # Rename shiboken-py2.pc back to the default shiboken.pc
+ mv lib/'pkgconfig/shiboken-py2.pc', lib/'pkgconfig/shiboken.pc' if python2
+ end
-
- args << '..'
- system 'cmake', *args
- system "make install"
+ def caveats
+ if python3
+ <<-EOS.undent
+ If you build software that uses the pkgconfig file, and you want
+ shiboken with Python 3.x support: Please, instead of 'shiboken.pc', use:
+ #{HOMEBREW_PREFIX}/lib/pkgconfig/shiboken-py3.pc
+ EOS
end
end
- def which_python
- "python" + `python -c 'import sys;print(sys.version[:3])'`.strip
+ def test
+ system 'python', "-c", "import shiboken" if Tab.for_formula('Shiboken').with? 'python'
+ system 'python3', "-c", "import shiboken" if Tab.for_formula('Shiboken').with? 'python3'
end
end
diff --git a/Library/Formula/shocco.rb b/Library/Formula/shocco.rb
index c30df7b24..15dac128d 100644
--- a/Library/Formula/shocco.rb
+++ b/Library/Formula/shocco.rb
@@ -32,6 +32,7 @@ class Shocco < Formula
sha1 'e29d58fb8109040b4fb4a816f330bb1c67064f6d'
depends_on MarkdownProvider
+ depends_on :python
def patches
DATA
diff --git a/Library/Formula/sip.rb b/Library/Formula/sip.rb
index 8f4841259..31bb36571 100644
--- a/Library/Formula/sip.rb
+++ b/Library/Formula/sip.rb
@@ -1,12 +1,5 @@
require 'formula'
-# NOTE TO MAINTAINERS:
-#
-# Unless Riverbank policy changes in the future or the Mercurial archive
-# becomes unavailable, *do not use* the SIP download URL from the Riverbank
-# website. This URL will break as soon as a new version of SIP is released
-# which causes panic and terror to flood the Homebrew issue tracker.
-
class Sip < Formula
homepage 'http://www.riverbankcomputing.co.uk/software/sip'
url 'http://download.sf.net/project/pyqt/sip/sip-4.14.6/sip-4.14.6.tar.gz'
@@ -14,85 +7,46 @@ class Sip < Formula
head 'http://www.riverbankcomputing.co.uk/hg/sip', :using => :hg
- def patches; DATA; end if build.head?
+ depends_on :python => :recommended
+ depends_on :python3 => :optional
def install
if build.head?
- # Set fallback version to the same value it would have without the patch
- # and link the Mercurial repository into the download directory so
+ # Link the Mercurial repository into the download directory so
# buid.py can use it to figure out a version number.
- sip_version = "0.1.0"
ln_s downloader.cached_location + '.hg', '.hg'
- inreplace 'build.py', /@SIP_VERSION@/, sip_version.to_s.gsub('.', ',')
- system "python", "build.py", "prepare"
+ system python, "build.py", "prepare"
else
sip_version = version
end
- system "python", "configure.py",
- "--destdir=#{lib}/#{which_python}/site-packages",
- "--bindir=#{bin}",
- "--incdir=#{include}",
- "--sipdir=#{HOMEBREW_PREFIX}/share/sip",
- "CFLAGS=#{ENV.cflags}",
- "LFLAGS=#{ENV.ldflags}"
- system "make install"
- end
+ # The python block is run once for each python (2.x and 3.x if requested)
+ python do
+ # To have sip (for 2.x) and sip3 for python3, we rename the sip binary:
+ inreplace "configure.py", 'os.path.join(opts.sipbindir, "sip")', "os.path.join(opts.sipbindir, 'sip3')" if python3
+
+ # Set --destdir such that the python modules will be in the HOMEBREWPREFIX/lib/pythonX.Y/site-packages
+ system python, "configure.py",
+ "--destdir=#{lib}/#{python.xy}/site-packages",
+ "--bindir=#{bin}",
+ "--incdir=#{include}",
+ "--sipdir=#{HOMEBREW_PREFIX}/share/sip#{python.if3then3}"
+ system "make"
+ if python3
+ bin.mkdir unless bin.exist?
+ bin.install 'sipgen/sip' => 'sip3'
+ end
+ system "make install"
+ system "make clean"
+ end
- def caveats; <<-EOS.undent
- For non-homebrew Python, you need to amend your PYTHONPATH like so:
- export PYTHONPATH=#{HOMEBREW_PREFIX}/lib/#{which_python}/site-packages:$PYTHONPATH
- EOS
end
- def which_python
- "python" + `python -c 'import sys;print(sys.version[:3])'`.strip
+ def caveats
+ s = ''
+ s += python.standard_caveats if python
+ s += "The sip-dir for Python #{python.version.major}.x is #{HOMEBREW_PREFIX}/share/sip#{python.if3then3}."
+ s
end
-end
-
-__END__
-Patch to allow the SIP build.py script to generate a reasonable version number
-for installing from a Mercurial snapshot without the .hg directory from the
-Mercurial repository. The install code hooks on to the @SIP_VERSION@ tag and
-inserts a real version tuple
-
-diff --git a/build.py b/build.py
-index 927d7f1..fdf13a3 100755
---- a/build.py
-+++ b/build.py
-@@ -185,7 +185,7 @@ def _get_release():
- changelog = None
- name = os.path.basename(_RootDir)
-
-- release_suffix = "-unknown"
-+ release_suffix = ""
- version = None
-
- parts = name.split('-')
-@@ -198,7 +198,7 @@ def _get_release():
-
- # Format the results.
- if version is None:
-- version = (0, 1, 0)
-+ version = (@SIP_VERSION@)
-
- major, minor, micro = version
-
-
-Patch to remove the seemingly unnecessary framework build requirement
-diff --git a/siputils.py b/siputils.py
-index 57e8911..1af6152 100644
---- a/siputils.py
-+++ b/siputils.py
-@@ -1485,8 +1485,8 @@ class ModuleMakefile(Makefile):
- # 'real_prefix' exists if virtualenv is being used.
- dl = getattr(sys, 'real_prefix', sys.exec_prefix).split(os.sep)
-
-- if "Python.framework" not in dl:
-- error("SIP requires Python to be built as a framework")
-+ # if "Python.framework" not in dl:
-+ # error("SIP requires Python to be built as a framework")
-
- self.LFLAGS.append("-undefined dynamic_lookup")
-
+end
diff --git a/Library/Formula/subversion.rb b/Library/Formula/subversion.rb
index 0485fbcb5..5c1a87e81 100644
--- a/Library/Formula/subversion.rb
+++ b/Library/Formula/subversion.rb
@@ -8,7 +8,6 @@ class Subversion < Formula
option :universal
option 'java', 'Build Java bindings'
option 'perl', 'Build Perl bindings'
- option 'python', 'Build Python bindings'
option 'ruby', 'Build Ruby bindings'
option 'unicode-path', 'Include support for OS X UTF-8-MAC filename'
@@ -18,12 +17,13 @@ class Subversion < Formula
depends_on 'neon'
depends_on 'sqlite'
depends_on 'serf'
+ depends_on :python => :optional
# Building Ruby bindings requires libtool
depends_on :libtool if build.include? 'ruby'
# If building bindings, allow non-system interpreters
- env :userpaths if (build.include? 'perl') or (build.include? 'python') or (build.include? 'ruby')
+ env :userpaths if (build.include? 'perl') or (build.include? 'ruby')
def patches
ps = []
@@ -43,13 +43,13 @@ class Subversion < Formula
end
end
- # When building Perl, Python or Ruby bindings, need to use a compiler that
+ # When building Perl or Ruby bindings, need to use a compiler that
# recognizes GCC-style switches, since that's what the system languages
# were compiled against.
fails_with :clang do
build 318
cause "core.c:1: error: bad value (native) for -march= switch"
- end if (build.include? 'perl') or (build.include? 'python') or (build.include? 'ruby')
+ end if (build.include? 'perl') or (build.include? 'ruby')
def apr_bin
superbin or "/usr/bin"
@@ -108,7 +108,7 @@ class Subversion < Formula
system "make install"
bash_completion.install 'tools/client-side/bash_completion' => 'subversion'
- if build.include? 'python'
+ python do
system "make swig-py"
system "make install-swig-py"
end
@@ -151,13 +151,7 @@ class Subversion < Formula
def caveats
s = ""
- if build.include? 'python'
- s += <<-EOS.undent
- You may need to add the Python bindings to your PYTHONPATH from:
- #{HOMEBREW_PREFIX}/lib/svn-python
-
- EOS
- end
+ s += python.standard_caveats if python
if build.include? 'perl'
s += <<-EOS.undent
diff --git a/Library/Formula/swatchbooker.rb b/Library/Formula/swatchbooker.rb
index 990980a67..a476300d8 100644
--- a/Library/Formula/swatchbooker.rb
+++ b/Library/Formula/swatchbooker.rb
@@ -5,27 +5,45 @@ class Swatchbooker < Formula
url 'http://launchpad.net/swatchbooker/trunk/0.7.3/+download/SwatchBooker-0.7.3.tar.gz'
sha1 'fd2e46c278e762dc0c3ed69f824ab620773f153e'
+ depends_on :python
depends_on 'little-cms' => 'with-python'
depends_on 'pil'
depends_on 'pyqt'
+ def patches
+ DATA
+ end
+
def install
# Tell launching shell scipts where the python library is
inreplace %w[data/swatchbooker data/sbconvert data/sbconvertor] do |s|
s.gsub! "/usr/lib", "#{HOMEBREW_PREFIX}/lib"
end
- system "python", "setup.py", "build"
- system "python", "setup.py", "install", "--prefix=#{prefix}"
+ python do
+ system python, "setup.py", "install", "--prefix=#{prefix}"
+ end
end
- def caveats; <<-EOS.undent
- For the graphical user interface to work, PyQT requires that you amend your PYTHONPATH:
- export PYTHONPATH=#{HOMEBREW_PREFIX}/lib/python:$PYTHONPATH
- EOS
+ def caveats
+ python.standard_caveats if python
end
def test
system "#{bin}/swatchbooker"
end
end
+
+__END__
+diff --git a/src/swatchbook/color.py b/src/swatchbook/color.py
+index 48ae503..f3511a2 100644
+--- a/src/swatchbook/color.py
++++ b/src/swatchbook/color.py
+@@ -28,7 +28,7 @@ def dirpath(name):
+ if not name:
+ return name
+ elif os.path.islink(name):
+- return os.path.dirname(os.path.abspath(os.path._resolve_link(name)))
++ return os.path.dirname(os.path.abspath(os.path.realpath(name)))
+ else:
+ return os.path.dirname(name)
diff --git a/Library/Formula/swig.rb b/Library/Formula/swig.rb
index 34443dd19..35ca07afd 100644
--- a/Library/Formula/swig.rb
+++ b/Library/Formula/swig.rb
@@ -8,6 +8,8 @@ class Swig < Formula
option :universal
depends_on 'pcre'
+ depends_on :python # assure swig find the "right" python
+ depends_on :python3 => :optional
def install
ENV.universal_binary if build.universal?
diff --git a/Library/Formula/thrift.rb b/Library/Formula/thrift.rb
index 8165795ba..dde090403 100644
--- a/Library/Formula/thrift.rb
+++ b/Library/Formula/thrift.rb
@@ -14,6 +14,7 @@ class Thrift < Formula
option "with-php", "Install Php binding"
depends_on 'boost'
+ depends_on :python => :optional
# Includes are fixed in the upstream. Please remove this patch in the next version > 0.9.0
def patches
@@ -23,17 +24,17 @@ class Thrift < Formula
def install
system "./bootstrap.sh" if build.head?
- exclusions = ["--without-python", "--without-ruby"]
+ exclusions = ["--without-ruby"]
+ exclusions << "--without-python" unless build.with? "python"
exclusions << "--without-haskell" unless build.include? "with-haskell"
exclusions << "--without-java" unless build.include? "with-java"
exclusions << "--without-perl" unless build.include? "with-perl"
exclusions << "--without-php" unless build.include? "with-php"
exclusions << "--without-erlang" unless build.include? "with-erlang"
- # Language bindings try to install outside of Homebrew's prefix, so
- # omit them here. For ruby you can install the gem, and for Python
- # you can use pip or easy_install.
+ ENV["PY_PREFIX"] = prefix # So python bindins don't install to /usr!
+
system "./configure", "--disable-debug",
"--prefix=#{prefix}",
"--libdir=#{lib}",
@@ -43,10 +44,8 @@ class Thrift < Formula
system "make install"
end
- def caveats; <<-EOS.undent
- To install Python bindings:
- pip install thrift
-
+ def caveats
+ s = <<-EOS.undent
To install Ruby bindings:
gem install thrift
@@ -54,7 +53,9 @@ class Thrift < Formula
export PHP_PREFIX=/path/to/homebrew/thrift/0.9.0/php
export PHP_CONFIG_PREFIX=/path/to/homebrew/thrift/0.9.0/php_extensions
brew install thrift --with-php
+
EOS
+ s += python.standard_caveats if python
end
end
__END__
diff --git a/Library/Formula/treeline.rb b/Library/Formula/treeline.rb
index baacda55b..699457605 100644
--- a/Library/Formula/treeline.rb
+++ b/Library/Formula/treeline.rb
@@ -5,10 +5,12 @@ class Treeline < Formula
url 'http://sourceforge.net/projects/treeline/files/1.4.1/treeline-1.4.1.tar.gz'
sha1 'ac5ef60fbb02e2295868134b8e3068c2f905c170'
+ depends_on :python
depends_on 'pyqt'
def install
- ENV.prepend "PYTHONPATH", "#{HOMEBREW_PREFIX}/lib/python"
- system "./install.py", "-p#{prefix}"
+ python do
+ system "./install.py", "-p#{prefix}"
+ end
end
end
diff --git a/Library/Formula/uwsgi.rb b/Library/Formula/uwsgi.rb
index 9017b28d5..9e88c5ba5 100644
--- a/Library/Formula/uwsgi.rb
+++ b/Library/Formula/uwsgi.rb
@@ -5,14 +5,17 @@ class Uwsgi < Formula
url 'https://projects.unbit.it/downloads/uwsgi-1.9.11.tar.gz'
sha1 '2b3d4f225808decb50399b9cdb387e022dd3729d'
+ depends_on :python
depends_on 'pcre'
depends_on 'libyaml'
def install
- arch = MacOS.prefer_64_bit? ? 'x86_64' : 'i386'
- %w{CFLAGS LDFLAGS}.each { |e| ENV.append e, "-arch #{arch}" }
+ python do
+ arch = MacOS.prefer_64_bit? ? 'x86_64' : 'i386'
+ %w{CFLAGS LDFLAGS}.each { |e| ENV.append e, "-arch #{arch}" }
- system "python", "uwsgiconfig.py", "--build"
- bin.install "uwsgi"
+ system python, "uwsgiconfig.py", "--build"
+ bin.install "uwsgi"
+ end
end
end
diff --git a/Library/Formula/vim.rb b/Library/Formula/vim.rb
index d3f5ff2bf..f48ef60a1 100644
--- a/Library/Formula/vim.rb
+++ b/Library/Formula/vim.rb
@@ -7,7 +7,10 @@ class Vim < Formula
sha1 'f308d219dd9c6b56e84109ace4e7487a101088f5'
head 'https://vim.googlecode.com/hg/'
- env :std # To find interpreters
+ # We only have special support for finding depends_on :python, but not yet for
+ # :ruby, :perl etc., so we use the standard environment that leaves the
+ # PATH as the user has set it right now.
+ env :std
depends_on :hg => :build if build.head?
@@ -20,6 +23,9 @@ class Vim < Formula
option "without-#{language}", "Build vim without #{language} support"
end
+ depends_on :python unless build.without? 'python'
+ depends_on :python3 if build.with? 'python3'
+
option "disable-nls", "Build vim without National Language Support (translated messages, keymaps)"
def install
diff --git a/Library/Formula/weechat.rb b/Library/Formula/weechat.rb
index 13ff47a72..33628c24f 100644
--- a/Library/Formula/weechat.rb
+++ b/Library/Formula/weechat.rb
@@ -8,16 +8,13 @@ class Weechat < Formula
depends_on 'cmake' => :build
depends_on 'gnutls'
depends_on 'libgcrypt'
- depends_on 'guile' if build.include? 'guile'
- depends_on 'aspell' if build.include? 'aspell'
- depends_on 'lua' if build.include? 'lua'
+ depends_on 'guile' => :optional
+ depends_on 'aspell' => :optional
+ depends_on 'lua' => :optional
+ depends_on :python => :optional
- option 'lua', 'Build the lua module'
option 'perl', 'Build the perl module'
option 'ruby', 'Build the ruby module'
- option 'guile', 'Build the guile module'
- option 'python', 'Build the python module (requires framework Python)'
- option 'aspell', 'Build the aspell module that checks your spelling'
# cmake finds brewed python when installed, but when searching for the
# libraries it searches for system libraries first. This patch disables
@@ -38,26 +35,15 @@ class Weechat < Formula
%Q{\n STRING(REGEX REPLACE "#{archs}" "" PERL_CFLAGS "${PERL_CFLAGS}")} +
%Q{\n STRING(REGEX REPLACE "#{archs}" "" PERL_LFLAGS "${PERL_LFLAGS}")}
- # FindPython.cmake queries the Python variable LINKFORSHARED which contains
- # a path that only exists during Python install when using HB framework
- # Python. So remove that and use what's common in every install of Python,
- # namely -u _PyMac_Error. Without the invalid path, it links okay.
- # Because Macports and Apple change LINKFORSHARED but HB does not, this
- # will have to persist, and it's not reported upstream. Fixes the error
- # no such file or directory: 'Python.framework/Versions/2.7/Python'
- inreplace 'src/plugins/python/CMakeLists.txt',
- '${PYTHON_LFLAGS}', '-u _PyMac_Error'
-
args = std_cmake_args + %W[
-DPREFIX=#{prefix}
-DENABLE_GTK=OFF
]
- args << '-DENABLE_LUA=OFF' unless build.include? 'lua'
- args << '-DENABLE_PERL=OFF' unless build.include? 'perl'
- args << '-DENABLE_RUBY=OFF' unless build.include? 'ruby'
- args << '-DENABLE_PYTHON=OFF' unless build.include? 'python'
- args << '-DENABLE_ASPELL=OFF' unless build.include? 'aspell'
- args << '-DENABLE_GUILE=OFF' unless build.include? 'guile'
+ args << '-DENABLE_LUA=OFF' unless build.with? 'lua'
+ args << '-DENABLE_PERL=OFF' unless build.with? 'perl'
+ args << '-DENABLE_RUBY=OFF' unless build.with? 'ruby'
+ args << '-DENABLE_ASPELL=OFF' unless build.with? 'aspell'
+ args << '-DENABLE_GUILE=OFF' unless build.with? 'guile'
# NLS/gettext support disabled for now since it doesn't work in stdenv
# see https://github.com/mxcl/homebrew/issues/18722
@@ -65,7 +51,14 @@ class Weechat < Formula
args << '..'
mkdir 'build' do
- system 'cmake', *args
+ if python do
+ system 'cmake', *args
+ end
+ else
+ # The same cmake call but without any python set up.
+ args << '-DENABLE_PYTHON=OFF'
+ system 'cmake', *args
+ end
system 'make install'
end
end
diff --git a/Library/Formula/wireshark.rb b/Library/Formula/wireshark.rb
index 0683fa8b5..1f58d80da 100644
--- a/Library/Formula/wireshark.rb
+++ b/Library/Formula/wireshark.rb
@@ -7,7 +7,6 @@ class Wireshark < Formula
option 'with-x', 'Include X11 support'
option 'with-qt', 'Use QT for GUI instead of GTK+'
- option 'with-python', 'Enable experimental Python bindings'
depends_on 'pkg-config' => :build
depends_on 'gnutls2' => :optional
@@ -15,6 +14,7 @@ class Wireshark < Formula
depends_on 'c-ares' => :optional
depends_on 'pcre' => :optional
depends_on 'qt' => :optional
+ depends_on :python => :optional
depends_on 'glib'
if build.with? 'x'
diff --git a/Library/Formula/wxmac.rb b/Library/Formula/wxmac.rb
index 4abb6ee9c..e65d73276 100644
--- a/Library/Formula/wxmac.rb
+++ b/Library/Formula/wxmac.rb
@@ -2,7 +2,6 @@ require 'formula'
class FrameworkPython < Requirement
fatal true
- env :userpaths
satisfy do
q = `python -c "import distutils.sysconfig as c; print(c.get_config_var('PYTHONFRAMEWORK'))"`
@@ -19,9 +18,8 @@ class Wxmac < Formula
url 'http://sourceforge.net/projects/wxpython/files/wxPython/2.9.4.0/wxPython-src-2.9.4.0.tar.bz2'
sha1 'c292cd45b51e29c558c4d9cacf93c4616ed738b9'
- option 'no-python', 'Do not build Python bindings'
-
- depends_on FrameworkPython unless build.include? "no-python"
+ depends_on :python => :recommended
+ depends_on FrameworkPython if build.with? "python"
def install_wx_python
args = [
@@ -40,15 +38,17 @@ class Wxmac < Formula
cd "wxPython" do
ENV.append_to_cflags '-arch x86_64' if MacOS.prefer_64_bit?
- system "python", "setup.py",
+ python do
+ system python, "setup.py",
"build_ext",
"WXPORT=osx_cocoa",
*args
- system "python", "setup.py",
+ system python, "setup.py",
"install",
"--prefix=#{prefix}",
"WXPORT=osx_cocoa",
*args
+ end
end
end
@@ -77,7 +77,7 @@ class Wxmac < Formula
system "./configure", *args
system "make install"
- unless build.include? "no-python"
+ if build.with? "python"
ENV['WXWIN'] = Dir.getwd
# We have already downloaded wxPython in a bundle with wxWidgets
install_wx_python
@@ -87,7 +87,7 @@ class Wxmac < Formula
def caveats
s = ''
fp = FrameworkPython.new
- unless build.include? 'no-python' or fp.satisfied?
+ unless build.without? 'python' or fp.satisfied?
s += fp.message
end
diff --git a/Library/Formula/xapian.rb b/Library/Formula/xapian.rb
index a15e1a205..d5c4000e9 100644
--- a/Library/Formula/xapian.rb
+++ b/Library/Formula/xapian.rb
@@ -13,13 +13,14 @@ class Xapian < Formula
option "java", "Java bindings"
option "php", "PHP bindings"
- option "python", "Python bindings"
option "ruby", "Ruby bindings"
+ depends_on :python => :optional
+
skip_clean :la
def build_any_bindings?
- build.include? 'ruby' or build.include? 'python' or build.include? 'java' or build.include? 'php'
+ build.include? 'ruby' or build.with? 'python' or build.include? 'java' or build.include? 'php'
end
def install
@@ -51,12 +52,8 @@ class Xapian < Formula
args << '--without-ruby'
end
- if build.include? 'python'
- python_lib = lib/which_python/'site-packages'
- python_lib.mkpath
- ENV.append 'PYTHONPATH', python_lib
- ENV['OVERRIDE_MACOSX_DEPLOYMENT_TARGET'] = '10.4'
- ENV['PYTHON_LIB'] = python_lib
+ if build.with? 'python'
+ ENV['PYTHON_LIB'] = python.site_packages
args << "--with-python"
else
args << "--without-python"
@@ -76,13 +73,7 @@ class Xapian < Formula
def caveats
s = ''
- if build.include? 'python'
- s += <<-EOS.undent
- The Python bindings won't function until you amend your PYTHONPATH like so:
- export PYTHONPATH=#{HOMEBREW_PREFIX}/lib/#{which_python}/site-packages:$PYTHONPATH
-
- EOS
- end
+ s += python.standard_caveats if python
if build.include? 'ruby'
s += <<-EOS.undent
You may need to add the Ruby bindings to your RUBYLIB from:
@@ -93,7 +84,4 @@ class Xapian < Formula
return s.empty? ? nil : s
end
- def which_python
- "python" + `python -c 'import sys;print(sys.version[:3])'`.strip
- end
end
diff --git a/Library/Formula/yasm.rb b/Library/Formula/yasm.rb
index 3751418b7..a0f89fb13 100644
--- a/Library/Formula/yasm.rb
+++ b/Library/Formula/yasm.rb
@@ -7,14 +7,13 @@ class Yasm < Formula
head 'https://github.com/yasm/yasm.git'
- option 'enable-python', 'Enable Python bindings'
-
if build.head?
depends_on 'gettext'
depends_on :automake
end
- depends_on 'Cython' => :python if build.include? 'enable-python'
+ depends_on :python => :optional
+ depends_on 'Cython' => :python if build.with? 'python'
def install
args = %W[
@@ -22,31 +21,18 @@ class Yasm < Formula
--prefix=#{prefix}
]
- if build.include? 'enable-python'
+ if build.with? 'python'
args << '--enable-python'
args << '--enable-python-bindings'
end
- # Avoid "ld: library not found for -lcrt1.10.6.o" on Xcode without CLT
- ENV['LIBS'] = ENV.ldflags
- ENV['INCLUDES'] = ENV.cppflags
system './autogen.sh' if build.head?
system './configure', *args
system 'make install'
end
def caveats
- if build.include? 'enable-python' then <<-EOS.undent
- Python bindings installed to:
- #{HOMEBREW_PREFIX}/lib/#{which_python}/site-packages
-
- For non-homebrew Python, you need to amend your PYTHONPATH like so:
- export PYTHONPATH=#{HOMEBREW_PREFIX}/lib/#{which_python}/site-packages:$PYTHONPATH
- EOS
- end
+ python.standard_caveats if python
end
- def which_python
- 'python' + `python -c 'import sys;print(sys.version[:3])'`.strip
- end
end
diff --git a/Library/Formula/zookeeper.rb b/Library/Formula/zookeeper.rb
index 78cdfd2b4..b35509a80 100644
--- a/Library/Formula/zookeeper.rb
+++ b/Library/Formula/zookeeper.rb
@@ -7,14 +7,15 @@ class Zookeeper < Formula
head 'http://svn.apache.org/repos/asf/zookeeper/trunk'
+ option "c", "Build C bindings."
+ option "perl", "Build Perl bindings."
+
if build.head?
depends_on :automake
depends_on :libtool
end
- option "c", "Build C bindings."
- option "perl", "Build Perl bindings."
- option "python", "Build Python bindings."
+ depends_on :python => :optional
def shim_script target
<<-EOS.undent
@@ -59,9 +60,8 @@ class Zookeeper < Formula
end
end
- build_python = build.include? "python"
build_perl = build.include? "perl"
- build_c = build_python || build_perl || build.include?("c")
+ build_c = build.with?('python') || build_perl || build.include?("c")
# Build & install C libraries.
cd "src/c" do
@@ -72,10 +72,12 @@ class Zookeeper < Formula
end if build_c
# Install Python bindings
- cd "src/contrib/zkpython" do
- system "python", "src/python/setup.py", "build"
- system "python", "src/python/setup.py", "install", "--prefix=#{prefix}"
- end if build_python
+ python do
+ cd "src/contrib/zkpython" do
+ system python, "src/python/setup.py", "build"
+ system python, "src/python/setup.py", "install", "--prefix=#{prefix}"
+ end
+ end
# Install Perl bindings
cd "src/contrib/zkperl" do
diff --git a/Library/Homebrew/build_options.rb b/Library/Homebrew/build_options.rb
index 24c49931f..077a8b3d8 100644
--- a/Library/Homebrew/build_options.rb
+++ b/Library/Homebrew/build_options.rb
@@ -85,4 +85,19 @@ class BuildOptions
def unused_options
Options.new(@options - @args)
end
+
+ # Some options are implicitly ON because they are not explictly turned off
+ # by their counterpart option. This applies only to with-/without- options.
+ # implicit_options are needed because `depends_on 'spam' => 'with-stuff'`
+ # complains if 'spam' has stuff as default and only defines `--without-stuff`.
+ def implicit_options
+ implicit = unused_options.map do |o|
+ if o.name =~ /^with-(.+)$/ && without?($1)
+ Option.new("without-#{$1}") # we loose the description, but that's ok
+ elsif o.name =~ /^without-(.+)$/ && with?($1)
+ Option.new("with-#{$1}")
+ end
+ end.compact
+ Options.new(implicit)
+ end
end
diff --git a/Library/Homebrew/cmd/audit.rb b/Library/Homebrew/cmd/audit.rb
index 6bab71095..99aad1392 100644
--- a/Library/Homebrew/cmd/audit.rb
+++ b/Library/Homebrew/cmd/audit.rb
@@ -148,11 +148,18 @@ class FormulaAuditor
problem <<-EOS.undent unless dep.tags.any? || f.name =~ /automake/ && dep.name == 'autoconf'
#{dep} dependency should be "depends_on '#{dep}' => :build"
EOS
- when "git", "python", "ruby", "emacs", "mysql", "mercurial"
+ when "git", "ruby", "emacs", "mysql", "mercurial"
problem <<-EOS.undent
Don't use #{dep} as a dependency. We allow non-Homebrew
#{dep} installations.
EOS
+ when 'python', 'python2', 'python3'
+ problem <<-EOS.undent
+ Don't use #{dep} as a dependency (string).
+ We have special `depends_on :python` (or :python2 or :python3 )
+ that works with brewed and system Python and allows us to support
+ bindings for 2.x and 3.x in parallel and much more.
+ EOS
when "postgresql"
# Postgis specifically requires a Homebrewed postgresql
unless f.name == "postgis"
@@ -232,7 +239,7 @@ class FormulaAuditor
end
if p =~ %r[^http://prdownloads\.]
- problem "Don't use prdownloads in SourceForge urls (url is #{p}).\n" +
+ problem "Don't use prdownloads in SourceForge urls (url is #{p}).\n" +
"\tSee: http://librelist.com/browser/homebrew/2011/1/12/prdownloads-is-bad/"
end
@@ -249,7 +256,7 @@ class FormulaAuditor
# Check for http:// GitHub repo urls, https:// is preferred.
urls.grep(%r[^http://github\.com/.*\.git$]) do |u|
problem "Use https:// URLs for accessing GitHub repositories (url is #{u})."
- end
+ end
# Use new-style archive downloads
urls.select { |u| u =~ %r[https://.*/(?:tar|zip)ball/] and not u =~ %r[\.git$] }.each do |u|
@@ -427,6 +434,14 @@ class FormulaAuditor
problem "Reference '#{$1}' without dashes"
end
+ if text =~ /build\.with\?\s+['"]-?-?with-(.*)['"]/
+ problem "No double 'with': Use `build.with? '#{$1}'` to check for \"--with-#{$1}\""
+ end
+
+ if text =~ /build\.without\?\s+['"]-?-?without-(.*)['"]/
+ problem "No double 'without': Use `build.without? '#{$1}'` to check for \"--without-#{$1}\""
+ end
+
if text =~ /ARGV\.(?!(debug\?|verbose\?|find[\(\s]))/
problem "Use build instead of ARGV to check options"
end
@@ -457,6 +472,52 @@ class FormulaAuditor
end
end
+ def audit_python
+ if text =~ /system\(?\s*['"]python/
+ # Todo: In `def test` it is okay to do it this way. It's even recommended!
+ problem "Instead of `system 'python', ...`, call `system python, ...`."
+ end
+
+ if text =~ /system\(?\s*python\.binary/
+ problem "Instead of `system python.binary, ...`, call `system python, ...`."
+ end
+
+ if text =~ /(def\s*)?which_python/
+ problem "Replace `which_python` by `python.xy`, which returns e.g. 'python2.7'."
+ end
+
+ if text =~ /which\(?["']python/
+ problem "Don't locate python with `which 'python'`, use `python.binary` instead"
+ end
+
+ if f.requirements.any?{ |r| r.kind_of?(PythonInstalled) }
+ # Don't check this for all formulae, because some are allowed to set the
+ # PYTHONPATH. E.g. python.rb itself needs to set it.
+ if text =~ /ENV\.append.*PYTHONPATH/ || text =~ /ENV\[['"]PYTHONPATH['"]\]\s*=[^=]/
+ problem "Don't set the PYTHONPATH, instead declare `depends_on :python`."
+ end
+ end
+
+ if text =~ /(\s*)def\s+caveats((.*\n)*?)(\1end)/ || /(\s*)def\s+caveats;(.*?)end/
+ caveats_body = $2
+ if caveats_body =~ /(python[23]?)\.(.*\w)/
+ # So if in the body of caveats there is a `python.whatever` called,
+ # check that there is a guard like `if python` or similiar:
+ python = $1
+ method = $2
+ unless caveats_body =~ /(if python[23]?)|(if build\.with\?\s?\(?['"]python)|(unless build.without\?\s?\(?['"]python)/
+ problem "Please guard `#{python}.#{method}` like so `#{python}.#{method} if #{python}`"
+ end
+ end
+ end
+
+ # Todo:
+ # The python do ... end block is possibly executed twice. Once for
+ # python 2.x and once for 3.x. So if a `system 'make'` is called, a
+ # `system 'make clean'` should also be called at the end of the block.
+
+ end
+
def audit
audit_file
audit_specs
@@ -465,6 +526,7 @@ class FormulaAuditor
audit_conflicts
audit_patches
audit_text
+ audit_python
end
private
diff --git a/Library/Homebrew/dependency.rb b/Library/Homebrew/dependency.rb
index cc378b7df..a6905bc37 100644
--- a/Library/Homebrew/dependency.rb
+++ b/Library/Homebrew/dependency.rb
@@ -47,7 +47,7 @@ class Dependency
end
def missing_options
- options - Tab.for_formula(to_formula).used_options
+ options - Tab.for_formula(to_formula).used_options - to_formula.build.implicit_options
end
def universal!
diff --git a/Library/Homebrew/dependency_collector.rb b/Library/Homebrew/dependency_collector.rb
index 3de385fbf..74f94dc63 100644
--- a/Library/Homebrew/dependency_collector.rb
+++ b/Library/Homebrew/dependency_collector.rb
@@ -17,7 +17,7 @@ require 'set'
class DependencyCollector
# Define the languages that we can handle as external dependencies.
LANGUAGE_MODULES = Set[
- :chicken, :jruby, :lua, :node, :ocaml, :perl, :python, :rbx, :ruby
+ :chicken, :jruby, :lua, :node, :ocaml, :perl, :python, :python2, :python3, :rbx, :ruby
].freeze
attr_reader :deps, :requirements
@@ -92,6 +92,9 @@ class DependencyCollector
when :clt then CLTDependency.new(tags)
when :arch then ArchRequirement.new(tags)
when :hg then MercurialDependency.new(tags)
+ when :python then PythonInstalled.new(tags)
+ when :python2 then PythonInstalled.new("2", tags)
+ when :python3 then PythonInstalled.new("3", tags)
else
raise "Unsupported special dependency #{spec}"
end
diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb
index 6745219fb..72a0652fb 100644
--- a/Library/Homebrew/download_strategy.rb
+++ b/Library/Homebrew/download_strategy.rb
@@ -548,6 +548,7 @@ class MercurialDownloadStrategy < AbstractDownloadStrategy
def cached_location; @clone; end
def hgpath
+ # #{HOMEBREW_PREFIX}/share/python/hg is deprecated, but we levae it in for a while
@path ||= %W[
#{which("hg")}
#{HOMEBREW_PREFIX}/bin/hg
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb
index dab9726ed..bf64044b3 100644
--- a/Library/Homebrew/formula.rb
+++ b/Library/Homebrew/formula.rb
@@ -305,6 +305,21 @@ class Formula
]
end
+ def python(options={:allowed_major_versions => [2, 3]}, &block)
+ require 'python_helper'
+ self.instance_eval{ python_helper(options, &block) }
+ end
+
+ # Explicitly only execute the block for 2.x (if a python 2.x is available)
+ def python2 &block
+ python(:allowed_major_versions => [2], &block)
+ end
+
+ # Explicitly only execute the block for 3.x (if a python 3.x is available)
+ def python3 &block
+ python(:allowed_major_versions => [3], &block)
+ end
+
def self.class_s name
# remove invalid characters and then camelcase it
name.capitalize.gsub(/[-_.\s]([a-zA-Z0-9])/) { $1.upcase } \
@@ -558,7 +573,7 @@ class Formula
@exec_count ||= 0
@exec_count += 1
logd = HOMEBREW_LOGS/name
- logfn = "#{logd}/%02d.%s" % [@exec_count, File.basename(cmd).split(' ').first]
+ logfn = "#{logd}/%02d.%s" % [@exec_count, File.basename(cmd.to_s).split(' ').first]
mkdir_p(logd)
rd, wr = IO.pipe
@@ -567,7 +582,7 @@ class Formula
$stdout.reopen wr
$stderr.reopen wr
args.collect!{|arg| arg.to_s}
- exec(cmd, *args) rescue nil
+ exec(cmd.to_s, *args) rescue nil
puts "Failed to execute: #{cmd}"
exit! 1 # never gets here unless exec threw or failed
end
diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb
index a63af419d..e1df0adb5 100644
--- a/Library/Homebrew/keg.rb
+++ b/Library/Homebrew/keg.rb
@@ -210,15 +210,18 @@ class Keg < Pathname
def link_dir foo, mode=OpenStruct.new
root = self+foo
return unless root.exist?
-
root.find do |src|
next if src == root
-
dst = HOMEBREW_PREFIX+src.relative_path_from(self)
dst.extend ObserverPathnameExtension
if src.file?
Find.prune if File.basename(src) == '.DS_Store'
+ # Don't link pyc files because Python overwrites these cached object
+ # files and next time brew wants to link, the pyc file is in the way.
+ if src.extname.to_s == '.pyc' && src.to_s =~ /site-packages/
+ Find.prune
+ end
case yield src.relative_path_from(root)
when :skip_file, nil
@@ -233,7 +236,6 @@ class Keg < Pathname
elsif src.directory?
# if the dst dir already exists, then great! walk the rest of the tree tho
next if dst.directory? and not dst.symlink?
-
# no need to put .app bundles in the path, the user can just use
# spotlight, or the open command and actual mac apps use an equivalent
Find.prune if src.extname.to_s == '.app'
diff --git a/Library/Homebrew/python_helper.rb b/Library/Homebrew/python_helper.rb
new file mode 100644
index 000000000..ef71b2a30
--- /dev/null
+++ b/Library/Homebrew/python_helper.rb
@@ -0,0 +1,80 @@
+
+# The python_helper is used in the Formula class when the user calls
+# `python`, `python2` or `python3`.
+
+# This method has a dual nature. For one, it takes a &block and sets up
+# the ENV such that a Python, as defined in the requirements, is the default.
+# If there are multiple `PythonInstalled` requirements, the block is evaluated
+# once for each Python. This makes it possible to easily support 2.x and
+# 3.x Python bindings without code duplication in formulae.
+# If you need to special case stuff, set :allowed_major_versions.
+# Second, inside the block, a formula author may call this method to access
+# certain convienience methods for the currently selected Python, e.g.
+# `python.site_packages`.
+def python_helper(options={:allowed_major_versions => [2, 3]}, &block)
+ if !block_given? and !@current_python.nil?
+ # We are already inside of a `python do ... end` block, so just return
+ # the current_python or false if the version.major is not allowed.
+ if options[:allowed_major_versions].include?(@current_python.version.major)
+ @current_python
+ else
+ false
+ end
+ else
+ # Look for PythonInstalled requirements for this formula
+ python_reqs = requirements.select{ |r| r.kind_of?(PythonInstalled) }
+ if python_reqs.empty?
+ raise "If you use python in the formula, you have to add `depends_on :python` (or :python3)!"
+ end
+ # Now select those that are satisfied and matching the version.major
+ python_reqs = python_reqs.select do |p|
+ p.satisfied? &&
+ options[:allowed_major_versions].include?(p.version.major) &&
+ if p.optional? || p.recommended?
+ self.build.with?(p.name)
+ else
+ true
+ end
+ end
+
+ # Allow to use an else-branch like so: `if python do ... end; else ... end`
+ return false if python_reqs.empty?
+
+ # Sort by version, so the older 2.x will be used first and if no
+ # block_given? then 2.x is preferred because it is returned.
+ # Further note, having 3.x last allows us to run `2to3 --write .`
+ # which modifies the sources in-place (for some packages that need this).
+ python_reqs.sort_by{ |py| py.version }.map do |py|
+ # Now is the time to set the site_packages to the correct value
+ py.site_packages = lib/py.xy/'site-packages'
+ if block_given?
+ puts "brew: Python block (#{py.binary})..." if ARGV.verbose?
+ require 'superenv'
+ # Ensure env changes are only temporary by using `with_build_environment`
+ ENV.with_build_environment do
+ # In order to install into the Cellar, the dir must exist and be in the
+ # PYTHONPATH. This will be executed in the context of the formula
+ # so that lib points to the HOMEBREW_PREFIX/Cellar/<formula>/<version>/lib
+ puts "brew: Setting PYTHONPATH=#{py.site_packages}" if ARGV.verbose?
+ mkdir_p py.site_packages
+ ENV.append 'PYTHONPATH', py.site_packages, ':'
+ ENV['PYTHON'] = py.binary
+ ENV.prepend 'CMAKE_INCLUDE_PATH', py.incdir, ':'
+ ENV.prepend 'PKG_CONFIG_PATH', py.pkg_config_path, ':' if py.pkg_config_path
+ ENV.prepend 'PATH', py.binary.dirname, ':' unless py.from_osx?
+ # Track the state of the currently selected python for this block,
+ # so if this python_helper is called again _inside_ the block, we can
+ # just return the right python (see `else`-branch a few lines down):
+ @current_python = py
+ res = instance_eval(&block)
+ @current_python = nil
+ res
+ end
+ else
+ puts "brew: Using #{py.binary}" if ARGV.verbose?
+ # We return here with intention, because no block_given?
+ return py
+ end
+ end
+ end
+end
diff --git a/Library/Homebrew/requirements.rb b/Library/Homebrew/requirements.rb
index ad621867c..c1c7fff7a 100644
--- a/Library/Homebrew/requirements.rb
+++ b/Library/Homebrew/requirements.rb
@@ -3,6 +3,7 @@ require 'requirements/conflict_requirement'
require 'requirements/language_module_dependency'
require 'requirements/x11_dependency'
require 'requirements/mpi_dependency'
+require 'requirements/python_dependency'
class XcodeDependency < Requirement
fatal true
diff --git a/Library/Homebrew/requirements/language_module_dependency.rb b/Library/Homebrew/requirements/language_module_dependency.rb
index 7c293e0c5..e62e61530 100644
--- a/Library/Homebrew/requirements/language_module_dependency.rb
+++ b/Library/Homebrew/requirements/language_module_dependency.rb
@@ -27,7 +27,8 @@ class LanguageModuleDependency < Requirement
when :node then %W{/usr/bin/env node -e require('#{@import_name}');}
when :ocaml then %W{/usr/bin/env opam list #{@import_name} | grep #{@import_name}}
when :perl then %W{/usr/bin/env perl -e use\ #{@import_name}}
- when :python then %W{/usr/bin/env python -c import\ #{@import_name}}
+ when :python then %W{/usr/bin/env python2 -c import\ #{@import_name}}
+ when :python3 then %W{/usr/bin/env python3 -c import\ #{@import_name}}
when :ruby then %W{/usr/bin/env ruby -rubygems -e require\ '#{@import_name}'}
when :rbx then %W{/usr/bin/env rbx -rubygems -e require\ '#{@import_name}'}
end
@@ -42,6 +43,7 @@ class LanguageModuleDependency < Requirement
when :ocaml then "opam install"
when :perl then "cpan -i"
when :python then "pip install"
+ when :python3 then "pip3 install"
when :rbx then "rbx gem install"
when :ruby then "gem install"
end
diff --git a/Library/Homebrew/requirements/python_dependency.rb b/Library/Homebrew/requirements/python_dependency.rb
new file mode 100644
index 000000000..194d434c7
--- /dev/null
+++ b/Library/Homebrew/requirements/python_dependency.rb
@@ -0,0 +1,296 @@
+require 'requirement'
+
+# We support Python 2.x and 3.x, either brewed or external.
+# This requirement locates the correct CPython binary (no PyPy), provides
+# support methods like `site_packages`, and writes our sitecustomize.py file.
+# In `dependency_collector.rb`, special `:python` and `:python3` shortcuts are
+# defined. You can specify a minimum version of the Python that needs to be
+# present, but since not every package is ported to 3.x yet,
+# `PythonInstalled("2")` is not satisfied by 3.x.
+# In a formula that shall provide support for 2.x and 3.x, the idiom is:
+# depends_on :python
+# depends_on :python3 => :optional # or :recommended
+#
+# Todo:
+# - Allow further options that choose: universal, framework?, brewed?...
+class PythonInstalled < Requirement
+ attr_reader :min_version
+ attr_reader :if3then3
+ attr_reader :site_packages
+ attr_accessor :site_packages
+
+ fatal true # you can still make Python optional by `depends_on :python => :optional`
+
+ class PythonVersion < Version
+ def major
+ to_a[0].to_s.to_i # Python's major.minor are always ints.
+ end
+ def minor
+ to_a[1].to_s.to_i
+ end
+ end
+
+ def initialize(*tags)
+ # Extract the min_version if given. Default to python 2.X else
+ tags.flatten!
+ if /(\d+\.)*\d+/ === tags.first
+ @min_version = PythonVersion.new(tags.shift)
+ else
+ @min_version = PythonVersion.new("2.7") # default
+ end
+
+ # often used idiom: e.g. sipdir = "share/sip" + python.if3then3
+ if @min_version.major == 3
+ @if3then3 = "3"
+ else
+ @if3then3 = ""
+ end
+
+ # Set name according to the major version.
+ # The name is used to generate the options like --without-python3
+ @name = "python" + @if3then3
+
+ # will be set later by the python_helper, because it needs the
+ # formula prefix to set site_packages
+ @site_packages = nil
+
+ super tags
+ end
+
+ # Note that during `satisfy` we still have the PATH as the user has set.
+ # We look for a brewed python or an external Python and store the loc of
+ # that binary for later usage. (See Formula#python)
+ satisfy :build_env => false do
+ @unsatisfied_because = "This formula needs #{@name}.\n"
+ if binary.nil?
+ @unsatisfied_because += "But no `#{@name}` found in your PATH! Consider to `brew install #{@name}`."
+ false
+ elsif pypy?
+ @unsatisfied_because += "Your #{@name} executable appears to be a PyPy, which is not supported."
+ false
+ elsif version.major != @min_version.major
+ @unsatisfied_because += "No Python #{@min_version.major}.x found!"
+ false
+ elsif version < @min_version
+ @unsatisfied_because += "Python version #{version} is too old (need at least #{@min_version})."
+ false
+ elsif @min_version.major == 2 && `python -c "import sys; print(sys.version_info.major)"`.strip == "3"
+ @unsatisfied_because += "Your `python` points to a Python 3.x. This is not supported."
+ false
+ else
+ true
+ end
+ end
+
+ # The full path to the python or python3 executable, depending on `version`.
+ def binary
+ if brewed?
+ # If the python is brewed we always prefer it!
+ # Note, we don't support homebrew/versions/pythonXX.rb, though.
+ Formula.factory(@name).opt_prefix/"bin/python#{@min_version.major}"
+ else
+ p = which(@name)
+ raise "PythonInstalled: #{p} is not executable" if !p.nil? && !p.executable?
+ p
+ end
+ end
+
+ # The python prefix (special cased for a brewed python to point into the opt_prefix)
+ def prefix
+ if brewed?
+ # Homebrew since a long while only supports frameworked python
+ HOMEBREW_PREFIX/"opt/#{name}/Frameworks/Python.framework/Versions/#{version.major}.#{version.minor}"
+ elsif from_osx?
+ # Python on OS X has been stripped off its includes (unless you install the CLT), therefore we use the MacOS.sdk.
+ Pathname.new("#{MacOS.sdk_path}/System/Library/Frameworks/Python.framework/Versions/#{version.major}.#{version.minor}")
+ else
+ # What Python knows about itself
+ Pathname.new(`#{binary} -c 'import sys;print(sys.prefix)'`.strip)
+ end
+ end
+
+ # Get the actual x.y.z version by asking python (or python3 if @min_version>=3)
+ def version
+ @version ||= PythonVersion.new(`#{binary} -c 'import sys;print(sys.version[:5])'`.strip)
+ end
+
+ # python.xy => "python2.7" is often used (and many formulae had this as `which_python`).
+ def xy
+ "python#{version.major}.#{version.minor}"
+ end
+
+ # Homebrew's global site-packages. The local ones are populated by the
+ # python_helper method when the `prefix` of a formula is known.
+ def global_site_packages
+ HOMEBREW_PREFIX/"lib/#{xy}/site-packages"
+ end
+
+ # Dir containing Python.h and others.
+ def incdir
+ if (from_osx? || brewed?) && framework?
+ prefix/"Headers"
+ else
+ # For all other we use Python's own standard method (works with a non-framework version, too)
+ Pathname.new(`#{binary} -c 'from distutils import sysconfig; print(sysconfig.get_python_inc())'`.strip)
+ end
+ end
+
+ # Dir containing e.g. libpython2.7.dylib
+ def libdir
+ if brewed? || from_osx?
+ prefix/"lib/#{xy}/config"
+ else
+ Pathname.new(`#{binary} -c "from distutils import sysconfig; print(sysconfig.get_config_var('LIBPL'))"`.strip)
+ end
+ end
+
+ # Pkgconfig (pc) files of python
+ def pkg_config_path
+ if from_osx?
+ # No matter if CLT-only or Xcode-only, the pc file is always here on OS X:
+ path = Pathname.new("/System/Library/Frameworks/Python.framework/Versions/#{version.major}.#{version.minor}/lib/pkgconfig")
+ path if path.exist?
+ else
+ prefix/"lib/pkgconfig"
+ end
+ end
+
+ # Is the Python brewed (and linked)?
+ def brewed?
+ @brewed ||= begin
+ require 'formula'
+ f = Formula.factory(@name)
+ f.installed? && f.linked_keg.exist?
+ end
+ end
+
+ # Is the python the one from OS X?
+ def from_osx?
+ @from_osx ||= begin
+ p = `#{binary} -c "import sys; print(sys.prefix)"`.strip
+ p.start_with?("/System/Library/Frameworks/Python.framework")
+ end
+ end
+
+ # Is the `python` a PyPy?
+ def pypy?
+ @pypy ||= !(`#{binary} -c "import sys; print(sys.version)"`.downcase =~ /.*pypy.*/).nil?
+ end
+
+ # Is this python a framework-style install (OS X only)?
+ def framework?
+ @framework ||= /Python[0-9]*\.framework/ === prefix.to_s
+ end
+
+ def universal?
+ @universal ||= archs_for_command(binary).universal?
+ end
+
+ def standard_caveats
+ if brewed?
+ "" # empty string, so we can concat this
+ else
+ <<-EOS.undent
+ For non-homebrew #{@name} (#{@min_version.major}.x), you need to amend your PYTHONPATH like so:
+ export PYTHONPATH=#{global_site_packages}:$PYTHONPATH
+ EOS
+ end
+ end
+
+ def modify_build_environment
+ # Write our sitecustomize.py
+ file = global_site_packages/"sitecustomize.py"
+ ohai "Writing #{file}" if ARGV.verbose? || ARGV.homebrew_developer?
+ [".pyc", ".pyo", ".py"].map{ |f|
+ global_site_packages/"sitecustomize#{f}"
+ }.each{ |f| f.delete if f.exist? }
+ file.write(sitecustomize)
+
+ # For non-system python's we add the opt_prefix/bin of python to the path.
+ ENV.prepend 'PATH', binary.dirname, ':' unless from_osx?
+
+ ENV['PYTHONHOME'] = nil # to avoid fuck-ups.
+ ENV['PYTHONNOUSERSITE'] = '1'
+ # Python respects the ARCHFLAGS var if set. Shall we set them here?
+ # ENV['ARCHFLAGS'] = ??? # FIXME
+ ENV.append 'CMAKE_INCLUDE_PATH', incdir, ':'
+ ENV.append 'PKG_CONFIG_PATH', pkg_config_path, ':' if pkg_config_path
+
+ # Udpate distutils.cfg (later we can remove this, but people still have
+ # their old brewed pythons and we have to update it here)
+ # Todo: If Jack's formula revisions arrive, we can get rid of this here!
+ if brewed?
+ require 'formula'
+ file = Formula.factory(@name).prefix/"Frameworks/Python.framework/Versions/#{version.major}.#{version.minor}/lib/#{xy}/distutils/distutils.cfg"
+ ohai "Writing #{file}" if ARGV.verbose? || ARGV.homebrew_developer?
+ file.delete if file.exist?
+ file.write <<-EOF.undent
+ [global]
+ verbose=1
+ [install]
+ force=1
+ prefix=#{HOMEBREW_PREFIX}
+ EOF
+ end
+ end
+
+ def sitecustomize
+ <<-EOF.undent
+ # This file is created by Homebrew and is executed on each python startup.
+ # Don't print from here, or else universe will collapse.
+ import sys
+
+ if sys.version_info.major == #{version.major} and sys.version_info.minor == #{version.minor}:
+ if sys.executable.startswith('#{HOMEBREW_PREFIX}'):
+ # Fix 1)
+ # A setuptools.pth and/or easy-install.pth sitting either in
+ # /Library/Python/2.7/site-packages or in
+ # ~/Library/Python/2.7/site-packages can inject the
+ # /System's Python site-packages. People then report
+ # "OSError: [Errno 13] Permission denied" because pip/easy_install
+ # attempts to install into
+ # /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
+ # See: https://github.com/mxcl/homebrew/issues/14712
+ # Fix 2)
+ # Remove brewed Python's hard-coded Cellar-site-packages
+ sys.path = [ p for p in sys.path
+ if not (p.startswith('/System') or
+ p.startswith('#{HOMEBREW_PREFIX}/Cellar/python') and p.endswith('site-packages')) ]
+ # Fix 3)
+ # Set the sys.executable to use the opt_prefix
+ sys.executable = '#{HOMEBREW_PREFIX}/opt/#{name}/bin/python#{version.major}.#{version.minor}'
+ # Fix 4)
+ # Make LINKFORSHARED (and python-confing --ldflags) return the
+ # full path to the lib (yes, "Python" is actually the lib, not a
+ # dir) so that third-party software does not need to add the
+ # -F/#{HOMEBREW_PREFIX}/Frameworks switch.
+ # Assume Framework style build (default since months in brew)
+ try:
+ from _sysconfigdata import build_time_vars
+ build_time_vars['LINKFORSHARED'] = '-u _PyMac_Error #{HOMEBREW_PREFIX}/opt/#{name}/Frameworks/Python.framework/Versions/#{version.major}.#{version.minor}/Python'
+ except:
+ pass # remember: don't print here. Better to fail silent.
+ # Fix 5)
+ # For all Pythons of the right major.minor version: Tell about homebrew's
+ # site-packages location. This is needed for Python to parse *.pth.
+ import site
+ site.addsitedir('#{global_site_packages}')
+ EOF
+ end
+
+ def message
+ @unsatisfied_because
+ end
+
+ def <=> other
+ version <=> other.version
+ end
+
+ def to_s
+ binary.to_s
+ end
+
+ def hash
+ to_s.hash
+ end
+end
diff --git a/Library/Homebrew/superenv.rb b/Library/Homebrew/superenv.rb
index 18a47ca0d..022517534 100644
--- a/Library/Homebrew/superenv.rb
+++ b/Library/Homebrew/superenv.rb
@@ -30,7 +30,7 @@ class << ENV
alias_method :x11?, :x11
def reset
- %w{CC CXX OBJC OBJCXX CPP MAKE LD
+ %w{CC CXX OBJC OBJCXX CPP MAKE LD LDSHARED
CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS LDFLAGS CPPFLAGS
MACOS_DEPLOYMENT_TARGET SDKROOT
CMAKE_PREFIX_PATH CMAKE_INCLUDE_PATH CMAKE_FRAMEWORK_PATH
@@ -57,7 +57,7 @@ class << ENV
ENV['HOMEBREW_BREW_FILE'] = HOMEBREW_BREW_FILE
ENV['HOMEBREW_SDKROOT'] = "#{MacOS.sdk_path}" if MacSystem.xcode43_without_clt?
ENV['CMAKE_PREFIX_PATH'] = determine_cmake_prefix_path
- ENV['CMAKE_FRAMEWORK_PATH'] = "#{MacOS.sdk_path}/System/Library/Frameworks" if MacSystem.xcode43_without_clt?
+ ENV['CMAKE_FRAMEWORK_PATH'] = determine_cmake_frameworks_path
ENV['CMAKE_INCLUDE_PATH'] = determine_cmake_include_path
ENV['CMAKE_LIBRARY_PATH'] = determine_cmake_library_path
ENV['ACLOCAL_PATH'] = determine_aclocal_path
@@ -133,7 +133,6 @@ class << ENV
paths << "#{MacOS::Xcode.prefix}/Toolchains/XcodeDefault.xctoolchain/usr/bin"
end
paths += deps.map{|dep| "#{HOMEBREW_PREFIX}/opt/#{dep}/bin" }
- paths << "#{HOMEBREW_PREFIX}/opt/python/bin" if brewed_python?
paths << "#{MacSystem.x11_prefix}/bin" if x11?
paths += %w{/usr/bin /bin /usr/sbin /sbin}
paths.to_path_s
@@ -158,6 +157,14 @@ class << ENV
paths.to_path_s
end
+ def determine_cmake_frameworks_path
+ # XXX: keg_only_deps perhaps? but Qt does not link its Frameworks because of Ruby's Find.find ignoring symlinks!!
+ paths = deps.map{|dep| "#{HOMEBREW_PREFIX}/opt/#{dep}/Frameworks" }
+ paths << "#{HOMEBREW_PREFIX}/Frameworks"
+ paths << "#{MacOS.sdk_path}/System/Library/Frameworks" if MacSystem.xcode43_without_clt?
+ paths.to_path_s
+ end
+
def determine_cmake_include_path
sdk = MacOS.sdk_path if MacSystem.xcode43_without_clt?
paths = []
@@ -165,11 +172,6 @@ class << ENV
paths << "#{sdk}/usr/include/libxml2" unless deps.include? 'libxml2'
if MacSystem.xcode43_without_clt?
paths << "#{sdk}/usr/include/apache2"
- paths << if brewed_python?
- "#{HOMEBREW_PREFIX}/opt/python/Frameworks/Python.framework/Headers"
- else
- "#{sdk}/System/Library/Frameworks/Python.framework/Versions/Current/include/python2.7"
- end
end
paths << "#{sdk}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Headers/" unless x11?
paths << "#{MacSystem.x11_prefix}/include" if x11?
@@ -227,11 +229,6 @@ class << ENV
MacOS::Xcode.prefix || ENV['DEVELOPER_DIR']
end
- def brewed_python?
- require 'formula'
- Formula.factory('python').linked_keg.directory?
- end
-
public
### NO LONGER NECESSARY OR NO LONGER SUPPORTED
diff --git a/Library/Homebrew/test/test_build_options.rb b/Library/Homebrew/test/test_build_options.rb
index daf5ef96b..cc5fd01d7 100644
--- a/Library/Homebrew/test/test_build_options.rb
+++ b/Library/Homebrew/test/test_build_options.rb
@@ -42,4 +42,15 @@ class BuildOptionsTests < Test::Unit::TestCase
def test_unused_options
assert @build.unused_options.include?("--without-baz")
end
+
+ def test_implicit_options
+ # --without-baz is not explicitly specified on the command line
+ # therefore --with-baz should be implicitly assumed:
+ assert @build.implicit_options.include?("--with-baz")
+ # But all these should not be in the implict_options:
+ assert !@build.implicit_options.include?("--without-baz")
+ assert !@build.implicit_options.include?("--with-bar")
+ assert !@build.implicit_options.include?("--without-bar")
+ assert !@build.implicit_options.include?("--with-qux")
+ end
end
diff --git a/Library/Homebrew/test/test_python.rb b/Library/Homebrew/test/test_python.rb
new file mode 100644
index 000000000..7658efa85
--- /dev/null
+++ b/Library/Homebrew/test/test_python.rb
@@ -0,0 +1 @@
+#TODO! \ No newline at end of file
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb
index e959d9d64..60eead67c 100644
--- a/Library/Homebrew/utils.rb
+++ b/Library/Homebrew/utils.rb
@@ -97,7 +97,7 @@ module Homebrew
fork do
yield if block_given?
args.collect!{|arg| arg.to_s}
- exec(cmd, *args) rescue nil
+ exec(cmd.to_s, *args) rescue nil
exit! 1 # never gets here unless exec failed
end
Process.wait