/
pyside@2.rb
121 lines (102 loc) 路 4.22 KB
/
pyside@2.rb
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
class PysideAT2 < Formula
desc "Official Python bindings for Qt"
homepage "https://wiki.qt.io/Qt_for_Python"
# TODO: Check if we can use unversioned `llvm` at version bump.
url "https://download.qt.io/official_releases/QtForPython/pyside2/PySide2-5.15.13-src/pyside-setup-opensource-src-5.15.13.tar.xz"
sha256 "7a57797b20268d6ebcb39deba48c754a69abf9221aee03e1f3dca6f6565b7da9"
license all_of: ["GFDL-1.3-only", "GPL-2.0-only", "GPL-3.0-only", "LGPL-3.0-only"]
livecheck do
url "https://download.qt.io/official_releases/QtForPython/pyside2/"
regex(%r{href=.*?PySide2[._-]v?(\d+(?:\.\d+)+)-src/}i)
end
bottle do
sha256 cellar: :any, arm64_sonoma: "6cd8403de2af27d30999b99640ddba22a9ed0083d58f7df82fda1ca9e606b295"
sha256 cellar: :any, arm64_ventura: "5411503db00e5b2bf0d47a4f9c3cf286c52e96e3a065602e5da079ac1d503e2e"
sha256 cellar: :any, arm64_monterey: "8383e625a3ca94bab45c4983cd0db63b01f07b21c6f162410b7542d3cae8d15b"
sha256 cellar: :any, sonoma: "1ccfa050c8024de9fa0d06cc544725b3b13d76f18479d1f8f1e659b56074ec55"
sha256 cellar: :any, ventura: "1bf7502b0fdb78704904b1854c9e5d4b478d305f1ab6e5ec102df921d9c46bb7"
sha256 cellar: :any, monterey: "931425ca15fcc9414a141478e15e8fbd8baf9e497d140647196dde01c7ee5e7c"
end
keg_only :versioned_formula
depends_on "cmake" => :build
depends_on "llvm@15" # Upstream issue ref: https://bugreports.qt.io/browse/PYSIDE-2268
depends_on "python@3.10"
depends_on "qt@5"
uses_from_macos "libxml2"
uses_from_macos "libxslt"
on_linux do
depends_on "libxcb"
depends_on "mesa"
end
fails_with gcc: "5"
# Don't copy qt@5 tools.
patch do
url "https://src.fedoraproject.org/rpms/python-pyside2/raw/009100c67a63972e4c5252576af1894fec2e8855/f/pyside2-tools-obsolete.patch"
sha256 "ede69549176b7b083f2825f328ca68bd99ebf8f42d245908abd320093bac60c9"
end
def python3
"python3.10"
end
def install
rpaths = if OS.mac?
pyside2_module = prefix/Language::Python.site_packages(python3)/"PySide2"
[rpath, rpath(source: pyside2_module)]
else
# Add missing include dirs on Linux.
# upstream issue: https://bugreports.qt.io/browse/PYSIDE-1684
extra_include_dirs = [Formula["mesa"].opt_include, Formula["libxcb"].opt_include]
inreplace "sources/pyside2/cmake/Macros/PySideModules.cmake",
"--include-paths=${shiboken_include_dirs}",
"--include-paths=${shiboken_include_dirs}:#{extra_include_dirs.join(":")}"
# Add rpath to qt@5 because it is keg-only.
[lib, Formula["qt@5"].opt_lib]
end
# Avoid shim reference.
inreplace "sources/shiboken2/ApiExtractor/CMakeLists.txt", "${CMAKE_CXX_COMPILER}", ENV.cxx
ENV.append_path "CMAKE_PREFIX_PATH", Formula["qt@5"].opt_lib
system "cmake", "-S", ".", "-B", "build",
"-DPYTHON_EXECUTABLE=#{which(python3)}",
"-DCMAKE_INSTALL_RPATH=#{rpaths.join(";")}",
"-DFORCE_LIMITED_API=yes",
*std_cmake_args
system "cmake", "--build", "build"
system "cmake", "--install", "build"
end
test do
python = which(python3)
ENV.append_path "PYTHONPATH", prefix/Language::Python.site_packages(python)
system python, "-c", "import PySide2"
system python, "-c", "import shiboken2"
modules = %w[
Core
Gui
Location
Multimedia
Network
Quick
Svg
WebEngineWidgets
Widgets
Xml
]
modules.each { |mod| system python, "-c", "import PySide2.Qt#{mod}" }
pyincludes = shell_output("#{python}-config --includes").chomp.split
pylib = shell_output("#{python}-config --ldflags --embed").chomp.split
(testpath/"test.cpp").write <<~EOS
#include <shiboken.h>
int main()
{
Py_Initialize();
Shiboken::AutoDecRef module(Shiboken::Module::import("shiboken2"));
assert(!module.isNull());
return 0;
}
EOS
rpaths = []
rpaths += ["-Wl,-rpath,#{lib}", "-Wl,-rpath,#{Formula["python@3.10"].opt_lib}"] unless OS.mac?
system ENV.cxx, "-std=c++11", "test.cpp",
"-I#{include}/shiboken2", "-L#{lib}", "-lshiboken2.abi3", *rpaths,
*pyincludes, *pylib, "-o", "test"
system "./test"
end
end