From a09beb0542ea7b93ad1df6c2fd7bf5bb085a7db2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rcio=20Moreira?= Date: Mon, 25 May 2020 15:37:50 -0300 Subject: [PATCH 01/17] Update instalation.rst for Windows 10 --- docs/source/installation.rst | 41 ++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/docs/source/installation.rst b/docs/source/installation.rst index f93e143..a1845ab 100644 --- a/docs/source/installation.rst +++ b/docs/source/installation.rst @@ -27,6 +27,47 @@ Android on Ubuntu 18.04 (64bit) # add the following line at the end of your ~/.bashrc file export PATH=$PATH:~/.local/bin/ +Android on Windows 10 +~~~~~~~~~~~~~~~~~~~~~ + +To use buildozer in Windows 10 you need first to enable Windows Subsystem for Linux (WSL) and install a Linux distribution: https://docs.microsoft.com/en-us/windows/wsl/install-win10. + +These instructions were tested with WSL 1 and Ubuntu 18.04 LTS. + +With WSL and Ubuntu installed on your Windows 10 machine, open Ubuntu and run these commands: + +:: + + sudo apt update + sudo apt install -y git zip unzip openjdk-8-jdk python3-pip autoconf libtool pkg-config zlib1g-dev libncurses5-dev libncursesw5-dev libtinfo5 cmake libffi-dev libssl-dev + # Use here the python version you need + sudo apt install -y python3.7-venv + # Create a folder for buildozer + mkdir /mnt/c/buildozer + cd /mnt/c/buildozer + python3.7 -m venv venv-buildozer + source venv/bin/activate + python -m pip install --upgrade pip + python -m pip install --upgrade wheel + python -m pip install --upgrade cython + python -m pip install --upgrade virtualenv + python -m pip install --upgrade buildozer + # Add the following line at the end of your ~/.bashrc file + export PATH=$PATH:~/.local/bin/ + # Restart your WSL terminal to enable the path change + +Now you need to install the Windows version of ADB (Android Debug Bridge): + +- Go to https://developer.android.com/studio/releases/platform-tools and click on "Download SDK Platform-Tools for Windows". + +- Unzip the downloaded file to a new folder. For example, "C:\\platform-tools". + +Before Using Buildozer +---------------------- + +If you wish, clone your code to a new folder, where the build process will run. You don't need to create a virtualenv for your code requirements. But just add these requirements to a configuration file called buildozer.spec as you will see in the following sections. + +Before running buildozer in your code folder, remember to go into the buildozer folder and activate the buildozer virtualenv. TroubleShooting ~~~~~~~~~~~~~~~ From ff55af5a05d5495d1671b8cb260c775d82daacf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rcio=20Moreira?= Date: Fri, 5 Jun 2020 21:32:33 -0300 Subject: [PATCH 02/17] Updated installation.rst avoiding duplication Updated Windows 10 installation instructions avoiding duplication --- docs/source/installation.rst | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/docs/source/installation.rst b/docs/source/installation.rst index a1845ab..7fdf780 100644 --- a/docs/source/installation.rst +++ b/docs/source/installation.rst @@ -1,3 +1,4 @@ + Installation ============ @@ -34,15 +35,16 @@ To use buildozer in Windows 10 you need first to enable Windows Subsystem for Li These instructions were tested with WSL 1 and Ubuntu 18.04 LTS. -With WSL and Ubuntu installed on your Windows 10 machine, open Ubuntu and run these commands: +After installing WSL and Ubuntu in your Windows 10 machine, open Ubuntu and do this: + +1) Run the commands listed on the previous section (Android in Ubuntu 18.04 (64-bit). +2) Run the following commands: :: - sudo apt update - sudo apt install -y git zip unzip openjdk-8-jdk python3-pip autoconf libtool pkg-config zlib1g-dev libncurses5-dev libncursesw5-dev libtinfo5 cmake libffi-dev libssl-dev # Use here the python version you need sudo apt install -y python3.7-venv - # Create a folder for buildozer + # Create a folder for buildozer. For example: C:\buildozer mkdir /mnt/c/buildozer cd /mnt/c/buildozer python3.7 -m venv venv-buildozer @@ -52,20 +54,20 @@ With WSL and Ubuntu installed on your Windows 10 machine, open Ubuntu and run th python -m pip install --upgrade cython python -m pip install --upgrade virtualenv python -m pip install --upgrade buildozer - # Add the following line at the end of your ~/.bashrc file - export PATH=$PATH:~/.local/bin/ # Restart your WSL terminal to enable the path change -Now you need to install the Windows version of ADB (Android Debug Bridge): +Windows Subsystem for Linux does not have direct access to USB. Due to this, you need to install the Windows version of ADB (Android Debug Bridge): - Go to https://developer.android.com/studio/releases/platform-tools and click on "Download SDK Platform-Tools for Windows". - Unzip the downloaded file to a new folder. For example, "C:\\platform-tools". Before Using Buildozer ----------------------- +~~~~~~~~~~~~~~~~~~~~~~ -If you wish, clone your code to a new folder, where the build process will run. You don't need to create a virtualenv for your code requirements. But just add these requirements to a configuration file called buildozer.spec as you will see in the following sections. +If you wish, clone your code to a new folder, where the build process will run. + +You don't need to create a virtualenv for your code requirements. But just add these requirements to a configuration file called buildozer.spec as you will see in the following sections. Before running buildozer in your code folder, remember to go into the buildozer folder and activate the buildozer virtualenv. From bc5b92e11faba584c9c25b3fe8c907483ddc2184 Mon Sep 17 00:00:00 2001 From: 0xloem <0xloem@gmail.com> Date: Mon, 14 Dec 2020 09:00:06 -0500 Subject: [PATCH 03/17] Pass debug loglevel down through to python for android --- buildozer/targets/android.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/buildozer/targets/android.py b/buildozer/targets/android.py index d16098b..9336522 100644 --- a/buildozer/targets/android.py +++ b/buildozer/targets/android.py @@ -98,6 +98,9 @@ class TargetAndroid(Target): else: self.extra_p4a_args += ' --ignore-setup-py' + if self.buildozer.log_level >= 2: + self.extra_p4a_args += ' --debug' + self.warn_on_deprecated_tokens() def warn_on_deprecated_tokens(self): From cd380cc87b54e309612c00938d8dfd5e28787341 Mon Sep 17 00:00:00 2001 From: 0xloem <0xloem@gmail.com> Date: Wed, 23 Dec 2020 20:09:10 -0500 Subject: [PATCH 04/17] Add option to specify specific p4a commit to build with --- buildozer/default.spec | 3 +++ buildozer/targets/android.py | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/buildozer/default.spec b/buildozer/default.spec index 988fbe8..b7ab9b6 100644 --- a/buildozer/default.spec +++ b/buildozer/default.spec @@ -245,6 +245,9 @@ android.allow_backup = True # (str) python-for-android branch to use, defaults to master #p4a.branch = master +# (str) python-for-android specific commit to use, defaults to HEAD, must be within p4a.branch +#p4a.commit = HEAD + # (str) python-for-android git clone directory (if empty, it will be automatically cloned from github) #p4a.source_dir = diff --git a/buildozer/targets/android.py b/buildozer/targets/android.py index d16098b..1c51ed4 100644 --- a/buildozer/targets/android.py +++ b/buildozer/targets/android.py @@ -60,6 +60,7 @@ class TargetAndroid(Target): p4a_directory_name = "python-for-android" p4a_fork = 'kivy' p4a_branch = 'master' + p4a_commit = 'HEAD' p4a_apk_cmd = "apk --debug --bootstrap=" p4a_recommended_ndk_version = None extra_p4a_args = '' @@ -691,6 +692,9 @@ class TargetAndroid(Target): p4a_branch = self.buildozer.config.getdefault( 'app', 'p4a.branch', self.p4a_branch ) + p4a_commit = self.buildozer.config.getdefault( + 'app', 'p4a.commit', self.p4a_commit + ) p4a_dir = self.p4a_dir system_p4a_dir = self.buildozer.config.getdefault('app', @@ -744,6 +748,8 @@ class TargetAndroid(Target): cmd('git fetch --tags origin {0}:{0}'.format(p4a_branch), cwd=p4a_dir) cmd('git checkout {}'.format(p4a_branch), cwd=p4a_dir) + if p4a_commit != 'HEAD': + cmd('git reset --hard {}'.format(p4a_commit), cwd=p4a_dir) # also install dependencies (currently, only setup.py knows about it) # let's extract them. From 7ebc048c9772a6e0f4b29b3e6c5feb26883337cf Mon Sep 17 00:00:00 2001 From: Andre Miras Date: Fri, 19 Feb 2021 01:04:38 +0100 Subject: [PATCH 05/17] :recycle: Minor check_requirements() refactoring (#1274) --- buildozer/targets/android.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/buildozer/targets/android.py b/buildozer/targets/android.py index a68aa0c..12bd0a0 100644 --- a/buildozer/targets/android.py +++ b/buildozer/targets/android.py @@ -243,10 +243,7 @@ class TargetAndroid(Target): 'adb.exe') self.javac_cmd = self._locate_java('javac.exe') self.keytool_cmd = self._locate_java('keytool.exe') - elif platform in ('darwin', ): - self.adb_cmd = join(self.android_sdk_dir, 'platform-tools', 'adb') - self.javac_cmd = self._locate_java('javac') - self.keytool_cmd = self._locate_java('keytool') + # darwin, linux else: self.adb_cmd = join(self.android_sdk_dir, 'platform-tools', 'adb') self.javac_cmd = self._locate_java('javac') From b24b77b36eaadcc372d3549f64005088a8274785 Mon Sep 17 00:00:00 2001 From: Gabriel Pettier Date: Sun, 21 Feb 2021 16:40:00 +0100 Subject: [PATCH 06/17] Allow displaying only the logcat of our app. (#1272) Todo [ ] test with a service [ ] consider making default [ ] test for robustness To discuss [ ] should it exit automatically like it does currently? what if user reruns manually? [ ] consider the cost of additional complexity vs usage simplification for users --- buildozer/__init__.py | 33 +++++++++++++++++++---------- buildozer/default.spec | 3 +++ buildozer/targets/android.py | 40 ++++++++++++++++++++++++++++++++---- 3 files changed, 61 insertions(+), 15 deletions(-) diff --git a/buildozer/__init__.py b/buildozer/__init__.py index 5184a80..070b010 100644 --- a/buildozer/__init__.py +++ b/buildozer/__init__.py @@ -19,7 +19,7 @@ from buildozer.jsonstore import JsonStore from sys import stdout, stderr, exit from re import search from os.path import join, exists, dirname, realpath, splitext, expanduser -from subprocess import Popen, PIPE +from subprocess import Popen, PIPE, TimeoutExpired from os import environ, unlink, walk, sep, listdir, makedirs from copy import copy from shutil import copyfile, rmtree, copytree, move @@ -269,15 +269,18 @@ class Buildozer: get_stderr = kwargs.pop('get_stderr', False) break_on_error = kwargs.pop('break_on_error', True) sensible = kwargs.pop('sensible', False) + run_condition = kwargs.pop('run_condition', None) + quiet = kwargs.pop('quiet', False) - if not sensible: - self.debug('Run {0!r}'.format(command)) - else: - if type(command) in (list, tuple): - self.debug('Run {0!r} ...'.format(command[0])) + if not quiet: + if not sensible: + self.debug('Run {0!r}'.format(command)) else: - self.debug('Run {0!r} ...'.format(command.split()[0])) - self.debug('Cwd {}'.format(kwargs.get('cwd'))) + if isinstance(command, (list, tuple)): + self.debug('Run {0!r} ...'.format(command[0])) + else: + self.debug('Run {0!r} ...'.format(command.split()[0])) + self.debug('Cwd {}'.format(kwargs.get('cwd'))) # open the process if sys.platform == 'win32': @@ -297,9 +300,9 @@ class Buildozer: ret_stdout = [] if get_stdout else None ret_stderr = [] if get_stderr else None - while True: + while not run_condition or run_condition(): try: - readx = select.select([fd_stdout, fd_stderr], [], [])[0] + readx = select.select([fd_stdout, fd_stderr], [], [], 1)[0] except select.error: break if fd_stdout in readx: @@ -322,7 +325,13 @@ class Buildozer: stdout.flush() stderr.flush() - process.communicate() + try: + process.communicate( + timeout=(1 if run_condition and not run_condition() else None) + ) + except TimeoutExpired: + pass + if process.returncode != 0 and break_on_error: self.error('Command failed: {0}'.format(command)) self.log_env(self.ERROR, kwargs['env']) @@ -337,10 +346,12 @@ class Buildozer: self.error('raising an issue with buildozer itself.') self.error('In case of a bug report, please add a full log with log_level = 2') raise BuildozerCommandException() + if ret_stdout: ret_stdout = b''.join(ret_stdout) if ret_stderr: ret_stderr = b''.join(ret_stderr) + return (ret_stdout.decode('utf-8', 'ignore') if ret_stdout else None, ret_stderr.decode('utf-8') if ret_stderr else None, process.returncode) diff --git a/buildozer/default.spec b/buildozer/default.spec index 0571c44..2279dc0 100644 --- a/buildozer/default.spec +++ b/buildozer/default.spec @@ -219,6 +219,9 @@ fullscreen = 0 # (str) Android logcat filters to use #android.logcat_filters = *:S python:D +# (bool) Android logcat only display log for activity's pid +#android.logcat_pid_only = False + # (str) Android additional adb arguments #android.adb_args = -H host.docker.internal diff --git a/buildozer/targets/android.py b/buildozer/targets/android.py index 12bd0a0..fbe4ec0 100644 --- a/buildozer/targets/android.py +++ b/buildozer/targets/android.py @@ -33,6 +33,7 @@ from os.path import exists, join, realpath, expanduser, basename, relpath from platform import architecture from shutil import copyfile, rmtree from glob import glob +from time import sleep from buildozer.libs.version import parse from distutils.version import LooseVersion @@ -955,6 +956,12 @@ class TargetAndroid(Target): cwd=self.buildozer.global_platform_dir) self.buildozer.environ.pop('ANDROID_SERIAL', None) + while True: + if self._get_pid(): + break + sleep(.1) + self.buildozer.info('Waiting for application to start.') + self.buildozer.info('Application started.') def cmd_p4a(self, *args): @@ -1383,6 +1390,18 @@ class TargetAndroid(Target): self.buildozer.info('Application pushed.') + def _get_pid(self): + pid, *_ = self.buildozer.cmd( + f'{self.adb_cmd} shell pidof {self._get_package()}', + get_stdout=True, + show_output=False, + break_on_error=False, + quiet=True, + ) + if pid: + return pid.strip() + return False + def cmd_logcat(self, *args): '''Show the log from the device ''' @@ -1394,10 +1413,23 @@ class TargetAndroid(Target): "app", "android.logcat_filters", "", section_sep=":", split_char=" ") filters = " ".join(filters) self.buildozer.environ['ANDROID_SERIAL'] = serial[0] - self.buildozer.cmd('{adb} logcat {filters}'.format(adb=self.adb_cmd, - filters=filters), - cwd=self.buildozer.global_platform_dir, - show_output=True) + extra_args = [] + pid = None + if self.buildozer.config.getdefault('app', 'android.logcat_pid_only'): + pid = self._get_pid() + if pid: + extra_args.extend(('--pid', pid)) + + self.buildozer.cmd( + f"{self.adb_cmd} logcat {filters} {' '.join(extra_args)}", + cwd=self.buildozer.global_platform_dir, + show_output=True, + run_condition=self._get_pid if pid else None, + break_on_error=False, + ) + + self.buildozer.info(f"{self._get_package()} terminated") + self.buildozer.environ.pop('ANDROID_SERIAL', None) From d2944ad54c40cb236616bf46dd22e1066c8900a4 Mon Sep 17 00:00:00 2001 From: Ankit Dobhal Date: Thu, 4 Mar 2021 09:34:12 -0500 Subject: [PATCH 07/17] Fixed code quality issues using deepsource (#1300) - Added .deepsource.toml to fix bug risks - Remove unnecessary use of comprehension - Use `os.environ.copy()` to copy the environment variables - Remove unnecessary return statement - Use `sys.exit()` calls --- .deepsource.toml | 25 +++++++++++++++++++++++++ buildozer/__init__.py | 7 +++---- buildozer/targets/android.py | 4 ++-- buildozer/targets/osx.py | 12 +++++------- 4 files changed, 35 insertions(+), 13 deletions(-) create mode 100644 .deepsource.toml diff --git a/.deepsource.toml b/.deepsource.toml new file mode 100644 index 0000000..29a28f5 --- /dev/null +++ b/.deepsource.toml @@ -0,0 +1,25 @@ +version = 1 + +test_patterns = ["tests/**"] + +[[analyzers]] +name = "python" +enabled = true + + [analyzers.meta] + runtime_version = "3.x.x" + + +[[analyzers]] +name = "docker" +enabled = true + + [analyzers.meta] + dockerfile_paths = [ + "dockerfile_dev", + "dockerfile_prod" + ] + +[[analyzers]] +name = "ruby" +enabled = true diff --git a/buildozer/__init__.py b/buildozer/__init__.py index 070b010..84c1ec7 100644 --- a/buildozer/__init__.py +++ b/buildozer/__init__.py @@ -253,7 +253,7 @@ class Buildozer: def cmd(self, command, **kwargs): # prepare the environ, based on the system + our own env - env = copy(environ) + env = environ.copy() env.update(self.environ) # prepare the process @@ -360,7 +360,7 @@ class Buildozer: from pexpect import spawnu # prepare the environ, based on the system + our own env - env = copy(environ) + env = environ.copy() env.update(self.environ) # prepare the process @@ -935,8 +935,7 @@ class Buildozer: if not meth.__doc__: continue - doc = [x for x in - meth.__doc__.strip().splitlines()][0].strip() + doc = list(meth.__doc__.strip().splitlines())[0].strip() print(' {0:<18} {1}'.format(name, doc)) print('') diff --git a/buildozer/targets/android.py b/buildozer/targets/android.py index fbe4ec0..80d665c 100644 --- a/buildozer/targets/android.py +++ b/buildozer/targets/android.py @@ -759,7 +759,7 @@ class TargetAndroid(Target): except IOError: self.buildozer.error('Failed to read python-for-android setup.py at {}'.format( join(self.p4a_dir, 'setup.py'))) - exit(1) + sys.exit(1) pip_deps = [] for dep in deps: pip_deps.append("'{}'".format(dep)) @@ -1287,7 +1287,7 @@ class TargetAndroid(Target): self.buildozer.error( 'Invalid library reference (path not found): {}'.format( cref)) - exit(1) + sys.exit(1) # get a relative path from the project file ref = relpath(ref, realpath(expanduser(dist_dir))) # ensure the reference exists diff --git a/buildozer/targets/osx.py b/buildozer/targets/osx.py index c6313ba..fa4444a 100644 --- a/buildozer/targets/osx.py +++ b/buildozer/targets/osx.py @@ -55,7 +55,7 @@ class TargetOSX(Target): "Unable to download the Kivy App. Check osx.kivy_version in your buildozer.spec, and verify " "Kivy servers are accessible. http://kivy.org/downloads/") check_call(("rm", "Kivy{}.dmg".format(py_branch)), cwd=cwd) - exit(1) + sys.exit(1) self.buildozer.info('Extracting and installing Kivy...') check_call(('hdiutil', 'attach', cwd + '/Kivy{}.dmg'.format(py_branch))) @@ -76,8 +76,6 @@ class TargetOSX(Target): else: self.download_kivy(kivy_app_dir, py_branch) - return - def check_requirements(self): self.ensure_sdk() self.ensure_kivyapp() @@ -90,7 +88,7 @@ class TargetOSX(Target): len(errors))) for error in errors: print(error) - exit(1) + sys.exit(1) # check def build_package(self): @@ -177,7 +175,7 @@ class TargetOSX(Target): if not args: self.buildozer.error('Missing target command') self.buildozer.usage() - exit(1) + sys.exit(1) result = [] last_command = [] @@ -191,7 +189,7 @@ class TargetOSX(Target): if not last_command: self.buildozer.error('Argument passed without a command') self.buildozer.usage() - exit(1) + sys.exit(1) last_command.append(arg) if last_command: result.append(last_command) @@ -202,7 +200,7 @@ class TargetOSX(Target): command, args = item[0], item[1:] if not hasattr(self, 'cmd_{0}'.format(command)): self.buildozer.error('Unknown command {0}'.format(command)) - exit(1) + sys.exit(1) func = getattr(self, 'cmd_{0}'.format(command)) From 1a3fb61b37e37d3e43e6fd6a5e1fdb9b266fd23c Mon Sep 17 00:00:00 2001 From: Kostiantyn Syrykh Date: Sun, 14 Mar 2021 11:47:27 +0200 Subject: [PATCH 08/17] Allow setting custom p4a URL instead of fork (#1305) * Allow setting custom p4a URL instead of fork * Apply suggestions from code review Co-authored-by: Pol Canelles * Add tests for p4a clone URL Co-authored-by: Pol Canelles --- buildozer/default.spec | 5 ++++- buildozer/targets/android.py | 20 ++++++++--------- tests/targets/test_android.py | 42 +++++++++++++++++++++++++++++++++++ tests/targets/utils.py | 2 +- 4 files changed, 57 insertions(+), 12 deletions(-) diff --git a/buildozer/default.spec b/buildozer/default.spec index 2279dc0..c807de4 100644 --- a/buildozer/default.spec +++ b/buildozer/default.spec @@ -251,7 +251,10 @@ android.allow_backup = True # Python for android (p4a) specific # -# (str) python-for-android fork to use, defaults to upstream (kivy) +# (str) python-for-android URL to use for checkout +#p4a.url = + +# (str) python-for-android fork to use in case if p4a.url is not specified, defaults to upstream (kivy) #p4a.fork = kivy # (str) python-for-android branch to use, defaults to master diff --git a/buildozer/targets/android.py b/buildozer/targets/android.py index 80d665c..d53c954 100644 --- a/buildozer/targets/android.py +++ b/buildozer/targets/android.py @@ -692,6 +692,9 @@ class TargetAndroid(Target): p4a_fork = self.buildozer.config.getdefault( 'app', 'p4a.fork', self.p4a_fork ) + p4a_url = self.buildozer.config.getdefault( + 'app', 'p4a.url', f'https://github.com/{p4a_fork}/python-for-android.git' + ) p4a_branch = self.buildozer.config.getdefault( 'app', 'p4a.branch', self.p4a_branch ) @@ -707,21 +710,19 @@ class TargetAndroid(Target): self.buildozer.error('') raise BuildozerException() else: - # check that fork/branch has not been changed + # check that url/branch has not been changed if self.buildozer.file_exists(p4a_dir): - cur_fork = cmd( + cur_url = cmd( 'git config --get remote.origin.url', get_stdout=True, cwd=p4a_dir, - )[0].split('/')[3] + )[0].strip() cur_branch = cmd( 'git branch -vv', get_stdout=True, cwd=p4a_dir )[0].split()[1] - if any([cur_fork != p4a_fork, cur_branch != p4a_branch]): + if any([cur_url != p4a_url, cur_branch != p4a_branch]): self.buildozer.info( - "Detected old fork/branch ({}/{}), deleting...".format( - cur_fork, cur_branch - ) + f"Detected old url/branch ({cur_url}/{cur_branch}), deleting..." ) rmtree(p4a_dir) @@ -729,11 +730,10 @@ class TargetAndroid(Target): cmd( ( 'git clone -b {p4a_branch} --single-branch ' - 'https://github.com/{p4a_fork}/python-for-android.git ' - '{p4a_dir}' + '{p4a_url} {p4a_dir}' ).format( p4a_branch=p4a_branch, - p4a_fork=p4a_fork, + p4a_url=p4a_url, p4a_dir=self.p4a_directory_name, ), cwd=self.buildozer.platform_dir, diff --git a/tests/targets/test_android.py b/tests/targets/test_android.py index 170840e..94ee1e0 100644 --- a/tests/targets/test_android.py +++ b/tests/targets/test_android.py @@ -1,5 +1,6 @@ import os import tempfile +from six import StringIO from unittest import mock import pytest @@ -350,3 +351,44 @@ class TestTargetAndroid: ] ) ] + + def test_install_platform_p4a_clone_url(self): + """The `p4a.url` config should be used for cloning p4a before the `p4a.fork` option.""" + target_android = init_target(self.temp_dir, { + 'p4a.url': 'https://custom-p4a-url/p4a.git', + 'p4a.fork': 'myfork', + }) + + with patch_buildozer_cmd() as m_cmd, mock.patch('buildozer.targets.android.open') as m_open: + m_open.return_value = StringIO('install_reqs = []') # to stub setup.py parsing + target_android._install_p4a() + + assert mock.call( + 'git clone -b master --single-branch https://custom-p4a-url/p4a.git python-for-android', + cwd=mock.ANY) in m_cmd.call_args_list + + def test_install_platform_p4a_clone_fork(self): + """The `p4a.fork` config should be used for cloning p4a.""" + target_android = init_target(self.temp_dir, { + 'p4a.fork': 'fork' + }) + + with patch_buildozer_cmd() as m_cmd, mock.patch('buildozer.targets.android.open') as m_open: + m_open.return_value = StringIO('install_reqs = []') # to stub setup.py parsing + target_android._install_p4a() + + assert mock.call( + 'git clone -b master --single-branch https://github.com/fork/python-for-android.git python-for-android', + cwd=mock.ANY) in m_cmd.call_args_list + + def test_install_platform_p4a_clone_default(self): + """The default URL should be used for cloning p4a if no config options `p4a.url` and `p4a.fork` are set.""" + target_android = init_target(self.temp_dir) + + with patch_buildozer_cmd() as m_cmd, mock.patch('buildozer.targets.android.open') as m_open: + m_open.return_value = StringIO('install_reqs = []') # to stub setup.py parsing + target_android._install_p4a() + + assert mock.call( + 'git clone -b master --single-branch https://github.com/kivy/python-for-android.git python-for-android', + cwd=mock.ANY) in m_cmd.call_args_list diff --git a/tests/targets/utils.py b/tests/targets/utils.py index 062820c..0c78712 100644 --- a/tests/targets/utils.py +++ b/tests/targets/utils.py @@ -53,7 +53,7 @@ def init_buildozer(temp_dir, target, options=None): spec = [] for line in default_spec: if line.strip(): - match = re.search(r"[#\s]?([a-z_\.]+)", line) + match = re.search(r"[#\s]?([0-9a-z_.]+)", line) key = match and match.group(1) if key in options: line = "{} = {}\n".format(key, options[key]) From e587305308c044b1ab610d50aefa312372dfa6a1 Mon Sep 17 00:00:00 2001 From: Kostiantyn Syrykh Date: Wed, 17 Mar 2021 17:20:49 +0200 Subject: [PATCH 09/17] Update iOS codesign options --- buildozer/default.spec | 6 +++++ buildozer/targets/ios.py | 47 +++++++++++++++++++++++---------------- tests/targets/test_ios.py | 14 +++++------- 3 files changed, 39 insertions(+), 28 deletions(-) diff --git a/buildozer/default.spec b/buildozer/default.spec index c807de4..4ffb3d9 100644 --- a/buildozer/default.spec +++ b/buildozer/default.spec @@ -307,9 +307,15 @@ ios.codesign.allowed = false # Get a list of available identities: buildozer ios list_identities #ios.codesign.debug = "iPhone Developer: ()" +# (str) The development team to use for signing the debug version +#ios.codesign.development_team.debug = + # (str) Name of the certificate to use for signing the release version #ios.codesign.release = %(ios.codesign.debug)s +# (str) The development team to use for signing the release version +#ios.codesign.development_team.release = + [buildozer] diff --git a/buildozer/targets/ios.py b/buildozer/targets/ios.py index 05eeedd..bb1fd1b 100644 --- a/buildozer/targets/ios.py +++ b/buildozer/targets/ios.py @@ -115,8 +115,8 @@ class TargetIos(Target): kwargs.setdefault('cwd', self.ios_dir) return self.buildozer.cmd(self._toolchain_cmd + cmd, **kwargs) - def xcodebuild(self, cmd='', **kwargs): - return self.buildozer.cmd(self._xcodebuild_cmd + cmd, **kwargs) + def xcodebuild(self, *args, **kwargs): + return self.buildozer.cmd(self._xcodebuild_cmd + ' '.join(arg for arg in args if arg is not None), **kwargs) @property def code_signing_allowed(self): @@ -124,6 +124,11 @@ class TargetIos(Target): allowed = "YES" if allowed else "NO" return f"CODE_SIGNING_ALLOWED={allowed}" + @property + def code_signing_development_team(self): + team = self.buildozer.config.getdefault("app", f"ios.codesign.development_team.{self.build_mode}", None) + return f"DEVELOPMENT_TEAM={team}" if team else None + def get_available_packages(self): available_modules = self.toolchain("recipes --compact", get_stdout=True)[0] return available_modules.splitlines()[0].split() @@ -216,7 +221,12 @@ class TargetIos(Target): mode = self.build_mode.capitalize() self.xcodebuild( - f"-configuration {mode} ENABLE_BITCODE=NO {self.code_signing_allowed} clean build", + f'-configuration {mode}', + '-allowProvisioningUpdates', + 'ENABLE_BITCODE=NO', + self.code_signing_allowed, + self.code_signing_development_team, + 'clean build', cwd=self.app_project_dir) ios_app_dir = '{app_lower}-ios/build/{mode}-iphoneos/{app_lower}.app'.format( app_lower=app_name.lower(), mode=mode) @@ -242,25 +252,24 @@ class TargetIos(Target): self.buildozer.rmdir(intermediate_dir) self.buildozer.info('Creating archive...') - self.xcodebuild(( - ' -alltargets' - ' -configuration {mode}' - ' -scheme {scheme}' - ' -archivePath "{xcarchive}"' - ' archive' - ' ENABLE_BITCODE=NO' - ).format(mode=mode, xcarchive=xcarchive, scheme=app_name.lower()), + self.xcodebuild( + '-alltargets', + f'-configuration {mode}', + f'-scheme {app_name.lower()}', + f'-archivePath "{xcarchive}"', + 'archive', + 'ENABLE_BITCODE=NO', + self.code_signing_development_team, cwd=build_dir) self.buildozer.info('Creating IPA...') - self.xcodebuild(( - ' -exportArchive' - ' -exportFormat IPA' - ' -archivePath "{xcarchive}"' - ' -exportPath "{ipa}"' - ' CODE_SIGN_IDENTITY={ioscodesign}' - ' ENABLE_BITCODE=NO' - ).format(xcarchive=xcarchive, ipa=ipa_tmp, ioscodesign=ioscodesign), + self.xcodebuild( + '-exportArchive', + f'-archivePath "{xcarchive}"', + f'-exportOptionsPlist "{plist_rfn}"', + f'-exportPath "{ipa_tmp}"', + f'CODE_SIGN_IDENTITY={ioscodesign}', + 'ENABLE_BITCODE=NO', cwd=build_dir) self.buildozer.info('Moving IPA to bin...') diff --git a/tests/targets/test_ios.py b/tests/targets/test_ios.py index f5c5709..862d11a 100644 --- a/tests/targets/test_ios.py +++ b/tests/targets/test_ios.py @@ -182,7 +182,6 @@ class TestTargetIos: # fmt: off with patch_target_ios("_unlock_keychain") as m_unlock_keychain, \ patch_buildozer_error() as m_error, \ - patch_target_ios("xcodebuild") as m_xcodebuild, \ mock.patch("buildozer.targets.ios.plistlib.readPlist") as m_readplist, \ mock.patch("buildozer.targets.ios.plistlib.writePlist") as m_writeplist, \ patch_buildozer_cmd() as m_cmd: @@ -196,13 +195,6 @@ class TestTargetIos: 'You must fill the "ios.codesign.debug" token.' ) ] - assert m_xcodebuild.call_args_list == [ - mock.call( - "-configuration Debug ENABLE_BITCODE=NO " - "CODE_SIGNING_ALLOWED=NO clean build", - cwd="/ios/dir/myapp-ios", - ) - ] assert m_readplist.call_args_list == [ mock.call("/ios/dir/myapp-ios/myapp-Info.plist") ] @@ -216,4 +208,8 @@ class TestTargetIos: "/ios/dir/myapp-ios/myapp-Info.plist", ) ] - assert m_cmd.call_args_list == [mock.call(mock.ANY, cwd=target.ios_dir)] + assert m_cmd.call_args_list == [mock.call(mock.ANY, cwd=target.ios_dir), mock.call( + "xcodebuild -configuration Debug -allowProvisioningUpdates ENABLE_BITCODE=NO " + "CODE_SIGNING_ALLOWED=NO clean build", + cwd="/ios/dir/myapp-ios", + )] From 290735a672bd14e704d53dba1136e499ca2fb90d Mon Sep 17 00:00:00 2001 From: Kostiantyn Syrykh Date: Tue, 16 Mar 2021 16:26:17 +0200 Subject: [PATCH 10/17] iOS OTA manifest generation for in-house app distribution --- buildozer/default.spec | 12 ++++++++++++ buildozer/targets/ios.py | 18 ++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/buildozer/default.spec b/buildozer/default.spec index 4ffb3d9..369c2b0 100644 --- a/buildozer/default.spec +++ b/buildozer/default.spec @@ -316,6 +316,18 @@ ios.codesign.allowed = false # (str) The development team to use for signing the release version #ios.codesign.development_team.release = +# (str) URL pointing to .ipa file to be installed +# This option should be defined along with `display_image_url` and `full_size_image_url` options. +#ios.manifest.app_url = + +# (str) URL pointing to an icon (57x57px) to be displayed during download +# This option should be defined along with `app_url` and `full_size_image_url` options. +#ios.manifest.display_image_url = + +# (str) URL pointing to a large icon (512x512px) to be used by iTunes +# This option should be defined along with `app_url` and `display_image_url` options. +#ios.manifest.full_size_image_url = + [buildozer] diff --git a/buildozer/targets/ios.py b/buildozer/targets/ios.py index bb1fd1b..6a8ced9 100644 --- a/buildozer/targets/ios.py +++ b/buildozer/targets/ios.py @@ -216,6 +216,24 @@ class TargetIos(Target): # add icons self._create_icons() + # Generate OTA distribution manifest if `app_url`, `display_image_url` and `full_size_image_url` are defined. + app_url = self.buildozer.config.getdefault("app", "ios.manifest.app_url", None) + display_image_url = self.buildozer.config.getdefault("app", "ios.manifest.display_image_url", None) + full_size_image_url = self.buildozer.config.getdefault("app", "ios.manifest.full_size_image_url", None) + + if any((app_url, display_image_url, full_size_image_url)): + + if not all((app_url, display_image_url, full_size_image_url)): + self.buildozer.error("Options ios.manifest.app_url, ios.manifest.display_image_url" + " and ios.manifest.full_size_image_url should be defined all together") + return + + plist['manifest'] = { + 'appURL': app_url, + 'displayImageURL': display_image_url, + 'fullSizeImageURL': full_size_image_url, + } + # ok, write the modified plist. plistlib.writePlist(plist, plist_rfn) From 6dcbe7ab9f46585677bb3c3a8f853e950d342ffa Mon Sep 17 00:00:00 2001 From: RobertF <34464649+RobertFlatt@users.noreply.github.com> Date: Wed, 21 Apr 2021 21:04:19 -1000 Subject: [PATCH 11/17] Add enable_androidx (#1311) * Add enable_androidx --- buildozer/default.spec | 5 +++++ buildozer/targets/android.py | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/buildozer/default.spec b/buildozer/default.spec index 4ffb3d9..c8817c5 100644 --- a/buildozer/default.spec +++ b/buildozer/default.spec @@ -162,6 +162,11 @@ fullscreen = 0 # (list) Gradle dependencies to add #android.gradle_dependencies = +# (bool) Enable AndroidX support. Enable when 'android.gradle_dependencies' +# contains an 'androidx' package, or any package from Kotlin source. +# android.enable_androidx requires android.api >= 28 +#android.enable_androidx = False + # (list) add java compile options # this can for example be necessary when importing certain java libraries using the 'android.gradle_dependencies' option # see https://developer.android.com/studio/write/java8-support for further information diff --git a/buildozer/targets/android.py b/buildozer/targets/android.py index d53c954..9a8eef3 100644 --- a/buildozer/targets/android.py +++ b/buildozer/targets/android.py @@ -1167,6 +1167,13 @@ class TargetAndroid(Target): if wakelock: build_cmd += [("--wakelock", )] + # AndroidX ? + enable_androidx = config.getbooldefault('app', + 'android.enable_androidx', + False) + if enable_androidx: + build_cmd += [("--enable-androidx", )] + # intent filters intent_filters = config.getdefault( 'app', 'android.manifest.intent_filters', '') From 56d047875c7ae90ef78025c36e6b4e842e49ce3d Mon Sep 17 00:00:00 2001 From: "Felix C. Stegerman" Date: Thu, 22 Apr 2021 17:25:31 +0200 Subject: [PATCH 12/17] use HTTPS urls --- README.md | 6 +++--- buildozer/targets/android.py | 8 ++++---- buildozer/targets/osx.py | 4 ++-- buildozer/tools/packer/Makefile | 2 +- buildozer/tools/packer/scripts/additional-packages.sh | 2 +- docs/Makefile | 2 +- docs/make.bat | 2 +- docs/source/contribute.rst | 6 +++--- setup.py | 2 +- tests/test_buildozer.py | 2 +- 10 files changed, 18 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 4445e65..64bf4f4 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ your application requirements and settings such as title, icon, included modules etc. Buildozer will use that spec to create a package for Android, iOS, Windows, OSX and/or Linux. -Buildozer currently supports packaging for Android via the [python-for-android](http://github.com/kivy/python-for-android/) +Buildozer currently supports packaging for Android via the [python-for-android](https://github.com/kivy/python-for-android/) project, and for iOS via the kivy-ios project. iOS and OSX are still under work. For Android, buildozer will automatically download and prepare the @@ -24,7 +24,7 @@ build dependencies. For more information, see Note that only Python 3 is supported. Note that this tool has nothing to do with the eponymous online build service -[buildozer.io](http://buildozer.io). +[buildozer.io](https://buildozer.io). ## Installing Buildozer with target Python 3 (default): @@ -176,7 +176,7 @@ For [debugging on Android](https://python-for-android.readthedocs.io/en/stable/t ## Contributing We love pull requests and discussing novel ideas. Check out our -[contribution guide](http://kivy.org/docs/contribute.html) and +[contribution guide](https://kivy.org/docs/contribute.html) and feel free to improve buildozer. The following mailing list and IRC channel are used exclusively for diff --git a/buildozer/targets/android.py b/buildozer/targets/android.py index 9a8eef3..381d40d 100644 --- a/buildozer/targets/android.py +++ b/buildozer/targets/android.py @@ -368,7 +368,7 @@ class TargetAndroid(Target): self.buildozer.info('Android ANT is missing, downloading') archive = 'apache-ant-{0}-bin.tar.gz'.format(APACHE_ANT_VERSION) - url = 'http://archive.apache.org/dist/ant/binaries/' + url = 'https://archive.apache.org/dist/ant/binaries/' self.buildozer.download(url, archive, cwd=ant_dir) @@ -427,7 +427,7 @@ class TargetAndroid(Target): # https://developer.android.com/ndk/downloads/older_releases if platform in ('win32', 'cygwin'): - # Checking of 32/64 bits at Windows from: http://stackoverflow.com/a/1405971/798575 + # Checking of 32/64 bits at Windows from: https://stackoverflow.com/a/1405971/798575 import struct archive = 'android-ndk-r{0}-windows-{1}.zip' is_64 = (8 * struct.calcsize("P") == 64) @@ -460,7 +460,7 @@ class TargetAndroid(Target): if _version >= '10e': url = 'https://dl.google.com/android/repository/' else: - url = 'http://dl.google.com/android/ndk/' + url = 'https://dl.google.com/android/ndk/' self.buildozer.download(url, archive, @@ -659,7 +659,7 @@ class TargetAndroid(Target): self.buildozer.error( 'You might have missed to install 32bits libs') self.buildozer.error( - 'Check http://buildozer.readthedocs.org/en/latest/installation.html') + 'Check https://buildozer.readthedocs.org/en/latest/installation.html') self.buildozer.error('') else: self.buildozer.error('') diff --git a/buildozer/targets/osx.py b/buildozer/targets/osx.py index fa4444a..6fd5d22 100644 --- a/buildozer/targets/osx.py +++ b/buildozer/targets/osx.py @@ -46,14 +46,14 @@ class TargetOSX(Target): self.buildozer.info('Downloading kivy...') status_code = check_output( ('curl', '-L', '--write-out', '%{http_code}', '-o', 'Kivy{}.dmg'.format(py_branch), - 'http://kivy.org/downloads/{}/Kivy-{}-osx-python{}.dmg' + 'https://kivy.org/downloads/{}/Kivy-{}-osx-python{}.dmg' .format(current_kivy_vers, current_kivy_vers, py_branch)), cwd=cwd) if status_code == "404": self.buildozer.error( "Unable to download the Kivy App. Check osx.kivy_version in your buildozer.spec, and verify " - "Kivy servers are accessible. http://kivy.org/downloads/") + "Kivy servers are accessible. https://kivy.org/downloads/") check_call(("rm", "Kivy{}.dmg".format(py_branch)), cwd=cwd) sys.exit(1) diff --git a/buildozer/tools/packer/Makefile b/buildozer/tools/packer/Makefile index 5021d91..8ae8b96 100644 --- a/buildozer/tools/packer/Makefile +++ b/buildozer/tools/packer/Makefile @@ -25,7 +25,7 @@ torrent: mktorrent \ -a ${TORRENT_ANNOUNCE} \ -o output-kivy-buildozer-vm/kivy-buildozer-vm.torrent \ - -w http://txzone.net/files/torrents/${PACKAGE_FILENAME} \ + -w https://txzone.net/files/torrents/${PACKAGE_FILENAME} \ -v output-kivy-buildozer-vm/${PACKAGE_FILENAME} upload: diff --git a/buildozer/tools/packer/scripts/additional-packages.sh b/buildozer/tools/packer/scripts/additional-packages.sh index b97ebe8..116cefe 100644 --- a/buildozer/tools/packer/scripts/additional-packages.sh +++ b/buildozer/tools/packer/scripts/additional-packages.sh @@ -3,7 +3,7 @@ # an error when using the android sdk: # "Can't read cryptographic policy directory: unlimited" -wget http://bootstrap.pypa.io/get-pip.py +wget https://bootstrap.pypa.io/get-pip.py python get-pip.py rm get-pip.py diff --git a/docs/Makefile b/docs/Makefile index 7048a95..0d57ec6 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -9,7 +9,7 @@ BUILDDIR = build # User-friendly check for sphinx-build ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) -$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) +$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from https://www.sphinx-doc.org/) endif # Internal variables. diff --git a/docs/make.bat b/docs/make.bat index c5f1be8..acd4fe5 100644 --- a/docs/make.bat +++ b/docs/make.bat @@ -56,7 +56,7 @@ if errorlevel 9009 ( echo.may add the Sphinx directory to PATH. echo. echo.If you don't have Sphinx installed, grab it from - echo.http://sphinx-doc.org/ + echo.https://www.sphinx-doc.org/ exit /b 1 ) diff --git a/docs/source/contribute.rst b/docs/source/contribute.rst index f3c7575..0ce90ba 100644 --- a/docs/source/contribute.rst +++ b/docs/source/contribute.rst @@ -15,10 +15,10 @@ limitation. To test your own recipe via Buildozer, you need to: -#. Fork `Python for Android `_, and +#. Fork `Python for Android `_, and clone your own version (this will allow easy contribution later):: - git clone http://github.com/YOURNAME/python-for-android + git clone https://github.com/YOURNAME/python-for-android #. Change your `buildozer.spec` to reference your version:: @@ -44,6 +44,6 @@ include it in the python-for-android project, by issuing a Pull Request: git push origin master -#. Go to `http://github.com/YOURNAME/python-for-android`, and you should see +#. Go to `https://github.com/YOURNAME/python-for-android`, and you should see your new branch and a button "Pull Request" on it. Use it, write a description about what you did, and Send! diff --git a/setup.py b/setup.py index 1df1fd9..01c2956 100644 --- a/setup.py +++ b/setup.py @@ -57,7 +57,7 @@ setup( long_description_content_type='text/markdown', author='Mathieu Virbel', author_email='mat@kivy.org', - url='http://github.com/kivy/buildozer', + url='https://github.com/kivy/buildozer', license='MIT', packages=[ 'buildozer', 'buildozer.targets', 'buildozer.libs', 'buildozer.scripts' diff --git a/tests/test_buildozer.py b/tests/test_buildozer.py index 7f27c42..0856072 100644 --- a/tests/test_buildozer.py +++ b/tests/test_buildozer.py @@ -158,7 +158,7 @@ class TestBuildozer(unittest.TestCase): assert m_file_extract.call_args_list == [mock.call(mock.ANY, cwd='/my/ant/path')] assert ant_path == my_ant_path assert download.call_args_list == [ - mock.call("http://archive.apache.org/dist/ant/binaries/", mock.ANY, cwd=my_ant_path)] + mock.call("https://archive.apache.org/dist/ant/binaries/", mock.ANY, cwd=my_ant_path)] # Mock ant already installed with mock.patch.object(Buildozer, 'file_exists', return_value=True): ant_path = target._install_apache_ant() From f81d21adac63c68aed4e486865140186b01aff79 Mon Sep 17 00:00:00 2001 From: "Felix C. Stegerman" Date: Sat, 1 May 2021 11:54:22 +0200 Subject: [PATCH 13/17] fix ndk version check & download link (#1271) * fix ndk version check & download link * tiny code cleanup --- buildozer/targets/android.py | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/buildozer/targets/android.py b/buildozer/targets/android.py index 381d40d..855ea36 100644 --- a/buildozer/targets/android.py +++ b/buildozer/targets/android.py @@ -416,7 +416,7 @@ class TargetAndroid(Target): return ndk_dir import re - _version = re.search('(.+?)[a-z]', self.android_ndk_version).group(1) + _version = int(re.search(r'(\d+)', self.android_ndk_version).group(1)) self.buildozer.info('Android NDK is missing, downloading') # Welcome to the NDK URL hell! @@ -426,28 +426,23 @@ class TargetAndroid(Target): # from 10e on the URLs can be looked up at # https://developer.android.com/ndk/downloads/older_releases + is_darwin = platform == 'darwin' + is_linux = platform.startswith('linux') + if platform in ('win32', 'cygwin'): # Checking of 32/64 bits at Windows from: https://stackoverflow.com/a/1405971/798575 import struct archive = 'android-ndk-r{0}-windows-{1}.zip' is_64 = (8 * struct.calcsize("P") == 64) - - elif platform in ('darwin', ): - if _version >= '10e': - archive = 'android-ndk-r{0}-darwin-{1}.zip' - elif _version >= '10c': - archive = 'android-ndk-r{0}-darwin-{1}.bin' + elif is_darwin or is_linux: + _platform = 'linux' if is_linux else 'darwin' + if self.android_ndk_version in ['10c', '10d', '10e']: + ext = 'bin' + elif _version <= 10: + ext = 'tar.bz2' else: - archive = 'android-ndk-r{0}-darwin-{1}.tar.bz2' - is_64 = (os.uname()[4] == 'x86_64') - - elif platform.startswith('linux'): - if _version >= '10e': - archive = 'android-ndk-r{0}-linux-{1}.zip' - elif _version >= '10c': - archive = 'android-ndk-r{0}-linux-{1}.bin' - else: - archive = 'android-ndk-r{0}-linux-{1}.tar.bz2' + ext = 'zip' + archive = 'android-ndk-r{0}-' + _platform + '-{1}.' + ext is_64 = (os.uname()[4] == 'x86_64') else: raise SystemError('Unsupported platform: {}'.format(platform)) @@ -457,7 +452,7 @@ class TargetAndroid(Target): archive = archive.format(self.android_ndk_version, architecture) unpacked = unpacked.format(self.android_ndk_version) - if _version >= '10e': + if _version >= 11: url = 'https://dl.google.com/android/repository/' else: url = 'https://dl.google.com/android/ndk/' From 0a8e4018775c54bea394e87f250eb6ad5a5152d4 Mon Sep 17 00:00:00 2001 From: ghost43 Date: Mon, 3 May 2021 10:50:44 +0000 Subject: [PATCH 14/17] android: adaptive icon/launcher: expose p4a options in buildozer.spec (#1312) see see https://developer.android.com/guide/practices/ui_guidelines/icon_design_adaptive --- buildozer/default.spec | 4 ++++ buildozer/targets/android.py | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/buildozer/default.spec b/buildozer/default.spec index 863b4e8..ddff292 100644 --- a/buildozer/default.spec +++ b/buildozer/default.spec @@ -87,6 +87,10 @@ fullscreen = 0 # Lottie files can be created using various tools, like Adobe After Effect or Synfig. #android.presplash_lottie = "path/to/lottie/file.json" +# (str) Adaptive icon of the application (used if Android API level is 26+ at runtime) +#icon.adaptive_foreground.filename = %(source.dir)s/data/icon_fg.png +#icon.adaptive_background.filename = %(source.dir)s/data/icon_bg.png + # (list) Permissions #android.permissions = INTERNET diff --git a/buildozer/targets/android.py b/buildozer/targets/android.py index 855ea36..f2986d0 100644 --- a/buildozer/targets/android.py +++ b/buildozer/targets/android.py @@ -1129,6 +1129,11 @@ class TargetAndroid(Target): icon = config.getdefault('app', 'icon.filename', '') if icon: build_cmd += [("--icon", join(self.buildozer.root_dir, icon))] + icon_fg = config.getdefault('app', 'icon.adaptive_foreground.filename', '') + icon_bg = config.getdefault('app', 'icon.adaptive_background.filename', '') + if icon_fg and icon_bg: + build_cmd += [("--icon-fg", join(self.buildozer.root_dir, icon_fg))] + build_cmd += [("--icon-bg", join(self.buildozer.root_dir, icon_bg))] # OUYA Console support ouya_category = config.getdefault('app', 'android.ouya.category', From b7e312255d99a822160be8e7f4f507cbda1a9560 Mon Sep 17 00:00:00 2001 From: Richard Larkin Date: Mon, 10 May 2021 20:05:15 +0200 Subject: [PATCH 15/17] Add option to disabling of byte-code compilation --- buildozer/default.spec | 3 +++ buildozer/targets/android.py | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/buildozer/default.spec b/buildozer/default.spec index ddff292..47d28b2 100644 --- a/buildozer/default.spec +++ b/buildozer/default.spec @@ -256,6 +256,9 @@ android.allow_backup = True # Usage example : android.manifest_placeholders = [myCustomUrl:\"org.kivy.customurl\"] # android.manifest_placeholders = [:] +# (bool) disables the compilation of py to pyc/pyo files when packaging +# android.no-compile-pyo = True + # # Python for android (p4a) specific # diff --git a/buildozer/targets/android.py b/buildozer/targets/android.py index f2986d0..edf5887 100644 --- a/buildozer/targets/android.py +++ b/buildozer/targets/android.py @@ -902,6 +902,11 @@ class TargetAndroid(Target): cmd.append('--manifest-placeholders') cmd.append("{}".format(manifest_placeholders)) + # support disabling of compilation + compile_py = self.buildozer.config.getdefault('app', 'android.no-compile-pyo', None) + if compile_py: + cmd.append('--no-compile-pyo') + cmd.append('--arch') cmd.append(self._arch) From 8673e59cfd96b07a1d8948d4d31b70211da3e631 Mon Sep 17 00:00:00 2001 From: Tim Gates Date: Wed, 19 May 2021 22:21:40 +1000 Subject: [PATCH 16/17] docs: fix a few simple typos There are small typos in: - buildozer/target.py - buildozer/targets/android.py - tests/test_buildozer.py Fixes: - Should read `specified` rather than `speficied`. - Should read `overridden` rather than `overriden`. - Should read `instantiated` rather than `instanciated`. Closes #1326 --- buildozer/target.py | 2 +- buildozer/targets/android.py | 2 +- tests/test_buildozer.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/buildozer/target.py b/buildozer/target.py index 631462c..7262a43 100644 --- a/buildozer/target.py +++ b/buildozer/target.py @@ -234,7 +234,7 @@ class Target: This will clone the contents of a git repository to `buildozer.platform_dir`. The location of this repo can be - speficied via URL and branch name, or via a custom (local) + specified via URL and branch name, or via a custom (local) directory name. :Parameters: diff --git a/buildozer/targets/android.py b/buildozer/targets/android.py index edf5887..cca471e 100644 --- a/buildozer/targets/android.py +++ b/buildozer/targets/android.py @@ -120,7 +120,7 @@ class TargetAndroid(Target): # Default p4a dir p4a_dir = join(self.buildozer.platform_dir, self.p4a_directory_name) - # Possibly overriden by user setting + # Possibly overridden by user setting system_p4a_dir = self.buildozer.config.getdefault('app', 'p4a.source_dir') if system_p4a_dir: p4a_dir = expanduser(system_p4a_dir) diff --git a/tests/test_buildozer.py b/tests/test_buildozer.py index 0856072..6ef385d 100644 --- a/tests/test_buildozer.py +++ b/tests/test_buildozer.py @@ -61,7 +61,7 @@ class TestBuildozer(unittest.TestCase): def test_buildozer_base(self): """ - Basic test making sure the Buildozer object can be instanciated. + Basic test making sure the Buildozer object can be instantiated. """ buildozer = Buildozer() assert buildozer.specfilename == 'buildozer.spec' From 530974e08c0fc3eb3e033ccc4e1d81ca52020883 Mon Sep 17 00:00:00 2001 From: meow464 <> Date: Sat, 14 Aug 2021 18:58:32 -0300 Subject: [PATCH 17/17] Fixes deprecated plistlib API Support for the old API was removed in Python 3.9 by bigfootjon. This new API has been available since 3.4. Issue: https://bugs.python.org/issue36409 --- buildozer/targets/ios.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/buildozer/targets/ios.py b/buildozer/targets/ios.py index 6a8ced9..5323763 100644 --- a/buildozer/targets/ios.py +++ b/buildozer/targets/ios.py @@ -207,7 +207,8 @@ class TargetIos(Target): plist_rfn = join(self.app_project_dir, plist_fn) version = self.buildozer.get_version() self.buildozer.info('Update Plist {}'.format(plist_fn)) - plist = plistlib.readPlist(plist_rfn) + with open(plist_rfn, 'rb') as f: + plist = plistlib.load(f) plist['CFBundleIdentifier'] = self._get_package() plist['CFBundleShortVersionString'] = version plist['CFBundleVersion'] = '{}.{}'.format(version, @@ -235,7 +236,8 @@ class TargetIos(Target): } # ok, write the modified plist. - plistlib.writePlist(plist, plist_rfn) + with open(plist_rfn, 'wb') as f: + plistlib.dump(plist, f) mode = self.build_mode.capitalize() self.xcodebuild(