Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with loding gevent: BadZipfile: File is not a zip file #1739

Closed
mkg20001 opened this issue Mar 5, 2019 · 13 comments
Closed

Problem with loding gevent: BadZipfile: File is not a zip file #1739

mkg20001 opened this issue Mar 5, 2019 · 13 comments

Comments

@mkg20001
Copy link
Contributor

mkg20001 commented Mar 5, 2019

Versions

  • Python: 2.7.15rc1
  • OS: Ubuntu 18.04 amd64
  • Kivy: master
  • Cython: 0.25

Description

It should load gevent.
Instead gevent loading causes a python error about some zip file being broken/missing.
I think this is an error that occurs during bundling (it's looking for something at the wrong place), that's why I have reported it here.

buildozer.spec

Command:

buildozer android release

Spec file:

[app]
warn_on_root = 0
buildozer.warn_on_root = 0
title = ZeroNetN
package.name = zeronet
package.domain = luna.mkg20001
source.dir = src
source.include_exts = 
source.exclude_exts = dll, cmd, exe
source.exclude_dirs = Test, zero/src/Test
version.regex = self\.version = ['"](.*)['"]
version.filename = %(source.dir)s/zero/src/Config.py
requirements = sqlite3,typing,openssl,m2crypto,gevent,msgpack-python,pil,hostpython2,git+https://github.com/kivy/plyer,android,kivy,sentry_sdk,urllib3,certifi
p4a.branch = master
presplash.filename = %(source.dir)s/splash.png
icon.filename = %(source.dir)s/icon.png
orientation = all
services = zn:service.py
osx.python_version = 3
osx.kivy_version = 1.9.1
fullscreen = 0
android.permissions = INTERNET
android.api = 28
android.minapi = 21
android.ndk_api = 21
android.private_storage = True
android.whitelist = sqlite3
android.accept_sdk_license = True
p4a.branch = master
android.arch = armeabi-v7a
ios.kivy_ios_url = https://github.com/kivy/kivy-ios
ios.kivy_ios_branch = master
ios.ios_deploy_url = https://github.com/phonegap/ios-deploy
ios.ios_deploy_branch = 1.7.0
[buildozer]
log_level = 2
warn_on_root = 1
title = ZeroNetN

APK files: https://gitlab.com/mkg20001-gh/ZeroNet-kivy/-/jobs/171320223/artifacts/browse/release/

Logs

Build: https://gitlab.com/mkg20001-gh/ZeroNet-kivy/-/jobs/171270719/raw

Application:

03-05 12:37:31.035 15940 15954 I zn      : Traceback (most recent call last):
03-05 12:37:31.035 15940 15954 I zn      :   File "/home/data/.buildozer/android/app/zero/zeronet.py", line 24, in main
03-05 12:37:31.035 15940 15954 I zn      :   File "/home/data/.buildozer/android/app/zero/src/main.py", line 13, in <module>
03-05 12:37:31.035 15940 15954 I zn      :   File "/home/data/.buildozer/android/platform/build/build/python-installs/zeronet/gevent/monkey.py", line 966, in patch_all
03-05 12:37:31.035 15940 15954 I zn      :   File "/home/data/.buildozer/android/platform/build/build/python-installs/zeronet/gevent/monkey.py", line 168, in _notify_patch
03-05 12:37:31.035 15940 15954 I zn      :   File "/home/data/.buildozer/android/platform/build/build/python-installs/zeronet/gevent/events.py", line 112, in notify_and_call_entry_points
03-05 12:37:31.035 15940 15954 I zn      :   File "/home/data/.buildozer/android/platform/build/build/python-installs/zeronet/pkg_resources/__init__.py", line 2320, in load
03-05 12:37:31.035 15940 15954 I zn      :   File "/home/data/.buildozer/android/platform/build/build/python-installs/zeronet/pkg_resources/__init__.py", line 2343, in require
03-05 12:37:31.035 15940 15954 I zn      :   File "/home/data/.buildozer/android/platform/build/build/python-installs/zeronet/pkg_resources/__init__.py", line 764, in resolve
03-05 12:37:31.035 15940 15954 I zn      :   File "/home/data/.buildozer/android/platform/build/build/python-installs/zeronet/pkg_resources/__init__.py", line 975, in __init__
03-05 12:37:31.035 15940 15954 I zn      :   File "/home/data/.buildozer/android/platform/build/build/python-installs/zeronet/pkg_resources/__init__.py", line 1007, in scan
03-05 12:37:31.035 15940 15954 I zn      :   File "/home/data/.buildozer/android/platform/build/build/python-installs/zeronet/pkg_resources/__init__.py", line 1884, in find_eggs_in_zip
03-05 12:37:31.035 15940 15954 I zn      :   File "/home/data/.buildozer/android/platform/build/build/python-installs/zeronet/pkg_resources/__init__.py", line 1416, in resource_listdir
03-05 12:37:31.035 15940 15954 I zn      :   File "/home/data/.buildozer/android/platform/build/build/python-installs/zeronet/pkg_resources/__init__.py", line 1759, in _listdir
03-05 12:37:31.035 15940 15954 I zn      :   File "/home/data/.buildozer/android/platform/build/build/python-installs/zeronet/pkg_resources/__init__.py", line 1739, in _index
03-05 12:37:31.035 15940 15954 I zn      :   File "/home/data/.buildozer/android/platform/build/build/python-installs/zeronet/pkg_resources/__init__.py", line 1630, in zipinfo
03-05 12:37:31.035 15940 15954 I zn      :   File "/home/data/.buildozer/android/platform/build/build/python-installs/zeronet/pkg_resources/__init__.py", line 1590, in load
03-05 12:37:31.035 15940 15954 I zn      :   File "/home/data/.buildozer/android/platform/build/build/python-installs/zeronet/pkg_resources/__init__.py", line 1563, in build
03-05 12:37:31.035 15940 15954 I zn      :   File "/home/data/.buildozer/android/platform/build/build/other_builds/python2-openssl-sqlite3/armeabi-v7a__ndk_target_21/python2/Lib/zipfile.py", line 770, in __init__
03-05 12:37:31.035 15940 15954 I zn      :   File "/home/data/.buildozer/android/platform/build/build/other_builds/python2-openssl-sqlite3/armeabi-v7a__ndk_target_21/python2/Lib/zipfile.py", line 811, in _RealGetContents
03-05 12:37:31.035 15940 15954 I zn      : BadZipfile: File is not a zip file
@mkg20001 mkg20001 changed the title Problem with loding gevent: Problem with loding gevent: BadZipfile: File is not a zip file Mar 5, 2019
@mkg20001
Copy link
Contributor Author

Problem seems to be solved by using gevent==1.2.2

Still leaving this open as newer version should be supported

@AndreMiras AndreMiras added the bug label Mar 12, 2019
@AndreMiras
Copy link
Member

The recipe is currently running on gevent==1.4.0 https://github.com/kivy/python-for-android/blob/19ca925/pythonforandroid/recipes/gevent/__init__.py#L7 which is the current last version of pypi.
I'm using it for one project and it run(time) just fine https://github.com/kivy/python-for-android/blob/19ca925/pythonforandroid/recipes/gevent/__init__.py#L7
However it's on Python3. Would you mind giving Python3 a try? There's no incentive to maintain Python2.
If you we can reproduce the issue on Python3, then we should definitely take a look. If it's only a Python2 issue then it's a wontfix for me 😬

@mkg20001
Copy link
Contributor Author

Using python2 currently isn't an option, but upstream zeronet HelloZeroNet/ZeroNet#1773 plans to upgrade in the future, so we'll simply be stuck on 1.2.2 until py3 is ready

Will try once that is done

@AndreMiras
Copy link
Member

Ouch so a project with over 10K ⭐ on :octocat: is still running on Python2 only, that hurts 😨
Good luck with it 🍀 😄

@mkg20001
Copy link
Contributor Author

mkg20001 commented Aug 5, 2019

It's a python3 issue now, since this is happening on ZeroNet python3 as well

I have a suspicion #763 could fix that (and then also removing the greenlet recipie and making it a pip only package) since the pip way seems to build the metadata, but uses the wrong arch (which the pr would fix)

@AndreMiras
Copy link
Member

Can you share the Python3 stacktrace then?

@mkg20001
Copy link
Contributor Author

mkg20001 commented Aug 5, 2019

There are multiple. When using a specific version for ex, the recipie is skipped and the package is instaled with pip. Here it then complains about being compiled for the wrong arch when executed.

When using it with recipie (edit: normally, without anything like greenlet>=version specified), there is always some weird error since the metadata is missing and python3 doesn't know where to look

I can give you the stacktrace for the last mentioned case, for the others a bit of digging in tons of gitlab ci pipelines would be required, unless I'll want to waste hours with compiling

@mkg20001
Copy link
Contributor Author

mkg20001 commented Aug 5, 2019

08-05 17:43:49.913 22133 22134 I adbd    : initializing functionfs
08-05 17:43:49.913 22133 22134 I adbd    : opening control endpoint /dev/usb-ffs/adb/ep0
08-05 17:43:50.377 22727 22741 I zn      : - Starting ZeroNet...
08-05 17:43:50.914 22133 22134 I adbd    : initializing functionfs
08-05 17:43:50.914 22133 22134 I adbd    : opening control endpoint /dev/usb-ffs/adb/ep0
08-05 17:43:51.098 22727 22741 I zn      : [ERROR  ] [Unhandled exception] The 'greenlet>=0.4.14' distribution was not found and is required by the application
08-05 17:43:51.099 22727 22741 I zn      : Traceback (most recent call last):
08-05 17:43:51.099 22727 22741 I zn      :   File "/home/data/.buildozer/android/app/zero/zeronet.py", line 18, in main
08-05 17:43:51.099 22727 22741 I zn      :   File "/home/data/.buildozer/android/app/zero/src/main.py", line 12, in <module>
08-05 17:43:51.099 22727 22741 I zn      :   File "/home/data/.buildozer/android/platform/build/build/python-installs/zeronet/gevent/monkey.py", line 966, in patch_all
08-05 17:43:51.099 22727 22741 I zn      :   File "/home/data/.buildozer/android/platform/build/build/python-installs/zeronet/gevent/monkey.py", line 168, in _notify_patch
08-05 17:43:51.099 22727 22741 I zn      :   File "/home/data/.buildozer/android/platform/build/build/python-installs/zeronet/gevent/events.py", line 112, in notify_and_call_entry_points
08-05 17:43:51.099 22727 22741 I zn      :   File "/home/data/.buildozer/android/platform/build/build/python-installs/zeronet/pkg_resources/__init__.py", line 2433, in load
08-05 17:43:51.099 22727 22741 I zn      :   File "/home/data/.buildozer/android/platform/build/build/python-installs/zeronet/pkg_resources/__init__.py", line 2456, in require
08-05 17:43:51.099 22727 22741 I zn      :   File "/home/data/.buildozer/android/platform/build/build/python-installs/zeronet/pkg_resources/__init__.py", line 786, in resolve
08-05 17:43:51.099 22727 22741 I zn      : pkg_resources.DistributionNotFound: The 'greenlet>=0.4.14' distribution was not found and is required by the application
08-05 17:43:51.319 22727 22741 I zn      :  Traceback (most recent call last):
08-05 17:43:51.321 22727 22741 I zn      :    File "/home/data/.buildozer/android/app/zero/zeronet.py", line 18, in main
08-05 17:43:51.323 22727 22741 I zn      :    File "/home/data/.buildozer/android/app/zero/src/main.py", line 12, in <module>
08-05 17:43:51.323 22727 22741 I zn      :    File "/home/data/.buildozer/android/platform/build/build/python-installs/zeronet/gevent/monkey.py", line 966, in patch_all
08-05 17:43:51.324 22727 22741 I zn      :    File "/home/data/.buildozer/android/platform/build/build/python-installs/zeronet/gevent/monkey.py", line 168, in _notify_patch
08-05 17:43:51.325 22727 22741 I zn      :    File "/home/data/.buildozer/android/platform/build/build/python-installs/zeronet/gevent/events.py", line 112, in notify_and_call_entry_points
08-05 17:43:51.326 22727 22741 I zn      :    File "/home/data/.buildozer/android/platform/build/build/python-installs/zeronet/pkg_resources/__init__.py", line 2433, in load
08-05 17:43:51.326 22727 22741 I zn      :    File "/home/data/.buildozer/android/platform/build/build/python-installs/zeronet/pkg_resources/__init__.py", line 2456, in require
08-05 17:43:51.327 22727 22741 I zn      :    File "/home/data/.buildozer/android/platform/build/build/python-installs/zeronet/pkg_resources/__init__.py", line 786, in resolve
08-05 17:43:51.328 22727 22741 I zn      :  pkg_resources.DistributionNotFound: The 'greenlet>=0.4.14' distribution was not found and is required by the application
08-05 17:43:51.328 22727 22741 I zn      :  
08-05 17:43:51.329 22727 22741 I zn      :  During handling of the above exception, another exception occurred:
08-05 17:43:51.330 22727 22741 I zn      :  
08-05 17:43:51.332 22727 22741 I zn      :  Traceback (most recent call last):
08-05 17:43:51.333 22727 22741 I zn      :    File "/home/data/.buildozer/android/app/platform_android.py", line 53, in wrapSentry
08-05 17:43:51.335 22727 22741 I zn      :    File "/home/data/.buildozer/android/app/service.py", line 62, in main
08-05 17:43:51.336 22727 22741 I zn      :    File "/home/data/.buildozer/android/app/zero/zeronet.py", line 126, in start
08-05 17:43:51.337 22727 22741 I zn      :    File "/home/data/.buildozer/android/app/zero/zeronet.py", line 30, in main
08-05 17:43:51.338 22727 22741 I zn      :  FileNotFoundError: [Errno 2] No such file or directory: './log/error.log'
08-05 17:43:51.507 22727 22741 I python  : Python for android ended.
08-05 17:43:51.610 22727 22741 I zn      :  Sentry is attempting to send 1 pending error messages
08-05 17:43:51.611 22727 22741 I zn      :  Waiting up to 2 seconds
08-05 17:43:51.612 22727 22741 I zn      :  Press Ctrl-C to quit
08-05 17:43:51.914 22133 22134 I adbd    : initializing functionfs
08-05 17:43:51.914 22133 22134 I adbd    : opening control endpoint /dev/usb-ffs/adb/ep0

There is the current one. HelloZeroNet/ZeroNet-kivy#60 (comment) for context on why this happens

@mkg20001
Copy link
Contributor Author

mkg20001 commented Aug 5, 2019

The other method results in an architecture mismatch error, since it's using the wheel that's appropriate for the machine it gets built on and not the appropriate for android (it'd probably have to build it)

@AndreMiras
Copy link
Member

Thanks for the log, then I don't see how it's the same error as the one in the ticket initially created? 🤔
It definitely looks different to me. I mean it's clearly complaining about missing greenlet. But let's not hijack this issue and create a dedicated one because that's not related.

@mkg20001
Copy link
Contributor Author

mkg20001 commented Aug 5, 2019

Thanks for the log, then I don't see how it's the same error as the one in the ticket initially created? thinking

This is basically a generic "I can't get python to load/find greenlet" issue

And we all know: A different error message means progress

But the problem is: Which way to solve it?

I also have a third stacktrace which is different too (that one where I attempted to directly specify the version, p4a ended up using a wheel for the build server architecture)

And now I'm confused as to which path to continue down: Fixing the greenlet recipe or implementing wheel support as mentioned in the pr #763 and making the greenlet recipe use wheel instead of directly calling setup.py?
(The problem is that the metadata python needs to find the module, is for some reason not being generated/included)

@mkg20001
Copy link
Contributor Author

mkg20001 commented Aug 6, 2019

Once we get that out of the way, we'll know which stacktrace to analyze next

Copy link

👋 We use the issue tracker exclusively for bug reports and feature requests. However, this issue appears to be a support request. Please use our support channels to get help with the project.

If you're having trouble installing or using python-for-android, maybe you could be interested in our quickstart guide.

Let us know if this comment was made in error, and we'll be happy to reopen the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants