lbry-android-sdk/recipes/coincurve/__init__.py
Akinwale Ariwodola b09e468ffb
Python 3.9.6 (#11)
* build Python 3.9.6
* use Python 3.9 docker image
* fix pyjnius recipe
* remove unused dependencies from cryptography recipe
* fix PYTHON3_DLL_REL_PATH value
* add idna requirement
* Remove m abi flag from python lib (https://docs.python.org/3/whatsnew/3.8.html#build-and-c-api-changes)
* aiohttp==3.6.0
* Add base Dockerfiles for builds
2021-08-21 10:30:12 +01:00

41 lines
2.1 KiB
Python

import os
from pythonforandroid.recipe import PythonRecipe, CompiledComponentsPythonRecipe
class CoincurveRecipe(CompiledComponentsPythonRecipe):
version = '7.1.0'
url = 'https://github.com/ofek/coincurve/archive/{version}.tar.gz'
call_hostpython_via_targetpython = False
depends = [('python2', 'python3crystax'), 'setuptools',
'libffi', 'cffi', 'libsecp256k1']
patches = [
"cross_compile.patch", "drop_setup_requires.patch",
"find_lib.patch", "no-download.patch", "setup.py.patch"]
def get_recipe_env(self, arch=None, with_flags_in_cc=True):
env = super(CoincurveRecipe, self).get_recipe_env(arch, with_flags_in_cc)
# sets linker to use the correct gcc (cross compiler)
env['LDSHARED'] = env['CC'] + ' -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions'
libsecp256k1 = self.get_recipe('libsecp256k1', self.ctx)
libsecp256k1_dir = libsecp256k1.get_build_dir(arch.arch)
env['LDFLAGS'] += ' -L{}'.format(os.path.join(libsecp256k1_dir, '.libs'))
env['CFLAGS'] += ' -I' + os.path.join(libsecp256k1_dir, 'include')
# only keeps major.minor (discards patch)
python_version = self.ctx.python_recipe.version[0:3]
# required additional library and path for Crystax
if self.ctx.ndk == 'crystax':
ndk_dir_python = os.path.join(self.ctx.ndk_dir, 'sources/python/', python_version)
env['LDFLAGS'] += ' -L{}'.format(os.path.join(ndk_dir_python, 'libs', arch.arch))
env['LDFLAGS'] += ' -lpython{}'.format(python_version)
# until `pythonforandroid/archs.py` gets merged upstream:
# https://github.com/kivy/python-for-android/pull/1250/files#diff-569e13021e33ced8b54385f55b49cbe6
env['CFLAGS'] += ' -I{}/include/python/'.format(ndk_dir_python)
else:
env['PYTHON_ROOT'] = self.ctx.get_python_install_dir()
env['CFLAGS'] += ' -I' + env['PYTHON_ROOT'] + '/include/python{}'.format(python_version)
env['LDFLAGS'] += " -lpython{}".format(python_version)
env['LDFLAGS'] += " -lsecp256k1"
return env
recipe = CoincurveRecipe()