forked from cartr/homebrew-qt4
-
Notifications
You must be signed in to change notification settings - Fork 0
98 lines (83 loc) · 3.5 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
class PyqtAT4 < Formula
desc "Python bindings for Qt"
homepage "https://www.riverbankcomputing.com/software/pyqt/intro"
url "https://sourceforge.net/projects/pyqt/files/PyQt4/PyQt-4.12/PyQt4_gpl_mac-4.12.tar.gz/download"
sha256 "19d28b09bfcb384af8c596f3f76beabd0fe4c3a2a55cd35e62402b7c7cd6f660"
revision 1
option "without-python", "Build without python 2 support"
depends_on :python3 => :optional
if build.without?("python3") && build.without?("python")
odie "pyqt: --with-python3 must be specified when using --without-python"
end
depends_on "cartr/qt4/qt@4"
depends_on "cartr/qt4/[email protected]" => :recommended
if build.with? "python3"
depends_on "sip" => "with-python3"
else
depends_on "sip"
end
def install
# On Mavericks we want to target libc++, this requires a non default qt makespec
if ENV.compiler == :clang && MacOS.version >= :mavericks
ENV.append "QMAKESPEC", "unsupported/macx-clang-libc++"
end
Language::Python.each_python(build) do |python, version|
ENV.append_path "PYTHONPATH", "#{Formula["sip"].opt_lib}/python#{version}/site-packages"
args = %W[
--confirm-license
--bindir=#{bin}
--destdir=#{lib}/python#{version}/site-packages
--sipdir=#{share}/sip
]
# We need to run "configure.py" so that pyqtconfig.py is generated, which
# is needed by QGIS, PyQWT (and many other PyQt interoperable
# implementations such as the ROS GUI libs). This file is currently needed
# for generating build files appropriate for the qmake spec that was used
# to build Qt. The alternatives provided by configure-ng.py is not
# sufficient to replace pyqtconfig.py yet (see
# https://github.com/qgis/QGIS/pull/1508). Using configure.py is
# deprecated and will be removed with SIP v5, so we do the actual compile
# using the newer configure-ng.py as recommended. In order not to
# interfere with the build using configure-ng.py, we run configure.py in a
# temporary directory and only retain the pyqtconfig.py from that.
require "tmpdir"
dir = Dir.mktmpdir
begin
cp_r(Dir.glob("*"), dir)
cd dir do
system python, "configure.py", *args
inreplace "pyqtconfig.py", "#{HOMEBREW_CELLAR}/#{Formula["cartr/qt4/qt@4"].name}/#{Formula["cartr/qt4/qt@4"].pkg_version}",
Formula["cartr/qt4/qt@4"].opt_prefix
(lib/"python#{version}/site-packages/PyQt4").install "pyqtconfig.py"
end
ensure
remove_entry_secure dir
end
# On Mavericks we want to target libc++, this requires a non default qt makespec
if ENV.compiler == :clang && MacOS.version >= :mavericks
args << "--spec" << "unsupported/macx-clang-libc++"
end
system python, "configure-ng.py", *args
system "make"
system "make", "install"
system "make", "clean" # for when building against multiple Pythons
end
end
def caveats
"Phonon support is broken."
end
test do
Pathname("test.py").write <<-EOS.undent
from PyQt4 import QtNetwork
QtNetwork.QNetworkAccessManager().networkAccessible()
EOS
Language::Python.each_python(build) do |python, _version|
system python, "test.py"
end
end
bottle do
root_url "https://dl.bintray.com/cartr/autobottle-qt4"
sha256 "e469b6a1064b23b5a429e391141cfc7e2ab06687cc1dd211cc249dd56020ade5" => :sierra
sha256 "5421fd941cc9436c56d2f3da486ad0373edb033f1419cc12a653f7df6b08fbcf" => :el_capitan
end
end