<commit_before>import os.path, sys

from envbuilder.sh import sh, warn
from envbuilder.command import BuiltinCommand

class Setup(BuiltinCommand):
    """
    Set up the parcels.  This usually installs the parcel into 
    the virtualenv.
    """
    name = 'setup'
    def run(self, args, config):
        if not args.no_create:
            venv_opts = config['project']['virtualenv-args']
            sh('virtualenv ' + venv_opts)
        if args.upgrade:
            upgrade_flag = '-U'
        else:
            upgrade_flag = ''
        requirements = config['project']['requires']
        if requirements:
            warn('The requires attribute is deprecated and will be removed in a '
                 'future release.')
        pip_install = config['project']['pip_install'] 
        for requirement in requirements:
            sh('%s %s %s' % (pip_install, upgrade_flag, requirement))
                
        config.run_command('setup', required=False)
        
    def get_arg_parser(self):
        parser = self.get_base_arg_parser()
        parser.add_argument('-n', '--no-create', default=False,
                            action='store_true',
                            help="Don't (re)create the virtualenv")
        return parser
<commit_msg>Breaking this out into its own method<commit_after>import os.path, sys

from envbuilder.sh import sh, warn
from envbuilder.command import BuiltinCommand

class Setup(BuiltinCommand):
    """
    Set up the parcels.  This usually installs the parcel into 
    the virtualenv.
    """
    name = 'setup'
    def run(self, args, config):
        if not args.no_create:
            venv_opts = config['project']['virtualenv-args']
            sh('virtualenv ' + venv_opts)
        if args.upgrade:
            upgrade_flag = '-U'
        else:
            upgrade_flag = ''
        self.install_env_requires(config, upgrade_flag)
               
        config.run_command('setup', required=False)
        
    def get_arg_parser(self):
        parser = self.get_base_arg_parser()
        parser.add_argument('-n', '--no-create', default=False,
                            action='store_true',
                            help="Don't (re)create the virtualenv")
        return parser

    def install_env_requires(self, config, upgrade_flag):
        requirements = config['project']['requires']
        if requirements:
            warn('The requires attribute is deprecated and will be removed in a '
                 'future release.')
        pip_install = config['project']['pip_install'] 
        for requirement in requirements:
            sh('%s %s %s' % (pip_install, upgrade_flag, requirement))
 
{'fraction_non_alphanumeric': 0.10236220472440945, 'fraction_numerical': 0.0, 'mean_word_length': 2.12778429073857, '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': '614433', 'n_tokens_mistral': 726, 'n_tokens_neox': 704, 'n_words': 192}