Skip to content

Commit

Permalink
rename; pin other dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
shapiromatron committed Aug 20, 2024
1 parent 307eb1f commit 717d122
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 5 deletions.
6 changes: 3 additions & 3 deletions tools/cibuildwheel-mac.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ set -xe

cd $GITHUB_WORKSPACE

brew install gsl --quiet
brew install --formula ./tools/mac-brew-nlopt-271.rb --quiet
brew install eigen --quiet
brew install --formula ./tools/mac/gsl.rb --quiet
brew install --formula ./tools/mac/nlopt.rb --quiet
brew install --formula ./tools/mac/eigen.rb --quiet
53 changes: 53 additions & 0 deletions tools/mac/eigen.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Vendor version 3.4.0; do not rename file.
# https://github.com/Homebrew/homebrew-core/blob/7061c51a7ac2945fc7602ab6df0e7ff31b1fb49c/Formula/e/eigen.rb
class Eigen < Formula
desc "C++ template library for linear algebra"
homepage "https://eigen.tuxfamily.org/"
url "https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.tar.gz"
sha256 "8586084f71f9bde545ee7fa6d00288b264a2b7ac3607b974e54d13e7162c1c72"
license "MPL-2.0"
revision 1
head "https://gitlab.com/libeigen/eigen.git", branch: "master"

livecheck do
url :stable
regex(/^v?(\d+(?:\.\d+)+)$/i)
end

bottle do
sha256 cellar: :any_skip_relocation, all: "211fd7f1d58b383e3d64335c08a376a7d8433007ce61410ead0320df34b6f4bd"
end

depends_on "cmake" => :build

conflicts_with "freeling", because: "freeling ships its own copy of eigen"

def install
mkdir "eigen-build" do
args = std_cmake_args
args << "-Dpkg_config_libdir=#{lib}" << ".."
system "cmake", *args
system "make", "install"
end
(share/"cmake/Modules").install "cmake/FindEigen3.cmake"
end

test do
(testpath/"test.cpp").write <<~EOS
#include <iostream>
#include <Eigen/Dense>
using Eigen::MatrixXd;
int main()
{
MatrixXd m(2,2);
m(0,0) = 3;
m(1,0) = 2.5;
m(0,1) = -1;
m(1,1) = m(1,0) + m(0,1);
std::cout << m << std::endl;
}
EOS
system ENV.cxx, "test.cpp", "-I#{include}/eigen3", "-o", "test"
assert_equal %w[3 -1 2.5 1.5], shell_output("./test").split
end
end
40 changes: 40 additions & 0 deletions tools/mac/gsl.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Vendor version 2.7.1; do not rename file.
# https://github.com/Homebrew/homebrew-core/blob/7061c51a7ac2945fc7602ab6df0e7ff31b1fb49c/Formula/g/gsl.rb
class Gsl < Formula
desc "Numerical library for C and C++"
homepage "https://www.gnu.org/software/gsl/"
url "https://ftp.gnu.org/gnu/gsl/gsl-2.7.1.tar.gz"
mirror "https://ftpmirror.gnu.org/gsl/gsl-2.7.1.tar.gz"
sha256 "dcb0fbd43048832b757ff9942691a8dd70026d5da0ff85601e52687f6deeb34b"
license "GPL-3.0-or-later"

bottle do
sha256 cellar: :any, arm64_sonoma: "67f4f4745081dd2d7a6d8434d59a240d2fc13b954d1015c82deb1445dcecdbfb"
sha256 cellar: :any, arm64_ventura: "2430e5586457f35f98014639a19d40c4d8d4b821949bb0cc7e091ac2aa9987bb"
sha256 cellar: :any, arm64_monterey: "207ba177628696ce2179fe94125ecd637794396a442a7550c92f9a8a202c03bf"
sha256 cellar: :any, arm64_big_sur: "1184a75460c96dc80a9fa5299f3f0931bbff729b556607e2b7492608dd7e44d7"
sha256 cellar: :any, sonoma: "5e7546917872e35511baa70ee1602db896c92e7801e241d891d1860ffa2ed950"
sha256 cellar: :any, ventura: "9e28ec4b8e62b94c208312780b63f417b08c3ca80dcb7e7f7223e06675e2807c"
sha256 cellar: :any, monterey: "3125ff756739ec6eea0ddac3c3b01e879f525eb3b7de88586d6438cd954e28a8"
sha256 cellar: :any, big_sur: "3cfd6c05d383ad930471e6d92942de62982d5e4149d5508bbbf5ed513561c288"
sha256 cellar: :any, catalina: "03a4c21c0384602ec0d5c802f61fdc0737730a703396b3fe37274c884019a6b8"
sha256 cellar: :any_skip_relocation, x86_64_linux: "daf456a559c5f031b5584db251ffe07aa02fbb04c3d7dc06e1202cfd9109a0c7"
end

# Fix -flat_namespace being used on Big Sur and later.
patch do
url "https://raw.githubusercontent.com/Homebrew/formula-patches/03cf8088210822aa2c1ab544ed58ea04c897d9c4/libtool/configure-big_sur.diff"
sha256 "35acd6aebc19843f1a2b3a63e880baceb0f5278ab1ace661e57a502d9d78c93c"
end

def install
ENV.deparallelize
system "./configure", "--disable-dependency-tracking", "--prefix=#{prefix}"
system "make" # A GNU tool which doesn't support just make install! Shameful!
system "make", "install"
end

test do
system bin/"gsl-randist", "0", "20", "cauchy", "30"
end
end
3 changes: 1 addition & 2 deletions tools/nlopt.rb → tools/mac/nlopt.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Vendor version 2.7.1 of nlopt; do not rename file.
# Vendor version 2.7.1; do not rename file.
# https://github.com/Homebrew/homebrew-core/blob/7061c51a7ac2945fc7602ab6df0e7ff31b1fb49c/Formula/n/nlopt.rb
# https://stackoverflow.com/questions/3987683/homebrew-install-specific-version-of-formula/9832084#9832084
class Nlopt < Formula
desc "Free/open-source library for nonlinear optimization"
homepage "https://nlopt.readthedocs.io/"
Expand Down

0 comments on commit 717d122

Please sign in to comment.