From a529d7732e220de6e08310d6a3be7ae13901d42e Mon Sep 17 00:00:00 2001 From: opacam Date: Fri, 19 Oct 2018 12:39:25 +0200 Subject: [PATCH] Move from bpo-30386 to python 3.7.0 maintaining libs support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Includes commits from @inclement's pr "Python 3 recipe" (squashed into this commit):     - Moved from bpo-30386 branch to python 3.7.0 official distribution     - Made all version references in python url dynamic Plus, update the libs patches in order to work with python 3.7.0. References: #1412, inclement/python-for-android@588f736 and inclement/python-for-android@a7f9348 --- pythonforandroid/recipes/python3/__init__.py | 8 +-- .../python3/patches/python-3.7.0-libs.patch | 51 +++++++++++++++++++ .../python3/patches/python-3.x.x-libs.patch | 47 ----------------- 3 files changed, 55 insertions(+), 51 deletions(-) create mode 100644 pythonforandroid/recipes/python3/patches/python-3.7.0-libs.patch delete mode 100644 pythonforandroid/recipes/python3/patches/python-3.x.x-libs.patch diff --git a/pythonforandroid/recipes/python3/__init__.py b/pythonforandroid/recipes/python3/__init__.py index e0747b5c4a..af4376f098 100644 --- a/pythonforandroid/recipes/python3/__init__.py +++ b/pythonforandroid/recipes/python3/__init__.py @@ -52,8 +52,8 @@ class Python3Recipe(TargetPythonRecipe): - version = 'bpo-30386' - url = 'https://github.com/inclement/cpython/archive/{version}.zip' + version = '3.7.0' + url = 'https://www.python.org/ftp/python/{version}/Python-{version}.tgz' name = 'python3' depends = ['hostpython3'] @@ -61,7 +61,7 @@ class Python3Recipe(TargetPythonRecipe): opt_depends = ['libffi', 'libexpat', 'openssl', 'sqlite3'] # TODO: More patches maybe be needed, but with those # two we successfully build and run a simple app - patches = ['patches/python-3.x.x-libs.patch', + patches = ['patches/python-{version}-libs.patch'.format(version=version), 'patches/fix-termios.patch'] def set_libs_flags(self, env, arch=None): @@ -121,7 +121,7 @@ def set_libs_flags(self, env, arch=None): # Sets special python compilation flags for some libs. # The openssl and sqlite env variables are set - # via patch: patches/python-3.x.x-libs.patch + # via patch: patches/python-3.7.0-libs.patch if lib == 'openssl': env['OPENSSL_BUILD'] = b env['OPENSSL_VERSION'] = r.version diff --git a/pythonforandroid/recipes/python3/patches/python-3.7.0-libs.patch b/pythonforandroid/recipes/python3/patches/python-3.7.0-libs.patch new file mode 100644 index 0000000000..c891593eb9 --- /dev/null +++ b/pythonforandroid/recipes/python3/patches/python-3.7.0-libs.patch @@ -0,0 +1,51 @@ +diff -Naurp Python-3.7.0.orig/setup.py Python-3.7.0-xcompile/setup.py +--- Python-3.7.0.orig/setup.py 2018-06-27 05:07:35.000000000 +0200 ++++ Python-3.7.0-xcompile/setup.py 2018-07-22 20:51:47.793048200 +0200 +@@ -1135,7 +1158,13 @@ class PyBuildExt(build_ext): + '/usr/local/include/sqlite3', + ] + if cross_compiling: +- sqlite_inc_paths = [] ++ # The common install prefix of 3rd party headers used during ++ # cross compilation ++ mydir = os.environ.get('PYTHON_XCOMPILE_DEPENDENCIES_PREFIX') ++ if mydir: ++ sqlite_inc_paths = [mydir + '/include'] ++ else: ++ sqlite_inc_paths = [] + MIN_SQLITE_VERSION_NUMBER = (3, 0, 8) + MIN_SQLITE_VERSION = ".".join([str(x) + for x in MIN_SQLITE_VERSION_NUMBER]) +@@ -1186,8 +1215,9 @@ class PyBuildExt(build_ext): + sqlite_dirs_to_check + lib_dirs, 'sqlite3') + if sqlite_libfile: + sqlite_libdir = [os.path.abspath(os.path.dirname(sqlite_libfile))] +- +- if sqlite_incdir and sqlite_libdir: ++ sqlite_incdir = os.environ["SQLITE3_INC_DIR"] ++ sqlite_libdir = [os.environ["SQLITE3_LIB_DIR"]] ++ if os.path.isdir(sqlite_incdir) and os.path.isdir(sqlite_libdir[0]): + sqlite_srcs = ['_sqlite/cache.c', + '_sqlite/connection.c', + '_sqlite/cursor.c', +@@ -2138,8 +2168,9 @@ class PyBuildExt(build_ext): + sep = ' ' + sep + return [v.strip() for v in value.split(sep) if v.strip()] + +- openssl_includes = split_var('OPENSSL_INCLUDES', '-I') +- openssl_libdirs = split_var('OPENSSL_LDFLAGS', '-L') ++ openssl_includes = [ ++ os.path.join(os.environ["OPENSSL_BUILD"], 'include')] ++ openssl_libdirs = [os.environ["OPENSSL_BUILD"]] + openssl_libs = split_var('OPENSSL_LIBS', '-l') + if not openssl_libs: + # libssl and libcrypto not found +@@ -2147,7 +2178,7 @@ class PyBuildExt(build_ext): + + # Find OpenSSL includes + ssl_incs = find_file( +- 'openssl/ssl.h', inc_dirs, openssl_includes ++ 'openssl/ssl.h', openssl_includes, inc_dirs + ) + if ssl_incs is None: + return None, None diff --git a/pythonforandroid/recipes/python3/patches/python-3.x.x-libs.patch b/pythonforandroid/recipes/python3/patches/python-3.x.x-libs.patch deleted file mode 100644 index ff7b3d7d01..0000000000 --- a/pythonforandroid/recipes/python3/patches/python-3.x.x-libs.patch +++ /dev/null @@ -1,47 +0,0 @@ -diff -Naurp cpython-bpo-30386.orig/setup.py cpython-bpo-30386/setup.py ---- cpython-bpo-30386.orig/setup.py 2018-09-15 23:45:17.000000000 +0200 -+++ cpython-bpo-30386/setup.py 2018-10-18 13:12:59.798278300 +0200 -@@ -859,6 +870,7 @@ class PyBuildExt(build_ext): - depends = ['socketmodule.h']) ) - # Detect SSL support for the socket module (via _ssl) - search_for_ssl_incs_in = [ -+ os.path.join(os.environ["OPENSSL_BUILD"], 'include'), - '/usr/local/ssl/include', - '/usr/contrib/ssl/include/' - ] -@@ -871,7 +883,8 @@ class PyBuildExt(build_ext): - if krb5_h: - ssl_incs += krb5_h - ssl_libs = find_library_file(self.compiler, 'ssl',lib_dirs, -- ['/usr/local/ssl/lib', -+ [os.environ["OPENSSL_BUILD"], -+ '/usr/local/ssl/lib', - '/usr/contrib/ssl/lib/' - ] ) - -@@ -1177,7 +1190,13 @@ class PyBuildExt(build_ext): - '/usr/local/include/sqlite3', - ] - if cross_compiling: -- sqlite_inc_paths = [] -+ # The common install prefix of 3rd party headers used during -+ # cross compilation -+ mydir = os.environ.get('PYTHON_XCOMPILE_DEPENDENCIES_PREFIX') -+ if mydir: -+ sqlite_inc_paths = [mydir + '/include'] -+ else: -+ sqlite_inc_paths = [] - MIN_SQLITE_VERSION_NUMBER = (3, 0, 8) - MIN_SQLITE_VERSION = ".".join([str(x) - for x in MIN_SQLITE_VERSION_NUMBER]) -@@ -1229,7 +1248,9 @@ class PyBuildExt(build_ext): - if sqlite_libfile: - sqlite_libdir = [os.path.abspath(os.path.dirname(sqlite_libfile))] - -- if sqlite_incdir and sqlite_libdir: -+ sqlite_incdir = os.environ["SQLITE3_INC_DIR"] -+ sqlite_libdir = [os.environ["SQLITE3_LIB_DIR"]] -+ if os.path.isdir(sqlite_incdir) and os.path.isdir(sqlite_libdir[0]): - sqlite_srcs = ['_sqlite/cache.c', - '_sqlite/connection.c', - '_sqlite/cursor.c', \ No newline at end of file