homebrew-core/Formula/numpy.rb

75 lines
2.8 KiB
Ruby
Raw Normal View History

2017-01-23 15:23:16 +00:00
class Numpy < Formula
desc "Package for scientific computing with Python"
homepage "http://www.numpy.org"
url "https://files.pythonhosted.org/packages/b7/9d/8209e555ea5eb8209855b6c9e60ea80119dab5eff5564330b35aa5dc4b2c/numpy-1.12.0.zip"
sha256 "ff320ecfe41c6581c8981dce892fe6d7e69806459a899e294e4bf8229737b154"
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