homebrew-core/Formula/numpy.rb
2017-06-09 10:29:44 -04:00

81 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/05/84/0feb999c05f252af50a5fbc463268044feda92cdaad8cb0d0a6073d76057/numpy-1.13.0.zip"
sha256 "dcff367b725586830ff0e20b805c7654c876c2d4585c0834a6049502b9d6cf7e"
bottle do
cellar :any_skip_relocation
sha256 "b936f3ef96e516969cc079c47fa1d115a767aed1a3f005d8cb6279f179cb226f" => :sierra
sha256 "aa7e529fc581358bbcb753c171819ef66006a0bc18e4674813af2f1623e6f51e" => :el_capitan
sha256 "728f055ed62e452b6faa4fb1d817291a1fa60fa521dc765f2d6097f72f7f449d" => :yosemite
end
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