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 17, 2024
1 parent 95e5aa8 commit a26cb04
Showing 1 changed file with 281 additions and 0 deletions.
281 changes: 281 additions & 0 deletions Formula/[email protected]_py310.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,281 @@
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 "file:///#{HOMEBREW_PREFIX}/Library/Taps/freecad/homebrew-freecad/patches/qt.patch"
# sha256 ""
# 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!

the cmake_policy command to set the policy and suppress this warning. Call Stack (most recent call first): /opt/homebrew/opt/pybind11_py310/share/cmake/pybind11/pybind11Tools.cmake:50 (find_package) /opt/homebrew/opt/pybind11_py310/share/cmake/pybind11/pybind11Common.cmake:188 (include) /opt/homebrew/opt/pybind11_py310/share/cmake/pybind11/pybind11Config.cmake:250 (include) cMake/FreeCAD_Helpers/SetupPybind11.cmake:7 (find_package) CMakeLists.txt:47 (SetupPybind11) This warning is for project developers. Use -Wno-dev to suppress it. -- Found PythonInterp: /opt/homebrew/opt/[email protected]/bin/python3.10 (found suitable version "3.10.13", minimum required is "3.6") -- Found PythonLibs: /opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.10/lib/libpython3.10.dylib -- Performing Test HAS_FLTO -- Performing Test HAS_FLTO - Success -- Performing Test HAS_FLTO_THIN -- Performing Test HAS_FLTO_THIN - Success -- Found pybind11: /opt/homebrew/opt/pybind11_py310/include (found version "2.11.1") -- Found XercesC: /opt/homebrew/opt/xerces-c/lib/libxerces-c.dylib (found version "3.2.5") -- Found ZLIB: /opt/homebrew/opt/zlib/lib/libz.dylib (found version "1.3") -- PyCXX found: -- Headers: /tmp/freecadA0.20.2_py310-20240317-15990-wb2xmu/FreeCAD-0.20.2/src -- Sources: /tmp/freecadA0.20.2_py310-20240317-15990-wb2xmu/FreeCAD-0.20.2/src/CXX -- Version: 6.2.8 -- Found OCC: /opt/homebrew/opt/opencascade/include/opencascade (found version "7.7.2") -- -- Found OCE/OpenCASCADE version: 7.7.2 -- -- OCE/OpenCASCADE include directory: /opt/homebrew/opt/opencascade/include/opencascade -- -- OCE/OpenCASCADE shared libraries directory: /opt/homebrew/opt/opencascade/lib -- Found OpenGL: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.tbd -- Found OpenGLU: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLU.tbd CMake Deprecation Warning at /opt/homebrew/opt/vtk/lib/cmake/vtk-9.2/vtk-config.cmake:75 (message): The new name for the 'vtkCommonCore' component is 'CommonCore' Call Stack (most recent call first): cMake/FreeCAD_Helpers/SetupSalomeSMESH.cmake:29 (find_package) CMakeLists.txt:58 (SetupSalomeSMESH) -- Performing Test CMAKE_HAVE_LIBC_PTHREAD -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success -- Found Threads: TRUE -- Found utf8cpp: /opt/homebrew/opt/utf8cpp/include/utf8cpp -- VTK components: CommonCore;CommonDataModel;FiltersVerdict;IOXML;FiltersCore;FiltersGeneral;IOLegacy;FiltersExtraction;FiltersSources;FiltersGeometry;hdf5;RenderingCore;InteractionStyle;RenderingFreeType;RenderingOpenGL2 -- Found GLEW: /opt/homebrew/opt/glew/lib/libGLEW.dylib -- Found OpenGL: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.tbd found components: OpenGL -- Found HDF5: hdf5-shared (found version "1.14.3") found components: C HL -- Found Eigen3: /opt/homebrew/opt/eigen/include/eigen3 (found version "3.4.0") -- Could NOT find EXPAT (missing: EXPAT_LIBRARY EXPAT_INCLUDE_DIR) -- Found double-conversion: /opt/homebrew/opt/double-conversion/lib/libdouble-conversion.dylib -- Found LZ4: /opt/homebrew/opt/lz4/lib/liblz4.dylib (found version "1.9.4") -- Found LZMA: /opt/homebrew/opt/xz/lib/liblzma.dylib (found version "5.4.5") -- Check for medfile (libmed and libmedc) ... -- Found MEDFile: /opt/homebrew/opt/[email protected]/include -- Found PkgConfig: /opt/homebrew/opt/pkg-config/bin/pkg-config (found version "0.29.2") -- We guess that libmed was built using hdf5-serial version -- Checking for one of the modules 'hdf5-serial' -------------------------------------------- ipatch, manually set hdf5_root, cmake build of hdf5 breaks h5cc -------------------------------------------- -- Checking for one of the modules 'ompi-cxx' CMake Warning at cMake/FreeCAD_Helpers/SetupSalomeSMESH.cmake:122 (message): ompi-cxx was not found. Check
# NOTE: ordered loosely by cmake checks
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 "--------------------------------------------"

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(";")

# 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

# args = std_cmake_args + %W[
args = %W[
-DHOMEBREW_PREFIX=#{hbp}
-DCMAKE_PREFIX_PATH=#{cmake_prefix_path_string}
-DPYTHON_EXECUTABLE=#{hbp}/opt/[email protected]/bin/python3.10
-DBUILD_SMESH=1
-DBUILD_QT5=1
-DQt5Core_DIR=#{hbp}/opt/qt@5/lib/cmake/Qt5Core
-DFREECAD_USE_EXTERNAL_KDL=1
-DBUILD_FEM_NETGEN=0
-DBUILD_ENABLE_CXX_STD=C++17
-DFREECAD_USE_PYBIND11=1
-DBUILD_DRAWING=1
-DCMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH=FALSE
-DCMAKE_FIND_USE_CMAKE_SYSTEM_PATH=FALSE
-DCMAKE_OSX_SYSROOT=#{cmake_osx_sysroot}
-DCMAKE_AR=/Users/ipatch/homebrew/opt/llvm/bin/llvm-ar
-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
-L
-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
]
# --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 a26cb04

Please sign in to comment.