aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula/pyqt5.rb
blob: 05c36d012d8e06bc38fcfa5b5c1bcd267df6cbe6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
require 'formula'

class Pyqt5 < Formula
  homepage 'http://www.riverbankcomputing.co.uk/software/pyqt/download5'
  url 'http://downloads.sf.net/project/pyqt/PyQt5/PyQt-5.1.1/PyQt-gpl-5.1.1.tar.gz'
  sha1 '90a3d6a805da7559ad83704866c1751d698f1873'

  option 'enable-debug', "Build with debug symbols"

  depends_on :python

  depends_on 'qt5'

  depends_on 'sip'

  def install
    args = [ "--confirm-license",
             "--bindir=#{bin}",
             "--destdir=#{lib}/python2.7/site-packages",
             # To avoid conflicst with PyQt (for Qt4):
             "--sipdir=#{share}/sip/Qt5/",
             # sip.h could not be found automatically
             "--sip-incdir=#{Formula.factory('sip').opt_prefix}/include",
             # Force deployment target to avoid libc++ issues
             "QMAKE_MACOSX_DEPLOYMENT_TARGET=#{MacOS.version}" ]
    args << '--debug' if build.include? 'enable-debug'

    system "python", "./configure.py", *args
    system "make"
    system "make", "install"
  end

  test do
    (testpath/'test.py').write <<-EOS.undent
      import sys
      from PyQt5 import QtGui, QtCore, QtWidgets

      class Test(QtWidgets.QWidget):
          def __init__(self, parent=None):
              QtWidgets.QWidget.__init__(self, parent)
              self.setGeometry(300, 300, 400, 150)
              self.setWindowTitle('Homebrew')
              QtWidgets.QLabel("Python " + "{0}.{1}.{2}".format(*sys.version_info[0:3]) +
                               " working with PyQt5. Quitting now...", self).move(50, 50)
              QtCore.QTimer.singleShot(1500, QtWidgets.qApp.quit)

      app = QtWidgets.QApplication([])
      window = Test()
      window.show()
      sys.exit(app.exec_())
    EOS
    system "python", "test.py"
  end
end