8000 Add recipes for libgeos, pyproj, and shapely · suriyan/python-for-android@296ed00 · GitHub
[go: up one dir, main page]

Skip to content

Commit 296ed00

Browse files
author
frmdstryr
committed
Add recipes for libgeos, pyproj, and shapely
1 parent 83c1fbf commit 296ed00

File tree

4 files changed

+91
-0
lines changed

4 files changed

+91
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
from pythonforandroid.toolchain import Recipe, shprint, shutil, current_directory
2+
from pythonforandroid.util import ensure_dir
3+
from os.path import exists, join, abspath
4+
import sh
5+
from multiprocessing import cpu_count
6+
7+
class LibgeosRecipe(Recipe):
8+
version = '3.5'
9+
#url = 'http://download.osgeo.org/geos/geos-{version}.tar.bz2'
10+
url = 'https://github.com/libgeos/libgeos/archive/svn-{version}.zip'
11+
depends = ['python2']
12+
13+
def should_build(self, arch):
14+
super(LibgeosRecipe, self).should_build(arch)
15+
return not exists(join(self.ctx.get_libs_dir(arch.arch), 'libgeos_c.so'))
16+
17+
def build_arch(self, arch):
18+
super(LibgeosRecipe, self).build_arch(arch)
19+
env = self.get_recipe_env(arch)
20+
21+
with current_directory(self.get_build_dir(arch.arch)):
22+
dst_dir = join(self.get_build_dir(arch.arch),'dist')
23+
bash = sh.Command('bash')
24+
print("If this fails make sure you have autoconf and libtool installed")
25+
shprint(bash,'autogen.sh') # Requires autoconf and libtool
26+
shprint(bash, 'configure', '--host=arm-linux-androideabi', '--enable-shared','--prefix={}'.format(dst_dir), _env=env)
27+
shprint(sh.make,'-j',str(cpu_count()),_env=env)
28+
shprint(sh.make,'install',_env=env)
29+
shutil.copyfile('{}/lib/libgeos_c.so'.format(dst_dir), join(self.ctx.get_libs_dir(arch.arch), 'libgeos_c.so'))
30+
31+
def get_recipe_env(self, arch):
32+
env = super(LibgeosRecipe, self).get_recipe_env(arch)
33+
env['CXXFLAGS'] += ' -I{}/sources/cxx-stl/gnu-libstdc++/4.8/include'.format(self.ctx.ndk_dir)
34+
env['CXXFLAGS'] += ' -I{}/sources/cxx-stl/gnu-libstdc++/4.8/libs/{}/include'.format(
35+
self.ctx.ndk_dir, arch)
36+
env['CXXFLAGS'] += ' -L{}/sources/cxx-stl/gnu-libstdc++/4.8/libs/{}'.format(
37+
self.ctx.ndk_dir, arch)
38+
env['CXXFLAGS'] += ' -lgnustl_shared'
39+
env['LDFLAGS'] += ' -L{}/sources/cxx-stl/gnu-libstdc++/4.8/libs/{}'.format(
40+
self.ctx.ndk_dir, arch)
41+
return env
42+
43+
recipe = LibgeosRecipe()
44+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from pythonforandroid.recipe import CythonRecipe
2+
3+
4+
class PyProjRecipe(CythonRecipe):
5+
version = '1.9.5.1'
6+
url = 'https://github.com/jswhit/pyproj/archive/master.zip'
7+
depends = ['python2', 'setuptools']
8+
call_hostpython_via_targetpython = False
9+
10+
11+
recipe = PyProjRecipe()
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from pythonforandroid.recipe import Recipe,CythonRecipe
2+
3+
4+
class ShapelyRecipe(CythonRecipe):
5+
version = '1.5'
6+
url = 'https://github.com/Toblerity/Shapely/archive/master.zip'
7+
depends = ['python2', 'setuptools', 'libgeos']
8+
call_hostpython_via_targetpython = False
9+
10+
patches = ['setup.patch'] # Patch to force setup to fail when C extention fails to build
11+
12+
# setup_extra_args = ['sdist'] # DontForce Cython
13+
14+
def get_recipe_env(self, arch, with_flags_in_cc=True):
15+
""" Add libgeos headers to path """
16+
env = super(ShapelyRecipe, self).get_recipe_env(arch,with_flags_in_cc)
17+
libgeos_dir = Recipe.get_recipe('libgeos', self.ctx).get_build_dir(arch.arch)
18+
env['CFLAGS'] += " -I{}/dist/include".format(libgeos_dir)
19+
return env
20+
21+
22+
23+
recipe = ShapelyRecipe()
24+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
*** shapely/setup.py 2016-06-29 11:29:49.000000000 -0400
2+
--- b/setup.py 2016-07-09 01:51:37.759670990 -0400
3+
***************
4+
*** 359,364 ****
5+
--- 359,365 ----
6+
construct_build_ext(existing_build_ext)
7+
setup(ext_modules=ext_modules, **setup_args)
8+
except BuildFailed as ex:
9+
+ raise # Force python only build to fail
10+
BUILD_EXT_WARNING = "The C extension could not be compiled, " \
11+
"speedups are not enabled."
12+
log.warn(ex)

0 commit comments

Comments
 (0)
0