From 296ed00ea353d93562cc52929cc53d185960c14c Mon Sep 17 00:00:00 2001 From: frmdstryr Date: Sat, 9 Jul 2016 02:01:56 -0400 Subject: [PATCH] Add recipes for libgeos, pyproj, and shapely --- pythonforandroid/recipes/libgeos/__init__.py | 44 ++++++++++++++++++++ pythonforandroid/recipes/pyproj/__init__.py | 11 +++++ pythonforandroid/recipes/shapely/__init__.py | 24 +++++++++++ pythonforandroid/recipes/shapely/setup.patch | 12 ++++++ 4 files changed, 91 insertions(+) create mode 100644 pythonforandroid/recipes/libgeos/__init__.py create mode 100644 pythonforandroid/recipes/pyproj/__init__.py create mode 100644 pythonforandroid/recipes/shapely/__init__.py create mode 100644 pythonforandroid/recipes/shapely/setup.patch diff --git a/pythonforandroid/recipes/libgeos/__init__.py b/pythonforandroid/recipes/libgeos/__init__.py new file mode 100644 index 0000000000..20f353978b --- /dev/null +++ b/pythonforandroid/recipes/libgeos/__init__.py @@ -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() + diff --git a/pythonforandroid/recipes/pyproj/__init__.py b/pythonforandroid/recipes/pyproj/__init__.py new file mode 100644 index 0000000000..3caec1dac9 --- /dev/null +++ b/pythonforandroid/recipes/pyproj/__init__.py @@ -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() diff --git a/pythonforandroid/recipes/shapely/__init__.py b/pythonforandroid/recipes/shapely/__init__.py new file mode 100644 index 0000000000..02b234dc54 --- /dev/null +++ b/pythonforandroid/recipes/shapely/__init__.py @@ -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() + \ No newline at end of file diff --git a/pythonforandroid/recipes/shapely/setup.patch b/pythonforandroid/recipes/shapely/setup.patch new file mode 100644 index 0000000000..9523f357bc --- /dev/null +++ b/pythonforandroid/recipes/shapely/setup.patch @@ -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)