kivy / kivy/python-for-android

reportlab recipe not working with python3.9

オープン
#2,782 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る
feature-request recipe
主要言語
Python
スター
8.9k
フォーク
2k
平均マージ
12時間 20分
マージ済み PR(30日)
9

説明

Hello,

I'm struggling to build my kivy project witch depends on `reportlab` on android.

I first tried to reference the recipe in my `buildozer.spec` file.

```
# (list) Application requirements
# comma separated e.g. requirements = sqlite3,kivy
requirements = python3,kivy,numpy,reportlab
```

This compiles but gives the following error at runtime:

```
04-22 19:09:16.960 7698 7741 I python : Traceback (most recent call last):
04-22 19:09:16.961 7698 7741 I python : File "[path_to_project]/.buildozer/android/app/main.py", line 48, in
04-22 19:09:16.961 7698 7741 I python : File "[path_to_project]/.buildozer/android/app/pdfexport.py", line 1, in
04-22 19:09:16.961 7698 7741 I python : File "[path_to_project]/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/cargoready/arm64-v8a/reportlab/pdfgen/canvas.py", line 19, in
04-22 19:09:16.961 7698 7741 I python : File "[path_to_project]/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/cargoready/arm64-v8a/reportlab/rl_config.py", line 45, in
04-22 19:09:16.961 7698 7741 I python : File "[path_to_project]/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/cargoready/arm64-v8a/reportlab/rl_config.py", line 13, in _defaults_init
04-22 19:09:16.961 7698 7741 I python : File "[path_to_project]/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/myapp/arm64-v8a/reportlab/lib/utils.py", line 8, in
04-22 19:09:16.962 7698 7741 I python : ImportError: cannot import name 'decodestring' from 'base64' (/data/user/0/com.example.myapp/files/app/_python_bundle/stdlib.zip/base64.pyc)
04-22 19:09:16.962 7698 7741 I python : Python for android ended.
```

I googled and found [the same issue in another context](https://bugzilla.redhat.com/show_bug.cgi?id=1808508), it comes from an issue in reportlab: `base64.encodestring()` and `base64.decodestring()`, aliases are deprecated since Python 3.1, and have been removed, `base64.encodebytes()` and `base64.decodebytes()` should be used instead.

This issue has been fixed it the last `reportlab` versions.

However, the version is frozen in python-for-android recipe:

https://github.com/kivy/python-for-android/blob/56bf7335f08a51ec4e8427dd672e1b25a674026b/pythonforandroid/recipes/reportlab/__init__.py#L8-L10

I tried to update the version number in the local copy of python-for-android used by buildozer, but it doesn't work (`recipes/reportlab/patches/fix-setup.patch` no more applies to latest reportlab version).

I also tried to remove reportlab from buildozer.spec requirements, download reportlab source and copy it directly in my project's root, and this way it seems to work at compilation and runtime.

My last try was to remove reportlab from python-for-android recipes directory and include it in buildozer.spec requirements, so that it ends-up included as a pure python module.
It worked at compilation and runtime, except that I had to include also pillow in buildozer requirements, but it may be specific to my app's use of reportlab (it's an optional dependency if I remember well).

**So after all the solution appears to be removing reportlab recipe from python-for-android, but I'm new to python-for-android so not sure of the overall impact of removing it.**
I could make a PR.

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

Start with pythonforandroid/recipes/reportlab/__init__.py and recipes/reportlab/patches/fix-setup.patch, then compare the frozen ReportLab version with the version that supports Python 3.9. Reproduce the reportlab import failure through the buildozer.spec requirements. Done means the recipe builds and runs without requiring the recipe to be removed or ReportLab copied into the project manually.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
android, python
領域
build-system, mobile-dev
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。