<commit_before>require 'formula'

class Shiboken < Formula
  homepage 'http://www.pyside.org/docs/shiboken'
  url 'http://download.qt-project.org/official_releases/pyside/shiboken-1.2.2.tar.bz2'
  mirror 'https://distfiles.macports.org/py-shiboken/shiboken-1.2.2.tar.bz2'
  sha1 '55731616791500750ef373f382057a43e133fa08'

  head 'git://gitorious.org/pyside/shiboken.git'

  bottle do
    sha1 "dd4d9cbbfcaf77bd7c0c45e55c41edab374b4216" => :yosemite
    sha1 "a2b38ded09743f12668275783b03aeb0f178e8d9" => :mavericks
    sha1 "1d567cda7cbccf13315a2d62baf0d73c9f137fec" => :mountain_lion
  end

  depends_on 'cmake' => :build
  depends_on 'qt'

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

  def install
    # As of 1.1.1 the install fails unless you do an out of tree build and put
    # the source dir last in the args.
    Language::Python.each_python(build) do |python, version|
      mkdir "macbuild#{version}" do
        args = std_cmake_args
        # Building the tests also runs them.
        args << "-DBUILD_TESTS=ON"
        # if not System Python
        python_framework = "#{Formula[python].prefix}/Frameworks/Python.framework/Versions/#{version}"
        if version.to_s[0,1] == "2" && Formula["python"].installed?
          args << "-DPYTHON_INCLUDE_DIR:PATH=#{python_framework}/Headers"
          args << "-DPYTHON_LIBRARY:FILEPATH=#{python_framework}/lib/libpython#{version}.dylib"
        elsif version.to_s[0,1] == "3"
          args << "-DPYTHON3_INCLUDE_DIR:PATH=#{python_framework}/Headers"
          args << "-DPYTHON3_LIBRARY:FILEPATH=#{python_framework}/lib/libpython#{version}.dylib"
          args << "-DUSE_PYTHON3:BOOL=ON"
        end
        args << ".."
        system "cmake", *args
        system "make", "install"
      end
    end
  end

  test do
    Language::Python.each_python(build) do |python, version|
      system python, "-c", "import shiboken"
    end
  end
end
<commit_msg>shiboken: recommend opt paths in build helpers<commit_after>require 'formula'

class Shiboken < Formula
  homepage 'http://www.pyside.org/docs/shiboken'
  url 'http://download.qt-project.org/official_releases/pyside/shiboken-1.2.2.tar.bz2'
  mirror 'https://distfiles.macports.org/py-shiboken/shiboken-1.2.2.tar.bz2'
  sha1 '55731616791500750ef373f382057a43e133fa08'

  head 'git://gitorious.org/pyside/shiboken.git'

  bottle do
    sha1 "dd4d9cbbfcaf77bd7c0c45e55c41edab374b4216" => :yosemite
    sha1 "a2b38ded09743f12668275783b03aeb0f178e8d9" => :mavericks
    sha1 "1d567cda7cbccf13315a2d62baf0d73c9f137fec" => :mountain_lion
  end

  depends_on 'cmake' => :build
  depends_on 'qt'

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

  def install
    # As of 1.1.1 the install fails unless you do an out of tree build and put
    # the source dir last in the args.
    Language::Python.each_python(build) do |python, version|
      mkdir "macbuild#{version}" do
        args = std_cmake_args
        # Building the tests also runs them.
        args << "-DBUILD_TESTS=ON"
        # if not System Python
        python_framework = "#{Formula[python].opt_prefix}/Frameworks/Python.framework/Versions/#{version}"
        if version.to_s[0,1] == "2" && Formula["python"].installed?
          args << "-DPYTHON_INCLUDE_DIR:PATH=#{python_framework}/Headers"
          args << "-DPYTHON_LIBRARY:FILEPATH=#{python_framework}/lib/libpython#{version}.dylib"
        elsif version.to_s[0,1] == "3" && Formula["python3"].installed?
          args << "-DPYTHON3_INCLUDE_DIR:PATH=#{python_framework}/Headers"
          args << "-DPYTHON3_LIBRARY:FILEPATH=#{python_framework}/lib/libpython#{version}.dylib"
          args << "-DUSE_PYTHON3:BOOL=ON"
        end
        args << ".."
        system "cmake", *args
        system "make", "install"
      end
    end
  end

  test do
    Language::Python.each_python(build) do |python, version|
      system python, "-c", "import shiboken"
    end
  end
end

{'fraction_non_alphanumeric': 0.1268920282542886, 'fraction_numerical': 0.06281533804238143, 'mean_word_length': 3.357142857142857, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 15, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1523663', 'n_tokens_mistral': 1578, 'n_tokens_neox': 1452, 'n_words': 263}