diff options
| author | Samuel John | 2013-01-21 10:33:56 +0100 |
|---|---|---|
| committer | Samuel John | 2013-06-03 17:29:43 +0200 |
| commit | 0b50110107ea2998e65011ec31ce45931b446dab (patch) | |
| tree | 9f28d410bcd3ac3bbd547bc1220919dbc8e5c39d /Library/Formula/pygtk.rb | |
| parent | 35c46b417c781864d1b772ed7f8b77504605f4ad (diff) | |
| download | homebrew-0b50110107ea2998e65011ec31ce45931b446dab.tar.bz2 | |
Python 2.x and 3.x support
New `depends_on :python` Dependency.
New `depends_on :python3` Dependency.
To avoid having multiple formulae with endings -py2 and -py3,
we will handle support for different pythons (2.x vs. 3.x)
in the same formula.
Further brewed vs. external python will be transparently supported.
The formula also gets a new object `python`, which is false if
no Python is available or the user has disabled it. Otherwise
it is defined and provides several support methods:
python.site_packages # the site-packages in the formula's Cellar
python.global_site_packages
python.binary # the full path to the python binary
python.prefix
python.version
python.version.major
python.version.minor
python.xy # => e.g. "python2.7"
python.incdir # includes of python
python.libdir # the python dylib library
python.pkg_config_path # used internally by brew
python.from_osx?
python.framework?
python.universal?
python.pypy?
python.standard_caveats # Text to set PYTHONPATH for python.from_osx?
python.if3then3 # => "" for 2.x and to "3" for 3.x.
Further, to avoid code duplication, `python` takes an optional
block that is run twice if the formula defines depends_on
:python AND :python3.
python do
system python, 'setup.py', "--prefix=#{prefix}"
end
Read more in the Homebrew wiki.
Diffstat (limited to 'Library/Formula/pygtk.rb')
| -rw-r--r-- | Library/Formula/pygtk.rb | 91 |
1 files changed, 45 insertions, 46 deletions
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 |
