diff --git a/pythonforandroid/recipes/coincurve/__init__.py b/pythonforandroid/recipes/coincurve/__init__.py new file mode 100644 index 0000000000..662772cb78 --- /dev/null +++ b/pythonforandroid/recipes/coincurve/__init__.py @@ -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() diff --git a/pythonforandroid/recipes/coincurve/coincurve.patch b/pythonforandroid/recipes/coincurve/coincurve.patch new file mode 100644 index 0000000000..64bfc2aee5 --- /dev/null +++ b/pythonforandroid/recipes/coincurve/coincurve.patch @@ -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 + diff --git a/pythonforandroid/recipes/libsecp256k1/__init__.py b/pythonforandroid/recipes/libsecp256k1/__init__.py index f3a2772cf9..f228ad8cb5 100644 --- a/pythonforandroid/recipes/libsecp256k1/__init__.py +++ b/pythonforandroid/recipes/libsecp256k1/__init__.py @@ -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)