Skip to content

recipes: new recipe coincurve #2835

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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