Skip to content

Commit 461545b

Browse files
titoopacam
authored andcommitted
speedup copy that can be very very long (up to 2 minutes)
This is now almost instant (1/2s.)
1 parent 21bc8b8 commit 461545b

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

pythonforandroid/python.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
'''
55

66
from os.path import dirname, exists, join
7+
from shutil import copy2
78
from os import environ
89
import glob
910
import sh
@@ -266,16 +267,19 @@ def create_python_bundle(self, dirn, arch):
266267
'2' if self.version[0] == '2' else '',
267268
self.major_minor_version_string
268269
))
269-
module_filens = (glob.glob(join(modules_build_dir, '*.so')) +
270-
glob.glob(join(modules_build_dir, '*.py')))
270+
module_filens = list(glob.glob(join(modules_build_dir, '*.so')) +
271+
glob.glob(join(modules_build_dir, '*.py')))
272+
info("Copy {} files into the bundle".format(len(module_filens)))
271273
for filen in module_filens:
272-
shprint(sh.cp, filen, modules_dir)
274+
info(" - copy {}".format(filen))
275+
copy2(filen, modules_dir)
273276

274277
# zip up the standard library
275278
stdlib_zip = join(dirn, 'stdlib.zip')
276279
with current_directory(join(self.get_build_dir(arch.arch), 'Lib')):
277-
stdlib_filens = walk_valid_filens(
278-
'.', self.stdlib_dir_blacklist, self.stdlib_filen_blacklist)
280+
stdlib_filens = list(walk_valid_filens(
281+
'.', self.stdlib_dir_blacklist, self.stdlib_filen_blacklist))
282+
info("Zip {} files into the bundle".format(len(stdlib_filens)))
279283
shprint(sh.zip, stdlib_zip, *stdlib_filens)
280284

281285
# copy the site-packages into place
@@ -286,9 +290,11 @@ def create_python_bundle(self, dirn, arch):
286290
filens = list(walk_valid_filens(
287291
'.', self.site_packages_dir_blacklist,
288292
self.site_packages_filen_blacklist))
293+
info("Copy {} files into the site-packages".format(len(filens)))
289294
for filen in filens:
295+
info(" - copy {}".format(filen))
290296
ensure_dir(join(dirn, 'site-packages', dirname(filen)))
291-
sh.cp(filen, join(dirn, 'site-packages', filen))
297+
copy2(filen, join(dirn, 'site-packages', filen))
292298

293299
# copy the python .so files into place
294300
python_build_dir = join(self.get_build_dir(arch.arch),

0 commit comments

Comments
 (0)