Skip to content

Commit d05fb74

Browse files
committed
Merge pull request #754 from felipenehmi/storm_psycopg2_recipes
Port storm and psycopg2 recipes from the old toolchain to the revamp.
2 parents 8e40271 + cca2163 commit d05fb74

File tree

3 files changed

+88
-0
lines changed

3 files changed

+88
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from pythonforandroid.toolchain import Recipe, current_directory, shprint
2+
import sh
3+
import os.path
4+
5+
6+
class LibpqRecipe(Recipe):
7+
version = '9.5.3'
8+
url = 'http://ftp.postgresql.org/pub/source/v{version}/postgresql-{version}.tar.bz2'
9+
depends = [('python2', 'python3')]
10+
11+
def should_build(self, arch):
12+
return not os.path.isfile('{}/libpq.a'.format(self.ctx.get_libs_dir(arch.arch)))
13+
14+
def build_arch(self, arch):
15+
env = self.get_recipe_env(arch)
16+
17+
with current_directory(self.get_build_dir(arch.arch)):
18+
configure = sh.Command('./configure')
19+
shprint(configure, '--without-readline', '--host=arm-linux',
20+
_env=env)
21+
shprint(sh.make, 'submake-libpq', _env=env)
22+
shprint(sh.cp, '-a', 'src/interfaces/libpq/libpq.a',
23+
self.ctx.get_libs_dir(arch.arch))
24+
25+
recipe = LibpqRecipe()
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
from pythonforandroid.toolchain import PythonRecipe, current_directory, shprint
2+
import sh
3+
4+
5+
class Psycopg2Recipe(PythonRecipe):
6+
version = 'latest'
7+
url = 'http://initd.org/psycopg/tarballs/psycopg2-{version}.tar.gz'
8+
depends = [('python2', 'python3'), 'libpq']
9+
site_packages_name = 'psycopg2'
10+
11+
def prebuild_arch(self, arch):
12+
libdir = self.ctx.get_libs_dir(arch.arch)
13+
with current_directory(self.get_build_dir(arch.arch)):
14+
# pg_config_helper will return the system installed libpq, but we
15+
# need the one we just cross-compiled
16+
shprint(sh.sed, '-i',
17+
"s|pg_config_helper.query(.libdir.)|'{}'|".format(libdir),
18+
'setup.py')
19+
20+
def get_recipe_env(self, arch):
21+
env = super(Psycopg2Recipe, self).get_recipe_env(arch)
22+
env['LDFLAGS'] = "{} -L{}".format(env['LDFLAGS'], self.ctx.get_libs_dir(arch.arch))
23+
env['EXTRA_CFLAGS'] = "--host linux-armv"
24+
return env
25+
26+
def install_python_package(self, arch, name=None, env=None, is_dir=True):
27+
'''Automate the installation of a Python package (or a cython
28+
package where the cython components are pre-built).'''
29+
if env is None:
30+
env = self.get_recipe_env(arch)
31+
32+
with current_directory(self.get_build_dir(arch.arch)):
33+
hostpython = sh.Command(self.ctx.hostpython)
34+
35+
shprint(hostpython, 'setup.py', 'build_ext', '--static-libpq',
36+
_env=env)
37+
shprint(hostpython, 'setup.py', 'install', '-O2',
38+
'--root={}'.format(self.ctx.get_python_install_dir()),
39+
'--install-lib=lib/python2.7/site-packages', _env=env)
40+
41+
recipe = Psycopg2Recipe()
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from pythonforandroid.toolchain import PythonRecipe, current_directory, shprint
2+
import sh
3+
4+
5+
class StormRecipe(PythonRecipe):
6+
version = '0.20'
7+
url = 'https://launchpad.net/storm/trunk/{version}/+download/storm-{version}.tar.bz2'
8+
depends = [('python2', 'python3')]
9+
site_packages_name = 'storm'
10+
call_hostpython_via_targetpython = False
11+
12+
def prebuild_arch(self, arch):
13+
with current_directory(self.get_build_dir(arch.arch)):
14+
# Cross compiling for 32 bits in 64 bit ubuntu before precise is
15+
# failing. See
16+
# https://bugs.launchpad.net/ubuntu/+source/python2.7/+bug/873007
17+
shprint(sh.sed, '-i',
18+
"s|BUILD_CEXTENSIONS = True|BUILD_CEXTENSIONS = False|",
19+
'setup.py')
20+
21+
22+
recipe = StormRecipe()

0 commit comments

Comments
 (0)