<commit_before>#!/bin/bash

set -u
set -o errexit

PWD="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$PWD/set_mc_root_dir.inc.sh"

cd "$MC_ROOT_DIR"

if pwd | grep ' ' ; then
    echo "Media Cloud cannot be installed in a file path with spaces in its name"
    exit 1
fi

# Net::SSLeay is unable to find system's <openssl/err.h> on OS X
if [ `uname` == 'Darwin' ]; then
    OPENSSL_PREFIX="/usr/local/opt/openssl"
else
    OPENSSL_PREFIX="/usr"
fi

# OS X no longer provides OpenSSL headers and Net::AMQP::RabbitMQ doesn't care
# about OPENSSL_PREFIX so we need to set CCFLAGS and install the module
# separately.
#
# Additionally, we reset LD to just "cc" in order to remove
# MACOSX_DEPLOYMENT_TARGET parameter.
if [ `uname` == 'Darwin' ]; then
    ./script/run_with_carton.sh ~/perl5/perlbrew/bin/cpanm \
        --configure-args="CCFLAGS=\"-I${OPENSSL_PREFIX}/include\" LDFLAGS=\"-L${OPENSSL_PREFIX}/lib\" LD=\"env cc\"" \
        --local-lib-contained local/ \
        --verbose \
        --notest \
        Net::AMQP::RabbitMQ~2.100001
fi

# Inline::Python needs to use virtualenv's Python 3 instead of the default Python2
set +u; source mc-venv/bin/activate; set -u
INLINE_PYTHON_EXECUTABLE=`command -v python3`   # `which` is a liar

# Install dependency modules; run the command twice because the first
# attempt might fail
ATTEMPT=1
CARTON_INSTALL_SUCCEEDED=0
until [ $ATTEMPT -ge 3 ]; do
    OPENSSL_PREFIX=$OPENSSL_PREFIX \
    INLINE_PYTHON_EXECUTABLE=$INLINE_PYTHON_EXECUTABLE \
    ./script/run_carton.sh install && {
        echo "Successfully installed Carton modules"
        CARTON_INSTALL_SUCCEEDED=1
        break
    } || {
        echo "Attempt $ATTEMPT to install Carton modules failed"
    }
    ATTEMPT=$[$ATTEMPT+1]
done
if [ $CARTON_INSTALL_SUCCEEDED -ne 1 ]; then
    echo "Gave up installing Carton modules."<commit_msg>Install patched Inline::Python which prints exception tracebacks<commit_after>#!/bin/bash

set -u
set -o errexit

PWD="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$PWD/set_mc_root_dir.inc.sh"

cd "$MC_ROOT_DIR"

if pwd | grep ' ' ; then
    echo "Media Cloud cannot be installed in a file path with spaces in its name"
    exit 1
fi

# Net::SSLeay is unable to find system's <openssl/err.h> on OS X
if [ `uname` == 'Darwin' ]; then
    OPENSSL_PREFIX="/usr/local/opt/openssl"
else
    OPENSSL_PREFIX="/usr"
fi

# OS X no longer provides OpenSSL headers and Net::AMQP::RabbitMQ doesn't care
# about OPENSSL_PREFIX so we need to set CCFLAGS and install the module
# separately.
#
# Additionally, we reset LD to just "cc" in order to remove
# MACOSX_DEPLOYMENT_TARGET parameter.
if [ `uname` == 'Darwin' ]; then
    ./script/run_with_carton.sh ~/perl5/perlbrew/bin/cpanm \
        --configure-args="CCFLAGS=\"-I${OPENSSL_PREFIX}/include\" LDFLAGS=\"-L${OPENSSL_PREFIX}/lib\" LD=\"env cc\"" \
        --local-lib-contained local/ \
        --verbose \
        --notest \
        Net::AMQP::RabbitMQ~2.100001
fi

# Inline::Python needs to use virtualenv's Python 3 instead of the default Python2
set +u; source mc-venv/bin/activate; set -u
INLINE_PYTHON_EXECUTABLE=`command -v python3`   # `which` is a liar

# Install Inline::Python variant which die()s with tracebacks (stack traces)
INLINE_PYTHON_EXECUTABLE=$INLINE_PYTHON_EXECUTABLE \
./script/run_with_carton.sh ~/perl5/perlbrew/bin/cpanm \
    --local-lib-contained local/ \
    --verbose \
    https://github.com/pypt/inline-python-pm.git@exception_traceback_memleak

# Install dependency modules; run the command twice because the first
# attempt might fail
ATTEMPT=1
CARTON_INSTALL_SUCCEEDED=0
until [ $ATTEMPT -ge 3 ]; do
    OPENSSL_PREFIX=$OPENSSL_PREFIX \
    INLINE_PYTHON_EXECUTABLE=$INLINE_PYTHON_EXECUTABLE \
    ./script/run_carton.sh install && {
        echo "Successfully installed Carton modules"
        CARTON_INSTALL_SUCCEEDED=1
        break
    } || {
        echo "Attempt $ATTEMPT to install Carton modules failed"
    }
    ATTEMPT=$[$ATTEMPT+1]
done
if [ $CARTON_INSTALL_SUCCEEDED -ne 1 ]; then
    echo "Gave up installing Carton modules."
{'fraction_non_alphanumeric': 0.11915830682652312, 'fraction_numerical': 0.009542451676045999, 'mean_word_length': 3.52212389380531, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 1, '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': '7383080', 'n_tokens_mistral': 1499, 'n_tokens_neox': 1387, 'n_words': 391}