Skip to content

Commit 31f8f96

Browse files
committed
recipes: add coincurve
1 parent 41595e5 commit 31f8f96

File tree

5 files changed

+75
-2
lines changed

5 files changed

+75
-2
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import os
2+
from pythonforandroid.recipe import PythonRecipe
3+
4+
5+
class CoincurveRecipe(PythonRecipe):
6+
version = "19.0.1"
7+
url = "https://github.com/ofek/coincurve/archive/v{version}.tar.gz"
8+
call_hostpython_via_targetpython = False
9+
depends = ["setuptools", "libffi", "cffi", "libsecp256k1"]
10+
patches = ["cross_compile.patch", "drop_setup_requires.patch", "find_lib.patch"]
11+
12+
def get_recipe_env(self, arch=None, with_flags_in_cc=True):
13+
env = super(CoincurveRecipe, self).get_recipe_env(arch, with_flags_in_cc)
14+
libsecp256k1 = self.get_recipe("libsecp256k1", self.ctx)
15+
libsecp256k1_dir = libsecp256k1.get_build_dir(arch.arch)
16+
env["CFLAGS"] += " -I" + os.path.join(libsecp256k1_dir, "include")
17+
env["LDFLAGS"] += " -lsecp256k1"
18+
return env
19+
20+
21+
recipe = CoincurveRecipe()
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

pythonforandroid/recipes/libsecp256k1/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
class LibSecp256k1Recipe(Recipe):
1010

1111
built_libraries = {'libsecp256k1.so': '.libs'}
12-
13-
url = 'https://github.com/bitcoin-core/secp256k1/archive/master.zip'
12+
version = '0.4.1'
13+
url = 'https://github.com/bitcoin-core/secp256k1/archive/refs/tags/v{version}.tar.gz'
1414

1515
def build_arch(self, arch):
1616
env = self.get_recipe_env(arch)

0 commit comments

Comments
 (0)