Skip to content

Commit

Permalink
[email protected]_py312: update test block
Browse files Browse the repository at this point in the history
Closes #603.

Signed-off-by: Chris <[email protected]>
  • Loading branch information
ipatch committed Oct 27, 2024
1 parent 1e6c88f commit 2d8a859
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions Formula/[email protected]_py312.rb
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,64 @@ def caveats
end

test do
# NOTE: ipatch, the below resolve to something like, HOMEBREW_PREFIX/Cellar/formula/lib/python/site-packages
ENV.append_path "PYTHONPATH", prefix/Language::Python.site_packages(python3)

puts "--------------------------------------------------------"
puts "PYTHON=#{ENV["PYTHON"]}"
puts "PYTHONPATH=#{ENV["PYTHONPATH"]}"
puts "--------------------------------------------------------"

system python3, "-c", "import PySide2"
system python3, "-c", "import shiboken2"

modules = %w[
Core
Gui
Network
Positioning
Quick
Svg
Widgets
Xml
]
modules << "WebEngineCore" if OS.linux? || (DevelopmentTools.clang_build_version > 1200)
modules.each { |mod| system python3, "-c", "import PySide2.Qt#{mod}" }

pyincludes = shell_output("#{python3}-config --includes").chomp.split
pylib = shell_output("#{python3}-config --ldflags --embed").chomp.split

if OS.linux?
pyver = Language::Python.major_minor_version python3
pylib += %W[
-Wl,-rpath,#{Formula["python@#{pyver}"].opt_lib}
-Wl,-rpath,#{lib}
]
end

(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

shiboken_lib = if OS.mac?
"shiboken2.cpython-312-darwin"
else
"shiboken2.cpython-312-x86_64-linux-gnu"
end

system ENV.cxx, "-std=c++17", "test.cpp",
"-I#{include}/shiboken2",
"-L#{lib}", "-l#{shiboken_lib}",
"-L#{Formula["gettext"].opt_lib}",
*pyincludes, *pylib, "-o", "test"
system "./test"
Language::Python.each_python(build) do |python, _version|
system python, "-c", "from PySide2 import QtCore"
end
Expand Down

0 comments on commit 2d8a859

Please sign in to comment.