<commit_before>#!/bin/bash

has() {
    which "$@" > /dev/null 2>&1
}

download() {
    if has wget; then
        wget -O "$1" "$2"
    elif has curl; then
        curl -# -o "$1" "$2"
    else
        echo "I need curl or wget!"
        exit 1
    fi
}

if ! has wine || ! has tar || ! has 7z || ! has unzip; then
    echo "Sorry, but I need wine, tar, 7z and unzip to generate a windows build."
    exit 1
fi

cd "$(dirname "$0")"

export WINEPREFIX="$PWD/_w"
export WINEARCH="win32"
export WINEDEBUG="fixme-all"

if [ ! -d _w ]; then
    echo "Setting up toolchain..."
    echo "==> Downloading..."
    
    download python.msi "http://python.org/ftp/python/2.7.6/python-2.7.6.msi"
    download pywin32.exe "http://sourceforge.net/projects/pywin32/files/pywin32/Build%20218/pywin32-218.win32-py2.7.exe/download"
    download pyside.exe "http://download.qt-project.org/official_releases/pyside/PySide-1.2.1.win32-py2.7.exe"
    # download pyside.exe "http://sourceforge.net/projects/pyqt/files/PyQt4/PyQt-4.10.3/PyQt4-4.10.3-gpl-Py2.7-Qt4.8.5-x32.exe/download"
    download get-pip.py "https://raw.github.com/pypa/pip/master/contrib/get-pip.py"
    download pyinstaller.tar.gz "https://pypi.python.org/packages/source/P/PyInstaller/PyInstaller-2.1.tar.gz"
    download upx.zip "http://upx.sourceforge.net/download/upx391w.zip"
    download 7z-inst.exe "http://downloads.sourceforge.net/sevenzip/7z920.exe"
    download SDL.zip "http://libsdl.org/release/SDL-1.2.15-win32.zip"
    download openal.zip "http://kcat.strangesoft.net/openal-soft-1.15.1-bin.zip"
    
    echo "==> Installing Python..."
    wine msiexec /i python.msi
    
    pushd _w/drive_c/windows > /dev/null
    ln -s ../Python27/python.exe .
    popd > /dev/null
    
    echo "==> Installing pywin32..."
    wine pywin32.exe
    
    echo "==> Installing PySide..."
    wine pyside.exe
    
    echo "==> Installing pip..."
    wine python get-pip.py
    
    echo "==> Installing six..."
    wine python -mpip install six
    
    echo "==> Unpacking PyInstaller..."
    tar -xzf pyinstaller.tar.gz
    
    echo "==> Unpacking upx..."
    unzip upx.zip
    mv upx*/upx.exe _w/drive_c/windows
    rm -r upx*
    
    echo "==> Unpacking 7z..."
    mkdir tmp<commit_msg>Hopefully this improves dash compatibility.<commit_after>#!/bin/bash

has() {
    which "$@" > /dev/null 2>&1
}

download() {
    if has wget; then
        wget -O "$1" "$2"
    elif has curl; then
        curl -# -o "$1" "$2"
    else
        echo "I need curl or wget!"
        exit 1
    fi
}

if ! has wine || ! has tar || ! has 7z || ! has unzip; then
    echo "Sorry, but I need wine, tar, 7z and unzip to generate a windows build."
    exit 1
fi

cd "$(dirname "$0")"

export WINEPREFIX="$PWD/_w"
export WINEARCH="win32"
export WINEDEBUG="fixme-all"

if [ ! -d _w ]; then
    echo "Setting up toolchain..."
    echo "==> Downloading..."
    
    download python.msi "http://python.org/ftp/python/2.7.6/python-2.7.6.msi"
    download pywin32.exe "http://sourceforge.net/projects/pywin32/files/pywin32/Build%20218/pywin32-218.win32-py2.7.exe/download"
    download pyside.exe "http://download.qt-project.org/official_releases/pyside/PySide-1.2.1.win32-py2.7.exe"
    # download pyside.exe "http://sourceforge.net/projects/pyqt/files/PyQt4/PyQt-4.10.3/PyQt4-4.10.3-gpl-Py2.7-Qt4.8.5-x32.exe/download"
    download get-pip.py "https://raw.github.com/pypa/pip/master/contrib/get-pip.py"
    download pyinstaller.tar.gz "https://pypi.python.org/packages/source/P/PyInstaller/PyInstaller-2.1.tar.gz"
    download upx.zip "http://upx.sourceforge.net/download/upx391w.zip"
    download 7z-inst.exe "http://downloads.sourceforge.net/sevenzip/7z920.exe"
    download SDL.zip "http://libsdl.org/release/SDL-1.2.15-win32.zip"
    download openal.zip "http://kcat.strangesoft.net/openal-soft-1.15.1-bin.zip"
    
    echo "==> Installing Python..."
    wine msiexec /i python.msi
    
    cd _w/drive_c/windows
    ln -s ../Python27/python.exe .
    cd ../../..
    
    echo "==> Installing pywin32..."
    wine pywin32.exe
    
    echo "==> Installing PySide..."
    wine pyside.exe
    
    echo "==> Installing pip..."
    wine python get-pip.py
    
    echo "==> Installing six..."
    wine python -mpip install six
    
    echo "==> Unpacking PyInstaller..."
    tar -xzf pyinstaller.tar.gz
    
    echo "==> Unpacking upx..."
    unzip upx.zip
    mv upx*/upx.exe _w/drive_c/windows
    rm -r upx*
    
    echo "==> Unpacking 7z..."
    mkdir tmp
{'fraction_non_alphanumeric': 0.1645146927871772, 'fraction_numerical': 0.04007123775601069, 'mean_word_length': 2.406368460955269, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 27, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 34, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2180639', 'n_tokens_mistral': 1861, 'n_tokens_neox': 1727, 'n_words': 341}