8000 Work on lxml · gruns/python-for-android@93f7384 · GitHub
[go: up one dir, main page]

Skip to content

Commit 93f7384

Browse files
committed
Work on lxml
1 parent 1ac0abc commit 93f7384

File tree

4 files changed

+124
-0
lines changed

4 files changed

+124
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
from pythonforandroid.toolchain import Recipe, shprint, shutil, current_directory
2+
from os.path import exists, join
3+
import sh
4+
5+
class Libxml2Recipe(Recipe):
6+
version = '2.7.8'
7+
url = 'http://xmlsoft.org/sources/libxml2-{version}.tar.gz'
8+
depends = []
9+
10+
def should_build(self, arch):
11+
super(Libxml2Recipe, self).should_build(arch)
12+
return not exists(join(self.ctx.get_libs_dir(arch.arch), 'libxml2.a'))
13+
14+
def build_arch(self, arch):
15+
super(Libxml2Recipe, self).build_arch(arch)
16+
env = self.get_recipe_env(arch)
17+
with current_directory(self.get_build_dir(arch.arch)):
18+
# If the build is done with /bin/sh things blow up,
19+
# try really hard to use bash
20+
bash = sh.Command('/bin/bash')
21+
sed = sh.Command('sed')
22+
make = sh.Command('make')
23+
shprint(bash, 'configure', '--build=i686-pc-linux-gnu', '--host=arm-linux-eabi',
24+
'--without-modules', '--without-legacy', '--without-history', '--without-debug', '--without-docbook', '--without-python', '--without-threads')
25+
shprint(make, _env=env)
26+
shutil.copyfile('.libs/libxml2.a', join(self.ctx.get_libs_dir(arch.arch), 'libxml2.a'))
27+
28+
29+
def get_recipe_env(self, arch):
30+
env = super(Libxml2Recipe, self).get_recipe_env(arch)
31+
env['CONFIG_SHELL'] = '/bin/bash'
32+
env['SHELL'] = '/bin/bash'
33+
return env
34+
35+
recipe = Libxml2Recipe()
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from pythonforandroid.toolchain import Recipe, shprint, shutil, current_directory
2+
from os.path import exists, join
3+
import sh
4+
5+
class LibxsltRecipe(Recipe):
6+
version = '1.1.28'
7+
url = 'http://xmlsoft.org/sources/libxslt-{version}.tar.gz'
8+
depends = ['libxml2']
9+
patches = ['fix-dlopen.patch']
10+
11+
def should_build(self, arch):
12+
super(LibxsltRecipe, self).should_build(arch)
13+
return not exists(join(self.ctx.get_libs_dir(arch.arch), 'libxslt.a'))
14+
15+
def build_arch(self, arch):
16+
super(LibxsltRecipe, self).build_arch(arch)
17+
env = self.get_recipe_env(arch)
18+
with current_directory(self.get_build_dir(arch.arch)):
19+
bash = sh.Command('bash')
20+
shprint(bash, 'configure',
21+
'--build=i686-pc-linux-gnu', '--host=arm-linux-eabi',
22+
'--without-plugins', '--without-debug', '--without-python', '--without-crypto',
23+
'--with-libxml-src=$BUILD_libxml2')
24+
shprint(sh.make, _env=env)
25+
shutil.copyfile('src/libxslt/.libs/libxslt.a', join(self.ctx.get_libs_dir(arch.arch), 'libxslt.a'))
26+
27+
28+
def get_recipe_env(self, arch):
29+
env = super(LibXml2Recipe, self).get_recipe_env(arch)
30+
env['CFLAGS'] += ' -Os'
31+
return env
32+
33+
recipe = LibxsltRecipe()
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--- libxslt-1.1.27.orig/python/libxsl.py 2012-09-04 16:26:23.000000000 +0200
2+
+++ libxslt-1.1.27/python/libxsl.py 2013-07-29 15:11:04.182227378 +0200
3+
@@ -4,7 +4,7 @@
4+
# loader to work in that mode if feasible
5+
#
6+
import sys
7+
-if not hasattr(sys,'getdlopenflags'):
8+
+if True:
9+
import libxml2mod
10+
import libxsltmod
11+
import libxml2
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
from pythonforandroid.toolchain import Recipe, shprint, shutil, current_directory
2+
from os.path import exists, join
3+
import sh
4+
5+
class LXMLRecipe(Recipe):
6+
version = '3.6.0'
7+
url = 'https://pypi.python.org/packages/source/l/lxml/lxml-{version}.tar.gz'
8+
depends = ['python2', 'libxml2', 'libxslt']
9+
10+
def should_build(self, arch):
11+
super(LXMLRecipe, self).should_build(arch)
12+
return not exists(join(self.ctx.get_libs_dir(arch.arch), 'liblxml.so'))
13+
14+
def build_arch(self, arch):
15+
super(LXMLRecipe, self).build_arch(arch)
16+
env = self.get_recipe_env(arch)
17+
with current_directory(self.get_build_dir(arch.arch)):
18+
#chmod +x $BUILD_libxslt/xslt-config
19+
bash = sh.Command('bash')
20+
shprint(bash, 'configure', '--enable-minimal', '--disable-soname-versions', '--host=arm-linux-androideabi', '--enable-shared', _env=env)
21+
shprint(sh.make, _env=env)
22+
shutil.copyfile('src/liblxml/.libs/libsodium.so', join(self.ctx.get_libs_dir(arch.arch), 'libsodium.so'))
23+
24+
25+
""" try $HOSTPYTHON setup.py build_ext -I$BUILD_libxml2/include -I$BUILD_libxslt
26+
try find . -iname '*.pyx' -exec $CYTHON {} \;
27+
try $HOSTPYTHON setup.py build_ext -v
28+
try find build/lib.* -name "*.o" -exec $STRIP {} \;
29+
30+
export PYTHONPATH=$BUILD_hostpython/Lib/site-packages
31+
try $BUILD_hostpython/hostpython setup.py install -O2 --root=$BUILD_PATH/python-install --install-lib=lib/python2.7/site-packages
32+
33+
unset LDSHARED
34+
pop_arm"""
35+
36+
def get_recipe_env(self, arch):
37+
env = super(LibsodiumRecipe, self).get_recipe_env(arch)
38+
env['CC'] += "-I$BUILD_libxml2/include -I$BUILD_libxslt"
39+
env['LDFLAGS'] = "-L$BUILD_libxslt/libxslt/.libs -L$BUILD_libxslt/libexslt/.libs -L$BUILD_libxml2/.libs -L$BUILD_libxslt/libxslt -L$BUILD_libxslt/libexslt -L$BUILD_libxml2/ " + env['LDFLAGS']
40+
env['LDSHARED'] = "$LIBLINK"
41+
env['PATH'] += ":$BUILD_libxslt"
42+
env['CFLAGS'] += ' -Os'
43+
return env
44+
45+
recipe = LXMLRecipe()

0 commit comments

Comments
 (0)
0