<commit_before>require 'formula'

class Pyqt5 < Formula
  homepage 'http://www.riverbankcomputing.co.uk/software/pyqt/download5'
  url 'http://downloads.sf.net/project/pyqt/PyQt5/PyQt-5.2/PyQt-gpl-5.2.tar.gz'
  sha1 'a1c232d34ab268587c127ad3097c725ee1a70cf0'

  option 'enable-debug', "Build with debug symbols"

  depends_on :python3 => :recommended
  depends_on :python => :optional

  if (build.without? "python") && (build.without? "python3")
    odie "pyqt: --with-python must be specified when using --without-python3"
  end

  depends_on 'qt5'

  if build.with? 'python3'
    depends_on 'sip' => 'with-python3'
  else
    depends_on 'sip'
  end

  def pythons
    pythons = []
    ["python", "python3"].each do |python|
      next if build.without? python
      version = /\d\.\d/.match `#{python} --version 2>&1`
      pythons << [python, version]
    end
    pythons
  end

  def install
    pythons.each do |python, version|
      ENV["PYTHONPATH"] = lib/"python#{version}/site-packages"
      args = [ "--confirm-license",
               "--bindir=#{bin}",
               "--destdir=#{lib}/python#{version}/site-packages",
               # To avoid conflicst with PyQt (for Qt4):
               "--sipdir=#{share}/sip/Qt5/",
               # sip.h could not be found automatically
               "--sip-incdir=#{Formula.factory('sip').opt_prefix}/include",
               # Force deployment target to avoid libc++ issues
               "QMAKE_MACOSX_DEPLOYMENT_TARGET=#{MacOS.version}" ]
      args << '--debug' if build.include? 'enable-debug'

      system python, "configure.py", *args
      system "make"
      system "make", "install"
      system "make", "clean" if pythons.length > 1
    end
  end

  test do
    system "pyuic5", "--version"
    system "pylupdate5", "-version"
    pythons.each do |python, version|
      system python, "-c", "import PyQt5"
    end
  end
end
<commit_msg>pyqt5: more python cleanup.<commit_after>require 'formula'

class Pyqt5 < Formula
  homepage 'http://www.riverbankcomputing.co.uk/software/pyqt/download5'
  url 'http://downloads.sf.net/project/pyqt/PyQt5/PyQt-5.2/PyQt-gpl-5.2.tar.gz'
  sha1 'a1c232d34ab268587c127ad3097c725ee1a70cf0'

  option 'enable-debug', "Build with debug symbols"

  depends_on :python3 => :recommended
  depends_on :python => :optional

  if !Formula.factory("python").installed? && build.with?("python") &&
     build.with?("python3")
    odie <<-EOS.undent
      pyqt5: You cannot use system Python 2 and Homebrew's Python 3 simultaneously.
      Either `brew install python` or use `--without-python3`.
    EOS
  elsif build.without?("python3") && build.without?("python")
    odie "pyqt5: --with-python3 must be specified when using --without-python"
  end

  depends_on 'qt5'

  if build.with? 'python3'
    depends_on 'sip' => 'with-python3'
  else
    depends_on 'sip'
  end

  def pythons
    pythons = []
    ["python", "python3"].each do |python|
      next if build.without? python
      version = /\d\.\d/.match `#{python} --version 2>&1`
      pythons << [python, version]
    end
    pythons
  end

  def install
    pythons.each do |python, version|
      args = [ "--confirm-license",
               "--bindir=#{bin}",
               "--destdir=#{lib}/python#{version}/site-packages",
               # To avoid conflicts with PyQt (for Qt4):
               "--sipdir=#{share}/sip/Qt5/",
               # sip.h could not be found automatically
               "--sip-incdir=#{Formula.factory('sip').opt_prefix}/include",
               # Force deployment target to avoid libc++ issues
               "QMAKE_MACOSX_DEPLOYMENT_TARGET=#{MacOS.version}" ]
      args << '--debug' if build.include? 'enable-debug'

      system python, "configure.py", *args
      system "make"
      system "make", "install"
      system "make", "clean" if pythons.length > 1
    end
  end

  test do
    system "pyuic5", "--version"
    system "pylupdate5", "-version"
    pythons.each do |python, version|
      system python, "-c", "import PyQt5"
    end
  end
end

{'fraction_non_alphanumeric': 0.14398812469074715, 'fraction_numerical': 0.025977238990598714, 'mean_word_length': 2.5874001774622895, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2306833', 'n_tokens_mistral': 1413, 'n_tokens_neox': 1360, 'n_words': 324}