-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Ethereum related recipes (#1068)
* Ethereum related recipes * ethash * libsecp256k1 * pycryptodome * pyethereum * pysha3 * scrypt * secp256k1 See https://github.com/ethereum * Added explicit version For pycryptodome, pyethereum and pysha3
- Loading branch information
1 parent
06f981f
commit 2dcd3cf
Showing
12 changed files
with
212 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from pythonforandroid.recipe import PythonRecipe | ||
|
||
|
||
class EthashRecipe(PythonRecipe): | ||
|
||
url = 'https://github.com/ethereum/ethash/archive/master.zip' | ||
|
||
depends = ['python2', 'setuptools'] | ||
|
||
|
||
recipe = EthashRecipe() |
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,32 @@ | ||
from pythonforandroid.toolchain import shprint, current_directory | ||
from pythonforandroid.recipe import Recipe | ||
from multiprocessing import cpu_count | ||
from os.path import exists | ||
import sh | ||
|
||
|
||
class LibSecp256k1Recipe(Recipe): | ||
|
||
url = 'https://github.com/bitcoin-core/secp256k1/archive/master.zip' | ||
|
||
def build_arch(self, arch): | ||
super(LibSecp256k1Recipe, self).build_arch(arch) | ||
env = self.get_recipe_env(arch) | ||
with current_directory(self.get_build_dir(arch.arch)): | ||
if not exists('configure'): | ||
shprint(sh.Command('./autogen.sh'), _env=env) | ||
shprint( | ||
sh.Command('./configure'), | ||
'--host=' + arch.toolchain_prefix, | ||
'--prefix=' + self.ctx.get_python_install_dir(), | ||
'--enable-shared', | ||
'--enable-module-recovery', | ||
'--enable-experimental', | ||
'--enable-module-ecdh', | ||
_env=env) | ||
shprint(sh.make, '-j' + str(cpu_count()), _env=env) | ||
libs = ['.libs/libsecp256k1.so'] | ||
self.install_libs(arch, *libs) | ||
|
||
|
||
recipe = LibSecp256k1Recipe() |
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,11 @@ | ||
from pythonforandroid.recipe import PythonRecipe | ||
|
||
|
||
class PycryptodomeRecipe(PythonRecipe): | ||
version = 'v3.4.6' | ||
url = 'https://github.com/Legrandin/pycryptodome/archive/{version}.tar.gz' | ||
|
||
depends = ['python2', 'setuptools'] | ||
|
||
|
||
recipe = PycryptodomeRecipe() |
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,15 @@ | ||
from pythonforandroid.recipe import PythonRecipe | ||
|
||
|
||
class PyethereumRecipe(PythonRecipe): | ||
version = 'v1.6.1' | ||
url = 'https://github.com/ethereum/pyethereum/archive/{version}.tar.gz' | ||
|
||
depends = [ | ||
'python2', 'setuptools', 'pycryptodome', 'pysha3', 'ethash', 'scrypt' | ||
] | ||
|
||
call_hostpython_via_targetpython = False | ||
|
||
|
||
recipe = PyethereumRecipe() |
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,11 @@ | ||
from pythonforandroid.recipe import PythonRecipe | ||
|
||
|
||
class Pysha3Recipe(PythonRecipe): | ||
version = '1.0.2' | ||
url = 'https://github.com/tiran/pysha3/archive/{version}.tar.gz' | ||
|
||
depends = ['python2', 'setuptools'] | ||
|
||
|
||
recipe = Pysha3Recipe() |
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,31 @@ | ||
from pythonforandroid.toolchain import CythonRecipe | ||
from os.path import join | ||
|
||
|
||
class ScryptRecipe(CythonRecipe): | ||
|
||
url = 'https://bitbucket.org/mhallin/py-scrypt/get/default.zip' | ||
|
||
depends = ['python2', 'setuptools', 'openssl'] | ||
|
||
call_hostpython_via_targetpython = False | ||
|
||
patches = ["remove_librt.patch"] | ||
|
||
def get_recipe_env(self, arch, with_flags_in_cc=True): | ||
""" | ||
Adds openssl recipe to include and library path. | ||
""" | ||
env = super(ScryptRecipe, self).get_recipe_env(arch, with_flags_in_cc) | ||
openssl_build_dir = self.get_recipe( | ||
'openssl', self.ctx).get_build_dir(arch.arch) | ||
print("openssl_build_dir:", openssl_build_dir) | ||
env['CC'] = '%s -I%s' % (env['CC'], join(openssl_build_dir, 'include')) | ||
env['LDFLAGS'] = env['LDFLAGS'] + ' -L{}'.format( | ||
self.ctx.get_libs_dir(arch.arch) + | ||
'-L{}'.format(self.ctx.libs_dir)) + ' -L{}'.format( | ||
openssl_build_dir) | ||
return env | ||
|
||
|
||
recipe = ScryptRecipe() |
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,20 @@ | ||
diff -r 91d194b6a6bd setup.py | ||
--- a/setup.py Sat Sep 17 15:29:49 2016 +0200 | ||
+++ b/setup.py Mon May 29 07:30:24 2017 +0000 | ||
@@ -13,7 +13,6 @@ | ||
|
||
if sys.platform.startswith('linux'): | ||
define_macros = [('HAVE_CLOCK_GETTIME', '1'), | ||
- ('HAVE_LIBRT', '1'), | ||
('HAVE_POSIX_MEMALIGN', '1'), | ||
('HAVE_STRUCT_SYSINFO', '1'), | ||
('HAVE_STRUCT_SYSINFO_MEM_UNIT', '1'), | ||
@@ -21,7 +20,7 @@ | ||
('HAVE_SYSINFO', '1'), | ||
('HAVE_SYS_SYSINFO_H', '1'), | ||
('_FILE_OFFSET_BITS', '64')] | ||
- libraries = ['crypto', 'rt'] | ||
+ libraries = ['crypto'] | ||
CFLAGS.append('-O2') | ||
elif sys.platform.startswith('win32'): | ||
define_macros = [('inline', '__inline')] |
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,32 @@ | ||
from os.path import join | ||
from pythonforandroid.recipe import CompiledComponentsPythonRecipe | ||
|
||
|
||
class Secp256k1Recipe(CompiledComponentsPythonRecipe): | ||
|
||
url = 'https://github.com/ludbb/secp256k1-py/archive/master.zip' | ||
|
||
call_hostpython_via_targetpython = False | ||
|
||
depends = [ | ||
'openssl', 'hostpython2', 'python2', 'setuptools', | ||
'libffi', 'cffi', 'libsecp256k1'] | ||
|
||
patches = ["cross_compile.patch", "pkg-config.patch", "find_lib.patch"] | ||
|
||
def get_recipe_env(self, arch=None): | ||
env = super(Secp256k1Recipe, self).get_recipe_env(arch) | ||
libsecp256k1 = self.get_recipe('libsecp256k1', self.ctx) | ||
libsecp256k1_dir = libsecp256k1.get_build_dir(arch.arch) | ||
env['PYTHON_ROOT'] = self.ctx.get_python_install_dir() | ||
env['CFLAGS'] = ' -I' + join(libsecp256k1_dir, 'include') | ||
env['CFLAGS'] += ' -I' + env['PYTHON_ROOT'] + '/include/python2.7' | ||
env['LDSHARED'] = env['CC'] + \ | ||
' -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions' | ||
env['LDFLAGS'] += ' -L{}'.format(libsecp256k1_dir) | ||
# TODO: hardcoded Python version | ||
env['LDFLAGS'] += " -landroid -lpython2.7 -lsecp256k1" | ||
return env | ||
|
||
|
||
recipe = Secp256k1Recipe() |
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 bba4bce..b86b369 100644 | ||
--- a/setup.py | ||
+++ b/setup.py | ||
@@ -191,6 +192,7 @@ class build_clib(_build_clib): | ||
"--disable-dependency-tracking", | ||
"--with-pic", | ||
"--enable-module-recovery", | ||
+ "--host=%s" % os.environ['TOOLCHAIN_PREFIX'], | ||
"--prefix", | ||
os.path.abspath(self.build_clib), | ||
] |
12 changes: 12 additions & 0 deletions
12
pythonforandroid/recipes/secp256k1/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 bba4bce..bfffbbc 100644 | ||
--- a/setup.py | ||
+++ b/setup.py | ||
@@ -263,7 +263,6 @@ setup( | ||
author_email='[email protected]', | ||
license='MIT', | ||
|
||
- setup_requires=['cffi>=1.3.0', 'pytest-runner==2.6.2'], | ||
install_requires=['cffi>=1.3.0'], | ||
tests_require=['pytest==2.8.7'], | ||
|
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 68a2a7f..b84f420 100644 | ||
--- a/setup_support.py | ||
+++ b/setup_support.py | ||
@@ -68,6 +68,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: |
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_support.py b/setup_support.py | ||
index 68a2a7f..42e85a3 100644 | ||
--- a/setup_support.py | ||
+++ b/setup_support.py | ||
@@ -40,6 +40,7 @@ def absolute(*paths): | ||
|
||
def build_flags(library, type_, path): | ||
"""Return separated build flags from pkg-config output""" | ||
+ return [] | ||
|
||
pkg_config_path = [path] | ||
if "PKG_CONFIG_PATH" in os.environ: |