Skip to content

Commit

Permalink
Move from bpo-30386 to python 3.7.0 maintaining libs support
Browse files Browse the repository at this point in the history
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: kivy#1412, inclement/python-for-android@588f736 and inclement/python-for-android@a7f9348
  • Loading branch information
opacam committed Oct 19, 2018
1 parent b38c6ae commit a529d77
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 51 deletions.
8 changes: 4 additions & 4 deletions pythonforandroid/recipes/python3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,16 @@


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']
conflicts = ['python3crystax', 'python2']
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):
Expand Down Expand Up @@ -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
Expand Down
51 changes: 51 additions & 0 deletions pythonforandroid/recipes/python3/patches/python-3.7.0-libs.patch
Original file line number Diff line number Diff line change
@@ -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
47 changes: 0 additions & 47 deletions pythonforandroid/recipes/python3/patches/python-3.x.x-libs.patch

This file was deleted.

0 comments on commit a529d77

Please sign in to comment.