class Numpy < Formula desc "Package for scientific computing with Python" homepage "https://www.numpy.org/" url "https://files.pythonhosted.org/packages/bf/e8/15aea783ea72e2d4e51e3ec365e8dc4a1a32c9e5eb3a6d695b0d58e67cdd/numpy-1.19.2.zip" sha256 "0d310730e1e793527065ad7dde736197b705d0e4c9999775f212b03c44a8484c" license "BSD-3-Clause" head "https://github.com/numpy/numpy.git" livecheck do url :stable end bottle do cellar :any sha256 "566527d2d7dcc3d603471bb38cdc38296cb4b0cf0d77482ae1f747b972746cab" => :catalina sha256 "c5b199f2cd1d5dca9de71735dd2898ceaf93149d7ae5ac6c2198c7059d289a45" => :mojave sha256 "b27dda4239fd4b4eeea7b99dab5884d4191f61373094ede658e5623e00694834" => :high_sierra end depends_on "cython" => :build depends_on "gcc" => :build # for gfortran depends_on "openblas" depends_on "python@3.8" def install openblas = Formula["openblas"].opt_prefix ENV["ATLAS"] = "None" # avoid linking against Accelerate.framework ENV["BLAS"] = ENV["LAPACK"] = "#{openblas}/lib/libopenblas.dylib" config = <<~EOS [openblas] libraries = openblas library_dirs = #{openblas}/lib include_dirs = #{openblas}/include EOS Pathname("site.cfg").write config version = Language::Python.major_minor_version Formula["python@3.8"].opt_bin/"python3" ENV.prepend_create_path "PYTHONPATH", Formula["cython"].opt_libexec/"lib/python#{version}/site-packages" system Formula["python@3.8"].opt_bin/"python3", "setup.py", "build", "--fcompiler=gnu95", "--parallel=#{ENV.make_jobs}", "install", "--prefix=#{prefix}", "--single-version-externally-managed", "--record=installed.txt" end test do system Formula["python@3.8"].opt_bin/"python3", "-c", <<~EOS import numpy as np t = np.ones((3,3), int) assert t.sum() == 9 assert np.dot(t, t).sum() == 27 EOS end end