7
7
from os import environ
8
8
import glob
9
9
import sh
10
+ from shutil import copy2
10
11
11
12
from pythonforandroid .recipe import Recipe , TargetPythonRecipe
12
13
from pythonforandroid .logger import logger , info , error , shprint
@@ -344,16 +345,19 @@ def create_python_bundle(self, dirn, arch):
344
345
'2' if self .version [0 ] == '2' else '' ,
345
346
self .major_minor_version_string
346
347
))
347
- module_filens = (glob .glob (join (modules_build_dir , '*.so' )) +
348
+ module_filens = list (glob .glob (join (modules_build_dir , '*.so' )) +
348
349
glob .glob (join (modules_build_dir , '*.py' )))
350
+ info ("Copy {} files into the bundle" .format (len (module_filens )))
349
351
for filen in module_filens :
350
- shprint (sh .cp , filen , modules_dir )
352
+ info (" - copy {}" .format (filen ))
353
+ copy2 (filen , modules_dir )
351
354
352
355
# zip up the standard library
353
356
stdlib_zip = join (dirn , 'stdlib.zip' )
354
357
with current_directory (join (self .get_build_dir (arch .arch ), 'Lib' )):
355
- stdlib_filens = walk_valid_filens (
356
- '.' , self .stdlib_dir_blacklist , self .stdlib_filen_blacklist )
358
+ stdlib_filens = list (walk_valid_filens (
359
+ '.' , self .stdlib_dir_blacklist , self .stdlib_filen_blacklist ))
360
+ info ("Zip {} files into the bundle" .format (len (stdlib_filens )))
357
361
shprint (sh .zip , stdlib_zip , * stdlib_filens )
358
362
359
363
# copy the site-packages into place
@@ -364,9 +368,11 @@ def create_python_bundle(self, dirn, arch):
364
368
filens = list (walk_valid_filens (
365
369
'.' , self .site_packages_dir_blacklist ,
366
370
self .site_packages_filen_blacklist ))
371
+ info ("Copy {} files into the site-packages" .format (len (filens )))
367
372
for filen in filens :
373
+ info (" - copy {}" .format (filen ))
368
374
ensure_dir (join (dirn , 'site-packages' , dirname (filen )))
369
- sh . cp (filen , join (dirn , 'site-packages' , filen ))
375
+ copy2 (filen , join (dirn , 'site-packages' , filen ))
370
376
371
377
# copy the python .so files into place
372
378
python_build_dir = join (self .get_build_dir (arch .arch ),
@@ -375,8 +381,9 @@ def create_python_bundle(self, dirn, arch):
375
381
if self .major_minor_version_string [0 ] == '3' :
376
382
python_lib_name += 'm'
377
383
for lib in [python_lib_name + '.so' , python_lib_name + '.so.1.0' ]:
378
- shprint (sh .cp , join (python_build_dir , lib ),
379
- 'libs/{}' .format (arch .arch ))
384
+ filename = join (python_build_dir , lib )
385
+ if exists (filename ):
386
+ shprint (sh .cp , filename , 'libs/{}' .format (arch .arch ))
380
387
381
388
info ('Renaming .so files to reflect cross-compile' )
382
389
self .reduce_object_file_names (join (dirn , 'site-packages' ))
0 commit comments