2017-01-23 15:23:16 +00:00
|
|
|
class Numpy < Formula
|
|
|
|
desc "Package for scientific computing with Python"
|
|
|
|
homepage "http://www.numpy.org"
|
2017-03-19 13:30:34 +00:00
|
|
|
url "https://files.pythonhosted.org/packages/a5/16/8a678404411842fe02d780b5f0a676ff4d79cd58f0f22acddab1b392e230/numpy-1.12.1.zip"
|
|
|
|
sha256 "a65266a4ad6ec8936a1bc85ce51f8600634a31a258b722c9274a80ff189d9542"
|
2017-01-23 15:23:16 +00:00
|
|
|
|
2017-01-24 08:48:56 +00:00
|
|
|
bottle do
|
|
|
|
cellar :any_skip_relocation
|
2017-03-19 13:45:48 +00:00
|
|
|
sha256 "9b5b02de10765dc7cfb66ab5237667e7106fb4f26468f202f5ea7ddac609b983" => :sierra
|
|
|
|
sha256 "bf6733745645afc5834e27fcd9db0cc9feb86164c4d3e6069ecb486d930ccdaa" => :el_capitan
|
|
|
|
sha256 "ec1d2fff7205da6d89270182ef8ff4b821725258954b971ad514ecca891e67d7" => :yosemite
|
2017-01-24 08:48:56 +00:00
|
|
|
end
|
|
|
|
|
2017-01-23 15:23:16 +00:00
|
|
|
head do
|
|
|
|
url "https://github.com/numpy/numpy.git"
|
|
|
|
|
|
|
|
resource "Cython" do
|
|
|
|
url "https://files.pythonhosted.org/packages/b7/67/7e2a817f9e9c773ee3995c1e15204f5d01c8da71882016cac10342ef031b/Cython-0.25.2.tar.gz"
|
|
|
|
sha256 "f141d1f9c27a07b5a93f7dc5339472067e2d7140d1c5a9e20112a5665ca60306"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
option "without-python", "Build without python2 support"
|
|
|
|
|
|
|
|
depends_on :fortran => :build
|
|
|
|
depends_on :python => :recommended if MacOS.version <= :snow_leopard
|
|
|
|
depends_on :python3 => :optional
|
|
|
|
|
|
|
|
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") && !Formula["python"].installed?
|
|
|
|
homebrew_site_packages = Language::Python.homebrew_site_packages
|
|
|
|
user_site_packages = Language::Python.user_site_packages "python"
|
|
|
|
<<-EOS.undent
|
|
|
|
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
|
|
|
|
system "python", "-c", <<-EOS.undent
|
|
|
|
import numpy as np
|
|
|
|
t = np.ones((3,3), int)
|
|
|
|
assert t.sum() == 9
|
|
|
|
assert np.dot(t, t).sum() == 27
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
end
|