Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ jobs:
run: |
pip install .
- run: buildozer --help
- run: buildozer init
- run: buildozer init android
- name: SDK, NDK, and p4a download
run: |
sed -i.bak "s/# android.accept_sdk_license = False/android.accept_sdk_license = True/" buildozer.spec
sed -i.bak "s/#android.accept_sdk_license = False/android.accept_sdk_license = True/" buildozer.spec
sed -i.bak "s/#p4a.branch = master/p4a.branch = develop/" buildozer.spec
buildozer android p4a -- --help
# Install OS specific dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
buildozer --help
- name: Initialize buildozer in project folder
run: |
buildozer init
buildozer init ios
- name: Install dependencies
run: |
brew install autoconf automake libtool pkg-config
Expand Down
64 changes: 59 additions & 5 deletions buildozer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

'''

__version__ = '1.5.1.dev0'
__version__ = '1.5.2.dev0'

import json
from fnmatch import fnmatch
import os
from os import environ, walk, sep, listdir
Expand Down Expand Up @@ -705,11 +706,64 @@ def check_root(self):
def cmd_init(self, *args):
'''Create an initial buildozer.spec in the current directory
'''
if exists('buildozer.spec'):
def_spec = 'default.spec'
exit_code = 1
largs = [x.lower().replace('--', '') for x in args]
new_spec = 'buildozer.spec'
options = ('android', 'ios', 'osx')
script_path = dirname(__file__)

if largs:
ignore_doc = len(largs) > 1 and largs[1] in ('no-docs', 'no-comments')

if largs[0] in options:
if exists(new_spec):
buildops.file_copy(new_spec, f'{new_spec}.bak')
print(f'Made a backup of {new_spec} as {new_spec}.bak!')
else:
buildops.file_copy(join(script_path, def_spec), new_spec)
print(f'File {new_spec} created, ready to customize!')

with open(new_spec, encoding='utf-8') as f:
old_spec = f.read()

inject_before = old_spec.find('\n[buildozer]\n')

with open(join(script_path, f"default-{largs[0]}.json"), encoding='utf-8') as f:
default_json = json.load(f)

with open(new_spec, 'w', encoding='utf-8') as f:
f.write(old_spec[:inject_before - 1])

for app_key, app_value in default_json.items():
if f"[{app_key}]" not in old_spec[:inject_before]:
f.write(f"\n[{app_key}]\n")

for key, value in default_json[app_key].items():
if key not in old_spec[:inject_before]:
f.write('\n')

if not ignore_doc:
for doc in value['doc']:
f.write(f"# {doc}\n")

f.write(f"#{key} = {value.get('default', '')}\n")

f.write(old_spec[inject_before:])

print(f'Modified {new_spec} for use with {largs[0]}!')
exit_code = 0
else:
print("ERROR: Valid target must be one of the following: "
f"{', '.join(options[:-1])} or {options[-1]}.")
elif exists(new_spec):
print('ERROR: You already have a buildozer.spec file.')
exit(1)
buildops.file_copy(join(dirname(__file__), 'default.spec'), 'buildozer.spec')
print('File buildozer.spec created, ready to customize!')
else:
buildops.file_copy(join(script_path, def_spec), new_spec)
print(f'File {new_spec} created, ready to customize!')
exit_code = 0

exit(exit_code)

def cmd_distclean(self, *args):
'''Clean the whole Buildozer environment.
Expand Down
Loading
Loading