homebrew-core/Formula/pyside.rb

79 lines
2.7 KiB
Ruby

class Pyside < Formula
desc "Official Python bindings for Qt"
homepage "https://wiki.qt.io/Qt_for_Python"
url "https://download.qt.io/official_releases/QtForPython/pyside6/PySide6-6.0.3-src/pyside-setup-opensource-src-6.0.3.tar.xz"
sha256 "8c9df25ee573f0034f2de27e14a285eee7db6bbfdf77abd522e85a20478bd841"
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/pyside6/"
regex(%r{href=.*?PySide6[._-]v?(\d+(?:\.\d+)+)-src/}i)
end
bottle do
sha256 arm64_big_sur: "83d5e476c788ae2788772f966fee1d941af55d63464b784099147791587254c8"
sha256 big_sur: "550013954ae3e0b8bb2a21d32d2e00814d3774dff13e454a4d81146398e25286"
sha256 catalina: "4e2b9519876919ea5bd50ded3917c85645d07c16bcddbd3e06507c3d1137a69f"
sha256 mojave: "6fb0d2db9b8eabb8998caf6b67eaf753facb9c16f55d63f1796ed8fec05cf778"
end
depends_on "cmake" => :build
depends_on "ninja" => :build
depends_on "llvm"
depends_on "python@3.9"
depends_on "qt"
def install
xy = Language::Python.major_minor_version Formula["python@3.9"].opt_bin/"python3"
args = std_cmake_args + %W[
-GNinja
-DPYTHON_EXECUTABLE=#{Formula["python@3.9"].opt_bin}/python#{xy}
-DCMAKE_INSTALL_RPATH=#{lib}
]
mkdir "build" do
system "cmake", *args, ".."
system "ninja", "install"
end
end
test do
system Formula["python@3.9"].opt_bin/"python3", "-c", "import PySide6"
system Formula["python@3.9"].opt_bin/"python3", "-c", "import shiboken6"
# TODO: add modules `Position`, `Multimedia`and `WebEngineWidgets` when qt6.2 is released
# arm support will finish in qt6.1
modules = %w[
Core
Gui
Network
Quick
Svg
Widgets
Xml
]
modules.each { |mod| system Formula["python@3.9"].opt_bin/"python3", "-c", "import PySide6.Qt#{mod}" }
pyincludes = shell_output("#{Formula["python@3.9"].opt_bin}/python3-config --includes").chomp.split
pylib = shell_output("#{Formula["python@3.9"].opt_bin}/python3-config --ldflags --embed").chomp.split
pyver = Language::Python.major_minor_version(Formula["python@3.9"].opt_bin/"python3").to_s.delete(".")
(testpath/"test.cpp").write <<~EOS
#include <shiboken.h>
int main()
{
Py_Initialize();
Shiboken::AutoDecRef module(Shiboken::Module::import("shiboken6"));
assert(!module.isNull());
return 0;
}
EOS
system ENV.cxx, "-std=c++11", "test.cpp",
"-I#{include}/shiboken6", "-L#{lib}", "-lshiboken6.cpython-#{pyver}-darwin",
*pyincludes, *pylib, "-o", "test"
system "./test"
end
end