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 13, 2024
1 parent de21a48 commit af14c3a
Showing 1 changed file with 212 additions and 0 deletions.
212 changes: 212 additions & 0 deletions Formula/[email protected]_py310.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
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
depends_on "hdf5-mpi" => :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 "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 "vtk"
depends_on "webp"
depends_on "xerces-c"

# 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

def install

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

View workflow job for this annotation

GitHub Actions / test-bot (macos-13)

`brew install --verbose --build-bottle freecad/freecad/[email protected]_py310` failed on macOS Ventura (13)!

ntura.bottle.tar.gz ==> Verifying checksum for '3ff7cf0938f64cbe2a4228a8bc84458d5ac5e9a8b2f620d9d911fe6747f86671--dbus--1.14.10.ventura.bottle.tar.gz' ==> Fetching xorgproto ==> Downloading https://ghcr.io/v2/homebrew/core/xorgproto/manifests/2023.2 Already downloaded: /Users/runner/Library/Caches/Homebrew/downloads/8740825bd79ba6441c86fb430f955cb3d08f4693dd2947fe877c11c7c8122343--xorgproto-2023.2.bottle_manifest.json ==> Downloading https://ghcr.io/v2/homebrew/core/xorgproto/blobs/sha256:de818c35cca25c4b2286a5642d5d1748320f6031039ec46b375fd11e935ef7e3 Already downloaded: /Users/runner/Library/Caches/Homebrew/downloads/838d9cbf93aa7a33dbb8c4f7dc2009c1e465930f4e78609d1c4a7612a2652855--xorgproto--2023.2.ventura.bottle.tar.gz ==> Verifying checksum for '838d9cbf93aa7a33dbb8c4f7dc2009c1e465930f4e78609d1c4a7612a2652855--xorgproto--2023.2.ventura.bottle.tar.gz' ==> Fetching libxau ==> Downloading https://ghcr.io/v2/homebrew/core/libxau/manifests/1.0.11 Already downloaded: /Users/runner/Library/Caches/Homebrew/downloads/7faff26297b2e07682655beaa529cff7b3de0ad1abc013863ca3d03602b79ee7--libxau-1.0.11.bottle_manifest.json ==> Downloading https://ghcr.io/v2/homebrew/core/libxau/blobs/sha256:7da43230a047e78a346707b6673d9f8a4077af03f1676121df279f7f5f1dc6c2 Already downloaded: /Users/runner/Library/Caches/Homebrew/downloads/5399247ebd66d2e156d54d948c886358369827c4c7714a2e0b66883b6e248683--libxau--1.0.11.ventura.bottle.tar.gz ==> Verifying checksum for '5399247ebd66d2e156d54d948c886358369827c4c7714a2e0b66883b6e248683--libxau--1.0.11.ventura.bottle.tar.gz' ==> Fetching libxdmcp ==> Downloading https://ghcr.io/v2/homebrew/core/libxdmcp/manifests/1.1.4 Already downloaded: /Users/runner/Library/Caches/Homebrew/downloads/1af80edced252b5f690f78a3805b785cbf689dc947cd5f45dced60c97640a9c9--libxdmcp-1.1.4.bottle_manifest.json ==> Downloading https://ghcr.io/v2/homebrew/core/libxdmcp/blobs/sha256:df9e4852a82d03c0388ed638999cb5dfe625b8e5b0b26e6ee2363529c0cc31bd Already downloaded: /Users/runner/Library/Caches/Homebrew/downloads/a966547dded13a6def89ba30b3d79c18fa47b15798346f05922573b0f576b983--libxdmcp--1.1.4.ventura.bottle.tar.gz ==> Verifying checksum for 'a966547dded13a6def89ba30b3d79c18fa47b15798346f05922573b0f576b983--libxdmcp--1.1.4.ventura.bottle.tar.gz' ==> Fetching libxcb ==> Downloading https://ghcr.io/v2/homebrew/core/libxcb/manifests/1.16-1 Already downloaded: /Users/runner/Library/Caches/Homebrew/downloads/9f2d408e88eb406c55d255e0e7c935c12ec3588a121c969d42635346d8ab3497--libxcb-1.16-1.bottle_manifest.json ==> Downloading https://ghcr.io/v2/homebrew/core/libxcb/blobs/sha256:e501531b388f9e218fc6deacfdf24f6b7daf922d82a7cade6838bddd0ac866ce Already downloaded: /Users/runner/Library/Caches/Homebrew/downloads/685ce41ee5e569146ea069b90dca226c5f3bb1768dcb2ae394f9954a6bd78a19--libxcb--1.16.ventura.bottle.1.tar.gz ==> Verifying checksum for '685ce41ee5e569146ea069b90dca226c5f3bb1768dcb2ae394f9954a6bd78a19--libxcb--1.16.ventura.bottle.1.tar.gz' ==> Fetching libx11 ==> Downloading https://ghcr.io/v2/homebrew/core/libx11/manifests/1.8.7 Already downloaded: /Users/runner/Library/Caches/Homebrew/downloads/4d15c929e0532c9a908dcb7d562929ecc5dd3a0a0cd4c19cf50683c06282fd7f--libx11-1.8.7.bottle_manifest.json ==> Downloading https://ghcr.io/v2/homebrew/core/libx11/blobs/sha256:60a6a9eff38b882a536a124a18216788fdb20f885e65d011129e57b92eecaec9 Already downloaded: /Users/runner/Library/Caches/Homebrew/downloads/ee819ea6ce0aa8db1c003e5cd505d09a237fb83d8e6848667b2ad66bba7c03d5--libx11--1.8.7.ventura.bottle.tar.gz ==> Verifying checksum for 'ee819ea6ce0aa8db1c003e5cd505d09a237fb83d8e6848667b2ad66bba7c03d5--libx11--1.8.7.ventura.bottle.tar.gz' ==> Fetching libxext ==> Downloading https://ghcr.io/v2/homebrew/core/libxext/manifests/1.3.5 Already downloaded: /Users/runner/Library/Caches/Homebrew/downloads/36b14aebd45b8fbf0f965d846bbc5126adbe882c0775c9936edb0432b347b9a1--libxext-1.3.5.bottle_manifest.json ==> Downloading https://ghcr.io/v2/homebrew/core/libxext/blobs/sha256:8567d6ebc49a8efcda5216368ba27ed2493bb4bb00492b66ba9e1686cee17c61 Already downloaded: /Users/run

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

View workflow job for this annotation

GitHub Actions / test-bot (macos-12)

`brew install --verbose --build-bottle freecad/freecad/[email protected]_py310` failed on macOS Monterey (12)!

ecksum for '4a86bf4e4cecacc72121323101c8b21ee65e414a25c56c0bcd455169905a933f--dbus--1.14.10.monterey.bottle.tar.gz' ==> Fetching xorgproto ==> Downloading https://ghcr.io/v2/homebrew/core/xorgproto/manifests/2023.2 Already downloaded: /Users/runner/Library/Caches/Homebrew/downloads/8740825bd79ba6441c86fb430f955cb3d08f4693dd2947fe877c11c7c8122343--xorgproto-2023.2.bottle_manifest.json ==> Downloading https://ghcr.io/v2/homebrew/core/xorgproto/blobs/sha256:de818c35cca25c4b2286a5642d5d1748320f6031039ec46b375fd11e935ef7e3 Already downloaded: /Users/runner/Library/Caches/Homebrew/downloads/838d9cbf93aa7a33dbb8c4f7dc2009c1e465930f4e78609d1c4a7612a2652855--xorgproto--2023.2.monterey.bottle.tar.gz ==> Verifying checksum for '838d9cbf93aa7a33dbb8c4f7dc2009c1e465930f4e78609d1c4a7612a2652855--xorgproto--2023.2.monterey.bottle.tar.gz' ==> Fetching libxau ==> Downloading https://ghcr.io/v2/homebrew/core/libxau/manifests/1.0.11 Already downloaded: /Users/runner/Library/Caches/Homebrew/downloads/7faff26297b2e07682655beaa529cff7b3de0ad1abc013863ca3d03602b79ee7--libxau-1.0.11.bottle_manifest.json ==> Downloading https://ghcr.io/v2/homebrew/core/libxau/blobs/sha256:3b8790c3aaf98e0ce10fd088f66b2591e6b5fb8b6b95df8ec254f389e15f81cf Already downloaded: /Users/runner/Library/Caches/Homebrew/downloads/c57fdec9da1dfb80853b20d0536c22cec96363aae3241fbe65e71b710ff25136--libxau--1.0.11.monterey.bottle.tar.gz ==> Verifying checksum for 'c57fdec9da1dfb80853b20d0536c22cec96363aae3241fbe65e71b710ff25136--libxau--1.0.11.monterey.bottle.tar.gz' ==> Fetching libxdmcp ==> Downloading https://ghcr.io/v2/homebrew/core/libxdmcp/manifests/1.1.4 Already downloaded: /Users/runner/Library/Caches/Homebrew/downloads/1af80edced252b5f690f78a3805b785cbf689dc947cd5f45dced60c97640a9c9--libxdmcp-1.1.4.bottle_manifest.json ==> Downloading https://ghcr.io/v2/homebrew/core/libxdmcp/blobs/sha256:16a26bf976f76e256466dc045e9691ef3cae5427fb7205274f17a1b37372c67b Already downloaded: /Users/runner/Library/Caches/Homebrew/downloads/dce026e3bc578e47fd926e8a74b3b4a346e644d7f3bf4967197f506b21f2a896--libxdmcp--1.1.4.monterey.bottle.tar.gz ==> Verifying checksum for 'dce026e3bc578e47fd926e8a74b3b4a346e644d7f3bf4967197f506b21f2a896--libxdmcp--1.1.4.monterey.bottle.tar.gz' ==> Fetching libxcb ==> Downloading https://ghcr.io/v2/homebrew/core/libxcb/manifests/1.16-1 Already downloaded: /Users/runner/Library/Caches/Homebrew/downloads/9f2d408e88eb406c55d255e0e7c935c12ec3588a121c969d42635346d8ab3497--libxcb-1.16-1.bottle_manifest.json ==> Downloading https://ghcr.io/v2/homebrew/core/libxcb/blobs/sha256:7df566b634d6266fbcc10bae41e98b535a92cf8baea722312b70ba521497c3c6 Already downloaded: /Users/runner/Library/Caches/Homebrew/downloads/7dfd256bbb712d88e5461e006f97a6022a6dd62a6e66d11f46429d41b64603a5--libxcb--1.16.monterey.bottle.1.tar.gz ==> Verifying checksum for '7dfd256bbb712d88e5461e006f97a6022a6dd62a6e66d11f46429d41b64603a5--libxcb--1.16.monterey.bottle.1.tar.gz' ==> Fetching libx11 ==> Downloading https://ghcr.io/v2/homebrew/core/libx11/manifests/1.8.7 Already downloaded: /Users/runner/Library/Caches/Homebrew/downloads/4d15c929e0532c9a908dcb7d562929ecc5dd3a0a0cd4c19cf50683c06282fd7f--libx11-1.8.7.bottle_manifest.json ==> Downloading https://ghcr.io/v2/homebrew/core/libx11/blobs/sha256:7f5eae59e701671a0ba8704ebc2cfa9f3087d8d085f22f69897f44ff8694cf62 Already downloaded: /Users/runner/Library/Caches/Homebrew/downloads/7be500ba78a10d9f7c191c5b6f7236d79ab4ac5edf42e3007a2b4ba1e2ed9f3c--libx11--1.8.7.monterey.bottle.tar.gz ==> Verifying checksum for '7be500ba78a10d9f7c191c5b6f7236d79ab4ac5edf42e3007a2b4ba1e2ed9f3c--libx11--1.8.7.monterey.bottle.tar.gz' ==> Fetching libxext ==> Downloading https://ghcr.io/v2/homebrew/core/libxext/manifests/1.3.5 Already downloaded: /Users/runner/Library/Caches/Homebrew/downloads/36b14aebd45b8fbf0f965d846bbc5126adbe882c0775c9936edb0432b347b9a1--libxext-1.3.5.bottle_manifest.json ==> Downloading https://ghcr.io/v2/homebrew/core/libxext/blobs/sha256:9682e4720a940f352af2cea9e4633cdf14947e23b640bac524e1b3674b9493a9 Already downloaded: /Users/runner/Library/Caches/Homebr
# 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++"

ENV.append_path "CMAKE_PREFIX_PATH", Formula["coin3d_py310"].prefix
ENV.append_path "CMAKE_PREFIX_PATH", Formula["hdf5-mpi"].prefix
ENV.append_path "CMAKE_PREFIX_PATH", Formula["llvm"].prefix
ENV.append_path "CMAKE_PREFIX_PATH", Formula["med-file"].prefix
ENV.append_path "CMAKE_PREFIX_PATH", Formula["mesa"].prefix if OS.linux?
ENV.append_path "CMAKE_PREFIX_PATH", Formula["opencascade"].prefix
ENV.append_path "CMAKE_PREFIX_PATH", Formula["[email protected]_py310"].prefix
ENV.append_path "CMAKE_PREFIX_PATH", Formula["qt@5"].prefix
ENV.append_path "CMAKE_PREFIX_PATH", Formula["vtk"].prefix
ENV.append_path "CMAKE_PREFIX_PATH", Formula["xerces-c"].prefix

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

args = std_cmake_args + %W[
-DHOMEBREW_PREFIX=#{hbp}
-DPYTHON_EXECUTABLE=#{hbp}/opt/[email protected]/bin/python3.10
-DBUILD_SMESH=1
-DBUILD_QT5=1
-DFREECAD_USE_EXTERNAL_KDL=1
-DBUILD_FEM_NETGEN=0
-DBUILD_ENABLE_CXX_STD=C++17
-DFREECAD_USE_PYBIND11=1
-L
]
# TODO: python library path needs to work with both linux and macos
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

# NOTE: useful cmake debugging args
# --trace
# -L

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"

# for reasons i dont understand pyside@2 is sneaking into the cmake_prefix_path
ENV.remove "CMAKE_PREFIX_PATH", Formula["pyside@2"].prefix
ENV.remove "CMAKE_PREFIX_PATH", HOMEBREW_PREFIX

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

# 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
5. it appears build will fail if qt version 6 is symlinked
into the homebrew prefix ie. /usr/local or /opt/local
EOS
end

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

0 comments on commit af14c3a

Please sign in to comment.