<commit_before>import os, sys, shutil, json
from subprocess import call, PIPE
from .venv import VirtualEnv
from .pool import FeaturePool 



def get_ape_venv():
    '''
    Returns the _ape virtualenv.
    '''
    return VirtualEnv(os.path.join(os.environ['APE_GLOBAL_DIR'], 'venv'))
    

def cleanup():
    '''
    Cleans up the installation directory.
    '''
    lib_dir = os.path.join(os.environ['CONTAINER_DIR'], '_lib')
    if os.path.exists(lib_dir):
        shutil.rmtree(lib_dir)
    os.mkdir(lib_dir)
    
    
def create_project_venv():
    '''
    Creates a project-level virtualenv and returns a ``VirtualEnv`` object.
    '''
    print '... creating project-level virtualenv'
    venv_dir = os.path.join(os.environ['CONTAINER_DIR'], '_lib/venv')
    
    if os.path.exists(venv_dir):
        print 'ERROR: virtualenv already exists!'
        sys.exit()
    
    try:
        call(['virtualenv', venv_dir, '--no-site-packages'])
    except OSError:
        print 'ERROR: You probably dont have virtualenv installed: sudo apt-get install python-virtualenv'
        sys.exit()
        
    print '... virtualenv successfully created'
    return VirtualEnv(venv_dir)


def fetch_pool(repo_url):
    '''
    Fetches a git repository from ``repo_url`` and returns a ``FeaturePool`` object.
    '''
    repo_name = repo_url.split('.git')[0].split('/')[-1]
    lib_dir = os.path.join(os.environ['CONTAINER_DIR'], '_lib')
    print '... fetching %s ' % repo_name
    
    if os.path.exists(os.path.join(lib_dir, repo_name)):
        print 'ERROR: repository already exists' 
        sys.exit()
        
    try:
        a = call(['git', 'clone', repo_url], cwd=lib_dir)
    except OSError:
        print 'ERROR: You probably dont have git installed: sudo apt-get install git'
        sys.exit()
    
    if a != 0:
        print 'ERROR: check your repository url and credentials!'<commit_msg>added support for debian virtualenv issue described in issue #5<commit_after>import os, sys, shutil, json
from subprocess import call, PIPE
from .venv import VirtualEnv
from .pool import FeaturePool 



def get_ape_venv():
    '''
    Returns the _ape virtualenv.
    '''
    return VirtualEnv(os.path.join(os.environ['APE_GLOBAL_DIR'], 'venv'))
    

def cleanup():
    '''
    Cleans up the installation directory.
    '''
    lib_dir = os.path.join(os.environ['CONTAINER_DIR'], '_lib')
    if os.path.exists(lib_dir):
        shutil.rmtree(lib_dir)
    os.mkdir(lib_dir)
    
    
def create_project_venv():
    '''
    Creates a project-level virtualenv and returns a ``VirtualEnv`` object.
    '''
    print '... creating project-level virtualenv'
    venv_dir = os.path.join(os.environ['CONTAINER_DIR'], '_lib/venv')
    
    if os.path.exists(venv_dir):
        print 'ERROR: virtualenv already exists!'
        sys.exit()
    
    try:
        r = call(['virtualenv', venv_dir, '--no-site-packages'])
    except OSError:
        print 'ERROR: You probably dont have virtualenv installed: sudo apt-get install python-virtualenv'
        sys.exit()
        
    if r != 0:
        raise Exception('ERROR: please install virtualenv in your current env.')
    
    print '... virtualenv successfully created'
    return VirtualEnv(venv_dir)


def fetch_pool(repo_url):
    '''
    Fetches a git repository from ``repo_url`` and returns a ``FeaturePool`` object.
    '''
    repo_name = repo_url.split('.git')[0].split('/')[-1]
    lib_dir = os.path.join(os.environ['CONTAINER_DIR'], '_lib')
    print '... fetching %s ' % repo_name
    
    if os.path.exists(os.path.join(lib_dir, repo_name)):
        print 'ERROR: repository already exists' 
        sys.exit()
        
    try:
        a = call(['git', 'clone', repo_url], cwd=lib_dir)
    except OSError:
        print 'ERROR: You probably dont have git installed: sudo apt-get install git'
        sys.exit()
    
    if a != 0:
        print 'ERROR: check your repository url and credentials!'
{'fraction_non_alphanumeric': 0.12832194381169323, 'fraction_numerical': 0.0020248038471273096, 'mean_word_length': 2.7459715639810427, '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': '2460788', 'n_tokens_mistral': 1266, 'n_tokens_neox': 1247, 'n_words': 331}