Remove support for Buildozer

This commit is contained in:
FestplattenSchnitzel 2023-03-08 10:45:54 +01:00
parent 00fefd35bd
commit 2dda9db1f1
No known key found for this signature in database
GPG key ID: 1B4181FC97673B9D
8 changed files with 8 additions and 245 deletions

View file

@ -30,7 +30,6 @@ import time
import requests
import tempfile
import argparse
from configparser import ConfigParser
import logging
from gettext import ngettext
from pathlib import Path
@ -456,9 +455,6 @@ def build_local(app, build, vcs, build_dir, output_dir, log_dir, srclib_dir, ext
cmd += ['clean']
p = FDroidPopen(cmd, cwd=root_dir, envs={"GRADLE_VERSION_DIR": config['gradle_version_dir'], "CACHEDIR": config['cachedir']})
elif bmethod == 'buildozer':
pass
elif bmethod == 'ant':
logging.info("Cleaning Ant project...")
p = FDroidPopen(['ant', 'clean'], cwd=root_dir)
@ -601,73 +597,6 @@ def build_local(app, build, vcs, build_dir, output_dir, log_dir, srclib_dir, ext
bindir = os.path.join(root_dir, 'target')
elif bmethod == 'buildozer':
logging.info("Building Kivy project using buildozer...")
# parse buildozer.spez
spec = os.path.join(root_dir, 'buildozer.spec')
if not os.path.exists(spec):
raise BuildException("Expected to find buildozer-compatible spec at {0}"
.format(spec))
defaults = {'orientation': 'landscape', 'icon': '',
'permissions': '', 'android.api': "19"}
bconfig = ConfigParser(defaults, allow_no_value=True)
bconfig.read(spec)
# update spec with sdk and ndk locations to prevent buildozer from
# downloading.
loc_ndk = common.env['ANDROID_NDK']
loc_sdk = common.env['ANDROID_SDK']
if loc_ndk == '$ANDROID_NDK':
loc_ndk = loc_sdk + '/ndk-bundle'
bc_ndk = None
bc_sdk = None
try:
bc_ndk = bconfig.get('app', 'android.sdk_path')
except Exception:
pass
try:
bc_sdk = bconfig.get('app', 'android.ndk_path')
except Exception:
pass
if bc_sdk is None:
bconfig.set('app', 'android.sdk_path', loc_sdk)
if bc_ndk is None:
bconfig.set('app', 'android.ndk_path', loc_ndk)
fspec = open(spec, 'w')
bconfig.write(fspec)
fspec.close()
logging.info("sdk_path = %s" % loc_sdk)
logging.info("ndk_path = %s" % loc_ndk)
p = None
# execute buildozer
cmd = ['buildozer', 'android', 'release']
try:
p = FDroidPopen(cmd, cwd=root_dir)
except Exception:
pass
# buidozer not installed ? clone repo and run
if (p is None or p.returncode != 0):
cmd = ['git', 'clone', 'https://github.com/kivy/buildozer.git']
p = subprocess.Popen(cmd, cwd=root_dir, shell=False)
p.wait()
if p.returncode != 0:
raise BuildException("Distribute build failed")
cmd = ['python', 'buildozer/buildozer/scripts/client.py', 'android', 'release']
p = FDroidPopen(cmd, cwd=root_dir)
# expected to fail.
# Signing will fail if not set by environnment vars (cf. p4a docs).
# But the unsigned APK will be ok.
p.returncode = 0
elif bmethod == 'gradle':
logging.info("Building Gradle project...")
@ -724,26 +653,6 @@ def build_local(app, build, vcs, build_dir, output_dir, log_dir, srclib_dir, ext
src = m.group(1)
src = os.path.join(bindir, src) + '.apk'
elif omethod == 'buildozer':
src = None
for apks_dir in [
os.path.join(root_dir, '.buildozer', 'android', 'platform', 'build', 'dists', bconfig.get('app', 'title'), 'bin'),
]:
for apkglob in ['*-release-unsigned.apk', '*-unsigned.apk', '*.apk']:
apks = glob.glob(os.path.join(apks_dir, apkglob))
if len(apks) > 1:
raise BuildException('More than one resulting apks found in %s' % apks_dir,
'\n'.join(apks))
if len(apks) == 1:
src = apks[0]
break
if src is not None:
break
if src is None:
raise BuildException('Failed to find any output apks')
elif omethod == 'gradle':
src = None
apk_dirs = [

View file

@ -17,7 +17,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import configparser
import os
import re
import stat
@ -183,44 +182,6 @@ def get_app_from_url(url):
return app
def check_for_kivy_buildozer(tmp_importer_dir, app, build):
versionCode = None
buildozer_spec = tmp_importer_dir / 'buildozer.spec'
if buildozer_spec.exists():
config = configparser.ConfigParser()
config.read(buildozer_spec)
import pprint
pprint.pprint(sorted(config['app'].keys()))
app.id = config['app'].get('package.domain')
print(app.id)
app.AutoName = config['app'].get('package.name', app.AutoName)
app.License = config['app'].get('license', app.License)
app.Description = config['app'].get('description', app.Description)
build.versionName = config['app'].get('version')
build.output = 'bin/%s-$$VERSION$$-release-unsigned.apk' % app.AutoName
build.ndk = 'r17c'
build.srclibs = [
'buildozer@586152c',
'python-for-android@ccb0f8e1',
]
build.sudo = [
'apt-get update',
'apt-get install -y build-essential libffi-dev libltdl-dev',
]
build.prebuild = [
'sed -iE "/^[# ]*android\\.(ant|ndk|sdk)_path[ =]/d" buildozer.spec',
'sed -iE "/^[# ]*android.accept_sdk_license[ =]+.*/d" buildozer.spec',
'sed -iE "/^[# ]*android.skip_update[ =]+.*/d" buildozer.spec',
'sed -iE "/^[# ]*p4a.source_dir[ =]+.*/d" buildozer.spec',
'sed -i "s,\\[app\\],[app]\\n\\nandroid.sdk_path = $$SDK$$\\nandroid.ndk_path = $$NDK$$\\np4a.source_dir = $$python-for-android$$\\nandroid.accept_sdk_license = False\\nandroid.skip_update = True\\nandroid.ant_path = /usr/bin/ant\\n," buildozer.spec',
'pip3 install --user --upgrade $$buildozer$$ Cython==0.28.6',
]
build.build = [
'PATH="$HOME/.local/bin:$PATH" buildozer android release',
]
return build.get('versionName'), versionCode, app.get('id')
def main():
global config, options
@ -287,8 +248,6 @@ def main():
app.UpdateCheckMode = 'Tags'
build.commit = common.get_head_commit_id(git_repo)
versionName, versionCode, appid = check_for_kivy_buildozer(tmp_importer_dir, app, build)
# Extract some information...
paths = common.get_all_gradle_and_manifests(tmp_importer_dir)
subdir = common.get_gradle_subdir(tmp_importer_dir, paths)
@ -300,7 +259,7 @@ def main():
logging.warning(_('Could not find latest version name'))
if not versionCode:
logging.warning(_('Could not find latest version code'))
elif not appid:
else:
raise FDroidException(_("No gradle project could be found. Specify --subdir?"))
# Make sure it's actually new...

View file

@ -225,7 +225,6 @@ build_flags = [
'patch',
'gradle',
'maven',
'buildozer',
'output',
'binary',
'srclibs',
@ -266,7 +265,6 @@ class Build(dict):
self.patch = []
self.gradle = []
self.maven = False
self.buildozer = False
self.output = None
self.binary = None
self.srclibs = []
@ -310,7 +308,7 @@ class Build(dict):
raise AttributeError("No such attribute: " + name)
def build_method(self):
for f in ['maven', 'gradle', 'buildozer']:
for f in ['maven', 'gradle']:
if self.get(f):
return f
if self.output:
@ -321,7 +319,7 @@ class Build(dict):
def output_method(self):
if self.output:
return 'raw'
for f in ['maven', 'gradle', 'buildozer']:
for f in ['maven', 'gradle']:
if self.get(f):
return f
return 'ant'
@ -656,7 +654,7 @@ def post_metadata_parse(app):
elif v == [False]:
return ['no']
_bool_allowed = ('maven', 'buildozer')
_bool_allowed = ('maven')
builds = []
if 'Builds' in app:
@ -963,7 +961,7 @@ def write_yaml(mf, app):
value = getattr(build, field)
if field == 'gradle' and value == ['off']:
value = [ruamel.yaml.scalarstring.SingleQuotedScalarString('off')]
if field in ('maven', 'buildozer'):
if field in ('maven'):
if value == 'no':
continue
typ = flagtype(field)