lbry-fdroid/p4a/pythonforandroid/recipes/psycopg2/__init__.py
Akinwale Ariwodola 8b2694efb7
New build (#508)
* fix build for openssl 1.1.1b required for sdk
(cherry picked from commit aa49e3b2755b97b6331cdbbb89efc954de8d5977)

* use js code from master

* fix openssl recipe and tweak build
(cherry picked from commit 6e94c27021c7bd7b1e880c2fc314850e36a5a38e)

* remove unused build recipes
(cherry picked from commit f5c0577bdb175bfc0990602936bbc9e2052e1f25)
2019-03-30 21:58:45 +01:00

50 lines
2 KiB
Python

from pythonforandroid.recipe import PythonRecipe
from pythonforandroid.toolchain import current_directory, shprint
import sh
class Psycopg2Recipe(PythonRecipe):
"""
Requires `libpq-dev` system dependency e.g. for `pg_config` binary.
If you get `nl_langinfo` symbol runtime error, make sure you're running on
`ANDROID_API` (`ndk-api`) >= 26, see:
https://github.com/kivy/python-for-android/issues/1711#issuecomment-465747557
"""
version = 'latest'
url = 'http://initd.org/psycopg/tarballs/psycopg2-{version}.tar.gz'
depends = ['libpq']
site_packages_name = 'psycopg2'
call_hostpython_via_targetpython = False
def prebuild_arch(self, arch):
libdir = self.ctx.get_libs_dir(arch.arch)
with current_directory(self.get_build_dir(arch.arch)):
# pg_config_helper will return the system installed libpq, but we
# need the one we just cross-compiled
shprint(sh.sed, '-i',
"s|pg_config_helper.query(.libdir.)|'{}'|".format(libdir),
'setup.py')
def get_recipe_env(self, arch):
env = super(Psycopg2Recipe, self).get_recipe_env(arch)
env['LDFLAGS'] = "{} -L{}".format(env['LDFLAGS'], self.ctx.get_libs_dir(arch.arch))
env['EXTRA_CFLAGS'] = "--host linux-armv"
return env
def install_python_package(self, arch, name=None, env=None, is_dir=True):
'''Automate the installation of a Python package (or a cython
package where the cython components are pre-built).'''
if env is None:
env = self.get_recipe_env(arch)
with current_directory(self.get_build_dir(arch.arch)):
hostpython = sh.Command(self.ctx.hostpython)
shprint(hostpython, 'setup.py', 'build_ext', '--static-libpq',
_env=env)
shprint(hostpython, 'setup.py', 'install', '-O2',
'--root={}'.format(self.ctx.get_python_install_dir()),
'--install-lib=.', _env=env)
recipe = Psycopg2Recipe()