Skip to content

Commit bb49cb7

Browse files
committed
recipes: new recipe coincurve
1 parent 41595e5 commit bb49cb7

File tree

3 files changed

+77
-2
lines changed

3 files changed

+77
-2
lines changed
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", "asn1crypto"]
10+
patches = ["coincurve.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()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
diff '--color=auto' -uNr coincurve-19.0.1/setup.py coincurve-19.0.1.patch/setup.py
2+
--- coincurve-19.0.1/setup.py 2024-03-02 10:40:59.000000000 +0530
3+
+++ coincurve-19.0.1.patch/setup.py 2024-03-10 09:51:58.034737104 +0530
4+
@@ -47,6 +47,7 @@
5+
6+
7+
def download_library(command):
8+
+ return
9+
if command.dry_run:
10+
return
11+
libdir = absolute('libsecp256k1')
12+
@@ -189,6 +190,7 @@
13+
absolute('libsecp256k1/configure'),
14+
'--disable-shared',
15+
'--enable-static',
16+
+ '--host=%s' % os.environ['TOOLCHAIN_PREFIX'],
17+
'--disable-dependency-tracking',
18+
'--with-pic',
19+
'--enable-module-extrakeys',
20+
@@ -269,13 +271,7 @@
21+
# ABI?: py_limited_api=True,
22+
)
23+
24+
- extension.extra_compile_args = [
25+
- subprocess.check_output(['pkg-config', '--cflags-only-I', 'libsecp256k1']).strip().decode('utf-8') # noqa S603
26+
- ]
27+
- extension.extra_link_args = [
28+
- subprocess.check_output(['pkg-config', '--libs-only-L', 'libsecp256k1']).strip().decode('utf-8'), # noqa S603
29+
- subprocess.check_output(['pkg-config', '--libs-only-l', 'libsecp256k1']).strip().decode('utf-8'), # noqa S603
30+
- ]
31+
+ extension.extra_link_args = ["-lsecp256k1"]
32+
33+
if os.name == 'nt' or sys.platform == 'win32':
34+
# Apparently, the linker on Windows interprets -lxxx as xxx.lib, not libxxx.lib
35+
@@ -340,7 +336,7 @@
36+
license='MIT OR Apache-2.0',
37+
38+
python_requires='>=3.8',
39+
- install_requires=['asn1crypto', 'cffi>=1.3.0'],
40+
+ install_requires=[],
41+
42+
packages=find_packages(exclude=('_cffi_build', '_cffi_build.*', 'libsecp256k1', 'tests')),
43+
package_data=package_data,
44+
diff '--color=auto' -uNr coincurve-19.0.1/setup_support.py coincurve-19.0.1.patch/setup_support.py
45+
--- coincurve-19.0.1/setup_support.py 2024-03-02 10:40:59.000000000 +0530
46+
+++ coincurve-19.0.1.patch/setup_support.py 2024-03-10 08:53:45.650056659 +0530
47+
@@ -56,6 +56,7 @@
48+
49+
50+
def _find_lib():
51+
+ return True
52+
if 'COINCURVE_IGNORE_SYSTEM_LIB' in os.environ:
53+
return False
54+

pythonforandroid/recipes/libsecp256k1/__init__.py

+2-2
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)