<commit_before>#!/bin/bash

cd "`dirname $0`"

# exit if virtualenv_name parameter is missing
if [ -z "$1" ]; then
    echo "Usage: rebuild_osx_dev_env <virtualenv_name>"
    exit -1
fi

# exit if virtualenv_paths.config file does not exist
if [ ! -e virtualenv_paths.config ]; then
    echo "Expected virtualenv_paths.config file not found -- use the virtualenv_paths.config.template file as a basis"
    exit -1
fi

VIRTUALENV_NAME=$1

source osx_build_flags_env_intel.config
source virtualenv_paths.config

workon $VIRTUALENV_NAME

printf "\n>> Virtualenv should be empty (i.e. wsgiref only)\n"
pip freeze

printf "\n>> Installing RSR modules\n"
pip install -M -r requirements/2_rsr.txt

printf "\n>> Installing further dev and testing modules\n"
pip install -M -r requirements/3_testing.txt

printf "\n>> Installed modules:\n"
pip freeze

deactivate<commit_msg>[#6699037] Refactored rebuild_osx_dev_env.sh script and added check to ensure the named virtualenv exists before continuing.<commit_after>#!/bin/bash

cd "`dirname $0`"

# exit if virtualenv_name parameter is missing
if [ -z "$1" ]; then
    echo "Usage: rebuild_osx_dev_env <virtualenv_name>"
    exit -1
fi

# exit if virtualenv_paths.config file does not exist
if [ ! -e virtualenv_paths.config ]; then
    echo "Expected virtualenv_paths.config file not found -- use the virtualenv_paths.config.template file as a basis"
    exit -1
fi

VIRTUALENV_NAME=$1

source osx_build_flags_env_intel.config
source virtualenv_paths.config

function install_rsr_and_testing_packages
{
    printf "\n>> Fresh virtualenv should only contain the distribute and wsgiref packages:\n"
    pip freeze

    printf "\n>> Installing RSR packages:\n"
    pip install -M -r requirements/2_rsr.txt

    printf "\n>> Installing further dev and testing packages:\n"
    pip install -M -r requirements/3_testing.txt

    printf "\n>> Packages installed in the $VIRTUALENV_NAME virtualenv:\n"
    pip freeze
}

function install_rsr_packages_within_virtualenv
{
    printf "\n>> Working on virtualenv: $VIRTUALENV_NAME\n"
    workon $VIRTUALENV_NAME

    # proceed if no errors occur when switching to the named virtualenv
    if [ $? -eq 0 ]; then
        install_rsr_and_testing_packages
        printf "\n>> Deactivating virtualenv: $VIRTUALENV_NAME\n"
        deactivate
    else
        printf "\n>> Could not switch to $VIRTUALENV_NAME -- has this virtualenv been created?\n"
        exit -1
    fi
}


install_rsr_packages_within_virtualenv
{'fraction_non_alphanumeric': 0.08487530168946097, 'fraction_numerical': 0.00925181013676589, 'mean_word_length': 3.847953216374269, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, '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': '5098769', 'n_tokens_mistral': 819, 'n_tokens_neox': 784, 'n_words': 260}