Skip to content

Commit

Permalink
Merge bb49cb7 into 41595e5
Browse files Browse the repository at this point in the history
  • Loading branch information
T-Dynamos committed Mar 10, 2024
2 parents 41595e5 + bb49cb7 commit e84d38c
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 2 deletions.
21 changes: 21 additions & 0 deletions pythonforandroid/recipes/coincurve/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import os
from pythonforandroid.recipe import PythonRecipe


class CoincurveRecipe(PythonRecipe):
version = "19.0.1"
url = "https://github.com/ofek/coincurve/archive/v{version}.tar.gz"
call_hostpython_via_targetpython = False
depends = ["setuptools", "libffi", "cffi", "libsecp256k1", "asn1crypto"]
patches = ["coincurve.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)
libsecp256k1 = self.get_recipe("libsecp256k1", self.ctx)
libsecp256k1_dir = libsecp256k1.get_build_dir(arch.arch)
env["CFLAGS"] += " -I" + os.path.join(libsecp256k1_dir, "include")
env["LDFLAGS"] += " -lsecp256k1"
return env


recipe = CoincurveRecipe()
54 changes: 54 additions & 0 deletions pythonforandroid/recipes/coincurve/coincurve.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
diff '--color=auto' -uNr coincurve-19.0.1/setup.py coincurve-19.0.1.patch/setup.py
--- coincurve-19.0.1/setup.py 2024-03-02 10:40:59.000000000 +0530
+++ coincurve-19.0.1.patch/setup.py 2024-03-10 09:51:58.034737104 +0530
@@ -47,6 +47,7 @@


def download_library(command):
+ return
if command.dry_run:
return
libdir = absolute('libsecp256k1')
@@ -189,6 +190,7 @@
absolute('libsecp256k1/configure'),
'--disable-shared',
'--enable-static',
+ '--host=%s' % os.environ['TOOLCHAIN_PREFIX'],
'--disable-dependency-tracking',
'--with-pic',
'--enable-module-extrakeys',
@@ -269,13 +271,7 @@
# ABI?: py_limited_api=True,
)

- extension.extra_compile_args = [
- subprocess.check_output(['pkg-config', '--cflags-only-I', 'libsecp256k1']).strip().decode('utf-8') # noqa S603
- ]
- extension.extra_link_args = [
- subprocess.check_output(['pkg-config', '--libs-only-L', 'libsecp256k1']).strip().decode('utf-8'), # noqa S603
- subprocess.check_output(['pkg-config', '--libs-only-l', 'libsecp256k1']).strip().decode('utf-8'), # noqa S603
- ]
+ extension.extra_link_args = ["-lsecp256k1"]

if os.name == 'nt' or sys.platform == 'win32':
# Apparently, the linker on Windows interprets -lxxx as xxx.lib, not libxxx.lib
@@ -340,7 +336,7 @@
license='MIT OR Apache-2.0',

python_requires='>=3.8',
- install_requires=['asn1crypto', 'cffi>=1.3.0'],
+ install_requires=[],

packages=find_packages(exclude=('_cffi_build', '_cffi_build.*', 'libsecp256k1', 'tests')),
package_data=package_data,
diff '--color=auto' -uNr coincurve-19.0.1/setup_support.py coincurve-19.0.1.patch/setup_support.py
--- coincurve-19.0.1/setup_support.py 2024-03-02 10:40:59.000000000 +0530
+++ coincurve-19.0.1.patch/setup_support.py 2024-03-10 08:53:45.650056659 +0530
@@ -56,6 +56,7 @@


def _find_lib():
+ return True
if 'COINCURVE_IGNORE_SYSTEM_LIB' in os.environ:
return False

4 changes: 2 additions & 2 deletions pythonforandroid/recipes/libsecp256k1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
class LibSecp256k1Recipe(Recipe):

built_libraries = {'libsecp256k1.so': '.libs'}

url = 'https://github.com/bitcoin-core/secp256k1/archive/master.zip'
version = '0.4.1'
url = 'https://github.com/bitcoin-core/secp256k1/archive/refs/tags/v{version}.tar.gz'

def build_arch(self, arch):
env = self.get_recipe_env(arch)
Expand Down

0 comments on commit e84d38c

Please sign in to comment.