Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions pythonforandroid/recipes/libgeos/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from pythonforandroid.toolchain import Recipe, shprint, shutil, current_directory
from pythonforandroid.util import ensure_dir
from os.path import exists, join, abspath
import sh
from multiprocessing import cpu_count

class LibgeosRecipe(Recipe):
version = '3.5'
#url = 'http://download.osgeo.org/geos/geos-{version}.tar.bz2'
url = 'https://github.com/libgeos/libgeos/archive/svn-{version}.zip'
depends = ['python2']

def should_build(self, arch):
super(LibgeosRecipe, self).should_build(arch)
return not exists(join(self.ctx.get_libs_dir(arch.arch), 'libgeos_c.so'))

def build_arch(self, arch):
super(LibgeosRecipe, self).build_arch(arch)
env = self.get_recipe_env(arch)

with current_directory(self.get_build_dir(arch.arch)):
dst_dir = join(self.get_build_dir(arch.arch),'dist')
bash = sh.Command('bash')
print("If this fails make sure you have autoconf and libtool installed")
shprint(bash,'autogen.sh') # Requires autoconf and libtool
shprint(bash, 'configure', '--host=arm-linux-androideabi', '--enable-shared','--prefix={}'.format(dst_dir), _env=env)
shprint(sh.make,'-j',str(cpu_count()),_env=env)
shprint(sh.make,'install',_env=env)
shutil.copyfile('{}/lib/libgeos_c.so'.format(dst_dir), join(self.ctx.get_libs_dir(arch.arch), 'libgeos_c.so'))

def get_recipe_env(self, arch):
env = super(LibgeosRecipe, self).get_recipe_env(arch)
env['CXXFLAGS'] += ' -I{}/sources/cxx-stl/gnu-libstdc++/4.8/include'.format(self.ctx.ndk_dir)
env['CXXFLAGS'] += ' -I{}/sources/cxx-stl/gnu-libstdc++/4.8/libs/{}/include'.format(
self.ctx.ndk_dir, arch)
env['CXXFLAGS'] += ' -L{}/sources/cxx-stl/gnu-libstdc++/4.8/libs/{}'.format(
self.ctx.ndk_dir, arch)
env['CXXFLAGS'] += ' -lgnustl_shared'
env['LDFLAGS'] += ' -L{}/sources/cxx-stl/gnu-libstdc++/4.8/libs/{}'.format(
self.ctx.ndk_dir, arch)
return env

recipe = LibgeosRecipe()

11 changes: 11 additions & 0 deletions pythonforandroid/recipes/pyproj/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from pythonforandroid.recipe import CythonRecipe


class PyProjRecipe(CythonRecipe):
version = '1.9.5.1'
url = 'https://github.com/jswhit/pyproj/archive/master.zip'
depends = ['python2', 'setuptools']
call_hostpython_via_targetpython = False


recipe = PyProjRecipe()
24 changes: 24 additions & 0 deletions pythonforandroid/recipes/shapely/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from pythonforandroid.recipe import Recipe,CythonRecipe


class ShapelyRecipe(CythonRecipe):
version = '1.5'
url = 'https://github.com/Toblerity/Shapely/archive/master.zip'
depends = ['python2', 'setuptools', 'libgeos']
call_hostpython_via_targetpython = False

patches = ['setup.patch'] # Patch to force setup to fail when C extention fails to build

# setup_extra_args = ['sdist'] # DontForce Cython

def get_recipe_env(self, arch, with_flags_in_cc=True):
""" Add libgeos headers to path """
env = super(ShapelyRecipe, self).get_recipe_env(arch,with_flags_in_cc)
libgeos_dir = Recipe.get_recipe('libgeos', self.ctx).get_build_dir(arch.arch)
env['CFLAGS'] += " -I{}/dist/include".format(libgeos_dir)
return env



recipe = ShapelyRecipe()

12 changes: 12 additions & 0 deletions pythonforandroid/recipes/shapely/setup.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
*** shapely/setup.py 2016-06-29 11:29:49.000000000 -0400
--- b/setup.py 2016-07-09 01:51:37.759670990 -0400
***************
*** 359,364 ****
--- 359,365 ----
construct_build_ext(existing_build_ext)
setup(ext_modules=ext_modules, **setup_args)
except BuildFailed as ex:
+ raise # Force python only build to fail
BUILD_EXT_WARNING = "The C extension could not be compiled, " \
"speedups are not enabled."
log.warn(ex)