MCPcopy Index your code
hub / github.com/kivy/python-for-android / check_ndk_version

Function check_ndk_version

pythonforandroid/recommendations.py:51–109  ·  view source on GitHub ↗

Check the NDK version against what is currently recommended and raise an exception of :class:`~pythonforandroid.util.BuildInterruptingException` in case that the user tries to use an NDK lower than minimum supported, specified via attribute `MIN_NDK_VERSION`. .. versionchanged:

(ndk_dir)

Source from the content-addressed store, hash-verified

49
50
51def check_ndk_version(ndk_dir):
52 """
53 Check the NDK version against what is currently recommended and raise an
54 exception of :class:`~pythonforandroid.util.BuildInterruptingException` in
55 case that the user tries to use an NDK lower than minimum supported,
56 specified via attribute `MIN_NDK_VERSION`.
57
58 .. versionchanged:: 2019.06.06.1.dev0
59 Added the ability to get android's NDK `letter version` and also
60 rewrote to raise an exception in case that an NDK version lower than
61 the minimum supported is detected.
62 """
63 ndk_version = read_ndk_version(ndk_dir)
64
65 if ndk_version is None:
66 warning(READ_ERROR_NDK_MESSAGE.format(ndk_dir=ndk_dir))
67 warning(
68 ENSURE_RIGHT_NDK_MESSAGE.format(
69 min_supported=MIN_NDK_VERSION,
70 rec_version=RECOMMENDED_NDK_VERSION,
71 ndk_url=NDK_DOWNLOAD_URL,
72 )
73 )
74 return
75
76 # create a dictionary which will describe the relationship of the android's
77 # NDK minor version with the `human readable` letter version, egs:
78 # Pkg.Revision = 17.1.4828580 => ndk-17b
79 # Pkg.Revision = 17.2.4988734 => ndk-17c
80 # Pkg.Revision = 19.0.5232133 => ndk-19 (No letter)
81 minor_to_letter = {0: ''}
82 minor_to_letter.update(
83 {n + 1: chr(i) for n, i in enumerate(range(ord('b'), ord('b') + 25))}
84 )
85 string_version = f"{ndk_version.major}{minor_to_letter[ndk_version.minor]}"
86
87 info(CURRENT_NDK_VERSION_MESSAGE.format(ndk_version=string_version))
88
89 if ndk_version.major < MIN_NDK_VERSION:
90 raise BuildInterruptingException(
91 NDK_LOWER_THAN_SUPPORTED_MESSAGE.format(
92 min_supported=MIN_NDK_VERSION, ndk_url=NDK_DOWNLOAD_URL
93 ),
94 instructions=(
95 'Please, go to the android NDK page ({ndk_url}) and download a'
96 ' supported version.\n*** The currently recommended NDK'
97 ' version is {rec_version} ***'.format(
98 ndk_url=NDK_DOWNLOAD_URL,
99 rec_version=RECOMMENDED_NDK_VERSION,
100 )
101 ),
102 )
103 elif ndk_version.major > MAX_NDK_VERSION:
104 warning(
105 RECOMMENDED_NDK_VERSION_MESSAGE.format(
106 recommended_ndk_version=RECOMMENDED_NDK_VERSION
107 )
108 )

Calls 3

read_ndk_versionFunction · 0.85
formatMethod · 0.80