Skip to content

Commit

Permalink
[email protected]_py312: checkin new version of pyside2
Browse files Browse the repository at this point in the history
  • Loading branch information
ipatch committed Oct 8, 2024
1 parent d73b2f8 commit aff27fd
Showing 1 changed file with 119 additions and 0 deletions.
119 changes: 119 additions & 0 deletions Formula/[email protected]_py312.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
class Pyside2AT51515Py312 < Formula
desc "Python bindings for Qt5 and greater"
homepage "https://code.qt.io/cgit/pyside/pyside-setup.git/tree/README.pyside2.md?h=5.15.2"
url ""
sha256 ""

Check failure on line 5 in Formula/[email protected]_py312.rb

View workflow job for this annotation

GitHub Actions / test-bot (ubuntu-22.04)

FormulaAudit/Checksum: sha256 is empty

Check failure on line 5 in Formula/[email protected]_py312.rb

View workflow job for this annotation

GitHub Actions / test-bot (macos-14)

FormulaAudit/Checksum: sha256 is empty

Check failure on line 5 in Formula/[email protected]_py312.rb

View workflow job for this annotation

GitHub Actions / test-bot (macos-13)

FormulaAudit/Checksum: sha256 is empty

Check failure on line 5 in Formula/[email protected]_py312.rb

View workflow job for this annotation

GitHub Actions / test-bot (macos-12)

FormulaAudit/Checksum: sha256 is empty
license all_of: ["GFDL-1.3-only", "GPL-2.0-only", "GPL-3.0-only", "LGPL-2.1-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

keg_only :versioned_formula

depends_on "cmake" => :build
depends_on "freecad/freecad/[email protected]_py312"
# epends_on "llvm@15" # Upstream issue ref: https://bugreports.qt.io/browse/PYSIDE-2268
depends_on "llvm" # Upstream issue ref: https://bugreports.qt.io/browse/PYSIDE-2268
depends_on "[email protected]"
depends_on "qt@5"
depends_on "sphinx-doc"

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.12"
end

# NOTE: ipatch >= [email protected] tarballs require a c++17 compiler
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

ENV.append_path "CMAKE_PREFIX_PATH", Formula["llvm"].opt_lib
ENV.append_path "CMAKE_PREFIX_PATH", Formula["qt@5"].opt_lib

cmake_args = std_cmake_args

# NOTE: ipatch build will fail if using `python3` cmake requires major+minor ie. `python3.10`
py_exe = Formula["[email protected]"].opt_bin/"python3.12"

py_lib = if OS.mac?
Formula["[email protected]"].opt_lib/"libpython3.12.dylib"
else
Formula["[email protected]"].opt_lib/"libpython3.12.so"
end

cmake_args << "-DPYTHON_EXECUTABLE=#{py_exe}"
cmake_args << "-DPYTHON_LIBRARY=#{py_lib}"

# Avoid shim reference.
inreplace "sources/shiboken2/ApiExtractor/CMakeLists.txt", "${CMAKE_CXX_COMPILER}", ENV.cxx

system "cmake", "-S", ".", "-B", "build",
"-DCMAKE_INSTALL_RPATH=#{rpaths.join(";")}",
"-DFORCE_LIMITED_API=NO",
"-DLLVM_CONFIG=#{Formula["llvm"].opt_bin}/llvm-config",
"-DCMAKE_LIBRARY_PATH=#{Formula["llvm"].opt_lib}",
"-L",
*cmake_args

system "cmake", "--build", "build"
system "cmake", "--install", "build"
end

def post_install
# explicitly set python version
python_version = "3.12"

# Unlink the existing .pth file to avoid reinstall issues
pth_file = lib/"python#{python_version}/pyside2.pth"
pth_file.unlink if pth_file.exist?

ohai "Creating .pth file for pyside2 module"
# write the .pth file to the parent dir of site-packages
(lib/"python#{python_version}/pyside2.pth").write <<~EOS
import site; site.addsitedir('#{lib}/python#{python_version}/site-packages/')
EOS
end

def caveats
<<-EOS
this formula may require manual linking after install
this a versioned formula designed to work with the homebrew-freecad tap
EOS
end

test do
Language::Python.each_python(build) do |python, _version|
system python, "-c", "from PySide2 import QtCore"
end
end
end

0 comments on commit aff27fd

Please sign in to comment.