kivy / kivy/python-for-android
Requirements parsing undefined/ambiguous behavior
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 8.9k
- Fork
- 2k
- Merge trung bình
- 12 giờ 20 phút
- Pull request đã merge (30 ngày)
- 9
Mô tả
Checklist
- the issue is indeed a bug and not a support request
- issue doesn't already exist: https://github.com/kivy/python-for-android/issues
- I have a short, runnable example that reproduces the issue
- I reproduced the problem with the latest development version (
p4a.branch = develop) - I used the grave accent (aka backticks) to format code or logs when appropriated
Versions
- Python: 3.11.5
- OS: Ubuntu
- Kivy: 2.2.1
- Cython: 0.29.36
- OpenJDK: 17
Description
I had an issue compiling my kivy application to .apk, after a lot of fiddling, I received the solution in the discord channel for the python-for-android project. (The content of the application does not matter, as the error happens for the basic application described in kivy's docs).
When running the error on my device I received the error ImportError: dlopen failed: "/data/data/org.uriyaharpeness.neverfever/files/app/_python_bundle/site-packages/kivy/_clock.so" is for EM_X86_64 (62) instead of EM_AARCH64 (183), which was caused apparently because of the way I specified the requirements - using ~=.
I now know the reason for the failure, which can be seen here:
https://github.com/kivy/python-for-android/blob/develop/pythonforandroid/toolchain.py#L654-L662
The parsing of the requirements supports only no constraints or exact version (==) of the packages, and not all the specifications pip supports, which I intuitively used for my requirements.
I have not seen any reference to that issue in the documentation, not a useful comment about this limitation in the buildozer.spec file. I would like to suggest a few mitigation steps, for all those theoretical poor souls who could run into the same issue:
- In the documentation of buildozer - specify that only no constrains or exact version are supported for the requirements.
- In the initial
buildozer.specfile - include this limitation in the comment. - In the parsing function, called upon compiling - raise an indicative exception if the above requirements are not met.
I would happily try to open a PR for all of these suggestions, but would first like to get some consensus.
"The first step in solving a problem is to recognize that it does exist."
- Zig Ziglar
buildozer.spec
Command:
buildozer android debug
Spec file:
...
requirements = python3,kivy~=2.2.1
...
Logs
...
12-06 16:25:57.472 31566 8670 I python : [ERROR ] [Clock ] Unable to import kivy._clock. Have you perhaps forgotten to compile kivy? Kivy contains Cython code which needs to be compiled. A missing kivy._clock often indicates the Cython code has not been compiled. Please follow the installation instructions and make sure to compile Kivy
12-06 16:25:57.473 31566 8670 I python : Traceback (most recent call last):
12-06 16:25:57.473 31566 8670 I python : File "/home/runner/work/myapp/myapp/.buildozer/android/app/main.py", line 1, in <module>
12-06 16:25:57.475 31566 8670 I python : File "/home/runner/work/myapp/myapp/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/neverfever/arm64-v8a/kivy/clock.py", line 466, in <module>
12-06 16:25:57.476 31566 8670 I python : ImportError: dlopen failed: "/data/data/org.uriyaharpeness.neverfever/files/app/_python_bundle/site-packages/kivy/_clock.so" is for EM_X86_64 (62) instead of EM_AARCH64 (183)
12-06 16:25:57.476 31566 8670 I python : Python for android ended.
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu với các dòng 654-662 trong pythonforandroid/toolchain.py và kiểm tra cách các yêu cầu như ~= được phân tích. Xem lại tài liệu buildozer và các tham chiếu buildozer.spec ban đầu được đề cập trong issue, sau đó làm rõ cú pháp được hỗ trợ và cách xử lý dự kiến đối với các ràng buộc không được hỗ trợ. Công việc được coi là hoàn tất khi giới hạn và hành vi được ghi lại trong tài liệu hoặc một thay đổi xác thực đã được thống nhất được kiểm thử.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- android, python
- Lĩnh vực
- build-system, mobile
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 38/100