Skip to content

Commit 5a830b0

Browse files
committed
recipes: new recipe coincurve
1 parent 37cb53e commit 5a830b0

File tree

4 files changed

+84
-0
lines changed

4 files changed

+84
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import os
2+
from pythonforandroid.recipe import PythonRecipe
3+
4+
5+
class CoincurveRecipe(PythonRecipe):
6+
version = '18.0.0'
7+
url = 'https://github.com/ofek/coincurve/archive/v{version}.tar.gz'
8+
call_hostpython_via_targetpython = False
9+
depends = [('python2', 'python3crystax'), 'setuptools',
10+
'libffi', 'cffi', 'libsecp256k1']
11+
patches = [
12+
"cross_compile.patch", "drop_setup_requires.patch",
13+
"find_lib.patch"]
14+
15+
def get_recipe_env(self, arch=None, with_flags_in_cc=True):
16+
env = super(CoincurveRecipe, self).get_recipe_env(arch, with_flags_in_cc)
17+
libsecp256k1 = self.get_recipe('libsecp256k1', self.ctx)
18+
libsecp256k1_dir = libsecp256k1.get_build_dir(arch.arch)
19+
env['CFLAGS'] += ' -I' + os.path.join(libsecp256k1_dir, 'include')
20+
# required additional library and path for Crystax
21+
if self.ctx.ndk == 'crystax':
22+
# only keeps major.minor (discards patch)
23+
python_version = self.ctx.python_recipe.version[0:3]
24+
ndk_dir_python = os.path.join(self.ctx.ndk_dir, 'sources/python/', python_version)
25+
env['LDFLAGS'] += ' -L{}'.format(os.path.join(ndk_dir_python, 'libs', arch.arch))
26+
env['LDFLAGS'] += ' -lpython{}m'.format(python_version)
27+
env['LDFLAGS'] += " -lsecp256k1"
28+
return env
29+
30+
31+
recipe = CoincurveRecipe()
32+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
diff '--color=auto' -uNr coincurve-18.0.0/setup.py coincurve-18.0.0.patched/setup.py
2+
--- coincurve-18.0.0/setup.py 2022-11-20 01:40:25.000000000 +0530
3+
+++ coincurve-18.0.0.patched/setup.py 2023-06-06 14:54:40.889434562 +0530
4+
@@ -176,6 +176,7 @@
5+
absolute('libsecp256k1/configure'),
6+
'--disable-shared',
7+
'--enable-static',
8+
+ '--host=%s' % os.environ['TOOLCHAIN_PREFIX'],
9+
'--disable-dependency-tracking',
10+
'--with-pic',
11+
'--enable-module-extrakeys',
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
--- coincurve-18.0.0/setup.py 2022-11-20 01:40:25.000000000 +0530
2+
+++ coincurve-18.0.0.patched/setup.py 2023-06-06 15:06:58.378312513 +0530
3+
@@ -49,6 +49,7 @@
4+
5+
6+
def download_library(command):
7+
+ return
8+
if command.dry_run:
9+
return
10+
libdir = absolute('libsecp256k1')
11+
@@ -131,7 +132,7 @@
12+
return build_flags('libsecp256k1', 'l', os.path.abspath(self.build_temp))
13+
14+
def run(self):
15+
- if has_system_lib():
16+
+ if True:
17+
log.info('Using system library')
18+
return
19+
20+
@@ -249,11 +250,10 @@
21+
return not has_system_lib()
22+
23+
setup_kwargs = dict(
24+
- setup_requires=['cffi>=1.3.0', 'requests'],
25+
+ setup_requires=[],
26+
ext_package='coincurve',
27+
cffi_modules=['_cffi_build/build.py:ffi'],
28+
cmdclass={
29+
- 'build_clib': build_clib,
30+
'build_ext': build_ext,
31+
'develop': develop,
32+
'egg_info': egg_info,
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
--- coincurve-18.0.0/setup_support.py 2022-11-20 01:40:25.000000000 +0530
2+
+++ coincurve-18.0.0.patched/setup_support.py 2023-06-06 14:58:52.960948988 +0530
3+
@@ -60,6 +60,7 @@
4+
5+
6+
def _find_lib():
7+
+ return True
8+
if 'COINCURVE_IGNORE_SYSTEM_LIB' in os.environ:
9+
return False

0 commit comments

Comments
 (0)