Last active
November 4, 2018 09:40
-
-
Save tito/73a2d35c236bb34f6441b64be44c5683 to your computer and use it in GitHub Desktop.
P4A: Python 3 fixes with openssl support
This file contains hidden or 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
diff --git a/pythonforandroid/archs.py b/pythonforandroid/archs.py | |
index 864c41f1..d48f25c6 100644 | |
--- a/pythonforandroid/archs.py | |
+++ b/pythonforandroid/archs.py | |
@@ -30,13 +30,25 @@ class Arch(object): | |
d.format(arch=self)) | |
for d in self.ctx.include_dirs] | |
- def get_env(self, with_flags_in_cc=True): | |
+ def get_env(self, with_flags_in_cc=True, clang=False): | |
env = {} | |
- env['CFLAGS'] = ' '.join([ | |
- '-DANDROID', '-mandroid', '-fomit-frame-pointer' | |
- ' -D__ANDROID_API__={}'.format(self.ctx._android_api), | |
- ]) | |
+ cflags = [ | |
+ '-DANDROID', | |
+ '-fomit-frame-pointer', | |
+ '-D__ANDROID_API__={}'.format(self.ctx.ndk_api)] | |
+ # '-D__ANDROID_API__={}'.format(self.ctx._android_api)] | |
+ if not clang: | |
+ cflags += ['-mandroid'] | |
+ else: | |
+ cflags += ['-target armv7-none-linux-androideabi'] | |
+ android_host = 'arm-linux-androideabi' | |
+ platform_dir = join(self.ctx.ndk_dir, 'platforms', 'android-{}'.format(self.ctx.ndk_api), 'arch-arm') | |
+ toolchain = '{android_host}-4.9'.format(android_host=android_host) | |
+ toolchain = join(self.ctx.ndk_dir, 'toolchains', toolchain, 'prebuilt', 'linux-x86_64') | |
+ cflags += ['-gcc-toolchain {}'.format(toolchain)] | |
+ | |
+ env['CFLAGS'] = ' '.join(cflags) | |
env['LDFLAGS'] = ' ' | |
sysroot = join(self.ctx._ndk_dir, 'sysroot') | |
@@ -82,9 +94,21 @@ class Arch(object): | |
env['NDK_CCACHE'] = self.ctx.ccache | |
env.update({k: v for k, v in environ.items() if k.startswith('CCACHE_')}) | |
- cc = find_executable('{command_prefix}-gcc'.format( | |
- command_prefix=command_prefix), path=environ['PATH']) | |
+ if clang: | |
+ clang_path = join( | |
+ self.ctx.ndk_dir, 'toolchains', 'llvm', 'prebuilt', | |
+ 'linux-x86_64', 'bin') | |
+ environ['PATH'] = '{clang_path}:{path}'.format( | |
+ clang_path=clang_path, path=environ['PATH']) | |
+ exe = join(clang_path, 'clang') | |
+ execxx = join(clang_path, 'clang++') | |
+ else: | |
+ exe = '{command_prefix}-gcc'.format(command_prefix=command_prefix) | |
+ execxx = '{command_prefix}-g++'.format(command_prefix=command_prefix) | |
+ | |
+ cc = find_executable(exe, path=environ['PATH']) | |
if cc is None: | |
+ print(environ['PATH']) | |
print('Searching path are: {!r}'.format(environ['PATH'])) | |
warning('Couldn\'t find executable for CC. This indicates a ' | |
'problem locating the {} executable in the Android ' | |
@@ -93,20 +117,20 @@ class Arch(object): | |
exit(1) | |
if with_flags_in_cc: | |
- env['CC'] = '{ccache}{command_prefix}-gcc {cflags}'.format( | |
- command_prefix=command_prefix, | |
+ env['CC'] = '{ccache}{exe} {cflags}'.format( | |
+ exe=exe, | |
ccache=ccache, | |
cflags=env['CFLAGS']) | |
- env['CXX'] = '{ccache}{command_prefix}-g++ {cxxflags}'.format( | |
- command_prefix=command_prefix, | |
+ env['CXX'] = '{ccache}{execxx} {cxxflags}'.format( | |
+ execxx=execxx, | |
ccache=ccache, | |
cxxflags=env['CXXFLAGS']) | |
else: | |
- env['CC'] = '{ccache}{command_prefix}-gcc'.format( | |
- command_prefix=command_prefix, | |
+ env['CC'] = '{ccache}{exe}'.format( | |
+ exe=exe, | |
ccache=ccache) | |
- env['CXX'] = '{ccache}{command_prefix}-g++'.format( | |
- command_prefix=command_prefix, | |
+ env['CXX'] = '{ccache}{execxx}'.format( | |
+ execxx=execxx, | |
ccache=ccache) | |
env['AR'] = '{}-ar'.format(command_prefix) | |
@@ -151,8 +175,8 @@ class ArchARM(Arch): | |
class ArchARMv7_a(ArchARM): | |
arch = 'armeabi-v7a' | |
- def get_env(self, with_flags_in_cc=True): | |
- env = super(ArchARMv7_a, self).get_env(with_flags_in_cc) | |
+ def get_env(self, with_flags_in_cc=True, clang=False): | |
+ env = super(ArchARMv7_a, self).get_env(with_flags_in_cc, clang=clang) | |
env['CFLAGS'] = (env['CFLAGS'] + | |
(' -march=armv7-a -mfloat-abi=softfp ' | |
'-mfpu=vfp -mthumb')) | |
@@ -166,8 +190,8 @@ class Archx86(Arch): | |
command_prefix = 'i686-linux-android' | |
platform_dir = 'arch-x86' | |
- def get_env(self, with_flags_in_cc=True): | |
- env = super(Archx86, self).get_env(with_flags_in_cc) | |
+ def get_env(self, with_flags_in_cc=True, clang=False): | |
+ env = super(Archx86, self).get_env(with_flags_in_cc, clang=clang) | |
env['CFLAGS'] = (env['CFLAGS'] + | |
' -march=i686 -mtune=intel -mssse3 -mfpmath=sse -m32') | |
env['CXXFLAGS'] = env['CFLAGS'] | |
@@ -180,8 +204,8 @@ class Archx86_64(Arch): | |
command_prefix = 'x86_64-linux-android' | |
platform_dir = 'arch-x86' | |
- def get_env(self, with_flags_in_cc=True): | |
- env = super(Archx86_64, self).get_env(with_flags_in_cc) | |
+ def get_env(self, with_flags_in_cc=True, clang=False): | |
+ env = super(Archx86_64, self).get_env(with_flags_in_cc, clang=clang) | |
env['CFLAGS'] = (env['CFLAGS'] + | |
' -march=x86-64 -msse4.2 -mpopcnt -m64 -mtune=intel') | |
env['CXXFLAGS'] = env['CFLAGS'] | |
@@ -194,8 +218,8 @@ class ArchAarch_64(Arch): | |
command_prefix = 'aarch64-linux-android' | |
platform_dir = 'arch-arm64' | |
- def get_env(self, with_flags_in_cc=True): | |
- env = super(ArchAarch_64, self).get_env(with_flags_in_cc) | |
+ def get_env(self, with_flags_in_cc=True, clang=False): | |
+ env = super(ArchAarch_64, self).get_env(with_flags_in_cc, clang=clang) | |
incpath = ' -I' + join(dirname(__file__), 'includes', 'arm64-v8a') | |
env['EXTRA_CFLAGS'] = incpath | |
env['CFLAGS'] += incpath | |
diff --git a/pythonforandroid/build.py b/pythonforandroid/build.py | |
index 8044025b..898277fc 100644 | |
--- a/pythonforandroid/build.py | |
+++ b/pythonforandroid/build.py | |
@@ -381,7 +381,7 @@ class Context(object): | |
self.ndk_platform = join( | |
self.ndk_dir, | |
'platforms', | |
- 'android-{}'.format(self.android_api), | |
+ 'android-{}'.format(self.ndk_api), | |
platform_dir) | |
if not exists(self.ndk_platform): | |
warning('ndk_platform doesn\'t exist: {}'.format( | |
@@ -515,6 +515,8 @@ class Context(object): | |
# archs. | |
if self.python_recipe.from_crystax: | |
return self.get_python_install_dir() | |
+ elif 'hostpython3' in self.recipe_build_order: | |
+ return self.get_python_install_dir() | |
return join(self.get_python_install_dir(), | |
'lib', 'python2.7', 'site-packages') | |
@@ -621,7 +623,10 @@ def run_pymodules_install(ctx, modules): | |
venv = sh.Command(ctx.virtualenv) | |
with current_directory(join(ctx.build_dir)): | |
- shprint(venv, '--python=python2.7', 'venv') | |
+ if 'hostpython3' in ctx.recipe_build_order: | |
+ shprint(venv, '--python=python3', 'venv') | |
+ else: | |
+ shprint(venv, '--python=python2.7', 'venv') | |
info('Creating a requirements.txt file for the Python modules') | |
with open('requirements.txt', 'w') as fileh: | |
diff --git a/pythonforandroid/logger.py b/pythonforandroid/logger.py | |
index 38afba0e..f293f007 100644 | |
--- a/pythonforandroid/logger.py | |
+++ b/pythonforandroid/logger.py | |
@@ -148,8 +148,10 @@ def shprint(command, *args, **kwargs): | |
kwargs["_bg"] = True | |
is_critical = kwargs.pop('_critical', False) | |
tail_n = kwargs.pop('_tail', None) | |
+ full_debug = False | |
if "P4A_FULL_DEBUG" in os.environ: | |
tail_n = 0 | |
+ full_debug = True | |
filter_in = kwargs.pop('_filter', None) | |
filter_out = kwargs.pop('_filterout', None) | |
if len(logger.handlers) > 1: | |
@@ -177,6 +179,10 @@ def shprint(command, *args, **kwargs): | |
if isinstance(line, bytes): | |
line = line.decode('utf-8', errors='replace') | |
if logger.level > logging.DEBUG: | |
+ if full_debug: | |
+ stdout.write(line) | |
+ stdout.flush() | |
+ continue | |
msg = line.replace( | |
'\n', ' ').replace( | |
'\t', ' ').replace( | |
diff --git a/pythonforandroid/recipe.py b/pythonforandroid/recipe.py | |
index 273e0359..bd0c1f05 100644 | |
--- a/pythonforandroid/recipe.py | |
+++ b/pythonforandroid/recipe.py | |
@@ -452,12 +452,12 @@ class Recipe(with_metaclass(RecipeMeta)): | |
else: | |
info('{} is already unpacked, skipping'.format(self.name)) | |
- def get_recipe_env(self, arch=None, with_flags_in_cc=True): | |
+ def get_recipe_env(self, arch=None, with_flags_in_cc=True, clang=False): | |
"""Return the env specialized for the recipe | |
""" | |
if arch is None: | |
arch = self.filtered_archs[0] | |
- return arch.get_env(with_flags_in_cc=with_flags_in_cc) | |
+ return arch.get_env(with_flags_in_cc=with_flags_in_cc, clang=clang) | |
def prebuild_arch(self, arch): | |
'''Run any pre-build tasks for the Recipe. By default, this checks if | |
diff --git a/pythonforandroid/recipes/android/__init__.py b/pythonforandroid/recipes/android/__init__.py | |
index 3c96a5fd..5513aa05 100644 | |
--- a/pythonforandroid/recipes/android/__init__.py | |
+++ b/pythonforandroid/recipes/android/__init__.py | |
@@ -13,7 +13,7 @@ class AndroidRecipe(IncludedFilesBehaviour, CythonRecipe): | |
src_filename = 'src' | |
- depends = [('pygame', 'sdl2', 'genericndkbuild'), ('python2', 'python3crystax')] | |
+ depends = [('pygame', 'sdl2', 'genericndkbuild'), ('python2', 'python3crystax', 'python3')] | |
config_env = {} | |
diff --git a/pythonforandroid/recipes/android/src/android/_android.pyx b/pythonforandroid/recipes/android/src/android/_android.pyx | |
index f4f37d8a..e5c62a98 100644 | |
--- a/pythonforandroid/recipes/android/src/android/_android.pyx | |
+++ b/pythonforandroid/recipes/android/src/android/_android.pyx | |
@@ -9,12 +9,12 @@ IF BOOTSTRAP == 'pygame': | |
def check_pause(): | |
return SDL_ANDROID_CheckPause() | |
- | |
+ | |
def wait_for_resume(): | |
android_accelerometer_enable(False) | |
SDL_ANDROID_WaitForResume() | |
android_accelerometer_enable(accelerometer_enabled) | |
- | |
+ | |
def map_key(scancode, keysym): | |
SDL_ANDROID_MapKey(scancode, keysym) | |
@@ -300,16 +300,16 @@ IF IS_PYGAME: | |
j_chooser_title = <bytes>chooser_title | |
android_action_send(j_mimetype, j_filename, j_subject, j_text, | |
j_chooser_title) | |
- | |
+ | |
cdef extern int android_checkstop() | |
cdef extern void android_ackstop() | |
- | |
+ | |
def check_stop(): | |
return android_checkstop() | |
- | |
+ | |
def ack_stop(): | |
android_ackstop() | |
- | |
+ | |
# ------------------------------------------------------------------- | |
# URL Opening. | |
def open_url(url): | |
@@ -330,9 +330,9 @@ class AndroidBrowser(object): | |
return open_url(url) | |
def open_new_tab(self, url): | |
return open_url(url) | |
- | |
+ | |
import webbrowser | |
-webbrowser.register('android', AndroidBrowser, None, -1) | |
+webbrowser.register('android', AndroidBrowser) | |
cdef extern void android_start_service(char *, char *, char *) | |
def start_service(title=None, description=None, arg=None): | |
@@ -381,5 +381,3 @@ class AndroidService(object): | |
'''Stop the service. | |
''' | |
stop_service() | |
- | |
- | |
diff --git a/pythonforandroid/recipes/cryptography/__init__.py b/pythonforandroid/recipes/cryptography/__init__.py | |
index 0429cc35..3a5c1cc3 100644 | |
--- a/pythonforandroid/recipes/cryptography/__init__.py | |
+++ b/pythonforandroid/recipes/cryptography/__init__.py | |
@@ -17,8 +17,8 @@ class CryptographyRecipe(CompiledComponentsPythonRecipe): | |
env['LDSHARED'] = env['CC'] + ' -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions' | |
env['CFLAGS'] += ' -I' + join(openssl_dir, 'include') | |
env['LDFLAGS'] += ' -L' + openssl_dir + \ | |
- ' -lssl' + r.version + \ | |
- ' -lcrypto' + r.version | |
+ ' -lssl' + r.lib_version + \ | |
+ ' -lcrypto' + r.lib_version | |
return env | |
diff --git a/pythonforandroid/recipes/dateutil/__init__.py b/pythonforandroid/recipes/dateutil/__init__.py | |
index ace3c638..4c19e643 100644 | |
--- a/pythonforandroid/recipes/dateutil/__init__.py | |
+++ b/pythonforandroid/recipes/dateutil/__init__.py | |
@@ -6,7 +6,7 @@ class DateutilRecipe(PythonRecipe): | |
version = '2.6.0' | |
url = 'https://pypi.python.org/packages/51/fc/39a3fbde6864942e8bb24c93663734b74e281b984d1b8c4f95d64b0c21f6/python-dateutil-2.6.0.tar.gz' | |
- depends = ['python2', "setuptools"] | |
+ depends = [('python2', 'python3'), "setuptools"] | |
call_hostpython_via_targetpython = False | |
install_in_hostpython = True | |
diff --git a/pythonforandroid/recipes/hostpython3/__init__.py b/pythonforandroid/recipes/hostpython3/__init__.py | |
index 791b0659..54af977c 100644 | |
--- a/pythonforandroid/recipes/hostpython3/__init__.py | |
+++ b/pythonforandroid/recipes/hostpython3/__init__.py | |
@@ -10,7 +10,7 @@ class Hostpython3Recipe(Recipe): | |
url = 'https://www.python.org/ftp/python/{version}/Python-{version}.tgz' | |
name = 'hostpython3' | |
- conflicts = ['hostpython2'] | |
+ conflicts = ['hostpython2', 'hostpython3crystax'] | |
def get_build_container_dir(self, arch=None): | |
choices = self.check_recipe_choices() | |
diff --git a/pythonforandroid/recipes/libtorrent/__init__.py b/pythonforandroid/recipes/libtorrent/__init__.py | |
index f358f516..46a51159 100644 | |
--- a/pythonforandroid/recipes/libtorrent/__init__.py | |
+++ b/pythonforandroid/recipes/libtorrent/__init__.py | |
@@ -72,7 +72,7 @@ class LibtorrentRecipe(Recipe): | |
if 'openssl' in recipe.ctx.recipe_build_order: | |
r = self.get_recipe('openssl', self.ctx) | |
env['OPENSSL_BUILD_PATH'] = r.get_build_dir(arch.arch) | |
- env['OPENSSL_VERSION'] = r.version | |
+ env['OPENSSL_VERSION'] = r.lib_version | |
return env | |
diff --git a/pythonforandroid/recipes/openssl/__init__.py b/pythonforandroid/recipes/openssl/__init__.py | |
index b8256e86..2e6e899c 100644 | |
--- a/pythonforandroid/recipes/openssl/__init__.py | |
+++ b/pythonforandroid/recipes/openssl/__init__.py | |
@@ -5,12 +5,13 @@ import sh | |
class OpenSSLRecipe(Recipe): | |
- version = '1.0.2h' | |
+ version = '1.1.1' | |
+ lib_version = '1.1' | |
url = 'https://www.openssl.org/source/openssl-{version}.tar.gz' | |
def should_build(self, arch): | |
- return not self.has_libs(arch, 'libssl' + self.version + '.so', | |
- 'libcrypto' + self.version + '.so') | |
+ return not self.has_libs(arch, 'libssl' + self.lib_version + '.so', | |
+ 'libcrypto' + self.lib_version + '.so') | |
def check_symbol(self, env, sofile, symbol): | |
nm = env.get('NM', 'nm') | |
@@ -22,11 +23,16 @@ class OpenSSLRecipe(Recipe): | |
return False | |
def get_recipe_env(self, arch=None): | |
- env = super(OpenSSLRecipe, self).get_recipe_env(arch) | |
- env['OPENSSL_VERSION'] = self.version | |
- env['CFLAGS'] += ' ' + env['LDFLAGS'] | |
- env['CC'] += ' ' + env['LDFLAGS'] | |
+ env = super(OpenSSLRecipe, self).get_recipe_env(arch, clang=True) | |
+ env['OPENSSL_VERSION'] = self.lib_version | |
+ # env['CFLAGS'] += ' ' + env['LDFLAGS'] | |
+ # env['CC'] += ' ' + env['LDFLAGS'] | |
env['MAKE'] = 'make' # This removes the '-j5', which isn't safe | |
+ env['ANDROID_NDK'] = self.ctx.ndk_dir | |
+ # env['ANDROID_SDK'] = self.ctx.sdk_dir | |
+ from pprint import pprint | |
+ pprint(env) | |
+ print(env) | |
return env | |
def select_build_arch(self, arch): | |
@@ -34,7 +40,7 @@ class OpenSSLRecipe(Recipe): | |
if 'arm64' in aname: | |
return 'linux-aarch64' | |
if 'v7a' in aname: | |
- return 'android-armv7' | |
+ return 'android-arm' | |
if 'arm' in aname: | |
return 'android' | |
if 'x86' in aname: | |
@@ -48,20 +54,27 @@ class OpenSSLRecipe(Recipe): | |
# so instead we manually run perl passing in Configure | |
perl = sh.Command('perl') | |
buildarch = self.select_build_arch(arch) | |
- shprint(perl, 'Configure', 'shared', 'no-dso', 'no-krb5', buildarch, _env=env) | |
+ # XXX if we don't have no-asm, using clang and ndk-15c, i got: | |
+ # crypto/aes/bsaes-armv7.S:1372:14: error: immediate operand must be in the range [0,4095] | |
+ # add r8, r6, #.LREVM0SR-.LM0 @ borrow r8 | |
+ # ^ | |
+ # crypto/aes/bsaes-armv7.S:1434:14: error: immediate operand must be in the range [0,4095] | |
+ # sub r6, r8, #.LREVM0SR-.LSR @ pass constants | |
+ shprint(perl, 'Configure', 'shared', 'no-dso', 'no-asm', buildarch, _env=env) | |
self.apply_patch('disable-sover.patch', arch.arch) | |
- self.apply_patch('rename-shared-lib.patch', arch.arch) | |
# check_ssl = partial(self.check_symbol, env, 'libssl' + self.version + '.so') | |
- check_crypto = partial(self.check_symbol, env, 'libcrypto' + self.version + '.so') | |
+ check_crypto = partial(self.check_symbol, env, 'libcrypto' + self.lib_version + '.so') | |
while True: | |
shprint(sh.make, 'build_libs', _env=env) | |
- if all(map(check_crypto, ('SSLeay', 'MD5_Transform', 'MD4_Init'))): | |
+ if all(map(check_crypto, ('MD5_Transform', 'MD4_Init'))): | |
break | |
+ import time | |
+ time.sleep(3) | |
shprint(sh.make, 'clean', _env=env) | |
- self.install_libs(arch, 'libssl' + self.version + '.so', | |
- 'libcrypto' + self.version + '.so') | |
+ self.install_libs(arch, 'libssl' + self.lib_version + '.so', | |
+ 'libcrypto' + self.lib_version + '.so') | |
recipe = OpenSSLRecipe() | |
diff --git a/pythonforandroid/recipes/openssl/disable-sover.patch b/pythonforandroid/recipes/openssl/disable-sover.patch | |
index 6099fadc..d944483c 100644 | |
--- a/pythonforandroid/recipes/openssl/disable-sover.patch | |
+++ b/pythonforandroid/recipes/openssl/disable-sover.patch | |
@@ -1,20 +1,11 @@ | |
---- openssl/Makefile 2016-01-28 17:26:49.159522273 +0100 | |
-+++ b/Makefile 2016-01-28 17:26:54.358438402 +0100 | |
-@@ -342,7 +342,7 @@ | |
- link-shared: | |
- @ set -e; for i in $(SHLIBDIRS); do \ | |
- $(MAKE) -f $(HERE)/Makefile.shared -e $(BUILDENV) \ | |
-- LIBNAME=$$i LIBVERSION=$(SHLIB_MAJOR).$(SHLIB_MINOR) \ | |
-+ LIBNAME=$$i LIBVERSION= \ | |
- LIBCOMPATVERSIONS=";$(SHLIB_VERSION_HISTORY)" \ | |
- symlink.$(SHLIB_TARGET); \ | |
- libs="$$libs -l$$i"; \ | |
-@@ -356,7 +356,7 @@ | |
- libs="$(LIBKRB5) $$libs"; \ | |
- fi; \ | |
- $(CLEARENV) && $(MAKE) -f Makefile.shared -e $(BUILDENV) \ | |
-- LIBNAME=$$i LIBVERSION=$(SHLIB_MAJOR).$(SHLIB_MINOR) \ | |
-+ LIBNAME=$$i LIBVERSION= \ | |
- LIBCOMPATVERSIONS=";$(SHLIB_VERSION_HISTORY)" \ | |
- LIBDEPS="$$libs $(EX_LIBS)" \ | |
- link_a.$(SHLIB_TARGET); \ | |
+--- openssl/Makefile.orig 2018-10-20 22:49:40.418310423 +0200 | |
++++ openssl/Makefile 2018-10-20 22:50:23.347322403 +0200 | |
+@@ -19,7 +19,7 @@ | |
+ SHLIB_MAJOR=1 | |
+ SHLIB_MINOR=1 | |
+ SHLIB_TARGET=linux-shared | |
+-SHLIB_EXT=.so.$(SHLIB_VERSION_NUMBER) | |
++SHLIB_EXT=$(SHLIB_VERSION_NUMBER).so | |
+ SHLIB_EXT_SIMPLE=.so | |
+ SHLIB_EXT_IMPORT= | |
+ | |
diff --git a/pythonforandroid/recipes/python2/__init__.py b/pythonforandroid/recipes/python2/__init__.py | |
index e58488b5..919f5e59 100644 | |
--- a/pythonforandroid/recipes/python2/__init__.py | |
+++ b/pythonforandroid/recipes/python2/__init__.py | |
@@ -92,7 +92,7 @@ class Python2Recipe(TargetPythonRecipe): | |
setuplocal = join('Modules', 'Setup.local') | |
shprint(sh.cp, join(self.get_recipe_dir(), 'Setup.local-ssl'), setuplocal) | |
shprint(sh.sed, '-i.backup', 's#^SSL=.*#SSL={}#'.format(openssl_build_dir), setuplocal) | |
- env['OPENSSL_VERSION'] = recipe.version | |
+ env['OPENSSL_VERSION'] = recipe.lib_version | |
if 'sqlite3' in self.ctx.recipe_build_order: | |
# Include sqlite3 in python2 build | |
diff --git a/pythonforandroid/recipes/python3/__init__.py b/pythonforandroid/recipes/python3/__init__.py | |
index 7fc5e14d..977a726a 100644 | |
--- a/pythonforandroid/recipes/python3/__init__.py | |
+++ b/pythonforandroid/recipes/python3/__init__.py | |
@@ -2,6 +2,7 @@ from pythonforandroid.recipe import TargetPythonRecipe, Recipe | |
from pythonforandroid.toolchain import shprint, current_directory, info | |
from pythonforandroid.patching import (is_darwin, is_api_gt, | |
check_all, is_api_lt, is_ndk) | |
+from pythonforandroid.util import ensure_dir | |
from pythonforandroid.logger import logger | |
from pythonforandroid.util import ensure_dir | |
from os.path import exists, join, realpath | |
@@ -17,11 +18,11 @@ class Python3Recipe(TargetPythonRecipe): | |
depends = ['hostpython3'] | |
conflicts = ['python3crystax', 'python2'] | |
- # opt_depends = ['openssl', 'sqlite3'] | |
+ opt_depends = ['openssl', 'sqlite3'] | |
def build_arch(self, arch): | |
recipe_build_dir = self.get_build_dir(arch.arch) | |
- | |
+ | |
# Create a subdirectory to actually perform the build | |
build_dir = join(recipe_build_dir, 'android-build') | |
ensure_dir(build_dir) | |
@@ -67,6 +68,26 @@ class Python3Recipe(TargetPythonRecipe): | |
env['CPPFLAGS'] = env.get('CPPFLAGS', '') + ' ' + ndk_flags | |
env['LDFLAGS'] = env.get('LDFLAGS', '') + ' --sysroot={} -L{}'.format(sysroot, join(sysroot, 'usr', 'lib')) | |
+ if 'openssl' in self.ctx.recipe_build_order: | |
+ recipe = Recipe.get_recipe('openssl', self.ctx) | |
+ openssl_build_dir = recipe.get_build_dir(arch.arch) | |
+ ensure_dir('Modules') | |
+ setuplocal = join('Modules', 'Setup.local') | |
+ shprint(sh.cp, join(self.get_recipe_dir(), 'Setup.local-ssl'), setuplocal) | |
+ shprint(sh.sed, '-i.backup', 's#^SSL=.*#SSL={}#'.format(openssl_build_dir), setuplocal) | |
+ env['OPENSSL_VERSION'] = recipe.lib_version | |
+ | |
+ if 'sqlite3' in self.ctx.recipe_build_order: | |
+ # Include sqlite3 in python2 build | |
+ recipe = Recipe.get_recipe('sqlite3', self.ctx) | |
+ include = ' -I' + recipe.get_build_dir(arch.arch) | |
+ lib = ' -L' + recipe.get_lib_dir(arch) + ' -lsqlite3' | |
+ # Insert or append to env | |
+ flag = 'CPPFLAGS' | |
+ env[flag] = env[flag] + include if flag in env else include | |
+ flag = 'LDFLAGS' | |
+ env[flag] = env[flag] + lib if flag in env else lib | |
+ | |
# Manually add the libs directory, and copy some object | |
# files to the current directory otherwise they aren't | |
# picked up. This seems necessary because the --sysroot | |
diff --git a/pythonforandroid/recipes/requests/__init__.py b/pythonforandroid/recipes/requests/__init__.py | |
index 6d3ee7c7..195fb62b 100644 | |
--- a/pythonforandroid/recipes/requests/__init__.py | |
+++ b/pythonforandroid/recipes/requests/__init__.py | |
@@ -4,7 +4,7 @@ from pythonforandroid.recipe import PythonRecipe | |
class RequestsRecipe(PythonRecipe): | |
version = '2.13.0' | |
url = 'https://github.com/kennethreitz/requests/archive/v{version}.tar.gz' | |
- depends = [('hostpython2', 'hostpython3crystax'), 'setuptools'] | |
+ depends = [('hostpython2', 'hostpython3', 'hostpython3crystax'), 'setuptools'] | |
site_packages_name = 'requests' | |
call_hostpython_via_targetpython = False | |
diff --git a/pythonforandroid/recipes/setuptools/__init__.py b/pythonforandroid/recipes/setuptools/__init__.py | |
index fd873e7d..2b67bcf0 100644 | |
--- a/pythonforandroid/recipes/setuptools/__init__.py | |
+++ b/pythonforandroid/recipes/setuptools/__init__.py | |
@@ -5,7 +5,7 @@ class SetuptoolsRecipe(PythonRecipe): | |
version = '40.0.0' | |
url = 'https://pypi.python.org/packages/source/s/setuptools/setuptools-{version}.zip' | |
- depends = [('python2', 'python3crystax')] | |
+ depends = [('python2', 'python3crystax', 'python3')] | |
call_hostpython_via_targetpython = False | |
install_in_hostpython = True |
This file contains hidden or 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
SSL= | |
_ssl _ssl.c \ | |
-DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \ | |
-L$(SSL) -lssl$(OPENSSL_VERSION) -lcrypto$(OPENSSL_VERSION) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment