84 lines
3.2 KiB
Ruby
84 lines
3.2 KiB
Ruby
class Numpy < Formula
|
|
desc "Package for scientific computing with Python"
|
|
homepage "http://www.numpy.org"
|
|
url "https://files.pythonhosted.org/packages/c0/3a/40967d9f5675fbb097ffec170f59c2ba19fc96373e73ad47c2cae9a30aed/numpy-1.13.1.zip"
|
|
sha256 "c9b0283776085cb2804efff73e9955ca279ba4edafd58d3ead70b61d209c4fbb"
|
|
revision 1
|
|
|
|
bottle do
|
|
sha256 "999689e3fe0f63cd4c4142fcf58e722b8abd544e80d40796be7e826dc5cfb976" => :high_sierra
|
|
sha256 "936fecb5154bd0e12d7f136468718e799bd4085b69d2e99bb3358be7e6cd658b" => :sierra
|
|
sha256 "93f36c7114c91d205dca6f473745ac9d53b15c70cebde6e7fec3f796a9f8d98f" => :el_capitan
|
|
sha256 "bd5c8a0ba531d9b194c48e16317f8b4f9c4f7f298c5824cd1f7876611acabb3c" => :yosemite
|
|
end
|
|
|
|
head do
|
|
url "https://github.com/numpy/numpy.git"
|
|
|
|
resource "Cython" do
|
|
url "https://files.pythonhosted.org/packages/10/d5/753d2cb5073a9f4329d1ffed1de30b0458821780af8fdd8ba1ad5adb6f62/Cython-0.26.tar.gz"
|
|
sha256 "4c24e2c22ddaed624d35229dc5db25049e9e225c6f64f3364326836cad8f2c66"
|
|
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 => :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") && !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
|
|
Language::Python.each_python(build) do |python, _version|
|
|
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
|
|
end
|