Skip to content

Commit 32c707d

Browse files
committed
Added build failure if run under Python 2
1 parent 7338ae4 commit 32c707d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pythonforandroid/toolchain.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,13 @@ def check_python_dependencies():
100100
toolchain_dir = dirname(__file__)
101101
sys.path.insert(0, join(toolchain_dir, "tools", "external"))
102102

103+
def check_python_version():
104+
py2_text = (
105+
'python-for-android no longer supports running under Python 2. Either upgrade to '
106+
'Python 3 (recommended), or revert to python-for-android 2019.07.08. Note that '
107+
'you *can* still target Python 2 on Android by including python2 in your requirements.')
108+
if sys.version_info.major < 3:
109+
raise BuildInterruptingException(py2_text)
103110

104111
def add_boolean_option(parser, names, no_names=None,
105112
default=True, dest=None, description=None):
@@ -568,6 +575,9 @@ def add_parser(subparsers, *args, **kwargs):
568575

569576
args, unknown = parser.parse_known_args(sys.argv[1:])
570577
args.unknown_args = unknown
578+
579+
check_python_version()
580+
571581
if hasattr(args, "private") and args.private is not None:
572582
# Pass this value on to the internal bootstrap build.py:
573583
args.unknown_args += ["--private", args.private]

0 commit comments

Comments
 (0)