Skip to content

Commit 8ce9207

Browse files
committed
Adapt webview's bootstrap to new python/gradle build system and enables some missing features (aars)
Note: Some files has been removed because we will use the generic ones of bootstraps/common
1 parent 044568b commit 8ce9207

File tree

12 files changed

+131
-450
lines changed

12 files changed

+131
-450
lines changed

pythonforandroid/bootstraps/webview/__init__.py

Lines changed: 9 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from pythonforandroid.toolchain import Bootstrap, current_directory, info, info_main, shprint
2-
from os.path import join, exists, curdir, abspath
3-
from os import walk
4-
import glob
2+
from pythonforandroid.util import ensure_dir
3+
from os.path import join
54
import sh
65

76

@@ -28,88 +27,18 @@ def run_distribute(self):
2827
with current_directory(self.dist_dir):
2928
info('Copying python distribution')
3029

31-
if not exists('private') and not self.ctx.python_recipe.from_crystax:
32-
shprint(sh.mkdir, 'private')
33-
if not exists('crystax_python') and self.ctx.python_recipe.from_crystax:
34-
shprint(sh.mkdir, 'crystax_python')
35-
shprint(sh.mkdir, 'crystax_python/crystax_python')
36-
if not exists('assets'):
37-
shprint(sh.mkdir, 'assets')
38-
39-
hostpython = sh.Command(self.ctx.hostpython)
40-
if not self.ctx.python_recipe.from_crystax:
41-
try:
42-
shprint(hostpython, '-OO', '-m', 'compileall',
43-
self.ctx.get_python_install_dir(),
44-
_tail=10, _filterout="^Listing")
45-
except sh.ErrorReturnCode:
46-
pass
47-
if not exists('python-install'):
48-
shprint(sh.cp, '-a', self.ctx.get_python_install_dir(), './python-install')
49-
5030
self.distribute_libs(arch, [self.ctx.get_libs_dir(arch.arch)])
5131
self.distribute_aars(arch)
5232
self.distribute_javaclasses(self.ctx.javaclass_dir)
5333

54-
if not self.ctx.python_recipe.from_crystax:
55-
info('Filling private directory')
56-
if not exists(join('private', 'lib')):
57-
info('private/lib does not exist, making')
58-
shprint(sh.cp, '-a', join('python-install', 'lib'), 'private')
59-
shprint(sh.mkdir, '-p', join('private', 'include', 'python2.7'))
60-
61-
if exists(join('libs', arch.arch, 'libpymodules.so')):
62-
shprint(sh.mv, join('libs', arch.arch, 'libpymodules.so'), 'private/')
63-
shprint(sh.cp, join('python-install', 'include', 'python2.7', 'pyconfig.h'), join('private', 'include', 'python2.7/'))
64-
65-
info('Removing some unwanted files')
66-
shprint(sh.rm, '-f', join('private', 'lib', 'libpython2.7.so'))
67-
shprint(sh.rm, '-rf', join('private', 'lib', 'pkgconfig'))
68-
69-
libdir = join(self.dist_dir, 'private', 'lib', 'python2.7')
70-
site_packages_dir = join(libdir, 'site-packages')
71-
with current_directory(libdir):
72-
# shprint(sh.xargs, 'rm', sh.grep('-E', '*\.(py|pyx|so\.o|so\.a|so\.libs)$', sh.find('.')))
73-
removes = []
74-
for dirname, something, filens in walk('.'):
75-
for filename in filens:
76-
for suffix in ('py', 'pyc', 'so.o', 'so.a', 'so.libs'):
77-
if filename.endswith(suffix):
78-
removes.append(filename)
79-
shprint(sh.rm, '-f', *removes)
80-
81-
info('Deleting some other stuff not used on android')
82-
# To quote the original distribute.sh, 'well...'
83-
# shprint(sh.rm, '-rf', 'ctypes')
84-
shprint(sh.rm, '-rf', 'lib2to3')
85-
shprint(sh.rm, '-rf', 'idlelib')
86-
for filename in glob.glob('config/libpython*.a'):
87-
shprint(sh.rm, '-f', filename)
88-
shprint(sh.rm, '-rf', 'config/python.o')
89-
# shprint(sh.rm, '-rf', 'lib-dynload/_ctypes_test.so')
90-
# shprint(sh.rm, '-rf', 'lib-dynload/_testcapi.so')
91-
92-
else: # Python *is* loaded from crystax
93-
ndk_dir = self.ctx.ndk_dir
94-
py_recipe = self.ctx.python_recipe
95-
python_dir = join(ndk_dir, 'sources', 'python', py_recipe.version,
96-
'libs', arch.arch)
97-
98-
shprint(sh.cp, '-r', join(python_dir, 'stdlib.zip'), 'crystax_python/crystax_python')
99-
shprint(sh.cp, '-r', join(python_dir, 'modules'), 'crystax_python/crystax_python')
100-
shprint(sh.cp, '-r', self.ctx.get_python_install_dir(), 'crystax_python/crystax_python/site-packages')
34+
python_bundle_dir = join('_python_bundle', '_python_bundle')
35+
ensure_dir(python_bundle_dir)
36+
site_packages_dir = self.ctx.python_recipe.create_python_bundle(
37+
join(self.dist_dir, python_bundle_dir), arch)
10138

102-
info('Renaming .so files to reflect cross-compile')
103-
site_packages_dir = 'crystax_python/crystax_python/site-packages'
104-
filens = shprint(sh.find, site_packages_dir, '-iname', '*.so').stdout.decode(
105-
'utf-8').split('\n')[:-1]
106-
for filen in filens:
107-
parts = filen.split('.')
108-
if len(parts) <= 2:
109-
continue
110-
shprint(sh.mv, filen, filen.split('.')[0] + '.so')
111-
site_packages_dir = join(abspath(curdir),
112-
site_packages_dir)
39+
if 'sqlite3' not in self.ctx.recipe_build_order:
40+
with open('blacklist.txt', 'a') as fileh:
41+
fileh.write('\nsqlite3/*\nlib-dynload/_sqlite3.so\n')
11342

11443
self.strip_libraries(arch)
11544
self.fry_eggs(site_packages_dir)

pythonforandroid/bootstraps/webview/build/ant.properties

Lines changed: 0 additions & 18 deletions
This file was deleted.

pythonforandroid/bootstraps/webview/build/build.properties

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)