<commit_before>#!/usr/bin/env python
"""
_build_

Implements the cirrus build command.

This command:
 - creates a virtualenv in the package
 - pip installs requirements.txt for the package into the venv

"""
import os
import subprocess
from cirrus.environment import cirrus_home
from cirrus.configuration import load_configuration


def main():
    """
    _main_

    Execute the build in the current package context.

    - reads the config to check for custom build parameters
      - defaults to ./venv for virtualenv
      - defaults to ./requirements.txt for reqs
    - builds the virtualenv
    - pip installs the requirements into it

    """
    working_dir = os.getcwd()
    config = load_configuration()
    build_params = config.get('build', {})

    # we have custom build controls in the cirrus.conf
    venv_name = build_params.get('virtualenv_name', 'venv')
    reqs_name = build_params.get('requirements_file', 'requirements.txt')
    venv_path = os.path.join(working_dir, venv_name)
    venv_command = os.path.join(cirrus_home(), 'bin', 'virtualenv')
    if not os.path.exists(venv_path):
        cmd = [venv_command, '--distribute', venv_path]
        subprocess.call(cmd)

    # now we can install requirements into the newly created venv
    cmd = [
        '{0}/bin/pip'.format(venv_path),
        'install',
        '-r',
        reqs_name
    ]
    subprocess.call(cmd)


if __name__ == '__main__':
    main()
<commit_msg>add debugging info to build command<commit_after>#!/usr/bin/env python
"""
_build_

Implements the cirrus build command.

This command:
 - creates a virtualenv in the package
 - pip installs requirements.txt for the package into the venv

"""
import os
import sys
import subprocess
from cirrus.environment import cirrus_home
from cirrus.configuration import load_configuration


def main():
    """
    _main_

    Execute the build in the current package context.

    - reads the config to check for custom build parameters
      - defaults to ./venv for virtualenv
      - defaults to ./requirements.txt for reqs
    - builds the virtualenv
    - pip installs the requirements into it

    """
    working_dir = os.getcwd()
    config = load_configuration()
    build_params = config.get('build', {})

    # we have custom build controls in the cirrus.conf
    venv_name = build_params.get('virtualenv_name', 'venv')
    reqs_name = build_params.get('requirements_file', 'requirements.txt')
    venv_path = os.path.join(working_dir, venv_name)
    venv_command = os.path.join(cirrus_home(), 'bin', 'virtualenv')
    if not os.path.exists(venv_path):
        cmd = [venv_command, '--distribute', venv_path]
        subprocess.call(cmd)

    # now we can install requirements into the newly created venv
    cmd = [
        '{0}/bin/pip'.format(venv_path),
        'install',
        '-r',
        reqs_name
    ]
    try:
        subprocess.call(cmd)
    except OSError as ex:
        msg = (
            "Error running pip install command during build\n"
            "Error was {0}\n"
            "Running command: {1}\n"
            "Working Dir: {2}\n"
            "Virtualenv: {3}\n"
            "Requirements: {4}\n"
            ).format(ex, cmd, working_dir, venv_path, reqs_name)
        print(msg)
        sys.exit(1)


if __name__ == '__main__':
    main()

{'fraction_non_alphanumeric': 0.10226244343891402, 'fraction_numerical': 0.0024132730015082957, 'mean_word_length': 2.763904653802497, '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': '1160084', 'n_tokens_mistral': 1026, 'n_tokens_neox': 1006, 'n_words': 302}