Skip to content

Commit c427344

Browse files
authored
✨ Compression libraries - episode III: add support for libbz2 & liblzma to python3 (#2097)
* ✨ Add `bz2` and `lzma` support to `Python3` * 📝 Update python3 recipe docstrings * 📝 Fix typos and grammar errors
1 parent 1c95b40 commit c427344

File tree

2 files changed

+32
-5
lines changed

2 files changed

+32
-5
lines changed

pythonforandroid/python.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,14 @@ def add_flags(include_flags, link_dirs, link_libs):
169169
add_flags(recipe.include_flags(arch),
170170
recipe.link_dirs_flags(arch), recipe.link_libs_flags())
171171

172+
for library_name in {'libbz2', 'liblzma'}:
173+
if library_name in self.ctx.recipe_build_order:
174+
info(f'Activating flags for {library_name}')
175+
recipe = Recipe.get_recipe(library_name, self.ctx)
176+
add_flags(recipe.get_library_includes(arch),
177+
recipe.get_library_ldflags(arch),
178+
recipe.get_library_libs_flag())
179+
172180
# python build system contains hardcoded zlib version which prevents
173181
# the build of zlib module, here we search for android's zlib version
174182
# and sets the right flags, so python can be build with android's zlib

pythonforandroid/recipes/python3/__init__.py

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,29 @@
66

77
class Python3Recipe(GuestPythonRecipe):
88
'''
9-
The python3's recipe.
9+
The python3's recipe
10+
^^^^^^^^^^^^^^^^^^^^
1011
11-
.. note:: This recipe can be built only against API 21+. Also, in order to
12-
build certain python modules, we need to add some extra recipes to our
13-
build requirements:
12+
The python 3 recipe can be built with some extra python modules, but to do
13+
so, we need some libraries. By default, we ship the python3 recipe with
14+
some common libraries, defined in ``depends``. We also support some optional
15+
libraries, which are less common that the ones defined in ``depends``, so
16+
we added them as optional dependencies (``opt_depends``).
1417
15-
- ctypes: you must add the recipe for ``libffi``.
18+
Below you have a relationship between the python modules and the recipe
19+
libraries::
1620
21+
- _ctypes: you must add the recipe for ``libffi``.
22+
- _sqlite3: you must add the recipe for ``sqlite3``.
23+
- _ssl: you must add the recipe for ``openssl``.
24+
- _bz2: you must add the recipe for ``libbz2`` (optional).
25+
- _lzma: you must add the recipe for ``liblzma`` (optional).
26+
27+
.. note:: This recipe can be built only against API 21+.
28+
29+
.. versionchanged:: 2019.10.06.post0
30+
Added optional dependencies: :mod:`~pythonforandroid.recipes.libbz2`
31+
and :mod:`~pythonforandroid.recipes.liblzma`
1732
.. versionchanged:: 0.6.0
1833
Refactored into class
1934
:class:`~pythonforandroid.python.GuestPythonRecipe`
@@ -39,6 +54,10 @@ class Python3Recipe(GuestPythonRecipe):
3954
]
4055

4156
depends = ['hostpython3', 'sqlite3', 'openssl', 'libffi']
57+
# those optional depends allow us to build python compression modules:
58+
# - _bz2.so
59+
# - _lzma.so
60+
opt_depends = ['libbz2', 'liblzma']
4261
conflicts = ['python2']
4362

4463
configure_args = (

0 commit comments

Comments
 (0)