From 619cc179210dabcc2f592d5ade214ce9191deef2 Mon Sep 17 00:00:00 2001 From: zeppi Date: Sun, 4 Dec 2022 00:34:08 -0500 Subject: [PATCH] update coincurve patches --- MovedRecipes/coincurve/__init__.py | 74 +++++++++++++++++++ MovedRecipes/coincurve/cross_compile.patch | 12 +++ .../coincurve/drop_setup_requires.patch | 12 +++ MovedRecipes/coincurve/find_lib.patch | 13 ++++ MovedRecipes/coincurve/no-download.patch | 13 ++++ .../coincurve/setup.py.patch | 0 recipes/coincurve/__init__.py | 2 +- recipes/coincurve/cross_compile.patch | 6 +- recipes/coincurve/drop_setup_requires.patch | 8 +- recipes/coincurve/find_lib.patch | 14 ++-- recipes/coincurve/no-download.patch | 4 +- 11 files changed, 141 insertions(+), 17 deletions(-) create mode 100644 MovedRecipes/coincurve/__init__.py create mode 100644 MovedRecipes/coincurve/cross_compile.patch create mode 100644 MovedRecipes/coincurve/drop_setup_requires.patch create mode 100644 MovedRecipes/coincurve/find_lib.patch create mode 100644 MovedRecipes/coincurve/no-download.patch rename {recipes => MovedRecipes}/coincurve/setup.py.patch (100%) diff --git a/MovedRecipes/coincurve/__init__.py b/MovedRecipes/coincurve/__init__.py new file mode 100644 index 0000000..9d11199 --- /dev/null +++ b/MovedRecipes/coincurve/__init__.py @@ -0,0 +1,74 @@ +import os +from pythonforandroid.recipe import PythonRecipe, CompiledComponentsPythonRecipe + + +class CoincurveRecipe(CompiledComponentsPythonRecipe): + # version = '15.0.0' + # url = 'https://github.com/ofek/coincurve/archive/{version}.tar.gz' + # call_hostpython_via_targetpython = False + # depends = ['setuptools', + # 'libffi', 'cffi', 'libsecp256k1'] + # patches = [ + # "cross_compile.patch", "drop_setup_requires.patch", + # "find_lib.patch", "no-download.patch", "setup.py.patch"] + # + # def get_recipe_env(self, arch=None, with_flags_in_cc=True): + # env = super().get_recipe_env(arch, with_flags_in_cc) + # # sets linker to use the correct gcc (cross compiler) + # env['LDSHARED'] = env['CC'] + ' -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions' + # libsecp256k1 = self.get_recipe('libsecp256k1', self.ctx) + # libsecp256k1_dir = libsecp256k1.get_build_dir(arch.arch) + # env['LDFLAGS'] += ' -L{}'.format(os.path.join(libsecp256k1_dir, '.libs')) + # env['CFLAGS'] += ' -I' + os.path.join(libsecp256k1_dir, 'include') + # # only keeps major.minor (discards patch) + # python_version = self.ctx.python_recipe.version[0:3] + # # required additional library and path for Crystax + # if self.ctx.ndk == 'crystax': + # ndk_dir_python = os.path.join(self.ctx.ndk_dir, 'sources/python/', python_version) + # env['LDFLAGS'] += ' -L{}'.format(os.path.join(ndk_dir_python, 'libs', arch.arch)) + # env['LDFLAGS'] += ' -lpython{}'.format(python_version) + # # until `pythonforandroid/archs.py` gets merged upstream: + # # https://github.com/kivy/python-for-android/pull/1250/files#diff-569e13021e33ced8b54385f55b49cbe6 + # env['CFLAGS'] += ' -I{}/include/python/'.format(ndk_dir_python) + # else: + # env['PYTHON_ROOT'] = self.ctx.get_python_install_dir(arch.arch) + # env['CFLAGS'] += ' -I' + env['PYTHON_ROOT'] + '/include/python{}'.format(python_version) + # env['LDFLAGS'] += " -lpython{}".format(python_version) + # env['LDFLAGS'] += " -lsecp256k1" + # return env + version = 'v15.0.1' + url = 'https://github.com/ofek/coincurve/archive/refs/tags/v15.0.1.tar.gz' + call_hostpython_via_targetpython = False + depends = [('python2', 'python3'), 'setuptools', + 'libffi', 'cffi', 'libsecp256k1'] + patches = [ + "cross_compile.patch", "drop_setup_requires.patch", + "find_lib.patch", "no-download.patch", "setup.py.patch"] + + def get_recipe_env(self, arch=None, with_flags_in_cc=True): + env = super().get_recipe_env(arch, with_flags_in_cc) + # sets linker to use the correct gcc (cross compiler) + env['LDSHARED'] = env['CC'] + ' -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions' + libsecp256k1 = self.get_recipe('libsecp256k1', self.ctx) + libsecp256k1_dir = libsecp256k1.get_build_dir(arch.arch) + env['LDFLAGS'] += ' -L{}'.format(os.path.join(libsecp256k1_dir, '.libs')) + env['CFLAGS'] += ' -I' + os.path.join(libsecp256k1_dir, 'include') + # only keeps major.minor (discards patch) + python_version = self.ctx.python_recipe.version[0:3] + # required additional library and path for Crystax + # if self.ctx.ndk == 'crystax': + # ndk_dir_python = os.path.join(self.ctx.ndk_dir, 'sources/python/', python_version) + # env['LDFLAGS'] += ' -L{}'.format(os.path.join(ndk_dir_python, 'libs', arch.arch)) + # env['LDFLAGS'] += ' -lpython{}m'.format(python_version) + # # until `pythonforandroid/archs.py` gets merged upstream: + # # https://github.com/kivy/python-for-android/pull/1250/files#diff-569e13021e33ced8b54385f55b49cbe6 + # env['CFLAGS'] += ' -I{}/include/python/'.format(ndk_dir_python) + # else: + env['PYTHON_ROOT'] = self.ctx.get_python_install_dir(arch.arch) + env['CFLAGS'] += ' -I' + env['PYTHON_ROOT'] + '/include/python{}'.format(python_version) + env['LDFLAGS'] += " -lpython{}".format(python_version) + env['LDFLAGS'] += " -lsecp256k1" + return env + + +recipe = CoincurveRecipe() diff --git a/MovedRecipes/coincurve/cross_compile.patch b/MovedRecipes/coincurve/cross_compile.patch new file mode 100644 index 0000000..fbbdd49 --- /dev/null +++ b/MovedRecipes/coincurve/cross_compile.patch @@ -0,0 +1,12 @@ +diff --git a/setup.py b/setup.py +index c224fb2..bf925bd 100644 +--- a/setup.py ++++ b/setup.py +@@ -182,6 +182,7 @@ class build_clib(_build_clib): + '--disable-dependency-tracking', + '--with-pic', + '--enable-module-recovery', ++ "--host=%s" % os.environ['TOOLCHAIN_PREFIX'], + '--disable-jni', + '--prefix', + os.path.abspath(self.build_clib), diff --git a/MovedRecipes/coincurve/drop_setup_requires.patch b/MovedRecipes/coincurve/drop_setup_requires.patch new file mode 100644 index 0000000..9994b3f --- /dev/null +++ b/MovedRecipes/coincurve/drop_setup_requires.patch @@ -0,0 +1,12 @@ +diff --git a/setup.py b/setup.py +index c224fb2..466e789 100644 +--- a/setup.py ++++ b/setup.py +@@ -250,7 +250,6 @@ else: + def has_c_libraries(self): + return not has_system_lib() + setup_kwargs = dict( +- setup_requires=['cffi>=1.3.0', 'pytest-runner>=2.6.2'], + ext_package='coincurve', + cffi_modules=['_cffi_build/build.py:ffi'], + cmdclass={ diff --git a/MovedRecipes/coincurve/find_lib.patch b/MovedRecipes/coincurve/find_lib.patch new file mode 100644 index 0000000..3d3c41d --- /dev/null +++ b/MovedRecipes/coincurve/find_lib.patch @@ -0,0 +1,13 @@ +diff --git a/setup_support.py b/setup_support.py +index e7a4f2e..72f0c4d 100644 +--- a/setup_support.py ++++ b/setup_support.py +@@ -68,6 +69,8 @@ def build_flags(library, type_, path): + + + def _find_lib(): ++ # we're picking up the recipe one ++ return True + from cffi import FFI + ffi = FFI() + try: diff --git a/MovedRecipes/coincurve/no-download.patch b/MovedRecipes/coincurve/no-download.patch new file mode 100644 index 0000000..fcf4d20 --- /dev/null +++ b/MovedRecipes/coincurve/no-download.patch @@ -0,0 +1,13 @@ +diff --git a/setup.py b/setup.py +index c224fb2..d5f6d1a 100644 +--- a/setup.py ++++ b/setup.py +@@ -51,6 +51,8 @@ if [int(i) for i in setuptools_version.split('.', 2)[:2]] < [3, 3]: + + + def download_library(command): ++ # we will use the custom libsecp256k1 recipe ++ return + if command.dry_run: + return + libdir = absolute('libsecp256k1') diff --git a/recipes/coincurve/setup.py.patch b/MovedRecipes/coincurve/setup.py.patch similarity index 100% rename from recipes/coincurve/setup.py.patch rename to MovedRecipes/coincurve/setup.py.patch diff --git a/recipes/coincurve/__init__.py b/recipes/coincurve/__init__.py index 9d11199..8e98ca7 100644 --- a/recipes/coincurve/__init__.py +++ b/recipes/coincurve/__init__.py @@ -43,7 +43,7 @@ class CoincurveRecipe(CompiledComponentsPythonRecipe): 'libffi', 'cffi', 'libsecp256k1'] patches = [ "cross_compile.patch", "drop_setup_requires.patch", - "find_lib.patch", "no-download.patch", "setup.py.patch"] + "find_lib.patch", "no-download.patch"] def get_recipe_env(self, arch=None, with_flags_in_cc=True): env = super().get_recipe_env(arch, with_flags_in_cc) diff --git a/recipes/coincurve/cross_compile.patch b/recipes/coincurve/cross_compile.patch index fbbdd49..6c37191 100644 --- a/recipes/coincurve/cross_compile.patch +++ b/recipes/coincurve/cross_compile.patch @@ -1,12 +1,12 @@ diff --git a/setup.py b/setup.py -index c224fb2..bf925bd 100644 +index f0d3ab3..ebb1b4f 100644 --- a/setup.py +++ b/setup.py -@@ -182,6 +182,7 @@ class build_clib(_build_clib): +@@ -177,6 +177,7 @@ class build_clib(_build_clib): '--disable-dependency-tracking', '--with-pic', '--enable-module-recovery', + "--host=%s" % os.environ['TOOLCHAIN_PREFIX'], - '--disable-jni', '--prefix', os.path.abspath(self.build_clib), + '--enable-experimental', diff --git a/recipes/coincurve/drop_setup_requires.patch b/recipes/coincurve/drop_setup_requires.patch index 9994b3f..73b66c1 100644 --- a/recipes/coincurve/drop_setup_requires.patch +++ b/recipes/coincurve/drop_setup_requires.patch @@ -1,12 +1,12 @@ diff --git a/setup.py b/setup.py -index c224fb2..466e789 100644 +index f0d3ab3..05c9ee0 100644 --- a/setup.py +++ b/setup.py -@@ -250,7 +250,6 @@ else: - def has_c_libraries(self): +@@ -243,7 +243,6 @@ else: return not has_system_lib() + setup_kwargs = dict( -- setup_requires=['cffi>=1.3.0', 'pytest-runner>=2.6.2'], +- setup_requires=['cffi>=1.3.0', 'requests'], ext_package='coincurve', cffi_modules=['_cffi_build/build.py:ffi'], cmdclass={ diff --git a/recipes/coincurve/find_lib.patch b/recipes/coincurve/find_lib.patch index 3d3c41d..63ef30c 100644 --- a/recipes/coincurve/find_lib.patch +++ b/recipes/coincurve/find_lib.patch @@ -1,13 +1,13 @@ diff --git a/setup_support.py b/setup_support.py -index e7a4f2e..72f0c4d 100644 +index fcd1d9d..0ac3bc0 100644 --- a/setup_support.py +++ b/setup_support.py -@@ -68,6 +69,8 @@ def build_flags(library, type_, path): - - +@@ -60,6 +60,8 @@ def build_flags(library, type_, path): + + def _find_lib(): + # we're picking up the recipe one + return True - from cffi import FFI - ffi = FFI() - try: + if 'COINCURVE_IGNORE_SYSTEM_LIB' in os.environ: + return False + diff --git a/recipes/coincurve/no-download.patch b/recipes/coincurve/no-download.patch index fcf4d20..99540a6 100644 --- a/recipes/coincurve/no-download.patch +++ b/recipes/coincurve/no-download.patch @@ -1,8 +1,8 @@ diff --git a/setup.py b/setup.py -index c224fb2..d5f6d1a 100644 +index f0d3ab3..1d81b43 100644 --- a/setup.py +++ b/setup.py -@@ -51,6 +51,8 @@ if [int(i) for i in setuptools_version.split('.', 2)[:2]] < [3, 3]: +@@ -47,6 +47,8 @@ if [int(i) for i in setuptools_version.split('.', 2)[:2]] < [3, 3]: def download_library(command):