Created
June 24, 2012 18:02
-
-
Save mvaz/2984200 to your computer and use it in GitHub Desktop.
trying to get pyqt to install
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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://www.riverbankcomputing.co.uk/static/Downloads/PyQt4/PyQt-mac-gpl-4.9.3.tar.gz' | |
| #sha1 '92d55cb6f57fdb9d61497c21770bb2458b102e8d' | |
| sha1 '6b315c4fdeecb6695a364ab0359a8090cff01661' | |
| depends_on 'sip' | |
| depends_on 'qt' | |
| def install | |
| ENV.prepend 'PYTHONPATH', "#{HOMEBREW_PREFIX}/lib/#{which_python}/site-packages", ':' | |
| system "python", "./configure.py", "--confirm-license", | |
| "--bindir=#{bin}", | |
| "--destdir=#{lib}/#{which_python}/site-packages", | |
| "--sipdir=#{share}/sip" | |
| system "make" | |
| 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 | |
| end | |
| def test | |
| # Reference: http://zetcode.com/tutorials/pyqt4/firstprograms/ | |
| mktemp do | |
| ENV.prepend 'PYTHONPATH', "#{HOMEBREW_PREFIX}/lib/#{which_python}/site-packages", ':' | |
| (Pathname.pwd/'test.py').write <<-EOS.undent | |
| #!/usr/bin/env python | |
| import sys | |
| from PyQt4 import QtGui, QtCore | |
| class QuitButton(QtGui.QWidget): | |
| def __init__(self, parent=None): | |
| QtGui.QWidget.__init__(self, parent) | |
| self.setGeometry(300, 300, 250, 150) | |
| self.setWindowTitle('Quit button') | |
| quit = QtGui.QPushButton('Close', self) | |
| quit.setGeometry(10, 10, 60, 35) | |
| 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 | |
| system "python", "test.py" | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment