diff options
| author | Christian Moritz | 2014-02-07 20:17:14 +0100 |
|---|---|---|
| committer | Mike McQuaid | 2014-02-07 23:01:26 +0000 |
| commit | 620d89cbc0b562003b3ce82530adf635c86d3044 (patch) | |
| tree | 95a1a7477d641fa349efccb8da260406a4a28d14 /Library/Formula | |
| parent | 50cea4509754ecee1bad36323f4f74077c561493 (diff) | |
| download | homebrew-620d89cbc0b562003b3ce82530adf635c86d3044.tar.bz2 | |
pyqt5: python3 support
Closes #26499.
Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Diffstat (limited to 'Library/Formula')
| -rw-r--r-- | Library/Formula/pyqt5.rb | 81 |
1 files changed, 46 insertions, 35 deletions
diff --git a/Library/Formula/pyqt5.rb b/Library/Formula/pyqt5.rb index 82f5bee5a..45f14b3ed 100644 --- a/Library/Formula/pyqt5.rb +++ b/Library/Formula/pyqt5.rb @@ -7,46 +7,57 @@ class Pyqt5 < Formula option 'enable-debug', "Build with debug symbols" - depends_on :python + depends_on :python3 => :recommended + depends_on :python => :optional + + if (build.without? "python") && (build.without? "python3") + odie "pyqt: --with-python must be specified when using --without-python3" + end + depends_on 'qt5' - depends_on 'sip' + + if build.with? 'python3' + depends_on 'sip' => 'with-python3' + else + depends_on 'sip' + end + + def pythons + pythons = [] + ["python", "python3"].each do |python| + next if build.without? python + version = /\d\.\d/.match `#{python} --version 2>&1` + pythons << [python, version] + end + pythons + end 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" + pythons.each do |python, version| + ENV["PYTHONPATH"] = lib/"python#{version}/site-packages" + args = [ "--confirm-license", + "--bindir=#{bin}", + "--destdir=#{lib}/python#{version}/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" + system "make", "clean" if pythons.length > 1 + end 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" + system "pyuic5", "--version" + system "pylupdate5", "-version" + pythons.each do |python, version| + system python, "-c", "import PyQt5" + end end end |
