<commit_before>class Scipy < Formula
  desc "Software for mathematics, science, and engineering"
  homepage "https://www.scipy.org"
  url "https://files.pythonhosted.org/packages/db/af/16906139f52bc6866c43401869ce247662739ad71afa11c6f18505eb0546/scipy-1.9.1.tar.gz"
  sha256 "26d28c468900e6d5fdb37d2812ab46db0ccd22c63baa095057871faa3a498bc9"
  license "BSD-3-Clause"
  head "https://github.com/scipy/scipy.git", branch: "master"

  bottle do
    sha256 cellar: :any, arm64_monterey: "eb6578a423f0d00416c3c5447174eb35a602cd603a6546a40cae70fe040682b0"
    sha256 cellar: :any, arm64_big_sur:  "2e9f46e809492c5b0c701d20f712f4238a7b86b7e42778963fc3d2cb6d63696b"
    sha256 cellar: :any, monterey:       "d421491023e80bad4be3da789a847993818ddfb0bf06c074db0b20120b855039"
    sha256 cellar: :any, big_sur:        "b2168d5dbbef232c844a155039e2f6e86f19ddfca2065063616f2f06faed6934"
    sha256 cellar: :any, catalina:       "eaa71d7f7bf55ddff604048ccec41e5d2640224fdde4ee9c62e0a8f9bc1248c8"
    sha256               x86_64_linux:   "1d4efe1f0132710ecbb2e89be57c106ef7f13be2c7b69009df6f0e9046b675e1"
  end

  depends_on "libcython" => :build
  depends_on "pythran" => :build
  depends_on "swig" => :build
  depends_on "gcc" # for gfortran
  depends_on "numpy"
  depends_on "openblas"
  depends_on "pybind11"
  depends_on "python@3.10"

  cxxstdlib_check :skip

  fails_with gcc: "5"

  def install
    openblas = Formula["openblas"]
    ENV["ATLAS"] = "None" # avoid linking against Accelerate.framework
    ENV["BLAS"] = ENV["LAPACK"] = openblas.opt_lib/shared_library("libopenblas")

    config = <<~EOS
      [DEFAULT]
      library_dirs = #{HOMEBREW_PREFIX}/lib
      include_dirs = #{HOMEBREW_PREFIX}/include
      [openblas]
      libraries = openblas
      library_dirs = #{openblas.opt_lib}
      include_dirs = #{openblas.opt_include}
    EOS

    Pathname("site.cfg").write config

    site_packages = Language::Python.site_packages("python3")
    ENV.prepend_path "PYTHONPATH", Formula["libcython"].opt_libexec/site_packages
    ENV.prepend_path "PYTHONPATH", Formula["pythran"].opt_libexec/site_packages
    ENV.prepend_path "PYTHONPATH", Formula["numpy"].opt_prefix/site_packages
    ENV.prepend_create_path "PYTHONPATH", site_packages

    system "python3", "setup.py", "build", "--fcompiler=gfortran", "--parallel=#{ENV.make_jobs}"
    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

  test do
    system Formula["python@3.10"].opt_bin/"python3", "-c", "import scipy"
  end
end<commit_msg>scipy: fix `python3` references. (#109851)<commit_after>class Scipy < Formula
  desc "Software for mathematics, science, and engineering"
  homepage "https://www.scipy.org"
  url "https://files.pythonhosted.org/packages/db/af/16906139f52bc6866c43401869ce247662739ad71afa11c6f18505eb0546/scipy-1.9.1.tar.gz"
  sha256 "26d28c468900e6d5fdb37d2812ab46db0ccd22c63baa095057871faa3a498bc9"
  license "BSD-3-Clause"
  head "https://github.com/scipy/scipy.git", branch: "master"

  bottle do
    sha256 cellar: :any, arm64_monterey: "eb6578a423f0d00416c3c5447174eb35a602cd603a6546a40cae70fe040682b0"
    sha256 cellar: :any, arm64_big_sur:  "2e9f46e809492c5b0c701d20f712f4238a7b86b7e42778963fc3d2cb6d63696b"
    sha256 cellar: :any, monterey:       "d421491023e80bad4be3da789a847993818ddfb0bf06c074db0b20120b855039"
    sha256 cellar: :any, big_sur:        "b2168d5dbbef232c844a155039e2f6e86f19ddfca2065063616f2f06faed6934"
    sha256 cellar: :any, catalina:       "eaa71d7f7bf55ddff604048ccec41e5d2640224fdde4ee9c62e0a8f9bc1248c8"
    sha256               x86_64_linux:   "1d4efe1f0132710ecbb2e89be57c106ef7f13be2c7b69009df6f0e9046b675e1"
  end

  depends_on "libcython" => :build
  depends_on "pythran" => :build
  depends_on "swig" => :build
  depends_on "gcc" # for gfortran
  depends_on "numpy"
  depends_on "openblas"
  depends_on "pybind11"
  depends_on "python@3.10"

  cxxstdlib_check :skip

  fails_with gcc: "5"

  def python3
    "python3.10"
  end

  def install
    openblas = Formula["openblas"]
    ENV["ATLAS"] = "None" # avoid linking against Accelerate.framework
    ENV["BLAS"] = ENV["LAPACK"] = openblas.opt_lib/shared_library("libopenblas")

    config = <<~EOS
      [DEFAULT]
      library_dirs = #{HOMEBREW_PREFIX}/lib
      include_dirs = #{HOMEBREW_PREFIX}/include
      [openblas]
      libraries = openblas
      library_dirs = #{openblas.opt_lib}
      include_dirs = #{openblas.opt_include}
    EOS

    Pathname("site.cfg").write config

    site_packages = Language::Python.site_packages(python3)
    ENV.prepend_path "PYTHONPATH", Formula["libcython"].opt_libexec/site_packages
    ENV.prepend_path "PYTHONPATH", Formula["pythran"].opt_libexec/site_packages
    ENV.prepend_path "PYTHONPATH", Formula["numpy"].opt_prefix/site_packages
    ENV.prepend_create_path "PYTHONPATH", site_packages

    system python3, "setup.py", "build", "--fcompiler=gfortran", "--parallel=#{ENV.make_jobs}"
    system python3, *Language::Python.setup_install_args(prefix, python3)
  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

  test do
    system python3, "-c", "import scipy"
  end
end
{'fraction_non_alphanumeric': 0.10932762618155877, 'fraction_numerical': 0.13857677902621723, 'mean_word_length': 4.734151329243354, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 8, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7172280', 'n_tokens_mistral': 2684, 'n_tokens_neox': 2258, 'n_words': 328}