Skip to content

Commit d36cd9d

Browse files
committed
[lxml] recipe fix
This patch fixes the recipes from PR kivy#1166. levenshtein recipe has been removed has it's not used anywhere and its causing compilation troubles.
1 parent 8fae315 commit d36cd9d

File tree

4 files changed

+98
-72
lines changed

4 files changed

+98
-72
lines changed

pythonforandroid/recipes/levenshtein/__init__.py

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

pythonforandroid/recipes/libxml2/__init__.py

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,53 @@
22
from os.path import exists, join
33
import sh
44

5+
56
class Libxml2Recipe(Recipe):
6-
version = '2.7.8'
7-
url = 'http://xmlsoft.org/sources/libxml2-{version}.tar.gz'
7+
version = "2.7.8"
8+
url = "http://xmlsoft.org/sources/libxml2-{version}.tar.gz"
89
depends = []
9-
patches = ['add-glob.c.patch']
10+
patches = ["add-glob.c.patch"]
1011

1112
def should_build(self, arch):
1213
super(Libxml2Recipe, self).should_build(arch)
13-
return not exists(join(self.ctx.get_libs_dir(arch.arch), 'libxml2.a'))
14+
return not exists(join(self.ctx.get_libs_dir(arch.arch), "libxml2.a"))
1415

1516
def build_arch(self, arch):
1617
super(Libxml2Recipe, self).build_arch(arch)
1718
env = self.get_recipe_env(arch)
1819
with current_directory(self.get_build_dir(arch.arch)):
19-
env['CC'] += " -I%s" % self.get_build_dir(arch.arch)
20-
shprint(sh.Command('./configure'), '--host=arm-linux-eabi',
21-
'--without-modules', '--without-legacy', '--without-hfinistory', '--without-debug', '--without-docbook', '--without-python', '--without-threads', '--without-iconv',
22-
_env=env)
20+
env["CC"] += " -I%s" % self.get_build_dir(arch.arch)
21+
shprint(
22+
sh.Command("./configure"),
23+
"--host=arm-linux-eabi",
24+
"--without-modules",
25+
"--without-legacy",
26+
"--without-history",
27+
"--without-debug",
28+
"--without-docbook",
29+
"--without-python",
30+
"--without-threads",
31+
"--without-iconv",
32+
_env=env,
33+
)
2334

2435
# Ensure we only build libxml2.la as if we do everything
2536
# we'll need the glob dependency which is a big headache
2637
shprint(sh.make, "libxml2.la", _env=env)
27-
shutil.copyfile('.libs/libxml2.a', join(self.ctx.get_libs_dir(arch.arch), 'libxml2.a'))
28-
38+
shutil.copyfile(
39+
".libs/libxml2.a", join(self.ctx.get_libs_dir(arch.arch), "libxml2.a")
40+
)
2941

3042
def get_recipe_env(self, arch):
3143
env = super(Libxml2Recipe, self).get_recipe_env(arch)
32-
env['CONFIG_SHELL'] = '/bin/bash'
33-
env['SHELL'] = '/bin/bash'
34-
env['CC'] = '/usr/bin/ccache arm-linux-androideabi-gcc -DANDROID -mandroid -fomit-frame-pointer'
44+
env["CONFIG_SHELL"] = "/bin/bash"
45+
env["SHELL"] = "/bin/bash"
46+
env[
47+
"CC"
48+
] = "arm-linux-androideabi-gcc -DANDROID -mandroid -fomit-frame-pointer --sysroot={}".format(
49+
self.ctx.ndk_platform
50+
)
3551
return env
3652

53+
3754
recipe = Libxml2Recipe()
Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,64 @@
11
from pythonforandroid.toolchain import Recipe, shprint, shutil, current_directory
2-
from os.path import exists, join, dirname, basename
2+
from os.path import exists, join, dirname
33
import sh
44

5+
56
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']
7+
version = "1.1.28"
8+
url = "http://xmlsoft.org/sources/libxslt-{version}.tar.gz"
9+
depends = ["libxml2"]
10+
patches = ["fix-dlopen.patch"]
1011

1112
call_hostpython_via_targetpython = False
1213

1314
def should_build(self, arch):
1415
super(LibxsltRecipe, self).should_build(arch)
15-
return not exists(join(self.ctx.get_libs_dir(arch.arch), 'libxslt.a'))
16+
return not exists(join(self.ctx.get_libs_dir(arch.arch), "libxslt.a"))
1617

1718
def build_arch(self, arch):
1819
super(LibxsltRecipe, self).build_arch(arch)
1920
env = self.get_recipe_env(arch)
2021
with current_directory(self.get_build_dir(arch.arch)):
2122
# If the build is done with /bin/sh things blow up,
2223
# try really hard to use bash
23-
env['CC'] += " -I%s" % self.get_build_dir(arch.arch)
24-
libxml = dirname(dirname(self.get_build_container_dir(arch.arch))) + "/libxml2/%s/libxml2" % arch.arch
25-
shprint(sh.Command('./configure'),
26-
'--build=i686-pc-linux-gnu', '--host=arm-linux-eabi',
27-
'--without-plugins', '--without-debug', '--without-python', '--without-crypto',
28-
'--with-libxml-src=%s' % libxml,
29-
_env=env)
24+
env["CC"] += " -I%s" % self.get_build_dir(arch.arch)
25+
libxml = (
26+
dirname(dirname(self.get_build_container_dir(arch.arch)))
27+
+ "/libxml2/%s/libxml2" % arch.arch
28+
)
29+
shprint(
30+
sh.Command("./configure"),
31+
"--build=i686-pc-linux-gnu",
32+
"--host=arm-linux-eabi",
33+
"--without-plugins",
34+
"--without-debug",
35+
"--without-python",
36+
"--without-crypto",
37+
"--with-libxml-src=%s" % libxml,
38+
_env=env,
39+
)
3040
shprint(sh.make, "V=1", _env=env)
31-
shutil.copyfile('libxslt/.libs/libxslt.a', join(self.ctx.get_libs_dir(arch.arch), 'libxslt.a'))
32-
shutil.copyfile('libexslt/.libs/libexslt.a', join(self.ctx.get_libs_dir(arch.arch), 'libexslt.a'))
33-
41+
shutil.copyfile(
42+
"libxslt/.libs/libxslt.a",
43+
join(self.ctx.get_libs_dir(arch.arch), "libxslt.a"),
44+
)
45+
shutil.copyfile(
46+
"libexslt/.libs/libexslt.a",
47+
join(self.ctx.get_libs_dir(arch.arch), "libexslt.a"),
48+
)
3449

3550
def get_recipe_env(self, arch):
3651
env = super(LibxsltRecipe, self).get_recipe_env(arch)
37-
env['CONFIG_SHELL'] = '/bin/bash'
38-
env['SHELL'] = '/bin/bash'
39-
env['CC'] = '/usr/bin/ccache arm-linux-androideabi-gcc -DANDROID -mandroid -fomit-frame-pointer'
40-
env['LDSHARED'] = "%s -nostartfiles -shared -fPIC" % env['CC']
52+
env["CONFIG_SHELL"] = "/bin/bash"
53+
env["SHELL"] = "/bin/bash"
54+
env[
55+
"CC"
56+
] = "arm-linux-androideabi-gcc -DANDROID -mandroid -fomit-frame-pointer --sysroot={}".format(
57+
self.ctx.ndk_platform
58+
)
59+
60+
env["LDSHARED"] = "%s -nostartfiles -shared -fPIC" % env["CC"]
4161
return env
4262

63+
4364
recipe = LibxsltRecipe()
Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,45 @@
1-
from pythonforandroid.toolchain import Recipe, shprint, shutil, current_directory
2-
from pythonforandroid.toolchain import CompiledComponentsPythonRecipe
3-
from pythonforandroid.util import current_directory, ensure_dir
4-
from pythonforandroid.logger import debug, shprint, info
1+
from pythonforandroid.toolchain import Recipe, shutil
2+
from pythonforandroid.recipe import CompiledComponentsPythonRecipe
53
from os.path import exists, join, dirname
6-
import sh
7-
import glob
4+
85

96
class LXMLRecipe(CompiledComponentsPythonRecipe):
10-
version = '3.6.0'
11-
url = 'https://pypi.python.org/packages/source/l/lxml/lxml-{version}.tar.gz'
12-
depends = ['python2', 'libxml2', 'libxslt']
13-
name = 'lxml'
7+
version = "3.6.0"
8+
url = "https://pypi.python.org/packages/source/l/lxml/lxml-{version}.tar.gz"
9+
depends = ["python2", "libxml2", "libxslt"]
10+
name = "lxml"
1411

15-
call_hostpython_via_targetpython = False # Due to setuptools
12+
call_hostpython_via_targetpython = False # Due to setuptools
1613

1714
def should_build(self, arch):
1815
super(LXMLRecipe, self).should_build(arch)
1916
return True
20-
return not exists(join(self.ctx.get_libs_dir(arch.arch), 'etree.so'))
17+
return not exists(join(self.ctx.get_libs_dir(arch.arch), "etree.so"))
2118

2219
def build_arch(self, arch):
2320
super(LXMLRecipe, self).build_arch(arch)
24-
shutil.copyfile('%s/build/lib.linux-x86_64-2.7/lxml/etree.so' % self.get_build_dir(arch.arch), join(self.ctx.get_libs_dir(arch.arch), 'etree.so'))
25-
shutil.copyfile('%s/build/lib.linux-x86_64-2.7/lxml/objectify.so' % self.get_build_dir(arch.arch), join(self.ctx.get_libs_dir(arch.arch), 'objectify.so'))
21+
shutil.copyfile(
22+
"%s/build/lib.linux-x86_64-2.7/lxml/etree.so" % self.get_build_dir(arch.arch),
23+
join(self.ctx.get_libs_dir(arch.arch), "etree.so"),
24+
)
25+
shutil.copyfile(
26+
"%s/build/lib.linux-x86_64-2.7/lxml/objectify.so"
27+
% self.get_build_dir(arch.arch),
28+
join(self.ctx.get_libs_dir(arch.arch), "objectify.so"),
29+
)
2630

2731
def get_recipe_env(self, arch):
2832
env = super(LXMLRecipe, self).get_recipe_env(arch)
29-
libxslt_recipe = Recipe.get_recipe('libxslt', self.ctx)
30-
libxml2_recipe = Recipe.get_recipe('libxml2', self.ctx)
33+
libxslt_recipe = Recipe.get_recipe("libxslt", self.ctx).get_build_dir(arch.arch)
34+
libxml2_recipe = Recipe.get_recipe("libxml2", self.ctx).get_build_dir(arch.arch)
3135
targetpython = "%s/include/python2.7/" % dirname(dirname(self.ctx.hostpython))
32-
env['CC'] += " -I%s/include -I%s -I%s" % (libxml2_recipe, libxslt_recipe, targetpython)
33-
env['LDSHARED'] = '%s -nostartfiles -shared -fPIC -lpython2.7' % env['CC']
36+
env["CC"] += " -I%s/include -I%s -I%s" % (
37+
libxml2_recipe,
38+
libxslt_recipe,
39+
targetpython,
40+
)
41+
env["LDSHARED"] = "%s -nostartfiles -shared -fPIC -lpython2.7" % env["CC"]
3442
return env
3543

44+
3645
recipe = LXMLRecipe()

0 commit comments

Comments
 (0)