2222
2323import argparse
2424import sh
25-
25+ from appdirs import user_data_dir
2626
2727from pythonforandroid .recipe import (Recipe , PythonRecipe , CythonRecipe ,
2828 CompiledComponentsPythonRecipe ,
@@ -93,7 +93,8 @@ def require_prebuilt_dist(func):
9393 def wrapper_func (self , args ):
9494 ctx = self .ctx
9595 ctx .set_archs (self ._archs )
96- ctx .prepare_build_environment (user_sdk_dir = self .sdk_dir ,
96+ ctx .prepare_build_environment (storage_dir = self .storage_dir ,
97+ user_sdk_dir = self .sdk_dir ,
9798 user_ndk_dir = self .ndk_dir ,
9899 user_android_api = self .android_api ,
99100 user_ndk_ver = self .ndk_version )
@@ -206,18 +207,23 @@ def __init__(self):
206207 '--debug' , dest = 'debug' , action = 'store_true' ,
207208 help = 'Display debug output and all build info' )
208209 parser .add_argument (
209- '--sdk_dir' , dest = 'sdk_dir' , default = '' ,
210+ '--sdk-dir' , '-- sdk_dir' , dest = 'sdk_dir' , default = '' ,
210211 help = 'The filepath where the Android SDK is installed' )
211212 parser .add_argument (
212- '--ndk_dir' , dest = 'ndk_dir' , default = '' ,
213+ '--ndk-dir' , '-- ndk_dir' , dest = 'ndk_dir' , default = '' ,
213214 help = 'The filepath where the Android NDK is installed' )
214215 parser .add_argument (
215- '--android_api' , dest = 'android_api' , default = 0 , type = int ,
216+ '--android-api' , '-- android_api' , dest = 'android_api' , default = 0 , type = int ,
216217 help = 'The Android API level to build against.' )
217218 parser .add_argument (
218- '--ndk_version' , dest = 'ndk_version' , default = '' ,
219+ '--ndk-version' , '-- ndk_version' , dest = 'ndk_version' , default = '' ,
219220 help = ('The version of the Android NDK. This is optional, '
220221 'we try to work it out automatically from the ndk_dir.' ))
222+ parser .add_argument (
223+ '--storage-dir' , dest = 'storage_dir' ,
224+ default = self .default_storage_dir ,
225+ help = ('Primary storage directory for downloads and builds '
226+ '(default: {})' .format (self .default_storage_dir )))
221227
222228 # AND: This option doesn't really fit in the other categories, the
223229 # arg structure needs a rethink
@@ -228,7 +234,7 @@ def __init__(self):
228234
229235 # Options for specifying the Distribution
230236 parser .add_argument (
231- '--dist_name' ,
237+ '--dist-name' , '-- dist_name' ,
232238 help = 'The name of the distribution to use or create' ,
233239 default = '' )
234240 parser .add_argument (
@@ -291,6 +297,7 @@ def __init__(self):
291297
292298 if args .debug :
293299 logger .setLevel (logging .DEBUG )
300+ self .storage_dir = args .storage_dir
294301 self .sdk_dir = args .sdk_dir
295302 self .ndk_dir = args .ndk_dir
296303 self .android_api = args .android_api
@@ -322,6 +329,13 @@ def __init__(self):
322329
323330 getattr (self , args .command )(unknown )
324331
332+ @property
333+ def default_storage_dir (self ):
334+ udd = user_data_dir ('python-for-android' )
335+ if ' ' in udd :
336+ udd = '~/.python-for-android'
337+ return udd
338+
325339 def _read_configuration (self ):
326340 # search for a .p4a configuration file in the current directory
327341 if not exists (".p4a" ):
0 commit comments