resolve conflicts

This commit is contained in:
Robert Niederreiter 2017-03-21 17:32:23 +01:00
commit c6061bdfc0
7 changed files with 55 additions and 23 deletions

4
.gitignore vendored
View file

@ -14,6 +14,7 @@ var
sdist sdist
develop-eggs develop-eggs
.installed.cfg .installed.cfg
.idea
# Installer logs # Installer logs
pip-log.txt pip-log.txt
@ -29,6 +30,8 @@ pip-log.txt
.mr.developer.cfg .mr.developer.cfg
MANIFEST MANIFEST
release\.log\.utf-8\.tmp
# Eclipse # Eclipse
.project .project
.pydevproject .pydevproject
@ -36,3 +39,4 @@ MANIFEST
# Custom virtualenv location # Custom virtualenv location
venv venv

View file

@ -627,10 +627,7 @@ class Buildozer(object):
return return
if archive.endswith('.zip'): if archive.endswith('.zip'):
archive = join(cwd, archive) self.cmd('unzip {}'.format(join(cwd, archive)), cwd=cwd)
zf = zipfile.ZipFile(archive)
zf.extractall(path=cwd)
zf.close()
return return
raise Exception('Unhandled extraction for type {0}'.format(archive)) raise Exception('Unhandled extraction for type {0}'.format(archive))
@ -826,9 +823,9 @@ class Buildozer(object):
#self.error('Unable to patch main_py to add applibs directory.') #self.error('Unable to patch main_py to add applibs directory.')
return return
header = ('import sys, os; ' header = (b'import sys, os; '
'sys.path = [os.path.join(os.getcwd(),' b'sys.path = [os.path.join(os.getcwd(),'
'"..", "_applibs")] + sys.path\n') b'"..", "_applibs")] + sys.path\n')
with open(main_py, 'rb') as fd: with open(main_py, 'rb') as fd:
data = fd.read() data = fd.read()
data = header + data data = header + data

View file

@ -111,6 +111,9 @@ fullscreen = 1
# (str) The directory in which python-for-android should look for your own build recipes (if any) # (str) The directory in which python-for-android should look for your own build recipes (if any)
#p4a.local_recipes = #p4a.local_recipes =
# (str) Filename to the hook for p4a
#p4a.hook =
# (list) python-for-android whitelist # (list) python-for-android whitelist
#android.p4a_whitelist = #android.p4a_whitelist =
@ -172,6 +175,9 @@ fullscreen = 1
# (bool) Copy library instead of making a libpymodules.so # (bool) Copy library instead of making a libpymodules.so
#android.copy_libs = 1 #android.copy_libs = 1
# (str) The Android arch to build for, choices: armeabi-v7a, arm64-v8a, x86
android.arch = armeabi-v7a
# #
# iOS specific # iOS specific
# #

View file

@ -1,11 +1,12 @@
from sys import exit from sys import exit
def no_config(f): def no_config(f):
f.__no_config = True f.__no_config = True
return f return f
class Target(object):
class Target(object):
def __init__(self, buildozer): def __init__(self, buildozer):
super(Target, self).__init__() super(Target, self).__init__()
self.buildozer = buildozer self.buildozer = buildozer

View file

@ -604,6 +604,11 @@ class TargetAndroid(Target):
def get_dist_dir(self, dist_name): def get_dist_dir(self, dist_name):
return join(self.pa_dir, 'dist', dist_name) return join(self.pa_dir, 'dist', dist_name)
@property
def dist_dir(self):
dist_name = self.buildozer.config.get('app', 'package.name')
return self.get_dist_dir(dist_name)
def execute_build_package(self, build_cmd): def execute_build_package(self, build_cmd):
dist_name = self.buildozer.config.get('app', 'package.name') dist_name = self.buildozer.config.get('app', 'package.name')
cmd = [self.p4a_apk_cmd] cmd = [self.p4a_apk_cmd]
@ -750,6 +755,14 @@ class TargetAndroid(Target):
self.execute_build_package(build_cmd) self.execute_build_package(build_cmd)
try:
self.buildozer.hook("android_pre_build_apk")
self.execute_build_package(build_cmd)
self.buildozer.hook("android_post_build_apk")
except:
# maybe the hook fail because the apk is not
pass
# XXX found how the apk name is really built from the title # XXX found how the apk name is really built from the title
bl = u'\'" ,' bl = u'\'" ,'
apptitle = config.get('app', 'title') apptitle = config.get('app', 'title')
@ -807,11 +820,7 @@ class TargetAndroid(Target):
# recreate the project.properties # recreate the project.properties
with io.open(project_fn, 'w', encoding='utf-8') as fd: with io.open(project_fn, 'w', encoding='utf-8') as fd:
for line in content: fd.writelines(content)
if IS_PY3:
fd.write(line)
else:
fd.write(line.decode('utf-8'))
for index, ref in enumerate(references): for index, ref in enumerate(references):
fd.write(u'android.library.reference.{}={}\n'.format(index + 1, fd.write(u'android.library.reference.{}={}\n'.format(index + 1,
ref)) ref))
@ -930,3 +939,4 @@ class TargetAndroid(Target):
def get_target(buildozer): def get_target(buildozer):
return TargetAndroid(buildozer) return TargetAndroid(buildozer)

View file

@ -4,6 +4,7 @@ Android target, based on python-for-android project (new toolchain)
''' '''
import sys import sys
import buildozer
from buildozer.targets.android import TargetAndroid from buildozer.targets.android import TargetAndroid
from buildozer import USE_COLOR from buildozer import USE_COLOR
from os.path import join, expanduser, realpath from os.path import join, expanduser, realpath
@ -13,19 +14,22 @@ class TargetAndroidNew(TargetAndroid):
targetname = 'android_new' targetname = 'android_new'
p4a_branch = "master" p4a_branch = "master"
p4a_directory = "python-for-android-master" p4a_directory = "python-for-android-master"
p4a_apk_cmd = "apk --bootstrap=" p4a_apk_cmd = "apk --debug --bootstrap="
extra_p4a_args = '' extra_p4a_args = ''
def __init__(self, buildozer): def __init__(self, buildozer):
super(TargetAndroidNew, self).__init__(buildozer) super(TargetAndroidNew, self).__init__(buildozer)
self._build_dir = join(self.buildozer.platform_dir, 'build') self._build_dir = join(self.buildozer.platform_dir, 'build')
self._p4a_cmd = ('python -m pythonforandroid.toolchain ') self._p4a_cmd = 'python -m pythonforandroid.toolchain '
self._p4a_bootstrap = self.buildozer.config.getdefault( self._p4a_bootstrap = self.buildozer.config.getdefault(
'app', 'android.bootstrap', 'sdl2') 'app', 'android.bootstrap', 'sdl2')
self.p4a_apk_cmd += self._p4a_bootstrap self.p4a_apk_cmd += self._p4a_bootstrap
color = 'always' if USE_COLOR else 'never' color = 'always' if USE_COLOR else 'never'
self.extra_p4a_args = ' --color={} --storage-dir={}'.format( self.extra_p4a_args = ' --color={} --storage-dir={}'.format(
color, self._build_dir) color, self._build_dir)
hook = self.buildozer.config.getdefault("app", "p4a.hook", None)
if hook is not None:
self.extra_p4a_args += ' --hook={}'.format(realpath(hook))
def _p4a(self, cmd, **kwargs): def _p4a(self, cmd, **kwargs):
if not hasattr(self, "pa_dir"): if not hasattr(self, "pa_dir"):
@ -63,14 +67,11 @@ class TargetAndroidNew(TargetAndroid):
options.append('--local-recipes') options.append('--local-recipes')
options.append(local_recipes) options.append(local_recipes)
available_modules = self._p4a( available_modules = self._p4a(
"create --dist_name={} --bootstrap={} --requirements={} --arch armeabi-v7a {}".format( "create --dist_name={} --bootstrap={} --requirements={} --arch {} {}".format(
dist_name, self._p4a_bootstrap, requirements, " ".join(options)), dist_name, self._p4a_bootstrap, requirements,
self.buildozer.config.getdefault('app', 'android.arch', "armeabi-v7a"), " ".join(options)),
get_stdout=True)[0] get_stdout=True)[0]
def _update_libraries_references(self, dist_dir):
# UNSUPPORTED YET
pass
def get_dist_dir(self, dist_name): def get_dist_dir(self, dist_name):
return join(self._build_dir, 'dists', dist_name) return join(self._build_dir, 'dists', dist_name)
@ -89,6 +90,7 @@ class TargetAndroidNew(TargetAndroid):
continue continue
elif option == "release": elif option == "release":
cmd.append("--release") cmd.append("--release")
cmd.append("--sign")
continue continue
if option == "--window": if option == "--window":
cmd.append("--window") cmd.append("--window")
@ -129,6 +131,9 @@ class TargetAndroidNew(TargetAndroid):
cmd.append('--blacklist') cmd.append('--blacklist')
cmd.append(realpath(blacklist_src)) cmd.append(realpath(blacklist_src))
cmd.append('--arch')
cmd.append(self.buildozer.config.getdefault('app', 'android.arch', "armeabi-v7a"))
cmd = " ".join(cmd) cmd = " ".join(cmd)
self._p4a(cmd) self._p4a(cmd)

View file

@ -17,6 +17,16 @@ If you target Android, you must install at least Cython, few build libs, and a
Java SDK. Some binaries of the Android SDK are still in 32 bits, so you need Java SDK. Some binaries of the Android SDK are still in 32 bits, so you need
few 32bits libraries available: few 32bits libraries available:
Android on Ubuntu 16.04 (64bit)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
::
sudo pip install --upgrade cython==0.21
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install build-essential ccache git libncurses5:i386 libstdc++6:i386 libgtk2.0-0:i386 libpangox-1.0-0:i386 libpangoxft-1.0-0:i386 libidn11:i386 python2.7 python2.7-dev openjdk-8-jdk unzip zlib1g-dev zlib1g:i386
Android on Ubuntu 15.10 (64bit) Android on Ubuntu 15.10 (64bit)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -27,7 +37,6 @@ Android on Ubuntu 15.10 (64bit)
sudo apt-get update sudo apt-get update
sudo apt-get install build-essential ccache git libncurses5:i386 libstdc++6:i386 libgtk2.0-0:i386 libpangox-1.0-0:i386 libpangoxft-1.0-0:i386 libidn11:i386 python2.7 python2.7-dev openjdk-7-jdk unzip zlib1g-dev zlib1g:i386 sudo apt-get install build-essential ccache git libncurses5:i386 libstdc++6:i386 libgtk2.0-0:i386 libpangox-1.0-0:i386 libpangoxft-1.0-0:i386 libidn11:i386 python2.7 python2.7-dev openjdk-7-jdk unzip zlib1g-dev zlib1g:i386
Android on Ubuntu 14.10 (64bit) Android on Ubuntu 14.10 (64bit)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~