@@ -86,17 +86,10 @@ def get_bootstrap_name():
86
86
environment = jinja2 .Environment (loader = jinja2 .FileSystemLoader (
87
87
join (curdir , 'templates' )))
88
88
89
-
90
- def try_unlink (fn ):
91
- if exists (fn ):
92
- os .unlink (fn )
93
-
94
-
95
89
def ensure_dir (path ):
96
90
if not exists (path ):
97
91
makedirs (path )
98
92
99
-
100
93
def render (template , dest , ** kwargs ):
101
94
'''Using jinja2, render `template` to the filename `dest`, supplying the
102
95
@@ -239,10 +232,8 @@ def make_package(args):
239
232
assets_dir = "src/main/assets"
240
233
241
234
# Delete the old assets.
242
- if os .path .exists (assets_dir ):
243
- shutil .rmtree (assets_dir )
235
+ shutil .rmtree (assets_dir , ignore_errors = True )
244
236
ensure_dir (assets_dir )
245
- open (os .path .join (assets_dir , ".gitkeep" ), 'a' ).close ()
246
237
247
238
# Add extra environment variable file into tar-able directory:
248
239
env_vars_tarpath = tempfile .mkdtemp (prefix = "p4a-extra-env-" )
@@ -305,14 +296,14 @@ def make_package(args):
305
296
tar_dirs .append (python_bundle_dir )
306
297
if get_bootstrap_name () == "webview" :
307
298
tar_dirs .append ('webview_includes' )
308
- if hasattr ( args , "assets" ) and args . assets is not None :
309
- for asset in args .assets :
310
- asset_src , asset_dest = asset .split (":" )
311
- if isfile (realpath (asset_src )):
312
- ensure_dir (dirname (join (assets_dir , asset_dest )))
313
- shutil .copy (realpath (asset_src ), join (assets_dir , asset_dest ))
314
- else :
315
- shutil .copytree (realpath (asset_src ), join (assets_dir , asset_dest ))
299
+
300
+ for asset in args .assets :
301
+ asset_src , asset_dest = asset .split (":" )
302
+ if isfile (realpath (asset_src )):
303
+ ensure_dir (dirname (join (assets_dir , asset_dest )))
304
+ shutil .copy (realpath (asset_src ), join (assets_dir , asset_dest ))
305
+ else :
306
+ shutil .copytree (realpath (asset_src ), join (assets_dir , asset_dest ))
316
307
317
308
if args .private or args .launcher :
318
309
make_tar (
@@ -609,8 +600,9 @@ def parse_args_and_make_package(args=None):
609
600
ap .add_argument ('--uses-library' , dest = 'android_used_libs' , action = 'append' , default = [],
610
601
help = 'Used shared libraries included using <uses-library> tag in AndroidManifest.xml' )
611
602
ap .add_argument ('--asset' , dest = 'assets' ,
612
- action = "append" ,
613
- help = ('Put this in the assets folder' ))
603
+ action = "append" , default = [],
604
+ metavar = "/path/to/source:dest"
605
+ help = 'Put this in the assets folder at assets/dest' )
614
606
ap .add_argument ('--icon' , dest = 'icon' ,
615
607
help = ('A png file to use as the icon for '
616
608
'the application.' ))
0 commit comments