<s> from pythonforandroid . toolchain import Bootstrap , shprint , current_directory , info , warning , ArchARM , info_main <EOL> from os . path import join , exists , curdir , abspath <EOL> from os import walk <EOL> import glob <EOL> import sh <EOL> class SDL2Bootstrap ( Bootstrap ) : <EOL> name = '<STR_LIT>' <EOL> recipe_depends = [ '<STR_LIT>' , ( '<STR_LIT>' , '<STR_LIT>' ) ] <EOL> def run_distribute ( self ) : <EOL> info_main ( '<STR_LIT>' . format ( <EOL> self . name ) ) <EOL> info ( '<STR_LIT>' ) <EOL> shprint ( sh . rm , '<STR_LIT>' , self . dist_dir ) <EOL> shprint ( sh . cp , '<STR_LIT>' , self . build_dir , self . dist_dir ) <EOL> with current_directory ( self . dist_dir ) : <EOL> with open ( '<STR_LIT>' , '<STR_LIT:w>' ) as fileh : <EOL> fileh . write ( '<STR_LIT>' . format ( self . ctx . sdk_dir ) ) <EOL> arch = self . ctx . archs [ <NUM_LIT:0> ] <EOL> if len ( self . ctx . archs ) > <NUM_LIT:1> : <EOL> raise ValueError ( '<STR_LIT>' ) <EOL> info ( '<STR_LIT>' . format ( arch ) ) <EOL> with current_directory ( self . dist_dir ) : <EOL> info ( '<STR_LIT>' ) <EOL> if not exists ( '<STR_LIT>' ) and not self . ctx . python_recipe . from_crystax : <EOL> shprint ( sh . mkdir , '<STR_LIT>' ) <EOL> if not exists ( '<STR_LIT>' ) and self . ctx . python_recipe . from_crystax : <EOL> shprint ( sh . mkdir , '<STR_LIT>' ) <EOL> shprint ( sh . mkdir , '<STR_LIT>' ) <EOL> if not exists ( '<STR_LIT>' ) : <EOL> shprint ( sh . mkdir , '<STR_LIT>' ) <EOL> hostpython = sh . Command ( self . ctx . hostpython ) <EOL> if not self . ctx . python_recipe . from_crystax : <EOL> try : <EOL> shprint ( hostpython , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> self . ctx . get_python_install_dir ( ) , <EOL> _tail = <NUM_LIT:10> , _filterout = "<STR_LIT>" ) <EOL> except sh . ErrorReturnCode : <EOL> pass <EOL> if not exists ( '<STR_LIT>' ) : <EOL> shprint ( sh . cp , '<STR_LIT>' , self . ctx . get_python_install_dir ( ) , '<STR_LIT>' ) <EOL> self . distribute_libs ( arch , [ self . ctx . get_libs_dir ( arch . arch ) ] ) <EOL> self . distribute_aars ( arch ) <EOL> self . distribute_javaclasses ( self . ctx . javaclass_dir ) <EOL> if not self . ctx . python_recipe . from_crystax : <EOL> info ( '<STR_LIT>' ) <EOL> if not exists ( join ( '<STR_LIT>' , '<STR_LIT>' ) ) : <EOL> info ( '<STR_LIT>' ) <EOL> shprint ( sh . cp , '<STR_LIT>' , join ( '<STR_LIT>' , '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> shprint ( sh . mkdir , '<STR_LIT>' , join ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> if exists ( join ( '<STR_LIT>' , arch . arch , '<STR_LIT>' ) ) : <EOL> shprint ( sh . mv , join ( '<STR_LIT>' , arch . arch , '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> shprint ( sh . cp , join ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , join ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> info ( '<STR_LIT>' ) <EOL> shprint ( sh . rm , '<STR_LIT>' , join ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> shprint ( sh . rm , '<STR_LIT>' , join ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> libdir = join ( self . dist_dir , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> site_packages_dir = join ( libdir , '<STR_LIT>' ) <EOL> with current_directory ( libdir ) : <EOL> removes = [ ] <EOL> for dirname , something , filens in walk ( '<STR_LIT:.>' ) : <EOL> for filename in filens : <EOL> for suffix in ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) : <EOL> if filename . endswith ( suffix ) : <EOL> removes . append ( filename ) <EOL> shprint ( sh . rm , '<STR_LIT>' , * removes ) <EOL> info ( '<STR_LIT>' ) <EOL> shprint ( sh . rm , '<STR_LIT>' , '<STR_LIT>' ) <EOL> shprint ( sh . rm , '<STR_LIT>' , '<STR_LIT>' ) <EOL> for filename in glob . glob ( '<STR_LIT>' ) : <EOL> shprint ( sh . rm , '<STR_LIT>' , filename ) <EOL> shprint ( sh . rm , '<STR_LIT>' , '<STR_LIT>' ) <EOL> else : <EOL> ndk_dir = self . ctx . ndk_dir <EOL> py_recipe = self . ctx . python_recipe <EOL> python_dir = join ( ndk_dir , '<STR_LIT>' , '<STR_LIT>' , py_recipe . version , <EOL> '<STR_LIT>' , arch . arch ) <EOL> shprint ( sh . cp , '<STR_LIT>' , join ( python_dir , '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> shprint ( sh . cp , '<STR_LIT>' , join ( python_dir , '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> shprint ( sh . cp , '<STR_LIT>' , self . ctx . get_python_install_dir ( ) , '<STR_LIT>' ) <EOL> info ( '<STR_LIT>' ) <EOL> site_packages_dir = '<STR_LIT>' <EOL> filens = shprint ( sh . find , site_packages_dir , '<STR_LIT>' , '<STR_LIT>' ) . stdout . decode ( <EOL> '<STR_LIT:utf-8>' ) . split ( '<STR_LIT:\n>' ) [ : - <NUM_LIT:1> ] <EOL> for filen in filens : <EOL> parts = filen . split ( '<STR_LIT:.>' ) <EOL> if len ( parts ) <= <NUM_LIT:2> : <EOL> continue <EOL> shprint ( sh . mv , filen , filen . split ( '<STR_LIT:.>' ) [ <NUM_LIT:0> ] + '<STR_LIT>' ) <EOL> site_packages_dir = join ( abspath ( curdir ) , <EOL> site_packages_dir ) <EOL> self . strip_libraries ( arch ) <EOL> self . fry_eggs ( site_packages_dir ) <EOL> super ( SDL2Bootstrap , self ) . run_distribute ( ) <EOL> bootstrap = SDL2Bootstrap ( ) </s>
