Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c1ec69c

Browse files
misl6rambodbnicholsonAndreMirasinterlark
authoredSep 5, 2022
Merge pull request #2666 from kivy/release-2022.09.04
* Add option for copying arbitratry xml files to src/main/res/xml without touching manifest * handle the case of getting list as res_xml * Remove stray - in output file name The final component in the package name is just the extension, so prefixing it with a - means the output file ends in -.<ext>. * Resolve absolute path to local recipes (#2640) This is necessary when using patches in a local recipe since `Recipe.apply_patch` assumes the recipe directory is absolute and uses `patch -d` to change directories. It could just be fixed there, but this ensures that recipe directories are always absolute. Closes: #2623 * Fix webview Back button behaviour (#2636) * Fixes TypeError: str.join() takes exactly one argument (2 given) in hostpython3/__init__.py", line 69 (#2642) * Update __init__.py .buildozer/android/platform/python-for-android/pythonforandroid/recipes/hostpython3/__init__.py", line 69, in get_recipe_env env["PKG_CONFIG_PATH"] = os.pathsep.join( TypeError: str.join() takes exactly one argument (2 given) * according of #2642 (review) * RTSP support for ffmpeg Added UDP and TCP protocols to "--enable-procol" to supporting RTSP streams over each. Added RTSP to "--enable-demuxer" to supporting RTSP with ffmpeg. * Fixes some E275 - assert is a keyword. (#2647) * Add icon-bg and icon-fg to fix_args + adds a missing folder in webview dir template (#2633) * Add icon-bg and icon-fg to fix_args Fix the icon-bg and icon-fg arguments and also create the folder mipmap-anydpi-v26 if it doesn't exists before trying to create a file inside. * Use existing ensure_dir function to create anydpi_dir * Add mipmap-anydpi-v26 to bootstrap template This makes available the directory in the final template so it's not needed to check the directory exists. * Updates matplotlib, fixes an issue related to shared libc++ (#2645) * Updates matplotlib, fixes an issue related to shared libc++ * Cleanup * Update supported Python versions (#2656) * Remove six and enum34 dependency (#2657) * Force --platform=linux/amd64 in Dockerfile (#2660) * Use p4a_install instead of install, as a file named INSTALL is already present. (#2663) * Update CHANGELOG.md & change version for release 2022.09.04 Co-authored-by: Eero af Heurlin <[email protected]> Co-authored-by: Dan Nicholson <[email protected]> Co-authored-by: Andre Miras <[email protected]> Co-authored-by: Andy Trofimov <[email protected]> Co-authored-by: Akshay Arora <[email protected]> Co-authored-by: --=FurtiF™=-- <[email protected]> Co-authored-by: alickc <[email protected]> Co-authored-by: danigm <[email protected]>
2 parents 17ec678 + 686c385 commit c1ec69c

File tree

26 files changed

+210
-343
lines changed

26 files changed

+210
-343
lines changed
 

‎.github/workflows/push.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ name: Unit tests & build apps
33
on: ['push', 'pull_request']
44

55
env:
6-
APK_ARTIFACT_FILENAME: bdist_unit_tests_app-debug-1.1-.apk
7-
AAB_ARTIFACT_FILENAME: bdist_unit_tests_app-release-1.1-.aab
8-
AAR_ARTIFACT_FILENAME: bdist_unit_tests_app-release-1.1-.aar
6+
APK_ARTIFACT_FILENAME: bdist_unit_tests_app-debug-1.1.apk
7+
AAB_ARTIFACT_FILENAME: bdist_unit_tests_app-release-1.1.aab
8+
AAR_ARTIFACT_FILENAME: bdist_unit_tests_app-release-1.1.aar
99
PYTHONFORANDROID_PREREQUISITES_INSTALL_INTERACTIVE: 0
1010

1111
jobs:

‎CHANGELOG.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,48 @@
11
# Changelog
22

3+
## [v2022.09.04](https://github.com/kivy/python-for-android/tree/v2022.09.04) (2022-09-04)
4+
5+
[Full Changelog](https://github.com/kivy/python-for-android/compare/v2022.07.20...v2022.09.04)
6+
7+
**Fixed bugs:**
8+
9+
- Matplotlib failed to import properly on an APK from Buildozer and Kivy [\#2643](https://github.com/kivy/python-for-android/issues/2643)
10+
11+
**Closed issues:**
12+
13+
- KeyError: Matplotlib with kivy android [\#2658](https://github.com/kivy/python-for-android/issues/2658)
14+
- KeyError: Matplotlib [\#2659](https://github.com/kivy/python-for-android/issues/2659)
15+
- Upgrade from NDK 19b to 23b causes problems with Pandas library [\#2654](https://github.com/kivy/python-for-android/issues/2654)
16+
- Update Dockerfile for ARM [\#2653](https://github.com/kivy/python-for-android/issues/2653)
17+
- Apple M2 chip doesn't generate apk: compiling error on liblzma [\#2652](https://github.com/kivy/python-for-android/issues/2652)
18+
- aiohttp/\_http\_parser.pyx:46:0: '\_headers.pxi' not found [\#2651](https://github.com/kivy/python-for-android/issues/2651)
19+
- \[Question\] Pip SSL ? [\#2649](https://github.com/kivy/python-for-android/issues/2649)
20+
- Colab gives me as error "No module named 'typing\_extensions' ", even if before with the same compilation it worked [\#2648](https://github.com/kivy/python-for-android/issues/2648)
21+
- \[Question\] Java Files [\#2646](https://github.com/kivy/python-for-android/issues/2646)
22+
- Using foreground services will cause wired behaviour on Android 8 [\#2641](https://github.com/kivy/python-for-android/issues/2641)
23+
- Can't apply patches with relative paths for local recipe [\#2623](https://github.com/kivy/python-for-android/issues/2623)
24+
- Compile for x86 on MacOS [\#2215](https://github.com/kivy/python-for-android/issues/2215)
25+
- splash always loading [\#1907](https://github.com/kivy/python-for-android/issues/1907)
26+
- python-for-android.readthedocs.io has problems updating, apparently [\#1709](https://github.com/kivy/python-for-android/issues/1709)
27+
- Webview apps not working on Android [\#1644](https://github.com/kivy/python-for-android/issues/1644)
28+
29+
**Merged pull requests:**
30+
31+
- `liblzma`: Use `p4a_install` instead of `install`, as a file named `INSTALL` is already present. [\#2663](https://github.com/kivy/python-for-android/pull/2663) ([misl6](https://github.com/misl6))
32+
- Force `--platform=linux/amd64` in Dockerfile [\#2660](https://github.com/kivy/python-for-android/pull/2660) ([misl6](https://github.com/misl6))
33+
- Remove six and enum34 dependency [\#2657](https://github.com/kivy/python-for-android/pull/2657) ([misl6](https://github.com/misl6))
34+
- Update supported Python versions [\#2656](https://github.com/kivy/python-for-android/pull/2656) ([misl6](https://github.com/misl6))
35+
- Fixes some E275 - assert is a keyword. [\#2647](https://github.com/kivy/python-for-android/pull/2647) ([misl6](https://github.com/misl6))
36+
- Updates matplotlib, fixes an issue related to shared libc++ [\#2645](https://github.com/kivy/python-for-android/pull/2645) ([misl6](https://github.com/misl6))
37+
- RTSP support for ffmpeg [\#2644](https://github.com/kivy/python-for-android/pull/2644) ([alicakici1234](https://github.com/alicakici1234))
38+
- Fixes TypeError: str.join\(\) takes exactly one argument \(2 given\) in hostpython3/\_\_init\_\_.py", line 69 [\#2642](https://github.com/kivy/python-for-android/pull/2642) ([Furtif](https://github.com/Furtif))
39+
- Resolve absolute path to local recipes [\#2640](https://github.com/kivy/python-for-android/pull/2640) ([dbnicholson](https://github.com/dbnicholson))
40+
- Merges master into develop after release 2022.07.20 [\#2639](https://github.com/kivy/python-for-android/pull/2639) ([misl6](https://github.com/misl6))
41+
- Fix webview Back button behaviour [\#2636](https://github.com/kivy/python-for-android/pull/2636) ([interlark](https://github.com/interlark))
42+
- Add icon-bg and icon-fg to fix\_args [\#2633](https://github.com/kivy/python-for-android/pull/2633) ([danigm](https://github.com/danigm))
43+
- Remove stray - in output file name [\#2581](https://github.com/kivy/python-for-android/pull/2581) ([dbnicholson](https://github.com/dbnicholson))
44+
- Add option for adding files to res/xml without touching manifest [\#2330](https://github.com/kivy/python-for-android/pull/2330) ([rambo](https://github.com/rambo))
45+
346
## [v2022.07.20](https://github.com/kivy/python-for-android/tree/v2022.07.20) (2022-07-20)
447

548
[Full Changelog](https://github.com/kivy/python-for-android/compare/v2022.03.13...v2022.07.20)

‎Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@
1515
# Use 'docker run' without '--rm' flag for keeping the container and use
1616
# 'docker commit <container hash> <new image>' to extend the original image
1717

18-
FROM ubuntu:20.04
18+
# If platform is not specified, by default the target platform of the build request is used.
19+
# This is not what we want, as Google doesn't provide a linux/arm64 compatible NDK.
20+
# See: https://docs.docker.com/engine/reference/builder/#from
21+
FROM --platform=linux/amd64 ubuntu:20.04
1922

2023
# configure locale
2124
RUN apt -y update -qq > /dev/null \

‎Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,17 +106,17 @@ docker/run/command: docker/build
106106

107107
docker/run/make/with-artifact/apk/%: docker/build
108108
docker run --name p4a-latest --env-file=.env $(DOCKER_IMAGE) make $*
109-
docker cp p4a-latest:/home/user/app/testapps/on_device_unit_tests/bdist_unit_tests_app-debug-1.1-.apk ./apks
109+
docker cp p4a-latest:/home/user/app/testapps/on_device_unit_tests/bdist_unit_tests_app-debug-1.1.apk ./apks
110110
docker rm -fv p4a-latest
111111

112112
docker/run/make/with-artifact/aar/%: docker/build
113113
docker run --name p4a-latest --env-file=.env $(DOCKER_IMAGE) make $*
114-
docker cp p4a-latest:/home/user/app/testapps/on_device_unit_tests/bdist_unit_tests_app-release-1.1-.aar ./aars
114+
docker cp p4a-latest:/home/user/app/testapps/on_device_unit_tests/bdist_unit_tests_app-release-1.1.aar ./aars
115115
docker rm -fv p4a-latest
116116

117117
docker/run/make/with-artifact/aab/%: docker/build
118118
docker run --name p4a-latest --env-file=.env $(DOCKER_IMAGE) make $*
119-
docker cp p4a-latest:/home/user/app/testapps/on_device_unit_tests/bdist_unit_tests_app-release-1.1-.aab ./aabs
119+
docker cp p4a-latest:/home/user/app/testapps/on_device_unit_tests/bdist_unit_tests_app-release-1.1.aab ./aabs
120120
docker rm -fv p4a-latest
121121

122122
docker/run/make/rebuild_updated_recipes: docker/build

‎pythonforandroid/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '2022.07.20'
1+
__version__ = '2022.09.04'

‎pythonforandroid/bootstraps/common/build/build.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,12 +508,20 @@ def make_package(args):
508508
url_scheme = 'kivy'
509509

510510
# Copy backup rules file if specified and update the argument
511+
res_xml_dir = join(res_dir, 'xml')
511512
if args.backup_rules:
512-
res_xml_dir = join(res_dir, 'xml')
513513
ensure_dir(res_xml_dir)
514514
shutil.copy(join(args.private, args.backup_rules), res_xml_dir)
515515
args.backup_rules = split(args.backup_rules)[1][:-4]
516516

517+
# Copy res_xml files to src/main/res/xml
518+
if args.res_xmls:
519+
ensure_dir(res_xml_dir)
520+
for xmlpath in args.res_xmls:
521+
if not os.path.exists(xmlpath):
522+
xmlpath = join(args.private, xmlpath)
523+
shutil.copy(xmlpath, res_xml_dir)
524+
517525
# Render out android manifest:
518526
manifest_path = "src/main/AndroidManifest.xml"
519527
render_args = {
@@ -803,6 +811,8 @@ def parse_args_and_make_package(args=None):
803811
'filename containing xml. The filename should be '
804812
'located relative to the python-for-android '
805813
'directory'))
814+
ap.add_argument('--res_xml', dest='res_xmls', action='append', default=[],
815+
help='Add files to res/xml directory (for example device-filters)', nargs='+')
806816
ap.add_argument('--with-billing', dest='billing_pubkey',
807817
help='If set, the billing service will be added (not implemented)')
808818
ap.add_argument('--add-source', dest='extra_source_dirs', action='append',
@@ -901,6 +911,9 @@ def _read_configuration():
901911
if args.permissions and isinstance(args.permissions[0], list):
902912
args.permissions = [p for perm in args.permissions for p in perm]
903913

914+
if args.res_xmls and isinstance(args.res_xmls[0], list):
915+
args.res_xmls = [x for res in args.res_xmls for x in res]
916+
904917
if args.try_system_python_compile:
905918
# Hardcoding python2.7 is okay for now, as python3 skips the
906919
# compilation anyway

‎pythonforandroid/bootstraps/service_only/build/src/main/java/org/kivy/android/PythonActivity.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -177,19 +177,22 @@ public void loadLibraries() {
177177
new File(getApplicationInfo().nativeLibraryDir));
178178
}
179179

180-
long lastBackClick = SystemClock.elapsedRealtime();
180+
long lastBackClick = 0;
181181
@Override
182182
public boolean onKeyDown(int keyCode, KeyEvent event) {
183-
// If it wasn't the Back key or there's no web page history, bubble up to the default
184-
// system behavior (probably exit the activity)
185-
if (SystemClock.elapsedRealtime() - lastBackClick > 2000){
183+
// Check if the key event was the Back button
184+
if (keyCode == KeyEvent.KEYCODE_BACK) {
185+
// If there's no web page history, bubble up to the default
186+
// system behavior (probably exit the activity)
187+
if (SystemClock.elapsedRealtime() - lastBackClick > 2000){
188+
lastBackClick = SystemClock.elapsedRealtime();
189+
Toast.makeText(this, "Tap again to close the app", Toast.LENGTH_LONG).show();
190+
return true;
191+
}
192+
186193
lastBackClick = SystemClock.elapsedRealtime();
187-
Toast.makeText(this, "Click again to close the app",
188-
Toast.LENGTH_LONG).show();
189-
return true;
190194
}
191195

192-
lastBackClick = SystemClock.elapsedRealtime();
193196
return super.onKeyDown(keyCode, event);
194197
}
195198

‎pythonforandroid/bootstraps/webview/build/src/main/java/org/kivy/android/PythonActivity.java

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import android.widget.AbsoluteLayout;
3333
import android.view.ViewGroup.LayoutParams;
3434

35+
import android.webkit.WebBackForwardList;
3536
import android.webkit.WebViewClient;
3637
import android.webkit.WebView;
3738
import android.webkit.CookieManager;
@@ -269,24 +270,30 @@ public static ViewGroup getLayout() {
269270
return mLayout;
270271
}
271272

272-
long lastBackClick = SystemClock.elapsedRealtime();
273+
long lastBackClick = 0;
273274
@Override
274275
public boolean onKeyDown(int keyCode, KeyEvent event) {
275-
// Check if the key event was the Back button and if there's history
276-
if ((keyCode == KeyEvent.KEYCODE_BACK) && mWebView.canGoBack()) {
277-
mWebView.goBack();
278-
return true;
279-
}
280-
// If it wasn't the Back key or there's no web page history, bubble up to the default
281-
// system behavior (probably exit the activity)
282-
if (SystemClock.elapsedRealtime() - lastBackClick > 2000){
276+
// Check if the key event was the Back button
277+
if (keyCode == KeyEvent.KEYCODE_BACK) {
278+
// Go back if there is web page history behind,
279+
// but not to the start preloader
280+
WebBackForwardList webViewBackForwardList = mWebView.copyBackForwardList();
281+
if (webViewBackForwardList.getCurrentIndex() > 1) {
282+
mWebView.goBack();
283+
return true;
284+
}
285+
286+
// If there's no web page history, bubble up to the default
287+
// system behavior (probably exit the activity)
288+
if (SystemClock.elapsedRealtime() - lastBackClick > 2000){
289+
lastBackClick = SystemClock.elapsedRealtime();
290+
Toast.makeText(this, "Tap again to close the app", Toast.LENGTH_LONG).show();
291+
return true;
292+
}
293+
283294
lastBackClick = SystemClock.elapsedRealtime();
284-
Toast.makeText(this, "Click again to close the app",
285-
Toast.LENGTH_LONG).show();
286-
return true;
287295
}
288296

289-
lastBackClick = SystemClock.elapsedRealtime();
290297
return super.onKeyDown(keyCode, event);
291298
}
292299

‎pythonforandroid/bootstraps/webview/build/src/main/res/mipmap-anydpi-v26/.gitkeep

Whitespace-only changes.

‎pythonforandroid/graph.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def get_dependency_tuple_list_for_recipe(recipe, blacklist=None):
4545
"""
4646
if blacklist is None:
4747
blacklist = set()
48-
assert(type(blacklist) == set)
48+
assert type(blacklist) == set
4949
if recipe.depends is None:
5050
dependencies = []
5151
else:

‎pythonforandroid/recipe.py

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from os.path import basename, dirname, exists, isdir, isfile, join, realpath, split
22
import glob
33
from shutil import rmtree
4-
from six import with_metaclass
54

65
import hashlib
76
from re import match
@@ -40,7 +39,7 @@ def __new__(cls, name, bases, dct):
4039
return super().__new__(cls, name, bases, dct)
4140

4241

43-
class Recipe(with_metaclass(RecipeMeta)):
42+
class Recipe(metaclass=RecipeMeta):
4443
_url = None
4544
'''The address from which the recipe may be downloaded. This is not
4645
essential, it may be omitted if the source is available some other
@@ -123,8 +122,8 @@ class Recipe(with_metaclass(RecipeMeta)):
123122
"""
124123

125124
need_stl_shared = False
126-
'''Some libraries or python packages may need to be linked with android's
127-
stl. We can automatically do this for any recipe if we set this property to
125+
'''Some libraries or python packages may need the c++_shared in APK.
126+
We can automatically do this for any recipe if we set this property to
128127
`True`'''
129128

130129
stl_lib_name = 'c++_shared'
@@ -492,20 +491,6 @@ def get_recipe_env(self, arch=None, with_flags_in_cc=True):
492491
if arch is None:
493492
arch = self.filtered_archs[0]
494493
env = arch.get_env(with_flags_in_cc=with_flags_in_cc)
495-
496-
if self.need_stl_shared:
497-
env['CPPFLAGS'] = env.get('CPPFLAGS', '')
498-
env['CPPFLAGS'] += ' -I{}'.format(self.ctx.ndk.libcxx_include_dir)
499-
500-
env['CXXFLAGS'] = env['CFLAGS'] + ' -frtti -fexceptions'
501-
502-
if with_flags_in_cc:
503-
env['CXX'] += ' -frtti -fexceptions'
504-
505-
env['LDFLAGS'] += ' -L{}'.format(arch.ndk_lib_dir)
506-
env['LIBS'] = env.get('LIBS', '') + " -l{}".format(
507-
self.stl_lib_name
508-
)
509494
return env
510495

511496
def prebuild_arch(self, arch):

‎pythonforandroid/recipes/cppy/__init__.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33

44
class CppyRecipe(PythonRecipe):
55
site_packages_name = 'cppy'
6-
7-
# Pin to commit: `Nucleic migration and project documentation`,
8-
# because the official releases are too old, at time of writing
9-
version = '4e0b956'
6+
version = '1.1.0'
107
url = 'https://github.com/nucleic/cppy/archive/{version}.zip'
118
call_hostpython_via_targetpython = False
129
# to be detected by the matplotlib install script

‎pythonforandroid/recipes/ffmpeg/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def build_arch(self, arch):
8282
'--enable-parser=aac,ac3,h261,h264,mpegaudio,mpeg4video,mpegvideo,vc1',
8383
'--enable-decoder=aac,h264,mpeg4,mpegvideo',
8484
'--enable-muxer=h264,mov,mp4,mpeg2video',
85-
'--enable-demuxer=aac,h264,m4v,mov,mpegvideo,vc1',
85+
'--enable-demuxer=aac,h264,m4v,mov,mpegvideo,vc1,rtsp',
8686
]
8787

8888
# needed to prevent _ffmpeg.so: version node not found for symbol av_init_packet@LIBAVFORMAT_52
@@ -100,7 +100,7 @@ def build_arch(self, arch):
100100
# other flags:
101101
flags += [
102102
'--enable-filter=aresample,resample,crop,adelay,volume,scale',
103-
'--enable-protocol=file,http,hls',
103+
'--enable-protocol=file,http,hls,udp,tcp',
104104
'--enable-small',
105105
'--enable-hwaccels',
106106
'--enable-pic',

‎pythonforandroid/recipes/hostpython3/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def get_recipe_env(self, arch=None):
6767
openssl_prereq = OpenSSLPrerequisite()
6868
if env.get("PKG_CONFIG_PATH", ""):
6969
env["PKG_CONFIG_PATH"] = os.pathsep.join(
70-
openssl_prereq.pkg_config_location, env["PKG_CONFIG_PATH"]
70+
[openssl_prereq.pkg_config_location, env["PKG_CONFIG_PATH"]]
7171
)
7272
else:
7373
env["PKG_CONFIG_PATH"] = openssl_prereq.pkg_config_location

‎pythonforandroid/recipes/kiwisolver/__init__.py

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,9 @@
33

44
class KiwiSolverRecipe(CppCompiledComponentsPythonRecipe):
55
site_packages_name = 'kiwisolver'
6-
# Pin to commit `docs: attempt to fix doc building`, the latest one
7-
# at the time of writing, just to be sure that we have te most up to date
8-
# version, but it should be pinned to an official release once the c++
9-
# changes that we want to include are merged to master branch
10-
# Note: the commit we want to include is
11-
# `Cppy use update and c++11 compatibility` (4858730)
12-
version = '0846189'
6+
version = '1.3.2'
137
url = 'https://github.com/nucleic/kiwi/archive/{version}.zip'
148
depends = ['cppy']
159

16-
def get_recipe_env(self, arch=None, with_flags_in_cc=True):
17-
env = super().get_recipe_env(arch, with_flags_in_cc)
18-
if self.need_stl_shared:
19-
# kiwisolver compile flags does not honor the standard flags:
20-
# `CPPFLAGS` and `LDLIBS`, so we put in `CFLAGS` and `LDFLAGS` to
21-
# correctly link with the `c++_shared` library
22-
env['CFLAGS'] += f' -I{self.ctx.ndk.libcxx_include_dir}'
23-
env['CFLAGS'] += ' -frtti -fexceptions'
24-
25-
env['LDFLAGS'] += f' -L{arch.ndk_lib_dir}'
26-
env['LDFLAGS'] += f' -l{self.stl_lib_name}'
27-
return env
28-
2910

3011
recipe = KiwiSolverRecipe()

‎pythonforandroid/recipes/liblzma/__init__.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@
66
from pythonforandroid.archs import Arch
77
from pythonforandroid.logger import shprint
88
from pythonforandroid.recipe import Recipe
9-
from pythonforandroid.util import current_directory, ensure_dir
9+
from pythonforandroid.util import current_directory
1010

1111

1212
class LibLzmaRecipe(Recipe):
1313

1414
version = '5.2.4'
1515
url = 'https://tukaani.org/xz/xz-{version}.tar.gz'
16-
built_libraries = {'liblzma.so': 'install/lib'}
16+
built_libraries = {'liblzma.so': 'p4a_install/lib'}
1717

1818
def build_arch(self, arch: Arch) -> None:
1919
env = self.get_recipe_env(arch)
20-
install_dir = join(self.get_build_dir(arch.arch), 'install')
20+
install_dir = join(self.get_build_dir(arch.arch), 'p4a_install')
2121
with current_directory(self.get_build_dir(arch.arch)):
2222
if not exists('configure'):
2323
shprint(sh.Command('./autogen.sh'), _env=env)
@@ -42,7 +42,6 @@ def build_arch(self, arch: Arch) -> None:
4242
_env=env
4343
)
4444

45-
ensure_dir('install')
4645
shprint(sh.make, 'install', _env=env)
4746

4847
def get_library_includes(self, arch: Arch) -> str:
@@ -52,7 +51,7 @@ def get_library_includes(self, arch: Arch) -> str:
5251
variable `CPPFLAGS`.
5352
"""
5453
return " -I" + join(
55-
self.get_build_dir(arch.arch), 'install', 'include',
54+
self.get_build_dir(arch.arch), 'p4a_install', 'include',
5655
)
5756

5857
def get_library_ldflags(self, arch: Arch) -> str:

‎pythonforandroid/recipes/matplotlib/__init__.py

Lines changed: 11 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,18 @@
1-
2-
from pythonforandroid.logger import info_notify
31
from pythonforandroid.recipe import CppCompiledComponentsPythonRecipe
42
from pythonforandroid.util import ensure_dir
53

64
from os.path import join
5+
import shutil
76

87

98
class MatplotlibRecipe(CppCompiledComponentsPythonRecipe):
109

11-
version = '3.1.3'
10+
version = '3.5.2'
1211
url = 'https://github.com/matplotlib/matplotlib/archive/v{version}.zip'
1312

14-
depends = ['numpy', 'png', 'setuptools', 'freetype', 'kiwisolver']
15-
16-
python_depends = ['pyparsing', 'cycler', 'python-dateutil']
17-
18-
# We need to patch to:
19-
# - make mpl install work without importing numpy
20-
# - make mpl use shared libraries for freetype and png
21-
# - make mpl link to png16, to match p4a library name for png
22-
# - prevent mpl trying to build TkAgg, which wouldn't work
23-
# on Android anyway but has build issues
24-
patches = ['mpl_android_fixes.patch']
13+
depends = ['kiwisolver', 'numpy', 'pillow', 'setuptools', 'freetype']
2514

26-
call_hostpython_via_targetpython = False
15+
python_depends = ['cycler', 'fonttools', 'packaging', 'pyparsing', 'python-dateutil']
2716

2817
def generate_libraries_pc_files(self, arch):
2918
"""
@@ -42,10 +31,9 @@ def generate_libraries_pc_files(self, arch):
4231
# version for freetype, but we have our recipe named without
4332
# the version...so we add it in here for our pc file
4433
'freetype': 'freetype2.pc',
45-
'png': 'png.pc',
4634
}
4735

48-
for lib_name in {'freetype', 'png'}:
36+
for lib_name in {'freetype'}:
4937
pc_template_file = join(
5038
self.get_recipe_dir(),
5139
f'lib{lib_name}.pc.template'
@@ -67,83 +55,26 @@ def generate_libraries_pc_files(self, arch):
6755
with open(pc_dest_file, 'w') as pc_file:
6856
pc_file.write(text_buffer)
6957

70-
def download_web_backend_dependencies(self, arch):
71-
"""
72-
During building, host needs to download the jquery-ui package (in order
73-
to make it work the mpl web backend). This operation seems to fail
74-
in our CI tests, so we download this package at the expected location
75-
by the mpl install script which is defined by the environ variable
76-
`XDG_CACHE_HOME` (we modify that one in our `get_recipe_env` so it will
77-
be the same regardless of the host platform).
78-
"""
79-
80-
env = self.get_recipe_env(arch)
81-
82-
info_notify('Downloading jquery-ui for matplatlib web backend')
83-
# We use the same jquery-ui version than mpl's setup.py script,
84-
# inside function `_download_jquery_to`
85-
jquery_sha = (
86-
'f8233674366ab36b2c34c577ec77a3d70cac75d2e387d8587f3836345c0f624d'
87-
)
88-
url = "https://jqueryui.com/resources/download/jquery-ui-1.12.1.zip"
89-
target_file = join(env['XDG_CACHE_HOME'], 'matplotlib', jquery_sha)
90-
91-
info_notify(f'Will download into {env["XDG_CACHE_HOME"]}')
92-
ensure_dir(join(env['XDG_CACHE_HOME'], 'matplotlib'))
93-
self.download_file(url, target_file)
94-
9558
def prebuild_arch(self, arch):
96-
with open(join(self.get_recipe_dir(), 'setup.cfg.template')) as fileh:
97-
setup_cfg = fileh.read()
98-
99-
with open(join(self.get_build_dir(arch), 'setup.cfg'), 'w') as fileh:
100-
fileh.write(setup_cfg.format(
101-
ndk_sysroot_usr=join(self.ctx.ndk.sysroot, 'usr')))
102-
59+
shutil.copyfile(
60+
join(self.get_recipe_dir(), "setup.cfg.template"),
61+
join(self.get_build_dir(arch), "mplsetup.cfg"),
62+
)
10363
self.generate_libraries_pc_files(arch)
104-
self.download_web_backend_dependencies(arch)
10564

10665
def get_recipe_env(self, arch=None, with_flags_in_cc=True):
10766
env = super().get_recipe_env(arch, with_flags_in_cc)
108-
if self.need_stl_shared:
109-
# matplotlib compile flags does not honor the standard flags:
110-
# `CPPFLAGS` and `LDLIBS`, so we put in `CFLAGS` and `LDFLAGS` to
111-
# correctly link with the `c++_shared` library
112-
env['CFLAGS'] += ' -I{}'.format(self.ctx.ndk.libcxx_include_dir)
113-
env['CFLAGS'] += ' -frtti -fexceptions'
114-
115-
env['LDFLAGS'] += ' -L{}'.format(arch.ndk_lib_dir)
116-
env['LDFLAGS'] += ' -l{}'.format(self.stl_lib_name)
117-
118-
# we modify `XDG_CACHE_HOME` to download `jquery-ui` into that folder,
119-
# or mpl install will fail when trying to download/install it, but if
120-
# we have the proper package already downloaded, it will use the cached
121-
# package to successfully finish the installation.
122-
# Note: this may not be necessary for some local systems, but it is
123-
# for our CI provider: `gh-actions`, which will
124-
# fail trying to download the `jquery-ui` package
125-
env['XDG_CACHE_HOME'] = join(self.get_build_dir(arch), 'p4a_files')
67+
12668
# we make use of the same directory than `XDG_CACHE_HOME`, for our
12769
# custom library pc files, so we have all the install files that we
12870
# generate at the same place
71+
env['XDG_CACHE_HOME'] = join(self.get_build_dir(arch), 'p4a_files')
12972
env['PKG_CONFIG_PATH'] = env['XDG_CACHE_HOME']
13073

131-
# We set a new environ variable `NUMPY_INCLUDES` to be able to tell
132-
# the matplotlib script where to find our numpy without importing it
133-
# (which will fail, because numpy isn't installed in our hostpython)
134-
env['NUMPY_INCLUDES'] = join(
135-
self.ctx.get_site_packages_dir(arch),
136-
'numpy', 'core', 'include',
137-
)
138-
13974
# creating proper *.pc files for our libraries does not seem enough to
14075
# success with our build (without depending on system development
14176
# libraries), but if we tell the compiler where to find our libraries
14277
# and includes, then the install success :)
143-
png = self.get_recipe('png', self.ctx)
144-
env['CFLAGS'] += f' -I{png.get_build_dir(arch)}'
145-
env['LDFLAGS'] += f' -L{join(png.get_build_dir(arch.arch), ".libs")}'
146-
14778
freetype = self.get_recipe('freetype', self.ctx)
14879
free_lib_dir = join(freetype.get_build_dir(arch.arch), 'objs', '.libs')
14980
free_inc_dir = join(freetype.get_build_dir(arch.arch), 'include')

‎pythonforandroid/recipes/matplotlib/libpng.pc.template

Lines changed: 0 additions & 10 deletions
This file was deleted.

‎pythonforandroid/recipes/matplotlib/mpl_android_fixes.patch

Lines changed: 0 additions & 60 deletions
This file was deleted.
Lines changed: 26 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,38 @@
1-
# Rename this file to setup.cfg to modify Matplotlib's
2-
# build options.
3-
4-
[egg_info]
5-
6-
[directories]
7-
# Uncomment to override the default basedir in setupext.py.
8-
# This can be a single directory or a comma-delimited list of directories.
9-
basedirlist = {ndk_sysroot_usr}
10-
11-
[test]
12-
# If you plan to develop Matplotlib and run or add to the test suite,
13-
# set this to True. It will download and build a specific version of
14-
# FreeType, and then use that to build the ft2font extension. This
15-
# ensures that test images are exactly reproducible.
16-
# local_freetype = True
17-
18-
[status]
19-
# To suppress display of the dependencies and their versions
20-
# at the top of the build log, uncomment the following line:
21-
#suppress = True
1+
# Rename this file to mplsetup.cfg to modify Matplotlib's build options.
2+
3+
[libs]
4+
# By default, Matplotlib builds with LTO, which may be slow if you re-compile
5+
# often, and don't need the space saving/speedup.
6+
enable_lto = False
7+
# By default, Matplotlib downloads and builds its own copies of FreeType and of
8+
# Qhull. You may set the following to True to instead link against a system
9+
# FreeType/Qhull. As an exception, Matplotlib defaults to the system version
10+
# of FreeType on AIX.
11+
system_freetype = True
12+
#system_qhull = False
2213

2314
[packages]
24-
# There are a number of subpackages of Matplotlib that are considered
25-
# optional. All except tests are installed by default, but that can
26-
# be changed here.
27-
#
28-
tests = False
29-
sample_data = False
30-
#toolkits = True
31-
# Tests for the toolkits are only automatically installed
32-
# if the tests and toolkits packages are also getting installed.
33-
toolkits_tests = False
15+
# There are a number of data subpackages from Matplotlib that are
16+
# considered optional. All except 'tests' data (meaning the baseline
17+
# image files) are installed by default, but that can be changed here.
18+
#tests = False
3419

3520
[gui_support]
36-
# Matplotlib supports multiple GUI toolkits, including
37-
# GTK3, MacOSX, Qt4, Qt5, Tk, and WX. Support for many of
38-
# these toolkits requires AGG, the Anti-Grain Geometry library,
39-
# which is provided by Matplotlib and built by default.
40-
#
41-
# Some backends are written in pure Python, and others require
42-
# extension code to be compiled. By default, Matplotlib checks for
43-
# these GUI toolkits during installation and, if present, compiles the
44-
# required extensions to support the toolkit.
45-
#
46-
# - Tk support requires Tk development headers and Tkinter.
47-
# - Mac OSX backend requires the Cocoa headers included with XCode.
48-
# - Windowing is MS-Windows specific, and requires the "windows.h"
49-
# header.
21+
# Matplotlib supports multiple GUI toolkits, known as backends.
22+
# The MacOSX backend requires the Cocoa headers included with XCode.
23+
# You can select whether to build it by uncommenting the following line.
24+
# It is never built on Linux or Windows, regardless of the config value.
5025
#
51-
# The other GUI toolkits do not require any extension code, and can be
52-
# used as long as the libraries are installed on your system --
53-
# therefore they are installed unconditionally.
54-
#
55-
# You can uncomment any the following lines to change this
56-
# behavior. Acceptable values are:
57-
#
58-
# True: build the extension. Exits with a warning if the
59-
# required dependencies are not available
60-
# False: do not build the extension
61-
# auto: build if the required dependencies are available,
62-
# otherwise skip silently. This is the default
63-
# behavior
64-
#
65-
agg = True
66-
cairo = False
67-
gtk3agg = False
68-
gtk3cairo = False
6926
macosx = False
70-
pyside = False
71-
qt4agg = False
72-
tkagg = False
73-
windowing = False
74-
wxagg = False
7527

7628
[rc_options]
7729
# User-configurable options
7830
#
79-
# Default backend, one of: Agg, Cairo, GTK3Agg, GTK3Cairo, MacOSX, Pdf, Ps,
80-
# Qt4Agg, Qt5Agg, SVG, TkAgg, WX, WXAgg.
31+
# Default backend, one of: Agg, Cairo, GTK3Agg, GTK3Cairo, GTK4Agg, GTK4Cairo,
32+
# MacOSX, Pdf, Ps, QtAgg, QtCairo, SVG, TkAgg, WX, WXAgg.
8133
#
82-
# The Agg, Ps, Pdf and SVG backends do not require external dependencies. Do
83-
# not choose MacOSX, or TkAgg if you have disabled the relevant extension
84-
# modules. Agg will be used by default.
85-
#
86-
backend = Agg
87-
#
88-
89-
[package_data]
90-
# Package additional files found in the lib/matplotlib directories.
34+
# The Agg, Ps, Pdf and SVG backends do not require external dependencies. Do
35+
# not choose MacOSX if you have disabled the relevant extension modules. The
36+
# default is determined by fallback.
9137
#
92-
# On Windows, package DLL files.
93-
#dlls = True
38+
#backend = Agg

‎pythonforandroid/toolchain.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ def check_python_dependencies():
2929

3030
ok = True
3131

32-
modules = [('colorama', '0.3.3'), 'appdirs', ('sh', '1.10'), 'jinja2',
33-
'six']
32+
modules = [('colorama', '0.3.3'), 'appdirs', ('sh', '1.10'), 'jinja2']
3433

3534
for module in modules:
3635
if isinstance(module, tuple):
@@ -720,7 +719,7 @@ def add_parser(subparsers, *args, **kwargs):
720719

721720
self._archs = args.arch
722721

723-
self.ctx.local_recipes = args.local_recipes
722+
self.ctx.local_recipes = realpath(args.local_recipes)
724723
self.ctx.copy_libs = args.copy_libs
725724

726725
self.ctx.activity_class_name = args.activity_class_name
@@ -990,7 +989,8 @@ def _fix_args(args):
990989
"""
991990

992991
fix_args = ('--dir', '--private', '--add-jar', '--add-source',
993-
'--whitelist', '--blacklist', '--presplash', '--icon')
992+
'--whitelist', '--blacklist', '--presplash', '--icon',
993+
'--icon-bg', '--icon-fg')
994994
unknown_args = args.unknown_args
995995

996996
for asset in args.assets:
@@ -1147,7 +1147,7 @@ def _finish_package(self, args, output, build_args, package_type, output_dir):
11471147
if package_add_version:
11481148
info('# Add version number to android package')
11491149
package_name = basename(package_file)[:-len(package_extension)]
1150-
package_file_dest = "{}-{}-{}".format(
1150+
package_file_dest = "{}-{}{}".format(
11511151
package_name, build_args.version, package_extension)
11521152
info('# Android package renamed to {}'.format(package_file_dest))
11531153
shprint(sh.cp, package_file, package_file_dest)

‎setup.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
# must be a single statement since buildozer is currently parsing it, refs:
2121
# https://github.com/kivy/buildozer/issues/722
2222
install_reqs = [
23-
'appdirs', 'colorama>=0.3.3', 'jinja2', 'six',
24-
'enum34; python_version<"3.4"', 'sh>=1.10; sys_platform!="nt"',
23+
'appdirs', 'colorama>=0.3.3', 'jinja2',
24+
'sh>=1.10; sys_platform!="nt"',
2525
'pep517<0.7.0', 'toml',
2626
]
2727
# (pep517 and toml are used by pythonpackage.py)
@@ -89,7 +89,7 @@ def recursively_include(results, directory, patterns):
8989
description='Android APK packager for Python scripts and apps',
9090
long_description=long_description,
9191
long_description_content_type='text/markdown',
92-
python_requires=">=3.6.0",
92+
python_requires=">=3.7.0",
9393
author='The Kivy team',
9494
author_email='kivy-dev@googlegroups.com',
9595
url='https://github.com/kivy/python-for-android',
@@ -117,9 +117,10 @@ def recursively_include(results, directory, patterns):
117117
'Operating System :: Android',
118118
'Programming Language :: C',
119119
'Programming Language :: Python :: 3',
120-
'Programming Language :: Python :: 3.6',
121120
'Programming Language :: Python :: 3.7',
122121
'Programming Language :: Python :: 3.8',
122+
'Programming Language :: Python :: 3.9',
123+
'Programming Language :: Python :: 3.10',
123124
'Topic :: Software Development',
124125
'Topic :: Utilities',
125126
],

‎tests/recipes/test_liblzma.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def test_get_library_includes(self):
1515
recipe_build_dir = self.recipe.get_build_dir(self.arch.arch)
1616
self.assertEqual(
1717
self.recipe.get_library_includes(self.arch),
18-
f" -I{join(recipe_build_dir, 'install/include')}",
18+
f" -I{join(recipe_build_dir, 'p4a_install/include')}",
1919
)
2020

2121
def test_get_library_ldflags(self):
@@ -25,11 +25,27 @@ def test_get_library_ldflags(self):
2525
recipe_build_dir = self.recipe.get_build_dir(self.arch.arch)
2626
self.assertEqual(
2727
self.recipe.get_library_ldflags(self.arch),
28-
f" -L{join(recipe_build_dir, 'install/lib')}",
28+
f" -L{join(recipe_build_dir, 'p4a_install/lib')}",
2929
)
3030

3131
def test_link_libs_flags(self):
3232
"""
3333
Test :meth:`~pythonforandroid.recipes.liblzma.get_library_libs_flag`.
3434
"""
3535
self.assertEqual(self.recipe.get_library_libs_flag(), " -llzma")
36+
37+
def test_install_dir_not_named_install(self):
38+
"""
39+
Tests that the install directory is not named ``install``.
40+
41+
liblzma already have a file named ``INSTALL`` in its source directory.
42+
On case-insensitive filesystems, using a folder named ``install`` will
43+
cause a conflict. (See issue: #2343).
44+
45+
WARNING: This test is quite flaky, but should be enough to
46+
ensure that someone in the future will not accidentally rename
47+
the install directory without seeing this test to fail.
48+
"""
49+
liblzma_install_dir = self.recipe.built_libraries["liblzma.so"]
50+
51+
self.assertNotIn("install", liblzma_install_dir.split("/"))

‎tests/test_graph.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def test_get_dependency_tuple_list_for_recipe(monkeypatch):
115115
dep_list = get_dependency_tuple_list_for_recipe(
116116
r, blacklist={"libffi"}
117117
)
118-
assert(dep_list == [("pillow",)])
118+
assert dep_list == [("pillow",)]
119119

120120

121121
@pytest.mark.parametrize('names,bootstrap', valid_combinations)

‎tests/test_recipe.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -279,25 +279,6 @@ def test_get_recipe_env_with(
279279
)
280280
self.assertIsInstance(env, dict)
281281

282-
# check `CPPFLAGS`
283-
expected_cppflags = {
284-
'-I{libcxx_include}'.format(libcxx_include=self.ctx.ndk.libcxx_include_dir)
285-
}
286-
self.assertIn('CPPFLAGS', env)
287-
for flags in expected_cppflags:
288-
self.assertIn(flags, env['CPPFLAGS'])
289-
290-
# check `LIBS`
291-
self.assertIn('LDFLAGS', env)
292-
self.assertIn('-L' + arch.ndk_lib_dir, env['LDFLAGS'])
293-
self.assertIn('LIBS', env)
294-
self.assertIn('-lc++_shared', env['LIBS'])
295-
296-
# check `CXXFLAGS` and `CXX`
297-
for flag in {'CXXFLAGS', 'CXX'}:
298-
self.assertIn(flag, env)
299-
self.assertIn('-frtti -fexceptions', env[flag])
300-
301282
@mock.patch('pythonforandroid.recipe.Recipe.install_libs')
302283
@mock.patch('pythonforandroid.recipe.isfile')
303284
@mock.patch('pythonforandroid.build.ensure_dir')

‎tests/test_toolchain.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import io
2+
import os
23
import sys
34
import pytest
45
from unittest import mock
@@ -136,3 +137,34 @@ def test_recipes(self):
136137
assert expected_string in m_stdout.getvalue()
137138
# deletes static attribute to not mess with other tests
138139
del Recipe.recipes
140+
141+
def test_local_recipes_dir(self):
142+
"""
143+
Checks the `local_recipes` attribute in the Context is absolute.
144+
"""
145+
cwd = os.path.realpath(os.getcwd())
146+
common_args = [
147+
'toolchain.py',
148+
'recommendations',
149+
]
150+
151+
# Check the default ./p4a-recipes becomes absolute.
152+
argv = common_args
153+
with patch_sys_argv(argv):
154+
toolchain = ToolchainCL()
155+
expected_local_recipes = os.path.join(cwd, 'p4a-recipes')
156+
assert toolchain.ctx.local_recipes == expected_local_recipes
157+
158+
# Check a supplied relative directory becomes absolute.
159+
argv = common_args + ['--local-recipes=foo']
160+
with patch_sys_argv(argv):
161+
toolchain = ToolchainCL()
162+
expected_local_recipes = os.path.join(cwd, 'foo')
163+
assert toolchain.ctx.local_recipes == expected_local_recipes
164+
165+
# An absolute directory should remain unchanged.
166+
local_recipes = os.path.join(cwd, 'foo')
167+
argv = common_args + ['--local-recipes={}'.format(local_recipes)]
168+
with patch_sys_argv(argv):
169+
toolchain = ToolchainCL()
170+
assert toolchain.ctx.local_recipes == local_recipes

0 commit comments

Comments
 (0)
Please sign in to comment.