-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
10af2d8
commit 69f2f24
Showing
7 changed files
with
103 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import os | ||
from pythonforandroid.recipe import PythonRecipe, CompiledComponentsPythonRecipe, CythonRecipe | ||
|
||
|
||
class CoincurveRecipe(CompiledComponentsPythonRecipe): | ||
version = '7.1.0' | ||
url = 'https://github.com/ofek/coincurve/archive/{version}.tar.gz' | ||
call_hostpython_via_targetpython = False | ||
depends = [('python2', 'python3crystax'), 'setuptools', | ||
'libffi', 'cffi', 'libsecp256k1'] | ||
patches = [ | ||
"cross_compile.patch", "drop_setup_requires.patch", | ||
"find_lib.patch", "no-download.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) | ||
# sets linker to use the correct gcc (cross compiler) | ||
env['LDSHARED'] = env['CC'] + ' -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions' | ||
# -Wl,-rpath -Wl, | ||
libsecp256k1 = self.get_recipe('libsecp256k1', self.ctx) | ||
libsecp256k1_dir = libsecp256k1.get_build_dir(arch.arch) | ||
# env['LDSHARED'] = ( | ||
# env['CC'] + | ||
# ' -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-rpath -Wl,' + | ||
# os.path.join(libsecp256k1_dir, '.libs')) | ||
env['LDFLAGS'] += ' -L{}'.format(os.path.join(libsecp256k1_dir, '.libs')) | ||
# assert False, env['LDSHARED'] | ||
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() | ||
env['CFLAGS'] += ' -I' + env['PYTHON_ROOT'] + '/include/python{}'.format(python_version) | ||
env['LDFLAGS'] += " -lpython{}".format(python_version) | ||
env['LDFLAGS'] += " -lsecp256k1" | ||
return env | ||
|
||
|
||
recipe = CoincurveRecipe() | ||
|
Binary file not shown.
12 changes: 12 additions & 0 deletions
12
src/python-for-android/recipes/coincurve/cross_compile.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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), |
12 changes: 12 additions & 0 deletions
12
src/python-for-android/recipes/coincurve/drop_setup_requires.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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={ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: |
13 changes: 13 additions & 0 deletions
13
src/python-for-android/recipes/coincurve/no-download.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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') |