<commit_before>
from pythonforandroid.toolchain import CythonRecipe, shprint, ArchAndroid, current_directory, info
import sh
import glob
from os.path import join, exists


class AudiostreamRecipe(CythonRecipe):
    version  = 'master'
    url = 'https://github.com/kivy/audiostream/archive/{version}.zip'
    name = 'audiostream'
    depends = ['python2', ('sdl', 'sdl2'), 'pyjnius']

    def get_recipe_env(self, arch):
        if 'sdl' in self.ctx.recipe_build_order:
            sdl_include = 'sdl'
            sdl_mixer_include = 'sdl_mixer'
        elif 'sdl2' in self.ctx.recipe_build_order:
            sdl_include = 'SDL'
            sdl_mixer_include = 'SDL2_mixer'

        #note: audiostream library is not yet able to judge whether it is being used with sdl or with sdl2.
        #this causes linking to fail against SDL2 (compiling against SDL2 works)
        #need to find a way to fix this in audiostream's setup.py
        
        env = super(AudiostreamRecipe, self).get_recipe_env(arch)
        env['CFLAGS'] += ' -I{jni_path}/{sdl_include}/include -I{jni_path}/{sdl_mixer_include}'.format(
                              jni_path = join(self.ctx.bootstrap.build_dir, 'jni'),
                              sdl_include = sdl_include,
                              sdl_mixer_include = sdl_mixer_include)
        return env
        


recipe = AudiostreamRecipe()<commit_msg>Because audiostream can't link against audiostream yet, raise an error with more helpful message<commit_after>
from pythonforandroid.toolchain import CythonRecipe, shprint, ArchAndroid, current_directory, info
import sh
import glob
from os.path import join, exists


class AudiostreamRecipe(CythonRecipe):
    version  = 'master'
    url = 'https://github.com/kivy/audiostream/archive/{version}.zip'
    name = 'audiostream'
    depends = ['python2', ('sdl', 'sdl2'), 'pyjnius']

    def get_recipe_env(self, arch):
        if 'sdl' in self.ctx.recipe_build_order:
            sdl_include = 'sdl'
            sdl_mixer_include = 'sdl_mixer'
        elif 'sdl2' in self.ctx.recipe_build_order:
            sdl_include = 'SDL'
            sdl_mixer_include = 'SDL2_mixer'
            
            #note: audiostream library is not yet able to judge whether it is being used with sdl or with sdl2.
            #this causes linking to fail against SDL2 (compiling against SDL2 works)
            #need to find a way to fix this in audiostream's setup.py
            raise RuntimeError('Audiostream library is not yet able to configure itself to link against SDL2.  Patch on audiostream library needed - any help much appreciated!')

        env = super(AudiostreamRecipe, self).get_recipe_env(arch)
        env['CFLAGS'] += ' -I{jni_path}/{sdl_include}/include -I{jni_path}/{sdl_mixer_include}'.format(
                              jni_path = join(self.ctx.bootstrap.build_dir, 'jni'),
                              sdl_include = sdl_include,
                              sdl_mixer_include = sdl_mixer_include)
        return env
        


recipe = AudiostreamRecipe()
{'fraction_non_alphanumeric': 0.08864900228982663, 'fraction_numerical': 0.004906771344455349, 'mean_word_length': 2.559953434225844, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '3514005', 'n_tokens_mistral': 957, 'n_tokens_neox': 902, 'n_words': 251}