83 lines
3.1 KiB
Ruby
83 lines
3.1 KiB
Ruby
class Numpy < Formula
|
|
desc "Package for scientific computing with Python"
|
|
homepage "http://www.numpy.org"
|
|
url "https://files.pythonhosted.org/packages/a3/99/74aa456fc740a7e8f733af4e8302d8e61e123367ec660cd89c53a3cd4d70/numpy-1.14.1.zip"
|
|
sha256 "fa0944650d5d3fb95869eaacd8eedbd2d83610c85e271bd9d3495ffa9bc4dc9c"
|
|
revision 1
|
|
|
|
bottle do
|
|
sha256 "60b6d4a20734d849394a15744341aa2919d61564d76878443a2b7dd98733abaf" => :high_sierra
|
|
sha256 "fa8a59395067c36d569f24d3a6f4834cdac453bd83476d722b6c1f33e8357b8a" => :sierra
|
|
sha256 "31c1ffd4ed481190a489049c874949cbde0d566e8603315b6c5eb863a876f4f5" => :el_capitan
|
|
end
|
|
|
|
head do
|
|
url "https://github.com/numpy/numpy.git"
|
|
|
|
resource "Cython" do
|
|
url "https://files.pythonhosted.org/packages/ee/2a/c4d2cdd19c84c32d978d18e9355d1ba9982a383de87d0fcb5928553d37f4/Cython-0.27.3.tar.gz"
|
|
sha256 "6a00512de1f2e3ce66ba35c5420babaef1fe2d9c43a8faab4080b0dbcc26bc64"
|
|
end
|
|
end
|
|
|
|
option "without-python@2", "Build without python2 support"
|
|
|
|
depends_on "gcc" => :build # for gfortran
|
|
depends_on "python@2" => :recommended if MacOS.version <= :snow_leopard
|
|
depends_on "python" => :recommended
|
|
|
|
resource "nose" do
|
|
url "https://files.pythonhosted.org/packages/58/a5/0dc93c3ec33f4e281849523a5a913fa1eea9a3068acfa754d44d88107a44/nose-1.3.7.tar.gz"
|
|
sha256 "f1bffef9cbc82628f6e7d7b40d7e255aefaa1adb6a1b1d26c69a8b79e6208a98"
|
|
end
|
|
|
|
def install
|
|
Language::Python.each_python(build) do |python, version|
|
|
dest_path = lib/"python#{version}/site-packages"
|
|
dest_path.mkpath
|
|
|
|
nose_path = libexec/"nose/lib/python#{version}/site-packages"
|
|
resource("nose").stage do
|
|
system python, *Language::Python.setup_install_args(libexec/"nose")
|
|
(dest_path/"homebrew-numpy-nose.pth").write "#{nose_path}\n"
|
|
end
|
|
|
|
if build.head?
|
|
ENV.prepend_create_path "PYTHONPATH", buildpath/"tools/lib/python#{version}/site-packages"
|
|
resource("Cython").stage do
|
|
system python, *Language::Python.setup_install_args(buildpath/"tools")
|
|
end
|
|
end
|
|
|
|
system python, "setup.py",
|
|
"build", "--fcompiler=gnu95", "--parallel=#{ENV.make_jobs}",
|
|
"install", "--prefix=#{prefix}",
|
|
"--single-version-externally-managed", "--record=installed.txt"
|
|
end
|
|
end
|
|
|
|
def caveats
|
|
if build.with?("python@2") && !Formula["python@2"].installed?
|
|
homebrew_site_packages = Language::Python.homebrew_site_packages
|
|
user_site_packages = Language::Python.user_site_packages "python"
|
|
<<~EOS
|
|
If you use system python (that comes - depending on the OS X version -
|
|
with older versions of numpy, scipy and matplotlib), you may need to
|
|
ensure that the brewed packages come earlier in Python's sys.path with:
|
|
mkdir -p #{user_site_packages}
|
|
echo 'import sys; sys.path.insert(1, "#{homebrew_site_packages}")' >> #{user_site_packages}/homebrew.pth
|
|
EOS
|
|
end
|
|
end
|
|
|
|
test do
|
|
Language::Python.each_python(build) do |python, _version|
|
|
system python, "-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
|
|
end
|