python-for-android icon indicating copy to clipboard operation
python-for-android copied to clipboard

reportlab recipe not working with python3.9

Open mtctn opened this issue 2 years ago • 4 comments

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 <module>
04-22 19:09:16.961  7698  7741 I python  :    File "[path_to_project]/.buildozer/android/app/pdfexport.py", line 1, in <module>
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 <module>
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 <module>
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 <module>
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, 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.

mtctn avatar Apr 22 '23 18:04 mtctn

hi! I am trying to create my own reportlab recipe for kivy-ios, but i really dont know how to do that. Seems like u created it for android, and can you please help me a little? all what i know is that i have to create init.py file like other recipes and put it into folder in all recipes directory. What am i have to do next? What am i have to type into that init.py file?

KonG196 avatar Aug 08 '23 13:08 KonG196

@KonG196: Try asking on our support channels. Writing a new recipe is not a trivial task.

Julian-O avatar Nov 20 '23 06:11 Julian-O

I am treating this issue as a feature request: Support a recipe for the latest version of reportlab.

Julian-O avatar Nov 20 '23 06:11 Julian-O

See my recipe in #2995

unton83 avatar Apr 06 '24 12:04 unton83