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

Method prepare_build_environment

pythonforandroid/build.py:226–375  ·  view source on GitHub ↗

Checks that build dependencies exist and sets internal variables for the Android SDK etc. ..warning:: This *must* be called before trying any build stuff

(self,
                                  user_sdk_dir,
                                  user_ndk_dir,
                                  user_android_api,
                                  user_ndk_api)

Source from the content-addressed store, hash-verified

224 self._ndk_dir = value
225
226 def prepare_build_environment(self,
227 user_sdk_dir,
228 user_ndk_dir,
229 user_android_api,
230 user_ndk_api):
231 '''Checks that build dependencies exist and sets internal variables
232 for the Android SDK etc.
233
234 ..warning:: This *must* be called before trying any build stuff
235
236 '''
237
238 self.ensure_dirs()
239
240 if self._build_env_prepared:
241 return
242
243 # Work out where the Android SDK is
244 sdk_dir = None
245 if user_sdk_dir:
246 sdk_dir = user_sdk_dir
247 # This is the old P4A-specific var
248 if sdk_dir is None:
249 sdk_dir = environ.get('ANDROIDSDK', None)
250 # This seems used more conventionally
251 if sdk_dir is None:
252 sdk_dir = environ.get('ANDROID_HOME', None)
253 # Checks in the buildozer SDK dir, useful for debug tests of p4a
254 if sdk_dir is None:
255 possible_dirs = glob.glob(expanduser(join(
256 '~', '.buildozer', 'android', 'platform', 'android-sdk-*')))
257 possible_dirs = [d for d in possible_dirs if not
258 d.endswith(('.bz2', '.gz'))]
259 if possible_dirs:
260 info('Found possible SDK dirs in buildozer dir: {}'.format(
261 ', '.join(d.split(os.sep)[-1] for d in possible_dirs)))
262 info('Will attempt to use SDK at {}'.format(possible_dirs[0]))
263 warning('This SDK lookup is intended for debug only, if you '
264 'use python-for-android much you should probably '
265 'maintain your own SDK download.')
266 sdk_dir = possible_dirs[0]
267 if sdk_dir is None:
268 raise BuildInterruptingException('Android SDK dir was not specified, exiting.')
269 self.sdk_dir = realpath(sdk_dir)
270
271 # Check what Android API we're using
272 android_api = None
273 if user_android_api:
274 android_api = user_android_api
275 info('Getting Android API version from user argument: {}'.format(android_api))
276 elif 'ANDROIDAPI' in environ:
277 android_api = environ['ANDROIDAPI']
278 info('Found Android API target in $ANDROIDAPI: {}'.format(android_api))
279 else:
280 info('Android API target was not set manually, using '
281 'the default of {}'.format(RECOMMENDED_TARGET_API))
282 android_api = RECOMMENDED_TARGET_API
283 android_api = int(android_api)

Callers 4

test_sdk_ndk_pathsMethod · 0.95
wrapper_funcFunction · 0.80
sdk_toolsMethod · 0.80
_adbMethod · 0.80

Calls 8

ensure_dirsMethod · 0.95
check_target_apiFunction · 0.90
check_ndk_versionFunction · 0.90
check_ndk_apiFunction · 0.90
AndroidNDKClass · 0.90
get_available_apisFunction · 0.85
formatMethod · 0.80

Tested by 1

test_sdk_ndk_pathsMethod · 0.76