Skip to content

Commit

Permalink
coin3d using py310
Browse files Browse the repository at this point in the history
  • Loading branch information
ipatch committed Dec 27, 2023
1 parent d13611d commit 7782ced
Showing 1 changed file with 116 additions and 0 deletions.
116 changes: 116 additions & 0 deletions Formula/coin3d_py310.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
class Coin3dPy310 < Formula
desc "Open Inventor 2.1 API implementation (Coin) with Python bindings (Pivy)"
homepage "https://coin3d.github.io/"
license all_of: ["BSD-3-Clause", "ISC"]

stable do
url "https://github.com/coin3d/coin/releases/download/v4.0.2/coin-4.0.2-src.zip"
sha256 "b764a88674f96fa540df3a9520d80586346843779858dcb6cd8657725fcb16f0"

# TODO: migrate pyside@2 -> pyside and [email protected] -> [email protected] on next pivy release
resource "pivy" do
url "https://github.com/coin3d/pivy/archive/refs/tags/0.6.8.tar.gz"
sha256 "c443dd7dd724b0bfa06427478b9d24d31e0c3b5138ac5741a2917a443b28f346"
end
end

head do
url "https://github.com/coin3d/coin.git", branch: "master"

resource "pivy" do
url "https://github.com/coin3d/pivy.git", branch: "master"
end
end

keg_only :versioned_formula

depends_on "cmake" => :build
depends_on "doxygen" => :build
depends_on "freecad/freecad/[email protected]" => :build
depends_on "ninja" => :build
depends_on "boost"
depends_on "freecad/freecad/[email protected]_py310"
depends_on "[email protected]"

on_linux do
depends_on "mesa"
depends_on "mesa-glu"
end

def python3
"python3.10"
end

def install

Check failure on line 44 in Formula/coin3d_py310.rb

View workflow job for this annotation

GitHub Actions / test-bot (self-hosted-catalinavm)

`brew install --verbose --build-bottle freecad/freecad/coin3d_py310` failed on macOS Catalina (10.15)!

^ pivy/coin_wrap.cpp:110771:9: warning: variable 'arg4' is uninitialized when used here [-Wuninitialized] if (arg4) { ^~~~ pivy/coin_wrap.cpp:110706:14: note: initialize the variable 'arg4' to silence this warning char **arg4 ; ^ = NULL pivy/coin_wrap.cpp:168824:9: warning: variable 'arg4' is uninitialized when used here [-Wuninitialized] if (arg4) { ^~~~ pivy/coin_wrap.cpp:168777:19: note: initialize the variable 'arg4' to silence this warning float (*arg4)[3] ; ^ = NULL pivy/coin_wrap.cpp:170193:9: warning: variable 'arg4' is uninitialized when used here [-Wuninitialized] if (arg4) { ^~~~ pivy/coin_wrap.cpp:170128:14: note: initialize the variable 'arg4' to silence this warning char **arg4 ; ^ = NULL pivy/coin_wrap.cpp:172962:8: warning: variable 'arg4' is uninitialized when used here [-Wuninitialized] if(arg4) free(arg4); ^~~~ pivy/coin_wrap.cpp:172917:19: note: initialize the variable 'arg4' to silence this warning float (*arg4)[2] ; ^ = NULL pivy/coin_wrap.cpp:233487:9: warning: variable 'arg4' is uninitialized when used here [-Wuninitialized] if (arg4) { ^~~~ pivy/coin_wrap.cpp:233435:19: note: initialize the variable 'arg4' to silence this warning float (*arg4)[3] ; ^ = NULL pivy/coin_wrap.cpp:233552:9: warning: variable 'arg4' is uninitialized when used here [-Wuninitialized] if (arg4) { ^~~~ pivy/coin_wrap.cpp:233500:19: note: initialize the variable 'arg4' to silence this warning float (*arg4)[3] ; ^ = NULL pivy/coin_wrap.cpp:255586:9: warning: variable 'arg4' is uninitialized when used here [-Wuninitialized] if (arg4) { ^~~~ pivy/coin_wrap.cpp:255539:20: note: initialize the variable 'arg4' to silence this warning double (*arg4)[3] ; ^ = NULL pivy/coin_wrap.cpp:342273:36: warning: array index 2 is past the end of the array (which contains 2 elements) [-Warray-bounds] int res = SWIG_AsVal_int(argv[2], NULL); ^ ~ pivy/coin_wrap.cpp:342248:3: note: array 'argv' declared here PyObject *argv[2] = { ^ pivy/coin_wrap.cpp:342298:36: warning: array index 2 is past the end of the array (which contains 2 elements) [-Warray-bounds] int res = SWIG_AsVal_int(argv[2], NULL); ^ ~ pivy/coin_wrap.cpp:342248:3: note: array 'argv' declared here PyObject *argv[2] = { ^ pivy/coin_wrap.cpp:342480:37: warning: array index 3 is past the end of the array (which contains 3 elements) [-Warray-bounds] int res = SWIG_ConvertPtr(argv[3], &vptr, SWIGTYPE_p_unsigned_char, 0); ^ ~ pivy/coin_wrap.cpp:1081:80: note: expanded from macro 'SWIG_ConvertPtr' #define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtr(obj, pptr, type, flags) ^~~ pivy/coin_wrap.cpp:1080:86: note: expanded from macro 'SWIG_Python_ConvertPtr' #define SWIG_Python_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0) ^~~ pivy/coin_wrap.cpp:342453:3: note: array 'argv' declared here PyObject *argv[3] = { ^ pivy/coin_wrap.cpp:342510:37: warning: array index 3 is past the end of the array (which contains 3 elements) [-Warray-bounds] int res = SWIG_ConvertPtr(argv[3], &vptr, SWIGTYPE_p_unsigned_char, 0); ^ ~ pivy/coin_wrap.cpp:1081:80: note: expa

Check failure on line 44 in Formula/coin3d_py310.rb

View workflow job for this annotation

GitHub Actions / test-bot (self-hosted-mojavevm)

`brew install --verbose --build-bottle freecad/freecad/coin3d_py310` failed on macOS Mojave (10.14)!

^ /usr/local/opt/[email protected]/Frameworks/Python.framework/Versions/3.10/include/python3.10/cpython/unicodeobject.h:445:1: note: '_PyUnicode_get_wstr_length' has been explicitly marked deprecated here Py_DEPRECATED(3.3) ^ /usr/local/opt/[email protected]/Frameworks/Python.framework/Versions/3.10/include/python3.10/pyport.h:513:54: note: expanded from macro 'Py_DEPRECATED' #define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__)) ^ pivy/coin_wrap.cpp:110771:9: warning: variable 'arg4' is uninitialized when used here [-Wuninitialized] if (arg4) { ^~~~ pivy/coin_wrap.cpp:110706:14: note: initialize the variable 'arg4' to silence this warning char **arg4 ; ^ = NULL pivy/coin_wrap.cpp:168824:9: warning: variable 'arg4' is uninitialized when used here [-Wuninitialized] if (arg4) { ^~~~ pivy/coin_wrap.cpp:168777:19: note: initialize the variable 'arg4' to silence this warning float (*arg4)[3] ; ^ = NULL pivy/coin_wrap.cpp:170193:9: warning: variable 'arg4' is uninitialized when used here [-Wuninitialized] if (arg4) { ^~~~ pivy/coin_wrap.cpp:170128:14: note: initialize the variable 'arg4' to silence this warning char **arg4 ; ^ = NULL pivy/coin_wrap.cpp:172962:8: warning: variable 'arg4' is uninitialized when used here [-Wuninitialized] if(arg4) free(arg4); ^~~~ pivy/coin_wrap.cpp:172917:19: note: initialize the variable 'arg4' to silence this warning float (*arg4)[2] ; ^ = NULL pivy/coin_wrap.cpp:233487:9: warning: variable 'arg4' is uninitialized when used here [-Wuninitialized] if (arg4) { ^~~~ pivy/coin_wrap.cpp:233435:19: note: initialize the variable 'arg4' to silence this warning float (*arg4)[3] ; ^ = NULL pivy/coin_wrap.cpp:233552:9: warning: variable 'arg4' is uninitialized when used here [-Wuninitialized] if (arg4) { ^~~~ pivy/coin_wrap.cpp:233500:19: note: initialize the variable 'arg4' to silence this warning float (*arg4)[3] ; ^ = NULL pivy/coin_wrap.cpp:255586:9: warning: variable 'arg4' is uninitialized when used here [-Wuninitialized] if (arg4) { ^~~~ pivy/coin_wrap.cpp:255539:20: note: initialize the variable 'arg4' to silence this warning double (*arg4)[3] ; ^ = NULL pivy/coin_wrap.cpp:342273:36: warning: array index 2 is past the end of the array (which contains 2 elements) [-Warray-bounds] int res = SWIG_AsVal_int(argv[2], NULL); ^ ~ pivy/coin_wrap.cpp:342248:3: note: array 'argv' declared here PyObject *argv[2] = { ^ pivy/coin_wrap.cpp:342298:36: warning: array index 2 is past the end of the array (which contains 2 elements) [-Warray-bounds] int res = SWIG_AsVal_int(argv[2], NULL); ^ ~ pivy/coin_wrap.cpp:342248:3: note: array 'argv' declared here PyObject *argv[2] = { ^ pivy/coin_wrap.cpp:342480:37: warning: array index 3 is past the end of the array (which contains 3 elements) [-Warray-bounds] int res = SWIG_ConvertPtr(argv[3], &vptr, SWIGTYPE_p_unsigned_char, 0); ^ ~ pivy/coin_wrap.cpp:1081:80: note: expanded from macro 'SWIG_ConvertPtr' #define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtr(obj, pptr, type, flags) ^~~ pivy/coin_wrap.cpp:1080:86: note: expanded from macro 'SWIG_Python_ConvertPtr' #define SWIG_Python_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0)
system "cmake", "-S", ".", "-B", "_build",
"-DCOIN_BUILD_MAC_FRAMEWORK=OFF",
"-DCOIN_BUILD_DOCUMENTATION=ON",
"-DCOIN_BUILD_TESTS=OFF",
*std_cmake_args
system "cmake", "--build", "_build"
system "cmake", "--install", "_build"

resource("pivy").stage do
ENV.append_path "CMAKE_PREFIX_PATH", prefix.to_s
ENV["LDFLAGS"] = "-Wl,-rpath,#{opt_lib}"
system python3, "-m", "pip", "install", *std_pip_args, "."
end
end

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

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

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

def caveats
<<~EOS
this formula is keg-only, and intended to aid in the building of freecad
this formula should NOT be linked using `brew link` or else errors will
arise when opening the python3.10 repl
EOS
end

test do

Check failure on line 83 in Formula/coin3d_py310.rb

View workflow job for this annotation

GitHub Actions / test-bot (self-hosted-bigsurvm)

`brew test --verbose freecad/freecad/coin3d_py310` failed on macOS Big Sur (11)!

/usr/local/Homebrew/Library/Homebrew/vendor/bundle/ruby/3.1.0/bin/bundle clean ==> Testing freecad/freecad/coin3d_py310 ==> /usr/bin/clang test.cpp -L/usr/local/Cellar/coin3d_py310/4.0.2/lib -lCoin -Wl,-framework,OpenGL -o test -I/usr/local/opt/coin3d_py310/include ==> ./test ==> /usr/local/opt/[email protected]/bin/python3.10 -c import shiboken2 from pivy.sogui import SoGui assert SoGui.init("test") is not None PasteBoard: Error creating pasteboard: com.apple.pasteboard.clipboard [-4960] PasteBoard: Error creating pasteboard: com.apple.pasteboard.find [-4960] no screens available, assuming 24-bit color Cannot create window: no screens available Error: freecad/freecad/coin3d_py310: failed An exception occurred within a child process: BuildError: Failed executing: /usr/local/opt/[email protected]/bin/python3.10 -c import\ shiboken2 from\ pivy.sogui\ import\ SoGui assert\ SoGui.init("test")\ is\ not\ None /usr/local/Homebrew/Library/Homebrew/formula.rb:2741:in `block in system' /usr/local/Homebrew/Library/Homebrew/formula.rb:2677:in `open' /usr/local/Homebrew/Library/Homebrew/formula.rb:2677:in `system' /usr/local/Homebrew/Library/Homebrew/vendor/bundle/ruby/3.1.0/gems/sorbet-runtime-0.5.11155/lib/types/private/methods/call_validation.rb:153:in `bind_call' /usr/local/Homebrew/Library/Homebrew/vendor/bundle/ruby/3.1.0/gems/sorbet-runtime-0.5.11155/lib/types/private/methods/call_validation.rb:153:in `validate_call_skip_block_type' /usr/local/Homebrew/Library/Homebrew/vendor/bundle/ruby/3.1.0/gems/sorbet-runtime-0.5.11155/lib/types/private/methods/call_validation.rb:95:in `block in create_validator_slow_skip_block_type' /usr/local/Homebrew/Library/Taps/freecad/homebrew-freecad/Formula/coin3d_py310.rb:115:in `block in <class:Coin3dPy310>' /usr/local/Homebrew/Library/Homebrew/formula.rb:2500:in `block (3 levels) in run_test' /usr/local/Homebrew/Library/Homebrew/extend/kernel.rb:493:in `with_env' /usr/local/Homebrew/Library/Homebrew/formula.rb:2499:in `block (2 levels) in run_test' /usr/local/Homebrew/Library/Homebrew/formula.rb:1055:in `with_logging' /usr/local/Homebrew/Library/Homebrew/formula.rb:2498:in `block in run_test' /usr/local/Homebrew/Library/Homebrew/mktemp.rb:75:in `block in run' /usr/local/Homebrew/Library/Homebrew/mktemp.rb:75:in `chdir' /usr/local/Homebrew/Library/Homebrew/mktemp.rb:75:in `run' /usr/local/Homebrew/Library/Homebrew/formula.rb:2792:in `mktemp' /usr/local/Homebrew/Library/Homebrew/formula.rb:2492:in `run_test' /usr/local/Homebrew/Library/Homebrew/test.rb:46:in `block in <main>' /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/lib/ruby/3.1.0/timeout.rb:107:in `block in timeout' /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/lib/ruby/3.1.0/timeout.rb:36:in `block in catch' /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/lib/ruby/3.1.0/timeout.rb:36:in `catch' /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/lib/ruby/3.1.0/timeout.rb:36:in `catch' /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/lib/ruby/3.1.0/timeout.rb:123:in `timeout' /usr/local/Homebrew/Library/Homebrew/test.rb:50:in `<main>'
# NOTE: required because formula is keg_only
coin3d_py310_include = Formula["coin3d_py310"].opt_include

(testpath/"test.cpp").write <<~EOS
#include <Inventor/SoDB.h>
int main() {
SoDB::init();
SoDB::cleanup();
return 0;
}
EOS

opengl_flags = if OS.mac?
["-Wl,-framework,OpenGL"]
else
["-L#{Formula["mesa"].opt_lib}", "-lGL"]
end

system ENV.cc, "test.cpp", "-L#{lib}", "-lCoin", *opengl_flags, "-o", "test", "-I#{coin3d_py310_include}"
system "./test"

ENV.append_path "PYTHONPATH", Formula["coin3d_py310"].opt_prefix/Language::Python.site_packages(python3)
ENV.append_path "PYTHONPATH", Formula["[email protected]_py310"].opt_prefix/Language::Python.site_packages(python3)
# Set QT_QPA_PLATFORM to minimal to avoid error:
# "This application failed to start because no Qt platform plugin could be initialized."
ENV["QT_QPA_PLATFORM"] = "minimal" if OS.linux? && ENV["HOMEBREW_GITHUB_ACTIONS"]
system Formula["[email protected]"].opt_bin/"python3.10", "-c", <<~EOS
import shiboken2
from pivy.sogui import SoGui
assert SoGui.init("test") is not None
EOS
end
end

0 comments on commit 7782ced

Please sign in to comment.