Skip to content

Commit 871cc31

Browse files
committed
Merge pull request kivy#698 from inclement/main_py_check
Added main.py existence check in both bootstraps
2 parents 6a5fd13 + 4523c9f commit 871cc31

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

pythonforandroid/bootstraps/pygame/build/build.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python2.7
22

3-
from os.path import dirname, join, isfile, realpath, relpath, split
3+
from os.path import dirname, join, isfile, realpath, relpath, split, exists
44
from zipfile import ZipFile
55
import sys
66
sys.path.insert(0, 'buildlib/jinja2.egg')
@@ -258,6 +258,13 @@ def make_package(args):
258258
# Figure out if application has service part
259259
service = False
260260
directory = args.dir if public_version else args.private
261+
if not (exists(join(realpath(directory), 'main.py')) or
262+
exists(join(realpath(directory), 'main.pyo'))):
263+
print('''BUILD FAILURE: No main.py(o) found in your app directory. This
264+
file must exist to act as the entry point for you app. If your app is
265+
started by a file with a different name, rename it to main.py or add a
266+
main.py that loads it.''')
267+
exit(1)
261268
if directory:
262269
service_main = join(realpath(directory), 'service', 'main.py')
263270
if os.path.exists(service_main) or os.path.exists(service_main + 'o'):

pythonforandroid/bootstraps/sdl2/build/build.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,14 @@ def make_package(args):
218218
# print('Your PATH must include android tools.')
219219
# sys.exit(-1)
220220

221+
if not (exists(join(realpath(args.private), 'main.py')) or
222+
exists(join(realpath(args.private), 'main.pyo'))):
223+
print('''BUILD FAILURE: No main.py(o) found in your app directory. This
224+
file must exist to act as the entry point for you app. If your app is
225+
started by a file with a different name, rename it to main.py or add a
226+
main.py that loads it.''')
227+
exit(1)
228+
221229
# Delete the old assets.
222230
if exists('assets/public.mp3'):
223231
os.unlink('assets/public.mp3')

0 commit comments

Comments
 (0)