From f633b159d3d1db10840b8ffadca644aaff539e75 Mon Sep 17 00:00:00 2001 From: Julian Date: Mon, 11 Sep 2023 00:35:54 +1000 Subject: [PATCH 1/2] Clean up inheritance of targets (#1690) 1) Target class contained Android-only attribute "artifact_format". Moved that code into TargetAndroid class. 2) TargetIos had a `check_build_prepared()` method that was ineffective. `prepare_for_build()` sets `target._build_prepared` to True. Then `check_build_prepared()` inexplicably set it to False. Then `build()` checks for its existence, rather than its value [this is code smell that is on my list for later], so the fact that it had been changed made no difference. So, I removed the method, and the call to it. 2) TargetOSX had lots of methods that were identical to its base class implementations (three more, once the above steps were done). They don't need to be specified; they are inherited. I removed them. `osx.py` is now 20% smaller. --- buildozer/target.py | 3 -- buildozer/targets/android.py | 11 ++++++++ buildozer/targets/osx.py | 54 ------------------------------------ 3 files changed, 11 insertions(+), 57 deletions(-) diff --git a/buildozer/target.py b/buildozer/target.py index 75a378363..9918c4b30 100644 --- a/buildozer/target.py +++ b/buildozer/target.py @@ -15,7 +15,6 @@ class Target: def __init__(self, buildozer): self.buildozer = buildozer self.build_mode = 'debug' - self.artifact_format = 'apk' self.platform_update = False self.logger = Logger() @@ -106,7 +105,6 @@ def cmd_update(self, *args): def cmd_debug(self, *args): self.buildozer.prepare_for_build() self.build_mode = 'debug' - self.artifact_format = self.buildozer.config.getdefault('app', 'android.debug_artifact', 'apk') self.buildozer.build() def cmd_release(self, *args): @@ -143,7 +141,6 @@ def cmd_release(self, *args): exit(1) self.build_mode = 'release' - self.artifact_format = self.buildozer.config.getdefault('app', 'android.release_artifact', 'aab') self.buildozer.build() def cmd_deploy(self, *args): diff --git a/buildozer/targets/android.py b/buildozer/targets/android.py index 932bb2fbb..f87c616ac 100644 --- a/buildozer/targets/android.py +++ b/buildozer/targets/android.py @@ -72,6 +72,9 @@ class TargetAndroid(Target): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) + + self.artifact_format = 'apk' + if self.buildozer.config.has_option( "app", "android.arch" ) and not self.buildozer.config.has_option("app", "android.archs"): @@ -989,6 +992,14 @@ def check_p4a_sign_env(self, error=False): check = False return check + def cmd_debug(self, *args): + self.artifact_format = self.buildozer.config.getdefault('app', 'android.debug_artifact', 'apk') + super().cmd_debug(*args) + + def cmd_release(self, *args): + self.artifact_format = self.buildozer.config.getdefault('app', 'android.release_artifact', 'aab') + super().cmd_release(*args) + def cmd_run(self, *args): entrypoint = self.buildozer.config.getdefault( 'app', 'android.entrypoint') diff --git a/buildozer/targets/osx.py b/buildozer/targets/osx.py index 6ceca122c..55a52ca7b 100644 --- a/buildozer/targets/osx.py +++ b/buildozer/targets/osx.py @@ -79,17 +79,6 @@ def check_requirements(self): self.ensure_sdk() self.ensure_kivyapp() - def check_configuration_tokens(self, errors=None): - if errors: - self.logger.info('Check target configuration tokens') - self.logger.error( - '{0} error(s) found in the buildozer.spec'.format( - len(errors))) - for error in errors: - print(error) - sys.exit(1) - # check - def build_package(self): self.logger.info('Building package') @@ -147,9 +136,6 @@ def build_package(self): binpath) self.logger.info('All Done!') - def compile_platform(self): - pass - def install_platform(self): # ultimate configuration check. # some of our configuration cannot be checked without platform. @@ -159,16 +145,6 @@ def install_platform(self): 'PACKAGES_PATH': self.buildozer.global_packages_dir, }) - def get_custom_commands(self): - result = [] - for x in dir(self): - if not x.startswith('cmd_'): - continue - if x[4:] in self.buildozer.standard_cmds: - continue - result.append((x[4:], getattr(self, x).__doc__)) - return result - def get_available_packages(self): return ['kivy', 'python3'] @@ -212,36 +188,6 @@ def run_commands(self, args): func(args) - def check_build_prepared(self): - self._build_prepared = False - - def cmd_clean(self, *args): - self.buildozer.clean_platform() - - def cmd_update(self, *args): - self.platform_update = True - self.buildozer.prepare_for_build() - - def cmd_debug(self, *args): - self.buildozer.prepare_for_build() - self.build_mode = 'debug' - self.check_build_prepared() - self.buildozer.build() - - def cmd_release(self, *args): - self.buildozer.prepare_for_build() - self.build_mode = 'release' - self.buildozer.build() - - def cmd_deploy(self, *args): - self.buildozer.prepare_for_build() - - def cmd_run(self, *args): - self.buildozer.prepare_for_build() - - def cmd_serve(self, *args): - self.buildozer.cmd_serve() - def get_target(buildozer): return TargetOSX(buildozer) From 84907914305f45735e2101ceef2888696b5a7451 Mon Sep 17 00:00:00 2001 From: Mirko Galimberti Date: Sun, 10 Sep 2023 17:16:34 +0200 Subject: [PATCH 2/2] Now Github Actions provides python3 via setup-python also for Apple Silicon macs (#1687) --- .ci/osx_ci.sh | 13 ------------- .github/workflows/ios.yml | 22 +++------------------- 2 files changed, 3 insertions(+), 32 deletions(-) delete mode 100644 .ci/osx_ci.sh diff --git a/.ci/osx_ci.sh b/.ci/osx_ci.sh deleted file mode 100644 index 8cdd1ac1a..000000000 --- a/.ci/osx_ci.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -set -e -x - -arm64_set_path_and_python_version(){ - python_version="$1" - if [[ $(/usr/bin/arch) = arm64 ]]; then - export PATH=/opt/homebrew/bin:$PATH - eval "$(pyenv init --path)" - pyenv install $python_version -s - pyenv global $python_version - export PATH=$(pyenv prefix)/bin:$PATH - fi -} \ No newline at end of file diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml index 9601c7c75..a9c7e97fc 100644 --- a/.github/workflows/ios.yml +++ b/.github/workflows/ios.yml @@ -3,46 +3,30 @@ name: iOS jobs: Integration: name: "Integration (${{ matrix.runs_on }}, ${{ matrix.python }})" - runs-on: ${{ matrix.runs_on || 'macos-latest' }} + runs-on: ${{ matrix.runs_on }} strategy: matrix: - include: - - runs_on: macos-latest - python: '3.9' - - runs_on: apple-silicon-m1 - python: '3.9.7' + runs_on: [macos-latest, apple-silicon-m1] steps: - name: Setup python - # Needs to be skipped on our self-hosted runners tagged as 'apple-silicon-m1' - if: ${{ matrix.runs_on != 'apple-silicon-m1' }} uses: actions/setup-python@v4 with: - python-version: ${{ matrix.python }} + python-version: '3.x' - uses: actions/checkout@v4 - name: Setup environment run: | - source .ci/osx_ci.sh - arm64_set_path_and_python_version ${{ matrix.python }} pip install -e . pip install Cython==0.29.36 cookiecutter pbxproj - name: Check buildozer installation run: | - source .ci/osx_ci.sh - arm64_set_path_and_python_version ${{ matrix.python }} buildozer --help - name: Initialize buildozer in project folder run: | - source .ci/osx_ci.sh - arm64_set_path_and_python_version ${{ matrix.python }} buildozer init - name: Install dependencies run: | - source .ci/osx_ci.sh - arm64_set_path_and_python_version ${{ matrix.python }} brew install autoconf automake libtool pkg-config - name: buildozer ios debug run: | - source .ci/osx_ci.sh - arm64_set_path_and_python_version ${{ matrix.python }} touch main.py buildozer ios debug