From 9c51ae1e81e89a9e48c107b4d36ef29593a078b7 Mon Sep 17 00:00:00 2001 From: Mathieu Virbel Date: Thu, 7 Feb 2013 03:57:13 +0100 Subject: [PATCH 1/9] fix get_config_list when the string is empty. closes #8 --- buildozer/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/buildozer/__init__.py b/buildozer/__init__.py index 87971f2..548e0b2 100644 --- a/buildozer/__init__.py +++ b/buildozer/__init__.py @@ -762,7 +762,10 @@ class Buildozer(object): def _get_config_list(self, section, token, default=None): # monkey-patch method for ConfigParser # get a key as a list of string, seperated from the comma - values = self.config.getdefault(section, token, '').split(',') + values = self.config.getdefault(section, token, '') + if not values: + return default + values = values.split(',') if not values: return default return [x.strip() for x in values] From fd5cbcb390ed8fcf7a59df187f9f853eb8ded31d Mon Sep 17 00:00:00 2001 From: Mathieu Virbel Date: Thu, 7 Feb 2013 04:09:40 +0100 Subject: [PATCH 2/9] avoid to prepend app_dir for icon/presplash. use root_dir instead. --- buildozer/__init__.py | 16 +++++++++------- buildozer/targets/android.py | 4 ++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/buildozer/__init__.py b/buildozer/__init__.py index 548e0b2..454ae61 100644 --- a/buildozer/__init__.py +++ b/buildozer/__init__.py @@ -572,10 +572,17 @@ class Buildozer(object): ''' return re.sub('[^a-zA-Z0-9_\-]', '_', name) + @property + def root_dir(self): + return realpath(join(dirname(self.specfilename))) + @property def buildozer_dir(self): - return realpath(join( - dirname(self.specfilename), '.buildozer')) + return join(self.root_dir, '.buildozer') + + @property + def bin_dir(self): + return join(self.root_dir, 'bin') @property def platform_dir(self): @@ -585,11 +592,6 @@ class Buildozer(object): def app_dir(self): return join(self.buildozer_dir, self.targetname, 'app') - @property - def bin_dir(self): - return realpath(join( - dirname(self.specfilename), 'bin')) - @property def applibs_dir(self): return join(self.buildozer_dir, 'applibs') diff --git a/buildozer/targets/android.py b/buildozer/targets/android.py index aae4f00..b8b309b 100644 --- a/buildozer/targets/android.py +++ b/buildozer/targets/android.py @@ -377,13 +377,13 @@ class TargetAndroid(Target): # add presplash presplash = config.getdefault('app', 'presplash.filename', '') if presplash: - build_cmd += ' --presplash {}'.format(join(self.buildozer.app_dir, + build_cmd += ' --presplash {}'.format(join(self.buildozer.root_dir, presplash)) # add icon icon = config.getdefault('app', 'icon.filename', '') if icon: - build_cmd += ' --icon {}'.format(join(self.buildozer.app_dir, icon)) + build_cmd += ' --icon {}'.format(join(self.buildozer.root_dir, icon)) # build only in debug right now. if self.build_mode == 'debug': From 86054353c50e129dba91f57497918f4b8e0438e2 Mon Sep 17 00:00:00 2001 From: Mathieu Virbel Date: Thu, 7 Feb 2013 04:14:40 +0100 Subject: [PATCH 3/9] add cython check for ios target. closes #5 --- buildozer/targets/ios.py | 1 + 1 file changed, 1 insertion(+) diff --git a/buildozer/targets/ios.py b/buildozer/targets/ios.py index 7960364..596b896 100644 --- a/buildozer/targets/ios.py +++ b/buildozer/targets/ios.py @@ -17,6 +17,7 @@ class TargetIos(Target): checkbin('Xcode xcodebuild', 'xcodebuild') checkbin('Xcode xcode-select', 'xcode-select') checkbin('Git git', 'git') + checkbin('Cython', 'cython') self.buildozer.debug('Check availability of a iPhone SDK') sdk = cmd('xcodebuild -showsdks | fgrep "iphoneos" |' From d797d3df782bbdd95bdfff3e1c6a717e9544b5fa Mon Sep 17 00:00:00 2001 From: Mathieu Virbel Date: Tue, 26 Feb 2013 23:44:32 +0100 Subject: [PATCH 4/9] remove bad readme --- README.md | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 README.md diff --git a/README.md b/README.md deleted file mode 100644 index 6020adc..0000000 --- a/README.md +++ /dev/null @@ -1,4 +0,0 @@ -buildozer -========= - -Generic Python packager for Android / iOS and Desktop \ No newline at end of file From 48f44e6e23037db0e70468c64bf7f1711efb4a89 Mon Sep 17 00:00:00 2001 From: Mathieu Virbel Date: Tue, 12 Mar 2013 15:33:19 +0100 Subject: [PATCH 5/9] ios: use the package.name instead of the title for creating the app- directory --- buildozer/targets/ios.py | 74 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 72 insertions(+), 2 deletions(-) diff --git a/buildozer/targets/ios.py b/buildozer/targets/ios.py index 596b896..af3f252 100644 --- a/buildozer/targets/ios.py +++ b/buildozer/targets/ios.py @@ -8,6 +8,52 @@ from buildozer.target import Target from os.path import join, basename from getpass import getpass +PHP_TEMPLATE = ''' + + + +Install {appname} + + + + + + + +''' + class TargetIos(Target): def check_requirements(self): @@ -18,6 +64,12 @@ class TargetIos(Target): checkbin('Xcode xcode-select', 'xcode-select') checkbin('Git git', 'git') checkbin('Cython', 'cython') + checkbin('Mercurial', 'hg') + checkbin('Cython cython', 'cython') + checkbin('pkg-config', 'pkg-config') + checkbin('autoconf', 'autoconf') + checkbin('automake', 'automake') + checkbin('libtool', 'libtool') self.buildozer.debug('Check availability of a iPhone SDK') sdk = cmd('xcodebuild -showsdks | fgrep "iphoneos" |' @@ -73,7 +125,8 @@ class TargetIos(Target): self._unlock_keychain() # create the project - app_name = self.buildozer.namify(self.buildozer.config.get('app', 'title')) + app_name = self.buildozer.namify(self.buildozer.config.get('app', + 'package.name')) self.app_project_dir = join(self.ios_dir, 'app-{0}'.format(app_name.lower())) if not self.buildozer.file_exists(self.app_project_dir): @@ -107,7 +160,7 @@ class TargetIos(Target): plistlib.writePlist(plist, plist_rfn) mode = 'Debug' if self.build_mode == 'debug' else 'Release' - self.buildozer.cmd('xcodebuild -configuration {}'.format(mode), + self.buildozer.cmd('xcodebuild -configuration {} clean build'.format(mode), cwd=self.app_project_dir) ios_app_dir = 'app-{app_lower}/build/{mode}-iphoneos/{app_lower}.app'.format( app_lower=app_name.lower(), mode=mode) @@ -139,6 +192,8 @@ class TargetIos(Target): self.buildozer.state['ios:latestipa'] = ipa self.buildozer.state['ios:latestmode'] = self.build_mode + self._create_index() + def cmd_deploy(self, *args): super(TargetIos, self).cmd_deploy(*args) self._run_fruitstrap(gdb=False) @@ -147,6 +202,17 @@ class TargetIos(Target): super(TargetIos, self).cmd_run(*args) self._run_fruitstrap(gdb=True) + def cmd_xcode(self, *args): + '''Open the xcode project. + ''' + app_name = self.buildozer.namify(self.buildozer.config.get('app', + 'package.name')) + app_name = app_name.lower() + + ios_dir = ios_dir = join(self.buildozer.platform_dir, 'kivy-ios') + self.buildozer.cmd('open {}.xcodeproj'.format( + app_name), cwd=join(ios_dir, 'app-{}'.format(app_name))) + def _run_fruitstrap(self, gdb=False): state = self.buildozer.state if 'ios:latestappdir' not in state: @@ -211,6 +277,10 @@ class TargetIos(Target): icon_fn = join(self.app_project_dir, icon_basename) return icon_fn + def _create_index(self): + # TODO + pass + def check_configuration_tokens(self): errors = [] config = self.buildozer.config From ac4b8ab1e8c1338aac793c894def92442c4bd3ed Mon Sep 17 00:00:00 2001 From: Mathieu Virbel Date: Fri, 15 Mar 2013 18:31:39 -0700 Subject: [PATCH 6/9] Update README.rst --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 59f530e..8f9f072 100644 --- a/README.rst +++ b/README.rst @@ -1,7 +1,7 @@ Buildozer ========= -THIS IS A WORK IN PROGRESS, DO NOT USE. +This tool is currently in alpha. Buildozer is a tool for creating application packages easily. From 2a8dd715efab1128931c26e8f8bfca1351d1e4fe Mon Sep 17 00:00:00 2001 From: tshirtman Date: Sat, 27 Apr 2013 00:34:21 +0200 Subject: [PATCH 7/9] Fixes for the android.branch feature Use getdefault instead of get (duh) Add commented option to default.spec for documentation fix: #12 --- buildozer/default.spec | 3 +++ buildozer/targets/android.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/buildozer/default.spec b/buildozer/default.spec index 5579922..f9d867d 100644 --- a/buildozer/default.spec +++ b/buildozer/default.spec @@ -62,6 +62,9 @@ requirements = twisted,kivy # (str) Android entry point, default is ok for Kivy-based app #android.entrypoint = org.renpy.android.PythonActivity +# (str) python-for-android branch to use, if not master, useful to try +# not yet merged features. +#android.branch = master # # iOS specific diff --git a/buildozer/targets/android.py b/buildozer/targets/android.py index b8b309b..672d472 100644 --- a/buildozer/targets/android.py +++ b/buildozer/targets/android.py @@ -277,7 +277,7 @@ class TargetAndroid(Target): cmd('git clean -dxf', cwd=pa_dir) cmd('git pull origin master', cwd=pa_dir) - source = self.buildozer.config.get('app', 'android.branch') + source = self.buildozer.config.getdefault('app', 'android.branch') if source: cmd('git checkout --track -b %s origin/%s' % (source, source), cwd=pa_dir) From 5474accca1c4ee2581bde5a54876a09b92591316 Mon Sep 17 00:00:00 2001 From: Mathieu Virbel Date: Sat, 4 May 2013 19:32:11 +0200 Subject: [PATCH 8/9] android: if multiples devices are plugged, deploy and run on all of them. except if a ANDROID_SERIAL env is set. --- buildozer/targets/android.py | 46 +++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/buildozer/targets/android.py b/buildozer/targets/android.py index 672d472..9ea39a4 100644 --- a/buildozer/targets/android.py +++ b/buildozer/targets/android.py @@ -19,6 +19,7 @@ import traceback from pipes import quote from sys import platform, executable from buildozer.target import Target +from os import environ from os.path import join, realpath, expanduser from shutil import copyfile @@ -410,6 +411,21 @@ class TargetAndroid(Target): self.buildozer.state['android:latestapk'] = apk self.buildozer.state['android:latestmode'] = self.build_mode + @property + def serials(self): + if hasattr(self, '_serials'): + return self._serials + serial = environ.get('ANDROID_SERIAL') + if serial: + return [serial] + l = self.buildozer.cmd('adb devices', + get_stdout=True)[0].splitlines()[1:-1] + serials = [] + for serial in l: + serials.append(serial.split()[0]) + self._serials = serials + return serials + def cmd_deploy(self, *args): super(TargetAndroid, self).cmd_deploy(*args) state = self.buildozer.state @@ -429,10 +445,14 @@ class TargetAndroid(Target): 'Unable to found the latest APK. Please run "debug" again.') # push on the device - self.buildozer.cmd('{0} install -r {1}'.format( - self.adb_cmd, full_apk), cwd=self.buildozer.global_platform_dir) + for serial in self.serials: + self.buildozer.environ['ANDROID_SERIAL'] = serial + self.buildozer.info('Deploy on {}'.format(serial)) + self.buildozer.cmd('{0} install -r {1}'.format( + self.adb_cmd, full_apk), cwd=self.buildozer.global_platform_dir) + self.buildozer.environ.pop('ANDROID_SERIAL', None) - self.buildozer.info('Application pushed on the device.') + self.buildozer.info('Application pushed.') def cmd_run(self, *args): super(TargetAndroid, self).cmd_run(*args) @@ -441,20 +461,30 @@ class TargetAndroid(Target): 'app', 'android.entrypoint', 'org.renpy.android.PythonActivity') package = self._get_package() - self.buildozer.cmd( - '{adb} shell am start -n {package}/{entry} -a {entry}'.format( - adb=self.adb_cmd, package=package, entry=entrypoint), - cwd=self.buildozer.global_platform_dir) + # push on the device + for serial in self.serials: + self.buildozer.environ['ANDROID_SERIAL'] = serial + self.buildozer.info('Run on {}'.format(serial)) + self.buildozer.cmd( + '{adb} shell am start -n {package}/{entry} -a {entry}'.format( + adb=self.adb_cmd, package=package, entry=entrypoint), + cwd=self.buildozer.global_platform_dir) + self.buildozer.environ.pop('ANDROID_SERIAL', None) - self.buildozer.info('Application started on the device.') + self.buildozer.info('Application started.') def cmd_logcat(self, *args): '''Show the log from the device ''' self.check_requirements() + serial = self.serials[0:] + if not serial: + return + self.buildozer.environ['ANDROID_SERIAL'] = serial[0] self.buildozer.cmd('{adb} logcat'.format(adb=self.adb_cmd), cwd=self.buildozer.global_platform_dir, show_output=True) + self.buildozer.environ.pop('ANDROID_SERIAL', None) From 6639efa8b08975005a391b61f5bf59b3f0ca13a6 Mon Sep 17 00:00:00 2001 From: Mathieu Virbel Date: Sun, 5 May 2013 18:30:47 +0200 Subject: [PATCH 9/9] add support for orientation and fullscreen (working on android only right now.) --- buildozer/__init__.py | 13 +++++++++++++ buildozer/default.spec | 9 ++++++++- buildozer/targets/android.py | 11 +++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/buildozer/__init__.py b/buildozer/__init__.py index 454ae61..9814e3a 100644 --- a/buildozer/__init__.py +++ b/buildozer/__init__.py @@ -66,6 +66,7 @@ class Buildozer(object): self.config = SafeConfigParser() self.config.getlist = self._get_config_list self.config.getdefault = self._get_config_default + self.config.getbooldefault = self._get_config_bool if exists(filename): self.config.read(filename) @@ -289,6 +290,10 @@ class Buildozer(object): adderror('[app] "version.filename" is missing' ', required by "version.regex"') + orientation = get('app', 'orientation', 'landscape') + if orientation not in ('landscape', 'portrait', 'all'): + adderror('[app] "orientation" have an invalid value') + if errors: self.error('{0} error(s) found in the buildozer.spec'.format( len(errors))) @@ -781,6 +786,14 @@ class Buildozer(object): return default return self.config.get(section, token) + def _get_config_bool(self, section, token, default=False): + # monkey-patch method for ConfigParser + # get a key in a section, or the default + if not self.config.has_section(section): + return default + if not self.config.has_option(section, token): + return default + return self.config.getboolean(section, token) class BuildozerRemote(Buildozer): def run_command(self, args): diff --git a/buildozer/default.spec b/buildozer/default.spec index f9d867d..b4353a4 100644 --- a/buildozer/default.spec +++ b/buildozer/default.spec @@ -26,7 +26,7 @@ version.filename = %(source.dir)s/main.py # version = 1.2.0 # (list) Application requirements -requirements = twisted,kivy +requirements = kivy # (str) Presplash of the application #presplash.filename = %(source.dir)s/data/presplash.png @@ -34,6 +34,13 @@ requirements = twisted,kivy # (str) Icon of the application #icon.filename = %(source.dir)s/data/icon.png +# (str) Supported orientation (one of landscape, portrait or all) +orientation = landscape + +# (bool) Indicate if the application should be fullscreen or not +fullscreen = 1 + + # # Android specific # diff --git a/buildozer/targets/android.py b/buildozer/targets/android.py index 9ea39a4..b132804 100644 --- a/buildozer/targets/android.py +++ b/buildozer/targets/android.py @@ -386,6 +386,17 @@ class TargetAndroid(Target): if icon: build_cmd += ' --icon {}'.format(join(self.buildozer.root_dir, icon)) + # add orientation + orientation = config.getdefault('app', 'orientation', 'landscape') + if orientation == 'all': + orientation = 'sensor' + build_cmd += ' --orientation {}'.format(orientation) + + # fullscreen ? + fullscreen = config.getbooldefault('app', 'fullscreen', True) + if not fullscreen: + build_cmd += ' --window' + # build only in debug right now. if self.build_mode == 'debug': build_cmd += ' debug'