1
1
from pythonforandroid .toolchain import Recipe , shutil
2
2
from pythonforandroid .recipe import CompiledComponentsPythonRecipe
3
- from os .path import exists , join , dirname
3
+ from os .path import exists , join
4
+ from os import listdir
4
5
5
6
6
7
class LXMLRecipe (CompiledComponentsPythonRecipe ):
7
8
version = "3.6.0"
8
9
url = "https://pypi.python.org/packages/source/l/lxml/lxml-{version}.tar.gz"
9
- depends = ["python2" , "libxml2" , "libxslt" ]
10
+ depends = [( "python2" , "python3crystax" ) , "libxml2" , "libxslt" ]
10
11
name = "lxml"
11
12
12
13
call_hostpython_via_targetpython = False # Due to setuptools
@@ -18,27 +19,39 @@ def should_build(self, arch):
18
19
19
20
def build_arch (self , arch ):
20
21
super (LXMLRecipe , self ).build_arch (arch )
22
+
23
+ def get_lib_build_dir_name ():
24
+ for f in listdir (join (self .get_build_dir (arch .arch ), "build" )):
25
+ if f .startswith ("lib.linux-x86_64" ):
26
+ return f
27
+ return None
28
+
29
+ def get_so_name (so_target , dirpath ):
30
+ for f in listdir (dirpath ):
31
+ if f .startswith (so_target .partition ("." )[0 ] + "." ) and \
32
+ f .endswith (".so" ):
33
+ return join (dirpath , f )
34
+ return None
35
+
36
+ so_origin_dir = "%s/build/%s/lxml/" % (self .get_build_dir (arch .arch ),
37
+ get_lib_build_dir_name ())
21
38
shutil .copyfile (
22
- "%s/build/lib.linux-x86_64-2.7/lxml/ etree.so" % self . get_build_dir ( arch . arch ),
39
+ join ( so_origin_dir , get_so_name ( " etree.so", so_origin_dir ) ),
23
40
join (self .ctx .get_libs_dir (arch .arch ), "etree.so" ),
24
41
)
25
42
shutil .copyfile (
26
- "%s/build/lib.linux-x86_64-2.7/lxml/objectify.so"
27
- % self .get_build_dir (arch .arch ),
43
+ join (so_origin_dir , get_so_name ("objectify.so" , so_origin_dir )),
28
44
join (self .ctx .get_libs_dir (arch .arch ), "objectify.so" ),
29
45
)
30
46
31
47
def get_recipe_env (self , arch ):
32
48
env = super (LXMLRecipe , self ).get_recipe_env (arch )
33
49
libxslt_recipe = Recipe .get_recipe ("libxslt" , self .ctx ).get_build_dir (arch .arch )
34
50
libxml2_recipe = Recipe .get_recipe ("libxml2" , self .ctx ).get_build_dir (arch .arch )
35
- targetpython = "%s/include/python2.7/" % dirname (dirname (self .ctx .hostpython ))
36
- env ["CC" ] += " -I%s/include -I%s -I%s" % (
51
+ env ["CC" ] += " -I%s/include -I%s " % (
37
52
libxml2_recipe ,
38
53
libxslt_recipe ,
39
- targetpython ,
40
54
)
41
- env ["LDSHARED" ] = "%s -nostartfiles -shared -fPIC -lpython2.7" % env ["CC" ]
42
55
return env
43
56
44
57
0 commit comments