#NEWLINE# def run_distribute( self ) : #NEWLINE# #INDENT# info_main ( '# Creating Android project from build and {} bootstrap' . format ( self . name ) ) #NEWLINE# src_path = join ( self . bootstrap_dir , 'build' ) #NEWLINE# arch = self . ctx . archs [ 0 ] #NEWLINE# if ( len ( self . ctx . archs ) > 1 ) : #NEWLINE# #INDENT# raise ValueError ( 'built for more than one arch, but bootstrap cannot handle that yet' ) #NEWLINE# #UNINDENT# info ( 'Bootstrap running with arch {}' . format ( arch ) ) #NEWLINE# with current_directory ( self . dist_dir ) : #NEWLINE# #INDENT# info ( 'Creating initial layout' ) #NEWLINE# for dirname in ( 'assets' , 'bin' , 'private' , 'res' , 'templates' ) : #NEWLINE# #INDENT# if ( not exists ( dirname ) ) : #NEWLINE# #INDENT# shprint ( sh . mkdir , dirname ) #NEWLINE# #UNINDENT# #UNINDENT# info ( 'Copying default files' ) #NEWLINE# shprint ( sh . cp , '-a' , join ( self . build_dir , 'project.properties' ) , '.' ) #NEWLINE# shprint ( sh . cp , '-a' , join ( src_path , 'build.py' ) , '.' ) #NEWLINE# shprint ( sh . cp , '-a' , join ( src_path , 'buildlib' ) , '.' ) #NEWLINE# shprint ( sh . cp , '-a' , join ( src_path , 'src' ) , '.' ) #NEWLINE# shprint ( sh . cp , '-a' , join ( src_path , 'templates' ) , '.' ) #NEWLINE# shprint ( sh . cp , '-a' , join ( src_path , 'res' ) , '.' ) #NEWLINE# shprint ( sh . cp , '-a' , join ( src_path , 'blacklist.txt' ) , '.' ) #NEWLINE# shprint ( sh . cp , '-a' , join ( src_path , 'whitelist.txt' ) , '.' ) #NEWLINE# with open ( 'local.properties' , 'w' ) as fileh : #NEWLINE# #INDENT# fileh . write ( 'sdk.dir={}' . format ( self . ctx . sdk_dir ) ) #NEWLINE# #UNINDENT# info ( 'Copying python distribution' ) #NEWLINE# hostpython = sh . Command ( src_path . ctx . hostpython ) #NEWLINE# try : #NEWLINE# #INDENT# shprint ( hostpython , '-OO' , '-m' , 'compileall' , self . ctx . get_python_install_dir ( ) , _tail = 10 , _filterout = '^Listing' ) #NEWLINE# #UNINDENT# except sh . ErrorReturnCode : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# if ( not exists ( 'python-install' ) ) : #NEWLINE# #INDENT# shprint ( sh . cp , '-a' , self . ctx . get_python_install_dir ( ) , './python-install' ) #NEWLINE# #UNINDENT# self . distribute_libs ( arch , [ join ( self . build_dir , 'libs' , arch . arch ) , self . ctx . get_libs_dir ( arch . arch ) ] ) #NEWLINE# self . distribute_aars ( arch ) #NEWLINE# self . distribute_javaclasses ( self . ctx . javaclass_dir ) #NEWLINE# info ( 'Filling private directory' ) #NEWLINE# if ( not exists ( join ( 'private' , 'lib' ) ) ) : #NEWLINE# #INDENT# shprint ( sh . cp , '-a' , join ( 'python-install' , 'lib' ) , 'private' ) #NEWLINE# #UNINDENT# shprint ( sh . mkdir , '-p' , join ( 'private' , 'include' , 'python2.7' ) ) #NEWLINE# shprint ( sh . mv , join ( 'libs' , arch . arch , 'libpymodules.so' ) , 'private/' ) #NEWLINE# shprint ( sh . cp , join ( 'python-install' , 'include' , 'python2.7' , 'pyconfig.h' ) , join ( 'private' , 'include' , 'python2.7/' ) ) #NEWLINE# info ( 'Removing some unwanted files' ) #NEWLINE# shprint ( sh . rm , '-f' , join ( 'private' , 'lib' , 'libpython2.7.so' ) ) #NEWLINE# shprint ( sh . rm , '-rf' , join ( 'private' , 'lib' , 'pkgconfig' ) ) #NEWLINE# with current_directory ( join ( self . dist_dir , 'private' , 'lib' , 'python2.7' ) ) : #NEWLINE# #INDENT# removes = [ ] #NEWLINE# for ( dirname , something , filens ) in walk ( '.' ) : #NEWLINE# #INDENT# for filename in filens : #NEWLINE# #INDENT# for suffix in ( 'py' , 'pyc' , 'so.o' , 'so.a' , 'so.libs' ) : #NEWLINE# #INDENT# if filename . endswith ( suffix ) : #NEWLINE# #INDENT# removes . append ( filename ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# shprint ( sh . rm , '-f' , * removes ) #NEWLINE# info ( 'Deleting some other stuff not used on android' ) #NEWLINE# shprint ( sh . rm , '-rf' , 'lib2to3' ) #NEWLINE# shprint ( sh . rm , '-rf' , 'idlelib' ) #NEWLINE# for filename in glob . glob ( 'config/libpython*.a' ) : #NEWLINE# #INDENT# shprint ( sh . rm , '-f' , filename ) #NEWLINE# #UNINDENT# shprint ( sh . rm , '-rf' , 'config/python.o' ) #NEWLINE# shprint ( sh . rm , '-rf' , 'lib-dynload/_ctypes_test.so' ) #NEWLINE# shprint ( sh . rm , '-rf' , 'lib-dynload/_testcapi.so' ) #NEWLINE# #UNINDENT# #UNINDENT# self . strip_libraries ( arch ) #NEWLINE# super ( PygameBootstrap , self ) . run_distribute ( )