<commit_before>require 'formula'

class Setuptools < Formula
  url 'https://pypi.python.org/packages/source/s/setuptools/setuptools-0.9.8.tar.gz'
  sha1 'a13ad9411149c52501a15c702a4f3a3c757b5ba9'
end

class Pip < Formula
  url 'https://pypi.python.org/packages/source/p/pip/pip-1.4.tar.gz'
  sha1 '3149dc77c66b77d02497205fca5df56ae9d3e753'
end

class Python < Formula
  homepage 'http://www.python.org'
  url 'http://www.python.org/ftp/python/2.7.5/Python-2.7.5.tar.bz2'
  sha1 '6cfada1a739544a6fa7f2601b500fba02229656b'

  head 'http://hg.python.org/cpython', :using => :hg, :branch => '2.7'

  option :universal
  option 'quicktest', 'Run `make quicktest` after the build (for devs; may fail)'
  option 'with-brewed-openssl', "Use Homebrew's openSSL instead of the one from OS X"
  option 'with-brewed-tk', "Use Homebrew's Tk (has optional Cocoa and threads support)"
  option 'with-poll', 'Enable select.poll, which is not fully implemented on OS X (http://bugs.python.org/issue5154)'
  # --with-dtrace relies on CLT as dtrace hard-codes paths to /usr
  option 'with-dtrace', 'Experimental DTrace support (http://bugs.python.org/issue13405)' if MacOS::CLT.installed?

  depends_on 'pkg-config' => :build
  depends_on 'readline' => :recommended
  depends_on 'sqlite' => :recommended
  depends_on 'gdbm' => :recommended
  depends_on 'openssl' if build.with? 'brewed-openssl'
  depends_on 'homebrew/dupes/tcl-tk' if build.with? 'brewed-tk'

  def patches
    p = []
    p << 'https://gist.github.com/paxswill/5402840/raw/75646d5860685c8be98858288d1772f64d6d5193/pythondtrace-patch.diff' if build.with? 'dtrace'
    # Patch to disable the search for Tk.framework, since Homebrew's Tk is
    # a plain unix build. Remove `-lX11`, too because our Tk is "AquaTk".
    p << DATA if build.with? 'brewed-tk'
    p
  end

  def site_packages_cellar
    prefix/"Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages"
  end

  # The HOMEBREW_PREFIX location of site-packages.
  def site_packages
    HOMEBREW_PREFIX/"lib/python2.7/site-packages"
  end

  def install
    opoo 'The given option --with-poll enables a somewhat broken poll() on OS X (http://bugs.python.org/issue5154).' if build.with? 'poll'

    # Unset these so that installing pip and setuptools puts them where we want
    # and not into some other Python the user has installed.
    ENV['PYTHONHOME'] = nil
    ENV['PYTHONPATH'] = nil

    args = %W[
             --prefix=#{prefix}<commit_msg>python: Fix --with-brewed-tk if that was installed --with-x11<commit_after>require 'formula'

class Setuptools < Formula
  url 'https://pypi.python.org/packages/source/s/setuptools/setuptools-0.9.8.tar.gz'
  sha1 'a13ad9411149c52501a15c702a4f3a3c757b5ba9'
end

class Pip < Formula
  url 'https://pypi.python.org/packages/source/p/pip/pip-1.4.tar.gz'
  sha1 '3149dc77c66b77d02497205fca5df56ae9d3e753'
end

class Python < Formula
  homepage 'http://www.python.org'
  url 'http://www.python.org/ftp/python/2.7.5/Python-2.7.5.tar.bz2'
  sha1 '6cfada1a739544a6fa7f2601b500fba02229656b'

  head 'http://hg.python.org/cpython', :using => :hg, :branch => '2.7'

  option :universal
  option 'quicktest', 'Run `make quicktest` after the build (for devs; may fail)'
  option 'with-brewed-openssl', "Use Homebrew's openSSL instead of the one from OS X"
  option 'with-brewed-tk', "Use Homebrew's Tk (has optional Cocoa and threads support)"
  option 'with-poll', 'Enable select.poll, which is not fully implemented on OS X (http://bugs.python.org/issue5154)'
  # --with-dtrace relies on CLT as dtrace hard-codes paths to /usr
  option 'with-dtrace', 'Experimental DTrace support (http://bugs.python.org/issue13405)' if MacOS::CLT.installed?

  depends_on 'pkg-config' => :build
  depends_on 'readline' => :recommended
  depends_on 'sqlite' => :recommended
  depends_on 'gdbm' => :recommended
  depends_on 'openssl' if build.with? 'brewed-openssl'
  depends_on 'homebrew/dupes/tcl-tk' if build.with? 'brewed-tk'
  depends_on :x11 if build.with? 'brewed-tk' and Tab.for_name('tcl-tk').used_options.include?('with-x11')

  def patches
    p = []
    p << 'https://gist.github.com/paxswill/5402840/raw/75646d5860685c8be98858288d1772f64d6d5193/pythondtrace-patch.diff' if build.with? 'dtrace'
    # Patch to disable the search for Tk.framework, since Homebrew's Tk is
    # a plain unix build. Remove `-lX11`, too because our Tk is "AquaTk".
    p << DATA if build.with? 'brewed-tk'
    p
  end

  def site_packages_cellar
    prefix/"Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages"
  end

  # The HOMEBREW_PREFIX location of site-packages.
  def site_packages
    HOMEBREW_PREFIX/"lib/python2.7/site-packages"
  end

  def install
    opoo 'The given option --with-poll enables a somewhat broken poll() on OS X (http://bugs.python.org/issue5154).' if build.with? 'poll'

    # Unset these so that installing pip and setuptools puts them where we want
    # and not into some other Python the user has installed.
    ENV['PYTHONHOME'] = nil
    ENV['PYTHONPATH'] = nil

    args = %W[
             --prefix=#{prefix}
{'fraction_non_alphanumeric': 0.12612966601178782, 'fraction_numerical': 0.062082514734774066, 'mean_word_length': 3.7983034872761547, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 15, 'https://': 6, 'lorem ipsum': 0, 'www.': 4, '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': '4790597', 'n_tokens_mistral': 2079, 'n_tokens_neox': 1861, 'n_words': 459}