class Scipy < Formula desc "Software for mathematics, science, and engineering" homepage "https://www.scipy.org" url "https://files.pythonhosted.org/packages/cb/97/361c8c6ceb3eb765371a702ea873ff2fe112fa40073e7d2b8199db8eb56e/scipy-1.3.0.tar.gz" sha256 "c3bb4bd2aca82fb498247deeac12265921fe231502a6bc6edea3ee7fe6c40a7a" head "https://github.com/scipy/scipy.git" bottle do cellar :any sha256 "6ba4af97b345fb1b95db42eafc9b5a89af45c2da60734b4d317daba2f93bd2f2" => :mojave sha256 "02c6c92cb694c7c1c493e4c309043f104538366dc2813c180d4def06d28892c6" => :high_sierra sha256 "9d3f6843a954b1b525af1deb5a0e66cd9b9e0ee377d4435ddd6bd602a68cb862" => :sierra end depends_on "swig" => :build depends_on "gcc" # for gfortran depends_on "numpy" depends_on "openblas" depends_on "python" cxxstdlib_check :skip def install openblas = Formula["openblas"].opt_prefix ENV["ATLAS"] = "None" # avoid linking against Accelerate.framework ENV["BLAS"] = ENV["LAPACK"] = "#{openblas}/lib/libopenblas.dylib" config = <<~EOS [DEFAULT] library_dirs = #{HOMEBREW_PREFIX}/lib include_dirs = #{HOMEBREW_PREFIX}/include [openblas] libraries = openblas library_dirs = #{openblas}/lib include_dirs = #{openblas}/include EOS Pathname("site.cfg").write config version = Language::Python.major_minor_version "python3" ENV["PYTHONPATH"] = Formula["numpy"].opt_lib/"python#{version}/site-packages" ENV.prepend_create_path "PYTHONPATH", lib/"python#{version}/site-packages" system "python3", "setup.py", "build", "--fcompiler=gnu95" system "python3", *Language::Python.setup_install_args(prefix) end # cleanup leftover .pyc files from previous installs which can cause problems # see https://github.com/Homebrew/homebrew-python/issues/185#issuecomment-67534979 def post_install rm_f Dir["#{HOMEBREW_PREFIX}/lib/python*.*/site-packages/scipy/**/*.pyc"] end def caveats 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 test do system "python3", "-c", "import scipy" end end