11from pythonforandroid .toolchain import Recipe , shutil
22from pythonforandroid .recipe import CompiledComponentsPythonRecipe
3- from os .path import exists , join , dirname
3+ from os .path import exists , join
4+ from os import listdir
45
56
67class LXMLRecipe (CompiledComponentsPythonRecipe ):
78 version = "3.6.0"
89 url = "https://pypi.python.org/packages/source/l/lxml/lxml-{version}.tar.gz"
9- depends = ["python2" , "libxml2" , "libxslt" ]
10+ depends = [( "python2" , "python3crystax" ) , "libxml2" , "libxslt" ]
1011 name = "lxml"
1112
1213 call_hostpython_via_targetpython = False # Due to setuptools
@@ -18,27 +19,39 @@ def should_build(self, arch):
1819
1920 def build_arch (self , arch ):
2021 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 ())
2138 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 ) ),
2340 join (self .ctx .get_libs_dir (arch .arch ), "etree.so" ),
2441 )
2542 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 )),
2844 join (self .ctx .get_libs_dir (arch .arch ), "objectify.so" ),
2945 )
3046
3147 def get_recipe_env (self , arch ):
3248 env = super (LXMLRecipe , self ).get_recipe_env (arch )
3349 libxslt_recipe = Recipe .get_recipe ("libxslt" , self .ctx ).get_build_dir (arch .arch )
3450 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 " % (
3752 libxml2_recipe ,
3853 libxslt_recipe ,
39- targetpython ,
4054 )
41- env ["LDSHARED" ] = "%s -nostartfiles -shared -fPIC -lpython2.7" % env ["CC" ]
4255 return env
4356
4457
0 commit comments