<commit_before>#!/bin/bash

set -o pipefail
set -e
set -x

# Don't produce a binary if something goes wrong
trap "rm -f px.pex" ERR

function do-tests() {
  PYTHON=$1
  ENVDIR=".${PYTHON}-env"

  test -d "$ENVDIR" || virtualenv "$ENVDIR" --python=$PYTHON
  # shellcheck source=/dev/null
  . "$ENVDIR"/bin/activate

  # Fix tools versions
  pip install -r requirements-dev.txt

  # Run tests
  ./setup.py test

  deactivate
}

source ./scripts/set-py2-p3.sh
do-tests $PY3
do-tests $PY2

ENVDIR=".${PY2}-env"
# shellcheck source=/dev/null
. "$ENVDIR"/bin/activate

flake8 px tests setup.py

# Create px wheel...
rm -rf dist .deps/px-*.egg .deps/px-*.whl build/lib/px
./setup.py bdist_wheel --universal
# ... and package everything in px.pex
rm -f px.pex

pex --disable-cache -r requirements.txt ./dist/px-*.whl -m px.px:main -o px.pex

echo<commit_msg>Tune test.sh a bit further<commit_after>#!/bin/bash

set -o pipefail
set -e
set -x

# Don't produce a binary if something goes wrong
trap "rm -f px.pex" ERR

function do-tests() {
  PYTHON=$1
  ENVDIR=".${PYTHON}-env"

  test -d "$ENVDIR" || virtualenv "$ENVDIR" --python=$PYTHON
  # shellcheck source=/dev/null
  . "$ENVDIR"/bin/activate

  # Fix tools versions
  pip install -r requirements-dev.txt

  # Run tests
  ./setup.py test

  deactivate
}

source ./scripts/set-py2-p3.sh
do-tests $PY3
do-tests $PY2

ENVDIR=".${PY2}-env"
# shellcheck source=/dev/null
. "$ENVDIR"/bin/activate

flake8 px tests setup.py

# Create px wheel...
./setup.py bdist_wheel --universal

# ... and package everything in px.pex
#
# Note that we have to --disable-cache here since otherwise changing the code
# without changing the "git describe" output won't change the resulting binary.
# And since that happens all the time during development we can't have that.
rm -f px.pex
pex --disable-cache -r requirements.txt ./dist/px-*.whl -m px.px:main -o px.pex

echo
{'fraction_non_alphanumeric': 0.14406332453825857, 'fraction_numerical': 0.007387862796833773, 'mean_word_length': 3.103896103896104, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '2569737', 'n_tokens_mistral': 721, 'n_tokens_neox': 701, 'n_words': 213}