class Scipy < Formula desc "Software for mathematics, science, and engineering" homepage "https://www.scipy.org" url "https://files.pythonhosted.org/packages/bd/f4/3882758754dc083fea6ea66a6e8ceef55e7df173d06a12a074612958800f/scipy-1.0.1.tar.gz" sha256 "8739c67842ed9a1c34c62d6cca6301d0ade40d50ef14ba292bd331f0d6c940ba" head "https://github.com/scipy/scipy.git" bottle do sha256 "05d58e182817e4a0a9a60991e152a71230f3315d07de252ff11bcd2113d239b6" => :high_sierra sha256 "fc4b501664bae60fdb2d360c1dd6a85e64fbf7391f3b753b1e4a6f6c76b157af" => :sierra sha256 "f407e1f9a6b6c2adad30214fe9603a28edc5cf871bd6491683970ca9c14b3c61" => :el_capitan end option "without-python", "Build without python2 support" depends_on "swig" => :build depends_on "gcc" # for gfortran depends_on "numpy" depends_on "python@2" => :recommended if MacOS.version <= :snow_leopard depends_on "python" => :recommended cxxstdlib_check :skip # https://github.com/Homebrew/homebrew-python/issues/110 # There are ongoing problems with gcc+accelerate. fails_with :gcc def install config = <<~EOS [DEFAULT] library_dirs = #{HOMEBREW_PREFIX}/lib include_dirs = #{HOMEBREW_PREFIX}/include EOS Pathname("site.cfg").write config # gfortran is gnu95 Language::Python.each_python(build) do |python, version| ENV["PYTHONPATH"] = Formula["numpy"].opt_lib/"python#{version}/site-packages" ENV.prepend_create_path "PYTHONPATH", lib/"python#{version}/site-packages" system python, "setup.py", "build", "--fcompiler=gnu95" system python, *Language::Python.setup_install_args(prefix) end 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 Language::Python.each_python(build) do |_python, version| rm_f Dir["#{HOMEBREW_PREFIX}/lib/python#{version}/site-packages/scipy/**/*.pyc"] end end def caveats if (build.with? "python@2") && !Formula["python@2"].installed? 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 end test do Language::Python.each_python(build) do |python, _version| system python, "-c", "import scipy" end end end