Skip to content

Commit

Permalink
setup new formula file for freecad 0.20.2 release using py310
Browse files Browse the repository at this point in the history
  • Loading branch information
ipatch committed Mar 18, 2024
1 parent 1fde4f6 commit 32db493
Showing 1 changed file with 299 additions and 0 deletions.
299 changes: 299 additions & 0 deletions Formula/[email protected]_py310.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,299 @@
class FreecadAT0202Py310 < Formula
desc "Parametric 3D modeler"
homepage "https://www.freecadweb.org"
url "https://github.com/FreeCAD/FreeCAD/archive/refs/tags/0.20.2.tar.gz"
sha256 "46922f3a477e742e1a89cd5346692d63aebb2b67af887b3e463e094a4ae055da"
license "GPL-2.0-only"
head "https://github.com/freecad/FreeCAD.git", branch: "main", shallow: false

depends_on "cmake" => :build
depends_on "gcc" => :build
# epends_on "hdf5-mpi" => :build # requires fortran compiler
depends_on "hdf5" => :build # requires fortran compiler
depends_on "llvm" => :build
depends_on "mesa" => :build if OS.linux?
depends_on "pkg-config" => :build
depends_on "[email protected]" => :build
depends_on "swig" => :build
depends_on "tbb" => :build
depends_on "boost"
depends_on "cython"
depends_on "doxygen"
depends_on "freecad/freecad/coin3d_py310"
depends_on "freecad/freecad/fc_bundle"
depends_on "freecad/freecad/med-file"
depends_on "freecad/freecad/[email protected]_py310"
depends_on "freecad/freecad/pybind11_py310"
depends_on "freecad/freecad/[email protected]_py310"
depends_on "freecad/freecad/[email protected]_py310"
depends_on "freetype"
depends_on "glew"
depends_on "icu4c"
depends_on macos: :high_sierra # no access to sierra test box
depends_on "openblas"
depends_on "opencascade"
depends_on "orocos-kdl"
# epends_on "freecad/freecad/[email protected]"
# TODO: is it possible to point qt@5 to a revision where py310 is being used
depends_on "qt@5"
depends_on "svn"
depends_on "vtk"
depends_on "webp"
depends_on "xerces-c"
depends_on "zlib"

# NOTE: `brew update-python-resources` check for outdated py resources
# TODO: ipatch, still appears freecad's cmake setup process is not finding matplotlib
resource "matplotlib" do
url "https://files.pythonhosted.org/packages/8a/46/425a44ab9a71afd2f2c8a78b039c1af8ec21e370047f0ad6e43ca819788e/matplotlib-3.5.1.tar.gz"
sha256 "b2e9810e09c3a47b73ce9cab5a72243a1258f61e7900969097a817232246ce1c"
end

resource "PyYAML" do
url "https://files.pythonhosted.org/packages/36/2b/61d51a2c4f25ef062ae3f74576b01638bebad5e045f747ff12643df63844/PyYAML-6.0.tar.gz"
sha256 "68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2"
end

# NOTE: https://docs.brew.sh/Formula-Cookbook#handling-different-system-configurations
# patch for mojave with 10.15 SDK
patch :p1 do
url "https://raw.githubusercontent.com/FreeCAD/homebrew-freecad/a4b71def99b5fe907550729038752aaf6fa1b9bf/patches/freecad-0.20.1-macos-10.15-sdk.patch"
sha256 "ce9f4b2afb2c621274e74208a563616eeeee54369f295b6c5f6f4f3112923135"
end

patch do
url "https://raw.githubusercontent.com/FreeCAD/homebrew-freecad/06bd260fc8c8bce1c283f86df3641fd2efea186d/patches/freecad-0.20.2-e57-add-missing-include.patch"
sha256 "83f033112845fde21c84f18bfa91609b18394dc9adb268c24aa8a1e5ec5aca85"
end

# newer versions of occ have removed offending header file
patch do
url "https://raw.githubusercontent.com/FreeCAD/homebrew-freecad/06bd260fc8c8bce1c283f86df3641fd2efea186d/patches/freecad-0.20.2-occ-error.patch"
sha256 "e345d1ced6e46dd6d7cdaa136d32a8fe55eb54ccb01468f22fb425645e5a0585"
end

patch do
# NOTE: ipatch, ie. local patch `url "file:///#{HOMEBREW_PREFIX}/Library/Taps/freecad/homebrew-freecad/patches/`
url "https://raw.githubusercontent.com/FreeCAD/homebrew-freecad/06bd260fc8c8bce1c283f86df3641fd2efea186d/patches/freecad-0.20.2-setup-python-cmake.patch"
sha256 "f259ec18294438a306fa58599c093d18bc9aaf3cb8056d140c15fdfe9247957a"
end

patch do
url "https://raw.githubusercontent.com/FreeCAD/homebrew-freecad/1fde4f693950d77e8617c08921d50c1aba3f0a56/patches/freecad-0.20.2-cmake-find-xercesc.patch"
sha256 "adb30f5d723672d1d54db4a236bce8a85e9bc9d0667ef88a7360e4cae1bb27c9"
end

patch do
url "https://raw.githubusercontent.com/FreeCAD/homebrew-freecad/95e5aa838ae8b5e7d4fd6ddd710bc53c8caedddc/patches/freecad-0.20.2-cmake-find-hdf5.patch"
sha256 "99d115426cb3e8d7e5ab070e1d726e51eda181ac08768866c6e0fd68cda97f20"
end

patch do
url "https://raw.githubusercontent.com/FreeCAD/homebrew-freecad/95e5aa838ae8b5e7d4fd6ddd710bc53c8caedddc/patches/freecad-0.20.2-vtk-9.3.patch"
sha256 "67794ebfcd70a160d379eeca7d2ef78d510057960d0eaa4e2e345acb7ae244aa"
end

def install

Check failure on line 96 in Formula/[email protected]_py310.rb

View workflow job for this annotation

GitHub Actions / test-bot (macos-14)

`brew install --verbose --build-bottle freecad/freecad/[email protected]_py310` failed on macOS Sonoma (14) on Apple Silicon!

ievbsp/FreeCAD-0.20.2/src/Gui/TreeItemMode.h:2:26: warning: invalid UTF-8 in comment [-Winvalid-utf8] 2 | * Copyright (c) 2004 J<FC>rgen Riegel <[email protected]> * | ^ 1 warning generated. [ 99%] Building CXX object src/Mod/PartDesign/Gui/CMakeFiles/PartDesignGui.dir/ViewProviderDatum.cpp.o 1 warning generated. [ 99%] Building CXX object src/Mod/PartDesign/Gui/CMakeFiles/PartDesignGui.dir/ViewProviderDatumPoint.cpp.o 1 warning generated. [ 99%] Building CXX object src/Mod/PartDesign/Gui/CMakeFiles/PartDesignGui.dir/ViewProviderDatumLine.cpp.o In file included from /tmp/freecadA0.20.2_py310-20240318-14701-ievbsp/FreeCAD-0.20.2/src/Mod/PartDesign/Gui/ViewProviderDatum.cpp:49: In file included from /tmp/freecadA0.20.2_py310-20240318-14701-ievbsp/FreeCAD-0.20.2/src/Gui/View3DInventor.h:31: In file included from /tmp/freecadA0.20.2_py310-20240318-14701-ievbsp/FreeCAD-0.20.2/src/Gui/MDIView.h:28: In file included from /tmp/freecadA0.20.2_py310-20240318-14701-ievbsp/FreeCAD-0.20.2/src/Gui/ActiveObjectList.h:30: /tmp/freecadA0.20.2_py310-20240318-14701-ievbsp/FreeCAD-0.20.2/src/Gui/TreeItemMode.h:2:26: warning: invalid UTF-8 in comment [-Winvalid-utf8] 2 | * Copyright (c) 2004 J<FC>rgen Riegel <[email protected]> * | ^ [ 99%] Building CXX object src/Mod/PartDesign/Gui/CMakeFiles/PartDesignGui.dir/ViewProviderDatumPlane.cpp.o 1 warning generated. [ 99%] Building CXX object src/Mod/PartDesign/Gui/CMakeFiles/PartDesignGui.dir/ViewProviderDatumCS.cpp.o [ 99%] Building CXX object src/Mod/PartDesign/Gui/CMakeFiles/PartDesignGui.dir/ViewProviderShapeBinder.cpp.o [ 99%] Building CXX object src/Mod/PartDesign/Gui/CMakeFiles/PartDesignGui.dir/ViewProviderBoolean.cpp.o In file included from /tmp/freecadA0.20.2_py310-20240318-14701-ievbsp/FreeCAD-0.20.2/src/Mod/PartDesign/Gui/ViewProviderShapeBinder.cpp:40: In file included from /tmp/freecadA0.20.2_py310-20240318-14701-ievbsp/FreeCAD-0.20.2/src/Gui/Document.h:33: /tmp/freecadA0.20.2_py310-20240318-14701-ievbsp/FreeCAD-0.20.2/src/Gui/TreeItemMode.h:2:26: warning: invalid UTF-8 in comment [-Winvalid-utf8] 2 | * Copyright (c) 2004 J<FC>rgen Riegel <[email protected]> * | ^ [ 99%] Building CXX object src/Mod/PartDesign/Gui/CMakeFiles/PartDesignGui.dir/ViewProviderAddSub.cpp.o 1 warning generated. [ 99%] Building CXX object src/Mod/PartDesign/Gui/CMakeFiles/PartDesignGui.dir/ViewProviderPrimitive.cpp.o In file included from /tmp/freecadA0.20.2_py310-20240318-14701-ievbsp/FreeCAD-0.20.2/src/Mod/PartDesign/Gui/ViewProviderBoolean.cpp:32: In file included from /tmp/freecadA0.20.2_py310-20240318-14701-ievbsp/FreeCAD-0.20.2/src/Mod/PartDesign/Gui/ViewProviderBoolean.h:28: In file included from /tmp/freecadA0.20.2_py310-20240318-14701-ievbsp/FreeCAD-0.20.2/src/Mod/PartDesign/Gui/ViewProvider.h:28: In file included from /tmp/freecadA0.20.2_py310-20240318-14701-ievbsp/FreeCAD-0.20.2/src/Mod/PartDesign/Gui/ViewProviderBody.h:29: In file included from /tmp/freecadA0.20.2_py310-20240318-14701-ievbsp/FreeCAD-0.20.2/src/Gui/ViewProviderOriginGroupExtension.h:27: In file included from /tmp/freecadA0.20.2_py310-20240318-14701-ievbsp/FreeCAD-0.20.2/src/Gui/ViewProviderGeoFeatureGroup.h:31: In file included from /tmp/freecadA0.20.2_py310-20240318-14701-ievbsp/FreeCAD-0.20.2/src/Gui/ViewProviderPythonFeature.h:31: In file included from /tmp/freecadA0.20.2_py310-20240318-14701-ievbsp/FreeCAD-0.20.2/src/Gui/Document.h:33: /tmp/freecadA0.20.2_py310-20240318-14701-ievbsp/FreeCAD-0.20.2/src/Gui/TreeItemMode.h:2:26: warning: invalid UTF-8 in comment [-Winvalid-utf8] 2 | * Copyright (c) 2004 J<FC>rgen Riegel <[email protected]> * | ^ In file included from /tmp/freecadA0.20.2_py310-20240318-14701-ievbsp/FreeCAD-0.20.2/src/Mod/PartDesign/Gui/ViewProviderAddSub.cpp:48: In file included from /tmp/freecadA0.20.2_py310-20240318-14701-ievbsp/FreeCAD-0.20.2/src/Mod/Part
hbp = HOMEBREW_PREFIX

# NOTE: taken from node@14 formula, node uses autoconf and not cmake
# make sure subprocesses spawned by make are using our Python 3
# TODO: set var in a more robust way, rm dep on which
ENV["PYTHON"] = which("python3.10")
puts "--------------------------------------------"
puts "PYTHON=#{ENV["PYTHON"]}"
puts "--------------------------------------------"

# NOTE: apple's clang & clang++ are unable to work with openmpi
# NOTE: when setting the compilers to brews' llvm, set the cmake_ar linker as well
ENV["CC"] = Formula["llvm"].opt_bin/"clang"
ENV["CXX"] = Formula["llvm"].opt_bin/"clang++"

# NOTE: ipatch, attempt to nuke default cmake_prefix_path to prevent qt6 from sneaking in
ENV.delete("CMAKE_PREFIX_PATH") # Clear existing paths
puts "--------------------------------------------"
puts "CMAKE_PREFIX_PATH=#{ENV["CMAKE_PREFIX_PATH"]}"
puts "CMAKE_PREFIX_PATH Datatype: #{ENV["CMAKE_PREFIX_PATH"].class}"
puts "--------------------------------------------"
puts hbp
puts "--------------------------------------------"

cmake_prefix_paths = []
cmake_prefix_paths << Formula["pybind11_py310"].prefix
cmake_prefix_paths << Formula["doxygen"].prefix
cmake_prefix_paths << Formula["xerces-c"].prefix
cmake_prefix_paths << Formula["zlib"].prefix
cmake_prefix_paths << Formula["opencascade"].prefix
cmake_prefix_paths << Formula["vtk"].prefix
cmake_prefix_paths << Formula["utf8cpp"].prefix
cmake_prefix_paths << Formula["glew"].prefix
cmake_prefix_paths << Formula["hdf5"].prefix
cmake_prefix_paths << Formula["libpng"].prefix
cmake_prefix_paths << Formula["pugixml"].prefix
cmake_prefix_paths << Formula["eigen"].prefix
cmake_prefix_paths << Formula["expat"].prefix
cmake_prefix_paths << Formula["double-conversion"].prefix
cmake_prefix_paths << Formula["lz4"].prefix
cmake_prefix_paths << Formula["xz"].prefix
cmake_prefix_paths << Formula["libjpeg-turbo"].prefix
cmake_prefix_paths << Formula["libtiff"].prefix
cmake_prefix_paths << Formula["medfile"].prefix
cmake_prefix_paths << Formula["pkg-config"].prefix
cmake_prefix_paths << Formula["boost"].prefix
cmake_prefix_paths << Formula["[email protected]"].prefix
cmake_prefix_paths << Formula["freetype"].prefix
cmake_prefix_paths << Formula["coin3d_py310"].prefix
cmake_prefix_paths << Formula["open-mpi"].prefix
cmake_prefix_paths << Formula["[email protected]_py310"].prefix
cmake_prefix_paths << Formula["[email protected]_py310"].prefix
cmake_prefix_paths << Formula["svn"].prefix
cmake_prefix_paths << Formula["llvm"].prefix

cmake_prefix_path_string = cmake_prefix_paths.join(";")

# NOTE: presently expat is not found during test-bot ci runs
# https://github.com/FreeCAD/homebrew-freecad/actions/runs/8317869406/job/22759137355#step:17:225

# TODO: exp with prepending qt@5 to PATH
# ENV.prepend_path "PATH", Formula["qt@5"].opt_bin

# exp with symlinked sdk path
cmake_osx_sysroot = "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"
macos_sdk_prefix = "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks"
macos_sdk_prefix_qt = "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks"

# -DQt5_ROOT=#{hbp}/opt/qt@5
qtwebmodule = "Qt WebEngine"

# args = std_cmake_args + %W[
# -DQt5WebKitWidgets_DIR=#{hbp}/opt/qt@5/lib/cmake/
args = %W[
-DHOMEBREW_PREFIX=#{hbp}
-DCMAKE_PREFIX_PATH=#{cmake_prefix_path_string}
-DPYTHON_EXECUTABLE=#{hbp}/opt/[email protected]/bin/python3.10
-DBUILD_SMESH=1
-DFREECAD_USE_EXTERNAL_KDL=1
-DBUILD_FEM_NETGEN=0
-DBUILD_ENABLE_CXX_STD=C++17
-DFREECAD_USE_PYBIND11=1
-DFREECAD_USE_QTWEBMODULE=#{qtwebmodule}
-DBUILD_DRAWING=1
-DBUILD_QT5=1
-DCMAKE_OSX_SYSROOT=#{cmake_osx_sysroot}
-DCMAKE_AR=#{hbp}/opt/llvm/bin/llvm-ar
-DQt5Concurrent_DIR=#{hbp}/opt/qt@5/lib/cmake/Qt5Concurrent
-DQt5Core_DIR=#{hbp}/opt/qt@5/lib/cmake/Qt5Core
-DQt5Gui_DIR=#{hbp}/opt/qt@5/lib/cmake/Qt5Gui
-DQt5Network_DIR=#{hbp}/opt/qt@5/lib/cmake/Qt5Network
-DQt5OpenGL_DIR=#{hbp}/opt/qt@5/lib/cmake/Qt5OpenGL
-DQt5PrintSupport_DIR=#{hbp}/opt/qt@5/lib/cmake/Qt5PrintSupport
-DQt5Svg_DIR=#{hbp}/opt/qt@5/lib/cmake/Qt5Svg
-DQt5UiTools_DIR=#{hbp}/opt/qt@5/lib/cmake/Qt5UiTools
-DQt5WebEngineWidgets_DIR=#{hbp}/opt/qt@5/lib/cmake/Qt5WebEngineWidgets
-DQt5Widgets_DIR=#{hbp}/opt/qt@5/lib/cmake/Qt5Widgets
-DQt5XmlPatterns_DIR=#{hbp}/opt/qt@5/lib/cmake/Qt5XmlPatterns
-DQt5Xml_DIR=#{hbp}/opt/qt@5/lib/cmake/Qt5Xml
-DCMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH=FALSE
-DCMAKE_FIND_USE_CMAKE_SYSTEM_PATH=FALSE
-DCMAKE_IGNORE_PATH=#{hbp}/lib;#{hbp}/include/QtCore;#{hbp}/Cellar/qt;
-DOPENGL_INCLUDE_DIR=#{macos_sdk_prefix}/OpenGL.framework/Headers/
-DOPENGL_gl_LIBRARY=#{macos_sdk_prefix}/OpenGL.framework/Versions/A/Libraries/libGL.tbd
-DOPENGL_glu_LIBRARY=#{macos_sdk_prefix}/OpenGL.framework/Versions/A/Libraries/libGLU.tbd
-D_Qt5UiTools_RELEASE_AppKit_PATH=#{macos_sdk_prefix_qt}/AppKit.framework
-D_Qt5UiTools_RELEASE_Metal_PATH=#{macos_sdk_prefix_qt}/Metal.framework
-D_Qt5UiTools_RELEASE_DiskArbitration_PATH=/#{macos_sdk_prefix_qt}/DiskArbitration.framework
-D_Qt5UiTools_RELEASE_IOKit_PATH=/#{macos_sdk_prefix_qt}/IOKit.framework
-D_Qt5UiTools_RELEASE_OpenGL_PATH=/#{macos_sdk_prefix_qt}/OpenGL.framework
-D_Qt5UiTools_RELEASE_AGL_PATH=/#{macos_sdk_prefix_qt}/AGL.framework
-L
]
# --trace
# NOTE: useful cmake debugging args
# -L

if OS.mac?
args += %W[
-DPYTHON_INCLUDE_DIR=#{hbp}/opt/[email protected]/Frameworks/Python.framework/Versions/3.10/Headers
-DPYTHON_LIBRARY=#{hbp}/opt/[email protected]/Frameworks/Python.framework/Versions/3.10/lib/libpython3.10.dylib
]
elsif OS.linux?
args += %W[
-DPYTHON_INCLUDE_DIR=#{hbp}/opt/[email protected]/include/python3.10
-DPYTHON_LIBRARY=#{hbp}/opt/[email protected]/lib/libpython3.10.so
]
else
odie "Unsupported operating system"
end

ENV.remove "PATH", Formula["pyside@2"].opt_prefix/"bin"
ENV.remove "PATH", Formula["qt"].opt_prefix/"bin"
ENV.remove "PATH", Formula["pyqt"].opt_prefix/"bin"

ENV.remove "PKG_CONFIG_PATH", Formula["pyside@2"].opt_prefix/"lib/pkgconfig"
ENV.remove "PKG_CONFIG_PATH", Formula["qt"].opt_prefix/"lib/pkgconfig"

ENV.remove "CMAKE_FRAMEWORK_PATH", Formula["qt"].opt_prefix/"Frameworks"

# TODO: ipatch, causes audit exception, ie. `brew style freecad/freecad`
# ENV.remove "PATH", Formula["[email protected]"].opt_prefix/"bin"
# ENV.remove "PATH", Formula["[email protected]"].opt_prefix/"libexec/bin"
# ENV.remove "PKG_CONFIG_PATH", Formula["[email protected]"].opt_prefix/"lib/pkgconfig"

# NOTE: ipatch, required for successful build
# ENV.prepend_path "PYTHONPATH", Formula["[email protected]"].opt_prefix/Language::Python.site_packages(python3)
# ENV.prepend_path "PYTHONPATH", Formula["[email protected]"].opt_prefix/Language::Python.site_packages(python3)

# TODO: ipatch, do not make build dir a sub dir of the src dir
mkdir "Build" do
system "cmake", *args, ".."
system "make", "install"
end
end

# TODO: ipatch, the below postinstall steps are only valid for macos, need to update for gnu+linux to
def post_install
if OS.mac?
ohai "the value of prefix = #{prefix}"
ln "#{prefix}/MacOS/FreeCAD", "#{HOMEBREW_PREFIX}/bin/freecad"
ln "#{prefix}/MacOS/FreeCADCmd", "#{HOMEBREW_PREFIX}/bin/freecadcmd"
elsif OS.linux?
ohai "the value of prefix = #{prefix}"
ln "#{bin}/FreeCAD", "#{HOMEBREW_PREFIX}/bin/freecad"
ln "#{bin}/FreeCADCmd", "#{HOMEBREW_PREFIX}/bin/freecadcmd"
end
end

def caveats
<<-EOS
After installing FreeCAD you may want to do the following:
1. Amend your PYTHONPATH environmental variable to point to
the FreeCAD directory
export PYTHONPATH=#{bin}:$PYTHONPATH
2. Due to recent code signing updates with Catalina and newer
building a FreeCAD.app bundle using the existing python
script no longer works due to updating the rpaths of the
copied executables and libraries into a FreeCAD.app
bundle. Until a fix or work around is made freecad
is built for CLI by default now.
3. if freecad launches with runtime errors a common fix
i have run into is to force link [email protected] and
[email protected] so workbenches such Draft and Arch
have the necessary runtime deps, see brew documenation
about force linking the above packages
4. upstream homebrew/core has begun to introduce python 3.11
with that said, testing the formula manually on my local
catalina box i ran into issues with regard to boost.
the quick fix, unlink python 3.11 and cmake is able to
finish its checks and the build process can begin
EOS
end

test do
# NOTE: make test more robust and accurate
system "true"
end
end

0 comments on commit 32db493

Please sign in to comment.