Skip to content
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
18 changes: 18 additions & 0 deletions pythonforandroid/recipes/cffi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from pythonforandroid.recipe import CompiledComponentsPythonRecipe


Expand All @@ -15,15 +16,32 @@ class CffiRecipe(CompiledComponentsPythonRecipe):

def get_recipe_env(self, arch=None):
env = super(CffiRecipe, self).get_recipe_env(arch)
# sets linker to use the correct gcc (cross compiler)
env['LDSHARED'] = env['CC'] + ' -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions'
libffi = self.get_recipe('libffi', self.ctx)
includes = libffi.get_include_dirs(arch)
env['CFLAGS'] = ' -I'.join([env.get('CFLAGS', '')] + includes)
env['LDFLAGS'] = (env.get('CFLAGS', '') + ' -L' +
self.ctx.get_libs_dir(arch.arch))
env['LDFLAGS'] += ' -L{}'.format(os.path.join(self.ctx.bootstrap.build_dir, 'libs', arch.arch))
# required for libc and libdl
ndk_dir = self.ctx.ndk_platform
ndk_lib_dir = os.path.join(ndk_dir, 'usr', 'lib')
env['LDFLAGS'] += ' -L{}'.format(ndk_lib_dir)
env['LDFLAGS'] += " --sysroot={}".format(self.ctx.ndk_platform)
env['PYTHONPATH'] = ':'.join([
self.ctx.get_site_packages_dir(),
env['BUILDLIB_PATH'],
])
if self.ctx.ndk == 'crystax':
# only keeps major.minor (discards patch)
python_version = self.ctx.python_recipe.version[0:3]
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)
return env


Expand Down
5 changes: 3 additions & 2 deletions pythonforandroid/recipes/decorator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@


class DecoratorPyRecipe(PythonRecipe):
version = '4.0.9'
version = '4.2.1'
url = 'https://pypi.python.org/packages/source/d/decorator/decorator-{version}.tar.gz'
depends = ['hostpython2', 'setuptools']
url = 'https://github.com/micheles/decorator/archive/{version}.tar.gz'
depends = [('python2', 'python3crystax'), 'setuptools']
site_packages_name = 'decorator'
call_hostpython_via_targetpython = False

Expand Down
4 changes: 2 additions & 2 deletions pythonforandroid/recipes/idna/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

class IdnaRecipe(PythonRecipe):
name = 'idna'
version = '2.0'
url = 'https://pypi.python.org/packages/source/i/idna/idna-{version}.tar.gz'
version = '2.6'
url = 'https://github.com/kjd/idna/archive/v{version}.tar.gz'

depends = [('python2', 'python3crystax'), 'setuptools']

Expand Down
11 changes: 8 additions & 3 deletions pythonforandroid/recipes/pycryptodome/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@


class PycryptodomeRecipe(PythonRecipe):
version = 'v3.4.6'
url = 'https://github.com/Legrandin/pycryptodome/archive/{version}.tar.gz'
version = '3.4.6'
url = 'https://github.com/Legrandin/pycryptodome/archive/v{version}.tar.gz'
depends = [('python2', 'python3crystax'), 'setuptools', 'cffi']

depends = ['python2', 'setuptools', 'cffi']
def get_recipe_env(self, arch=None, with_flags_in_cc=True):
env = super(PycryptodomeRecipe, 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'
return env


recipe = PycryptodomeRecipe()
19 changes: 18 additions & 1 deletion pythonforandroid/recipes/pysha3/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
import os
from pythonforandroid.recipe import PythonRecipe


# TODO: CompiledComponentsPythonRecipe
class Pysha3Recipe(PythonRecipe):
version = '1.0.2'
url = 'https://github.com/tiran/pysha3/archive/{version}.tar.gz'
depends = [('python2', 'python3crystax'), 'setuptools']

depends = ['python2', 'setuptools']
def get_recipe_env(self, arch=None, with_flags_in_cc=True):
env = super(Pysha3Recipe, 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'
# CFLAGS may only be used to specify C compiler flags, for macro definitions use CPPFLAGS
env['CPPFLAGS'] = env['CFLAGS'] + ' -I{}/sources/python/3.5/include/python/'.format(self.ctx.ndk_dir)
env['CFLAGS'] = ''
# LDFLAGS may only be used to specify linker flags, for libraries use LIBS
env['LDFLAGS'] = env['LDFLAGS'].replace('-lm', '').replace('-lcrystax', '')
env['LDFLAGS'] += ' -L{}'.format(os.path.join(self.ctx.bootstrap.build_dir, 'libs', arch.arch))
env['LIBS'] = ' -lm'
if self.ctx.ndk == 'crystax':
env['LIBS'] += ' -lcrystax -lpython{}m'.format(self.ctx.python_recipe.version[0:3])
env['LDSHARED'] += env['LIBS']
return env


recipe = Pysha3Recipe()
3 changes: 1 addition & 2 deletions pythonforandroid/recipes/pyyaml/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@


class PyYamlRecipe(PythonRecipe):
version = "3.11"
version = "3.12"
url = 'http://pyyaml.org/download/pyyaml/PyYAML-{version}.tar.gz'
depends = [('python2', 'python3crystax'), "setuptools"]
site_packages_name = 'pyyaml'
call_hostpython_via_targetpython = False


recipe = PyYamlRecipe()
2 changes: 1 addition & 1 deletion pythonforandroid/recipes/requests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
class RequestsRecipe(PythonRecipe):
version = '2.13.0'
url = 'https://github.com/kennethreitz/requests/archive/v{version}.tar.gz'
depends = ['hostpython2', 'setuptools']
depends = [('hostpython2', 'hostpython3crystax'), 'setuptools']
site_packages_name = 'requests'
call_hostpython_via_targetpython = False

Expand Down
25 changes: 16 additions & 9 deletions pythonforandroid/recipes/scrypt/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import os
from pythonforandroid.recipe import CythonRecipe
from os.path import join


class ScryptRecipe(CythonRecipe):

url = 'https://bitbucket.org/mhallin/py-scrypt/get/default.zip'

depends = ['python2', 'setuptools', 'openssl']

version = '0.8.6'
url = 'https://bitbucket.org/mhallin/py-scrypt/get/v{version}.zip'
depends = [('python2', 'python3crystax'), 'setuptools', 'openssl']
call_hostpython_via_targetpython = False

patches = ["remove_librt.patch"]

def get_recipe_env(self, arch, with_flags_in_cc=True):
Expand All @@ -19,12 +17,21 @@ def get_recipe_env(self, arch, with_flags_in_cc=True):
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(
env['CFLAGS'] += ' -I{}'.format(os.path.join(openssl_build_dir, 'include'))
env['LDFLAGS'] += ' -L{}'.format(
self.ctx.get_libs_dir(arch.arch) +
'-L{}'.format(self.ctx.libs_dir)) + ' -L{}'.format(
openssl_build_dir)
# required additional library and path for Crystax
if self.ctx.ndk == 'crystax':
# only keeps major.minor (discards patch)
python_version = self.ctx.python_recipe.version[0:3]
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)
return env


Expand Down
10 changes: 5 additions & 5 deletions pythonforandroid/recipes/scrypt/remove_librt.patch
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
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 @@
--- a/setup.py 2018-05-06 23:25:08.757522119 +0200
+++ b/setup.py 2018-05-06 23:25:30.269797365 +0200
@@ -15,7 +15,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 @@
@@ -23,8 +22,7 @@
('HAVE_SYSINFO', '1'),
('HAVE_SYS_SYSINFO_H', '1'),
('_FILE_OFFSET_BITS', '64')]
- libraries = ['crypto', 'rt']
- includes = ['/usr/local/include', '/usr/include']
+ libraries = ['crypto']
CFLAGS.append('-O2')
elif sys.platform.startswith('win32'):
Expand Down
36 changes: 24 additions & 12 deletions pythonforandroid/recipes/secp256k1/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from os.path import join
import os
from pythonforandroid.recipe import PythonRecipe


Expand All @@ -9,25 +9,37 @@ class Secp256k1Recipe(PythonRecipe):
call_hostpython_via_targetpython = False

depends = [
'openssl', 'hostpython2', 'python2', 'setuptools',
'libffi', 'cffi', 'libffi', 'libsecp256k1']
'openssl', ('hostpython2', 'hostpython3crystax'),
('python2', 'python3crystax'), 'setuptools',
'libffi', 'cffi', 'libsecp256k1']

patches = [
"cross_compile.patch", "drop_setup_requires.patch",
"pkg-config.patch", "find_lib.patch", "no-download.patch"]

def get_recipe_env(self, arch=None):
env = super(Secp256k1Recipe, self).get_recipe_env(arch)
def get_recipe_env(self, arch=None, with_flags_in_cc=True):
env = super(Secp256k1Recipe, 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'
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"
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


Expand Down