<commit_before>#
# Copyright:: Copyright (c) 2013-2014 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

name "python"
default_version "2.7.12"

if ohai['platform'] != 'windows'

  dependency "ncurses"
  dependency "zlib"
  dependency "openssl"
  dependency "bzip2"
  dependency "libsqlite3"

  source :url => "http://python.org/ftp/python/#{version}/Python-#{version}.tgz",
         :sha256 => '3cb522d17463dfa69a155ab18cffa399b358c966c0363d6c8b5b3bf1384da4b6'

  relative_path "Python-#{version}"

  env = {
    "CFLAGS" => "-I#{install_dir}/embedded/include -O3 -g -pipe",
    "LDFLAGS" => "-Wl,-rpath,#{install_dir}/embedded/lib -L#{install_dir}/embedded/lib"
  }

  python_configure = ["./configure",
                      "--enable-universalsdk=/",
                      "--prefix=#{install_dir}/embedded"]

  if ohai['platform_family'] == 'mac_os_x'
    python_configure.push('--enable-ipv6',
                          '--with-universal-archs=intel',
                          '--enable-shared')
  end

  python_configure.push("--with-dbmliborder=")

  build do
    ship_license "PSFL"
    patch :source => 'python-2.7.11-avoid-allocating-thunks-in-ctypes.patch' if linux?
    patch :source => 'python-2.7.11-fix-platform-ubuntu.diff' if linux?

    command python_configure.join(" "), :env => env
    command "make -j #{workers}", :env => env
    command "make install", :env => env
    delete "#{install_dir}/embedded/lib/python2.7/test"

    # There exists no configure flag to tell Python to not compile readline support :(
    block do
      FileUtils.rm_f(Dir.glob("#{install_dir}/embedded/lib/python2.7/lib-dynload/readline.*"))
    end
  end

else

  dependency "vc_redist"
  dependency "vc_python"

  if ohai['kernel']['machine'] == 'x86_64'
    msi_name = "python-#{version}.amd64.msi"
    source :url => "https://www.python.org/ftp/python/#{version}/python-#{version}.amd64.msi",
           :md5 => '25acca42662d4b02682eee0df3f3446d'
  else
    msi_name = "python-#{version}.msi"
    source :url => "https://www.python.org/ftp/python/#{version}/python-#{version}.msi",
           :md5 => '4ba2c79b103f6003bc4611c837a08208'
  end

  build do
    # In case Python is already installed on the build machine well... let's uninstall it
    # (fortunately we're building in a VM :) )
    command "start /wait msiexec /x #{msi_name} /L uninstallation_logs.txt ADDLOCAL=DefaultFeature /qn"<commit_msg>Revert to python 2.7.10<commit_after>#
# Copyright:: Copyright (c) 2013-2014 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

name "python"
default_version "2.7.12"

if ohai['platform'] != 'windows'

  dependency "ncurses"
  dependency "zlib"
  dependency "openssl"
  dependency "bzip2"
  dependency "libsqlite3"

  source :url => "http://python.org/ftp/python/#{version}/Python-#{version}.tgz",
         :sha256 => '3cb522d17463dfa69a155ab18cffa399b358c966c0363d6c8b5b3bf1384da4b6'

  relative_path "Python-#{version}"

  env = {
    "CFLAGS" => "-I#{install_dir}/embedded/include -O3 -g -pipe",
    "LDFLAGS" => "-Wl,-rpath,#{install_dir}/embedded/lib -L#{install_dir}/embedded/lib"
  }

  python_configure = ["./configure",
                      "--enable-universalsdk=/",
                      "--prefix=#{install_dir}/embedded"]

  if ohai['platform_family'] == 'mac_os_x'
    python_configure.push('--enable-ipv6',
                          '--with-universal-archs=intel',
                          '--enable-shared')
  end

  python_configure.push("--with-dbmliborder=")

  build do
    ship_license "PSFL"
    patch :source => 'python-2.7.11-avoid-allocating-thunks-in-ctypes.patch' if linux?
    patch :source => 'python-2.7.11-fix-platform-ubuntu.diff' if linux?

    command python_configure.join(" "), :env => env
    command "make -j #{workers}", :env => env
    command "make install", :env => env
    delete "#{install_dir}/embedded/lib/python2.7/test"

    # There exists no configure flag to tell Python to not compile readline support :(
    block do
      FileUtils.rm_f(Dir.glob("#{install_dir}/embedded/lib/python2.7/lib-dynload/readline.*"))
    end
  end

else

  dependency "vc_redist"
  dependency "vc_python"

  if ohai['kernel']['machine'] == 'x86_64'
    msi_name = "python-#{version}.amd64.msi"
    source :url => "https://www.python.org/ftp/python/#{version}/python-#{version}.amd64.msi",
           :md5 => '35f5c301beab341f6f6c9785939882ee'
  else
    msi_name = "python-#{version}.msi"
    source :url => "https://www.python.org/ftp/python/#{version}/python-#{version}.msi",
           :md5 => '4ba2c79b103f6003bc4611c837a08208'
  end

  build do
    # In case Python is already installed on the build machine well... let's uninstall it
    # (fortunately we're building in a VM :) )
    command "start /wait msiexec /x #{msi_name} /L uninstallation_logs.txt ADDLOCAL=DefaultFeature /qn"
{'fraction_non_alphanumeric': 0.13983193277310924, 'fraction_numerical': 0.04403361344537815, 'mean_word_length': 3.2936507936507935, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 29, 'https://': 4, 'lorem ipsum': 0, 'www.': 6, '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': '6479005', 'n_tokens_mistral': 2127, 'n_tokens_neox': 1954, 'n_words': 484}