forked from kivy/python-for-android
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduces a simple mechanism to set cflags/ldflags for some optional libs that can be linked with python. This mechanism is created in order to keep the code clean and readable, and should make easier to add other optional libs. The supported libraries are: - sqlite3 - openssl - libexpat - libffi The libraries should be tested with a real app and further changes may be needed. Also add termios patch in order to avoid runtime error when running the app.
- Loading branch information
Showing
3 changed files
with
221 additions
and
16 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
29 changes: 29 additions & 0 deletions
29
pythonforandroid/recipes/python3/patches/fix-termios.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,29 @@ | ||
--- Python-2.7.2.orig/Modules/termios.c 2012-06-12 02:49:39.780162534 +0200 | ||
+++ Python-2.7.2/Modules/termios.c 2012-06-12 02:51:52.092157828 +0200 | ||
@@ -227,6 +227,7 @@ | ||
return Py_None; | ||
} | ||
|
||
+#if 0 // No tcdrain defined for Android. | ||
PyDoc_STRVAR(termios_tcdrain__doc__, | ||
"tcdrain(fd) -> None\n\ | ||
\n\ | ||
@@ -246,6 +247,7 @@ | ||
Py_INCREF(Py_None); | ||
return Py_None; | ||
} | ||
+#endif | ||
|
||
PyDoc_STRVAR(termios_tcflush__doc__, | ||
"tcflush(fd, queue) -> None\n\ | ||
@@ -301,8 +303,10 @@ | ||
METH_VARARGS, termios_tcsetattr__doc__}, | ||
{"tcsendbreak", termios_tcsendbreak, | ||
METH_VARARGS, termios_tcsendbreak__doc__}, | ||
+#if 0 // No tcdrain defined for Android. | ||
{"tcdrain", termios_tcdrain, | ||
METH_VARARGS, termios_tcdrain__doc__}, | ||
+#endif | ||
{"tcflush", termios_tcflush, | ||
METH_VARARGS, termios_tcflush__doc__}, | ||
{"tcflow", termios_tcflow, |
47 changes: 47 additions & 0 deletions
47
pythonforandroid/recipes/python3/patches/python-3.x.x-libs.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,47 @@ | ||
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', |