kivy / kivy/python-for-android
reportlab recipe not working with python3.9
- Langage dominant
- Python
- Étoiles
- 8.9k
- Forks
- 2k
- Merge moyen
- 12 h 20 min
- PR mergées (30 j)
- 9
Description
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.
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Commencez par pythonforandroid/recipes/reportlab/__init__.py et recipes/reportlab/patches/fix-setup.patch, puis comparez la version figée de ReportLab avec la version qui prend en charge Python 3.9. Reproduisez l’échec de l’importation de reportlab via les requirements de buildozer.spec. Le travail est terminé lorsque la recette se construit et s’exécute sans qu’il soit nécessaire de supprimer la recette ou de copier ReportLab manuellement dans le projet.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- android, python
- Domaine
- build-system, mobile-dev
- Type d'issue
- Bug
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100