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

Bump to SDL2 2.0.10 & extract .java from SDL2 tarball #1779

Closed
wants to merge 1 commit into from
Closed

Bump to SDL2 2.0.10 & extract .java from SDL2 tarball #1779

wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Apr 3, 2019

Bumps SDL2 to the next 2.0.10 release, and fixes the SDL2 bootstrap so it copies .java out of the tarball instead of having a copy in our source tree

Major SDL2 fixes this brings:

  • Fixes SDL_TOUCH_MOUSEID so it works reliably on Android and other platforms like X11
  • Adds new hint SDL_HINT_MOUSE_TOUCH_EVENTS (to control whether mouse will cause fake touch events), and removal of android-specific SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH such that this can now be controlled cross-platform in the same manner, not just for android/mobile
  • Adds new SDL_HINT_ANDROID_ON_PAUSE to control whether SDL_PollEvent blocks when the app goes into background or not, currently SDL_PollEvent always blocks and this is force-enabled
  • Fixes to avoid OpenGL context corruption and other issues when using ANDROID_ON_PAUSE=0 (not the default, and not what kivy uses - so mostly relevant to non-kivy apps)

Major python-for-android fixes:

  • all the .java copied out of SDL2 in our source tree is gone, only the .patch for SDLActivity.java for making the loading screen work is left. This should make future upgrades considerably less work since one can just bump the version in recipes/SDL2/__init__.py and adapt the patch as necessary and done. (right now you'd also need to copy over the new .java files in the exact matching version and if you forgot it might crash, misbehave, or do all sorts of weird things)

@ghost
Copy link
Author

ghost commented Apr 7, 2019

For what it's worth, upstream has still some unfixed Android concurrency issues and stuff regarding SDL_TOUCH_MOUSEID and mouse focus on Android which is making some progress, so I'll keep bumping this up for a while seeing how they progress fixing things.

(Unless someone here is really adamant about getting this in super quick)

@inclement
Copy link
Member

Code changes look good to me, but I won't merge for now as you've suggested. Also didn't test with Kivy yet, although I don't anticipate any issues.

inclement
inclement previously approved these changes Apr 7, 2019
@ghost
Copy link
Author

ghost commented Apr 7, 2019

Summary from chat: SDL_TOUCH_MOUSEID is in non-default settings now sent when sometimes it wouldn't have been in stable, and some ways to get non-default touch behavior (like SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH) are now gone and need to be done differently. So it would be possible that kivy doesn't like that, depending on how it handles touch - and it would probably be a good idea to test it (I can help with that once this is more ready for inclusion!)

@ghost ghost changed the title [WIP] Bump to dev SDL2 for touch fix & extract .java from SDL2 tarball Bump to dev SDL2 for touch fix & extract .java from SDL2 tarball Apr 15, 2019
@ghost ghost added need-testing and removed WIP labels Apr 15, 2019
@ghost
Copy link
Author

ghost commented Apr 15, 2019

Concurrency issues and ANDROID_ON_PAUSE=0 bugs have been addressed in SDL2 now, at least for the ones I am aware, so I think it's not at a bad spot for a potential merge right now. (Especially since these concurrency issues are still present in 2.0.9 stable which is what we currently use, and ANDROID_ON_PAUSE=0 is not even really possible with that version)

Is someone with a complex kivy app interested in testing this by any chance? Things to look out for is mainly touch and multitouch, and if you can a USB hardware mouse (or an app that emulates one) to see if all the input stuff still works as expected. Possible issues could be that the input no longer works for one variant at all, or that clicks are processed twice with one input variant

@inclement
Copy link
Member

Just tested this a bit with my Kivy app, just normal touch interaction but everything seemed fine.
I'm not completely sure if anything needs doing though, could I check:

Adds new hint SDL_HINT_MOUSE_TOUCH_EVENTS (to control whether mouse will cause fake touch events), and removal of android-specific SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH such that this can now be controlled cross-platform in the same manner, not just for android/mobile

Has the default actually changed here, I couldn't find much information about it? Kivy's SDL2 code does make an effort to deal properly with touch and mouse events independently so it may not even matter, and certainly doesn't if they were separated before, but I don't think it was setting anything non-default.

Adds new SDL_HINT_ANDROID_ON_PAUSE to control whether SDL_PollEvent blocks when the app goes into background or not, currently SDL_PollEvent always blocks and this is force-enabled

Do I understand right that the new behaviour (not blocking) remains not the default, so Kivy doesn't need any changes to work as before? Probably we want to change Kivy to work with the non-blocking, but just checking that there's no immediate change for now.

@ghost
Copy link
Author

ghost commented Apr 29, 2019

@inclement yeah defaults are the same. Any default changes were reverted, nothing regarding blocking or touch has changed if no hints are set. Per default they are not separated however, which would mean kivy wouldn't handle mouse wheel and in general act like a hardware mouse is like a finger. That works well enough to use the app but it's not ideal if you want first class mouse support, so if you want that you should look into the new hints

inclement
inclement previously approved these changes Apr 29, 2019
@inclement
Copy link
Member

@Jonast Perfect, in that case it's good to merge as far as I'm concerned. It sounds like Kivy doesn't handle hardware mouse properly on Android, but I bet almost nobody has even tried it, I'll maybe try to fix it since it should be a trivial hint change.

@inclement inclement changed the base branch from master to develop June 6, 2019 20:40
@Fak3
Copy link

Fak3 commented Jun 20, 2019

i rebased this on top of develop branch, and built a simple kivy app
app fails to start on android:

V/pythonutil(18396): Loading library: SDL2
V/pythonutil(18396): Loading library: SDL2_image
V/pythonutil(18396): Loading library: SDL2_mixer
V/pythonutil(18396): Loading library: SDL2_ttf
V/pythonutil(18396): Loading library: ssl1.1
W/linker  (18396): Unsupported flags DT_FLAGS_1=0x8
W/linker  (18396): Unsupported flags DT_FLAGS_1=0x8
V/pythonutil(18396): Loading library: crypto1.1
V/pythonutil(18396): Loading library: python2.7
V/pythonutil(18396): Library loading error: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/org.spbelect.paradox2-1/base.apk"],nativeLibraryDirectories=[/data/app/org.spbelect.paradox2-1/lib/arm, /vendor/lib, /system/lib]]] couldn't find "libpython2.7.so"
V/pythonutil(18396): Loading library: python3.5m
V/pythonutil(18396): Library loading error: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/org.spbelect.paradox2-1/base.apk"],nativeLibraryDirectories=[/data/app/org.spbelect.paradox2-1/lib/arm, /vendor/lib, /system/lib]]] couldn't find "libpython3.5m.so"
V/pythonutil(18396): Loading library: python3.6m
V/pythonutil(18396): Library loading error: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/org.spbelect.paradox2-1/base.apk"],nativeLibraryDirectories=[/data/app/org.spbelect.paradox2-1/lib/arm, /vendor/lib, /system/lib]]] couldn't find "libpython3.6m.so"
V/pythonutil(18396): Loading library: python3.7m
V/pythonutil(18396): Loading library: main
E/art     (18396): dlopen("/data/data/org.spbelect.paradox2/files/app/lib/python2.7/lib-dynload/_io.so", RTLD_LAZY) failed: dlopen failed: library "/data/data/org.spbelect.paradox2/files/app/lib/python2.7/lib-dynload/_io.so" not found
V/pythonutil(18396): Failed to load _io.so or unicodedata.so...but that's okay.
E/art     (18396): dlopen("/data/data/org.spbelect.paradox2/files/app/lib/python2.7/lib-dynload/_ctypes.so", RTLD_LAZY) failed: dlopen failed: library "/data/data/org.spbelect.paradox2/files/app/lib/python2.7/lib-dynload/_ctypes.so" not found
V/pythonutil(18396): Unsatisfied linker when loading ctypes
V/pythonutil(18396): Loaded everything!
V/SDL     (18396): nativeSetupJNI()
V/SDL     (18396): AUDIO nativeSetupJNI()
V/SDL     (18396): CONTROLLER nativeSetupJNI()
V/PythonActivity(18396): Setting env vars for start.c and Python to use
V/PythonActivity(18396): Access to our meta-data...
I/PythonActivity(18396): Surface will NOT be transparent
V/PythonActivity(18396): onResume()
V/SDL     (18396): onResume()
V/WindowManager( 1210): Adding window Window{33b25996 u0 SurfaceView} at 6 of 11 (before Window{1bae4040 u0 org.spbelect.paradox2/org.kivy.android.PythonActivity})
V/SDL     (18396): surfaceCreated()
V/SDL     (18396): surfaceChanged()
V/SDL     (18396): pixel format RGB_565
V/SDL     (18396): Window size: 1080x1920
V/SDL     (18396): Device size: 1080x1920
V/SDL     (18396): Running main function SDL_main from library /data/app/org.spbelect.paradox2-1/lib/arm/libmain.so
V/SDL     (18396): nativeRunMain()
I/python  (18396): Initializing Python for Android
I/python  (18396): Setting additional env vars from p4a_env_vars.txt
I/python  (18396): Changing directory to the one provided by ANDROID_ARGUMENT
I/python  (18396): /data/data/org.spbelect.paradox2/files/app
I/python  (18396): Preparing to initialize python
I/python  (18396): _python_bundle dir exists
I/python  (18396): calculated paths to be...
I/python  (18396): /data/data/org.spbelect.paradox2/files/app/_python_bundle/stdlib.zip:/data/data/org.spbelect.paradox2/files/app/_python_bundle/modules
I/python  (18396): set wchar paths...
I/Timeline( 1210): Timeline: Activity_windows_visible id: ActivityRecord{820a337 u0 org.spbelect.paradox2/org.kivy.android.PythonActivity t30050} time:517210460
V/SDL     (18396): surfaceChanged()
V/SDL     (18396): pixel format RGB_565
V/SDL     (18396): Window size: 1080x1845
V/SDL     (18396): Device size: 1080x1920
D/PhoneStatusBar(15161): ******setStatusBarIconsColor, iconYiqLuma =0 ,mIconYiqLuma =0,isLauncher =false, color =-16777216 , title =org.spbelect.paradox2/org.kivy.android.PythonActivity ,mstate= 0
I/python  (18396): Initialized python
I/python  (18396): AND: Init threads
I/python  (18396): testing python print redirection
I/python  (18396): Android path ['.', '/data/data/org.spbelect.paradox2/files/app/_python_bundle/stdlib.zip', '/data/data/org.spbelect.paradox2/files/app/_python_bundle/modules', '/data/data/org.spbelect.paradox2/files/app/_python_bundle/site-packages']
I/python  (18396): os.environ is environ({'PATH': '/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin', 'ANDROID_BOOTLOGO': '1', 'ANDROID_ROOT': '/system', 'ANDROID_ASSETS': '/system/app', 'ANDROID_DATA': '/data', 'ANDROID_STORAGE': '/storage', 'ASEC_MOUNTPOINT': '/mnt/asec', 'LOOP_MOUNTPOINT': '/mnt/obb', 'BOOTCLASSPATH': '/system/framework/core-libart.jar:/system/framework/conscrypt.jar:/system/framework/okhttp.jar:/system/framework/core-junit.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/telephony-common.jar:/system/framework/voip-common.jar:/system/framework/ims-common.jar:/system/framework/mms-common.jar:/system/framework/android.policy.jar:/system/framework/apache-xml.jar:/system/framework/qcmediaplayer.jar:/system/framework/vcard.jar:/system/framework/tcmiface.jar:/system/framework/qcom.fmradio.jar:/system/framework/WfdCommon.jar:/system/framework/oem-services.jar:/system/framework/profile.jar:/system/framework/nubiatel-common.jar:/system/framework/nubia-vibrate.jar:/system/framework/telephony-static-config.jar:/system/framework/gesture.jar:/system/framework/com.powermo.smartshow.jar', 'SYSTEMSERVERCLASSPATH': '/system/framework/services.jar:/system/framework/ethernet-service.jar:/system/framework/wifi-service.jar:/system/framework/com.powermo.smartshowcore.jar', 'LD_PRELOAD': 'libsigchain.so:libNimsWrap.so', 'EXTERNAL_STORAGE': '/storage/emulated/legacy', 'SECONDARY_STORAGE': '/storage/sdcard1', 'EMULATED_STORAGE_SOURCE': '/mnt/shell/emulated', 'EMULATED_STORAGE_TARGET': '/storage/emulated', 'OTG_STORAGE': '/storage/usba', 'ANDROID_PROPERTY_WORKSPACE': '8,0', 'ANDROID_SOCKET_zygote_secondary': '9', 'ANDROID_ENTRYPOINT': 'main.pyc', 'ANDROID_ARGUMENT': '/data/data/org.spbelect.paradox2/files/app', 'ANDROID_APP_PATH': '/data/data/org.spbelect.paradox2/files/app', 'ANDROID_PRIVATE': '/data/data/org.spbelect.paradox2/files', 'ANDROID_UNPACK': '/data/data/org.spbelect.paradox2/files/app', 'PYTHONHOME': '/data/data/org.spbelect.paradox2/files/app', 'PYTHONPATH': '/data/data/org.spbelect.paradox2/files/app:/data/data/org.spbelect.paradox2/files/app/lib', 'PYTHONOPTIMIZE': '2', 'P4A_BOOTSTRAP': 'SDL2', 'PYTHON_NAME': 'python', 'P4A_IS_WINDOWED': 'False', 'P4A_ORIENTATION': 'portrait', 'P4A_NUMERIC_VERSION': 'None', 'P4A_MINSDK': '21', 'LC_CTYPE': 'C.UTF-8'})
I/python  (18396): Android kivy bootstrap done. __name__ is __main__
I/python  (18396): AND: Ran string
I/python  (18396): Run user program, change dir and execute entrypoint
I/python  (18396): [WARNING] [Config      ] Older configuration version detected (0 instead of 21)
I/python  (18396): [WARNING] [Config      ] Upgrading configuration in progress.
I/python  (18396): [INFO   ] [Logger      ] Record log in /data/data/org.spbelect.paradox2/files/app/.kivy/logs/kivy_19-06-20_0.txt
I/python  (18396): [INFO   ] [Kivy        ] v1.11.0
I/python  (18396): [INFO   ] [Kivy        ] Installed at "/data/data/org.spbelect.paradox2/files/app/_python_bundle/site-packages/kivy/__init__.pyc"
I/python  (18396): [INFO   ] [Python      ] v3.7.1 (default, Jun 20 2019, 19:05:10) 
I/python  (18396): [Clang 6.0.2 (https://android.googlesource.com/toolchain/clang 183abd29fc496f55
I/python  (18396): [INFO   ] [Python      ] Interpreter at "android_python"
I/python  (18396): [INFO   ] [Factory     ] 184 symbols loaded
I/python  (18396): [INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_gif (img_pil, img_ffpyplayer ignored)
I/python  (18396): [INFO   ] [Text        ] Provider: sdl2
I/python  (18396): [INFO   ] [Window      ] Provider: sdl2
V/SDL     (18396): setOrientation() orientation=-1 width=1080 height=1920 resizable=true hint=
V/SDL     (18396): surfaceDestroyed()
V/SDL     (18396): nativePause()
V/SDL     (18396): surfaceCreated()
V/SDL     (18396): surfaceChanged()
V/SDL     (18396): pixel format RGBA_8888
V/SDL     (18396): Window size: 1080x1845
V/SDL     (18396): Device size: 1080x1920
I/python  (18396): [CRITICAL] [Window      ] Unable to find any valuable Window provider. Please enable debug logging (e.g. add -d if running from the command line, or change the log level in the config) and re-run your app to identify potential causes
I/python  (18396): sdl2 - RuntimeError: b'Unable to make EGL context current (call to eglMakeCurrent failed, reporting an error of EGL_BAD_SURFACE)'
I/python  (18396):   File "/home/u1/.local/share/python-for-android/build/python-installs/tst/kivy/core/__init__.py", line 71, in core_select_lib
I/python  (18396):   File "/home/u1/.local/share/python-for-android/build/python-installs/tst/kivy/core/window/window_sdl2.py", line 152, in __init__
I/python  (18396):   File "/home/u1/.local/share/python-for-android/build/python-installs/tst/kivy/core/window/__init__.py", line 969, in __init__
I/python  (18396):   File "/home/u1/.local/share/python-for-android/build/python-installs/tst/kivy/core/window/window_sdl2.py", line 289, in create_window
I/python  (18396):   File "kivy/core/window/_window_sdl2.pyx", line 233, in kivy.core.window._window_sdl2._WindowSDL2Storage.setup_window
I/python  (18396):   File "kivy/core/window/_window_sdl2.pyx", line 75, in kivy.core.window._window_sdl2._WindowSDL2Storage.die
V/SDL     (18396): nativeResume()
I/python  (18396): [CRITICAL] [App         ] Unable to get a Window, abort.

@Fak3
Copy link

Fak3 commented Jun 20, 2019

@Fak3
Copy link

Fak3 commented Jun 20, 2019

@Fak3
Copy link

Fak3 commented Jun 21, 2019

I just tried the most recent sdl from hg: http://hg.libsdl.org/SDL/rev/89b3e1e9839c
the bug is still there :(

@Fak3
Copy link

Fak3 commented Jun 21, 2019

I have disabled multisamples in kivy config and app worked!

from kivy.config import Config
Config.set('graphics', 'multisamples', '0')

@Fak3
Copy link

Fak3 commented Jun 21, 2019

I tried the latest sdl2 version from hg. It also fixed #1876

@Fak3
Copy link

Fak3 commented Jun 21, 2019

sdl2 issue with multisampling reported upstream: https://bugzilla.libsdl.org/show_bug.cgi?id=4681

@Fak3
Copy link

Fak3 commented Jun 21, 2019

Ah, issue with EGL_BAD_SURFACE is more complicated. For more complex app, even without multisampling the chance of successful start is about 30%

@ghost ghost added the WIP label Jul 21, 2019
@ghost ghost changed the title Bump to dev SDL2 for touch fix & extract .java from SDL2 tarball [WIP/don't merge just yet] Bump to dev SDL2 for touch fix & extract .java from SDL2 tarball Jul 21, 2019
@ghost
Copy link
Author

ghost commented Jul 21, 2019

@Fak3 I bumped the SDL2 version to the one with the fix. Can you retest if it works now? (edit: also thanks so much for debugging this with the SDL2 devs 🎉 ❤️ )

I also need to look into the loading screen sometimes not going away, I think that might be a regression of the SDL2 version change

@Fak3
Copy link

Fak3 commented Jul 22, 2019

@Jonast I've been testing with latest sdl for a while. I am also experiencing a bug with app hanging during startup. It only happens on more recent versions of Android (6+ I believe). If you minimize and then maximize app, it will continue the startup normally.

Also the new sdl version sometimes results in app being momentarily paused and resumed during startup, which results in the kivy bug, which I have opened pr for: kivy/kivy#6404

@ghost
Copy link
Author

ghost commented Jul 22, 2019

@Fak3 yeah the startup hang is why I put the WIP/don't merge just yet back. I noticed that too on my device, I'll figure out how to fix it I poked around the loading screen code before and have to look into it for another issue anyway 😄

So the crash is gone? That's good! 🎉

@Fak3
Copy link

Fak3 commented Jul 22, 2019

Yes, the crash was fixed in sdl repo.

Another issue the new sdl introduces is the weird multisampling + fullscreen jumping bug: #1876

@Fak3
Copy link

Fak3 commented Jul 22, 2019

I've been debugging the issue with the freeze on startup. This is what I discovered so far:

case 1

On android 8.1, API 27 app freezes on startup. The last thing in the adb logcat is this:

7-22 12:30:53.785 V/PythonActivity(13045): considerLoadingScreenRemoval()
07-22 12:30:53.785 V/PythonActivity(13045): considerLoadingScreenRemoval - run()
07-22 12:30:53.786 V/PythonActivity(13045): Setting env vars for start.c and Python to use
07-22 12:30:53.786 V/PythonActivity(13045): Access to our meta-data...
07-22 12:30:53.791 I/PythonActivity(13045): Surface will NOT be transparent
07-22 12:30:53.792 V/PythonActivity(13045): onResume() start
07-22 12:30:53.792 V/PythonActivity(13045): onResume() mid
07-22 12:30:53.792 V/SDL     (13045): onResume()
07-22 12:30:53.793 V/PythonActivity(13045): considerLoadingScreenRemoval()
07-22 12:30:53.793 V/PythonActivity(13045): considerLoadingScreenRemoval - run()
07-22 12:30:53.882 V/SDL     (13045): surfaceCreated()
07-22 12:30:53.882 V/SDL     (13045): surfaceChanged()
07-22 12:30:53.882 V/SDL     (13045): pixel format RGB_565
07-22 12:30:53.882 V/SDL     (13045): Window size: 480x764
07-22 12:30:53.882 V/SDL     (13045): Device size: 480x800
07-22 12:30:53.884 V/SDL     (13045): handleNativeState start
07-22 12:30:53.884 V/SDL     (13045): handleNativeState RESUMED RESUMED
07-22 12:30:53.884 V/SDL     (13045): org.libsdl.app.SDLSurface{ff0a2e4 VFE...... .F....ID 0,0-480,764} true false
07-22 12:30:53.975 V/PythonActivity(13045): onWindowFocusChanged() start
07-22 12:30:53.975 V/SDL     (13045): onWindowFocusChanged(): true
07-22 12:30:53.975 V/SDL     (13045): handleNativeState start
07-22 12:30:53.976 V/SDL     (13045): handleNativeState RESUMED RESUMED
07-22 12:30:53.976 V/SDL     (13045): org.libsdl.app.SDLSurface{ff0a2e4 VFE...... .F...... 0,0-480,764} true false
07-22 12:30:53.976 V/PythonActivity(13045): considerLoadingScreenRemoval()
07-22 12:30:53.976 V/PythonActivity(13045): considerLoadingScreenRemoval - run()
07-22 12:30:53.992 I/ActivityManager( 1608): Displayed org.spbelect.paradox2/org.kivy.android.PythonActivity: +812ms

When handleNativeState() is called, mIsResumedCalled is false.

case 2

On Android 5.1, API 22 app does not freeze. The difference is that mIsResumedCalled is true.

@ghost
Copy link
Author

ghost commented Jul 24, 2019

@Fak3 I think I figured the problem out, it's related to p4a's loading screen code and how it interacts with SDL2's new multi window/side by side handling. Can you give it another try to see if the loading screen works okay for you now?

@Fak3
Copy link

Fak3 commented Jul 25, 2019

Hm. Now I can't build my app, it fails with the weird error:

**[INFO]:    *** PYTHON PACKAGE / PROJECT INSTALL STAGE ***
[INFO]:    The requirements (app-state, better-exceptions-fork, minidjango, python-dateutil, requests-async) don't have recipes, attempting to install them with pip
[INFO]:    If this fails, it may mean that the module has compiled components and needs a recipe.
[INFO]:    -> directory context /home/u1/.local/share/python-for-android/build
[INFO]:    -> running virtualenv --python=python3 venv
[INFO]:    Upgrade pip to latest version                                                                                                                                  
[INFO]:    -> running bash -c source venv/bin/activate && pip install -U pip
[INFO]:    Install Cython in case one of the modules needs it to build                                                                                                    
[INFO]:    -> running bash -c venv/bin/pip install Cython
[INFO]:    Creating a requirements.txt file for the Python modules                                                                                                        
[INFO]:    Installing Python modules with pip
[INFO]:    IF THIS FAILS, THE MODULES MAY NEED A RECIPE. A reason for this is often modules compiling native code that is unaware of Android cross-compilation and does not work without additional changes / workarounds.
[INFO]:    -> running bash -c venv/bin/pip install -v --target '/home/u1/.local/share/python-for-android/build/python-installs/paradox-x86' --n...(and 26 more)**

  RAN: /usr/bin/bash -c venv/bin/pip install -v --target '/home/u1/.local/share/python-for-android/build/python-installs/paradox-x86' --no-deps -r requirements.txt

  STDOUT:
Traceback (most recent call last):
  File "venv/bin/pip", line 6, in <module>
    from pip._internal import main
  File "/home/u1/.local/share/python-for-android/build/venv/lib/python3.7/site-packages/pip/_internal/__init__.py", line 40, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "/home/u1/.local/share/python-for-android/build/venv/lib/python3.7/site-packages/pip/_internal/cli/autocompletion.py", line 8, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "/home/u1/.local/share/python-for-android/build/venv/lib/python3.7/site-packages/pip/_internal/cli/main_parser.py", line 7, in <module>
    from pip._internal.cli import cmdoptions
  File "/home/u1/.local/share/python-for-android/build/venv/lib/python3.7/site-packages/pip/_internal/cli/cmdoptions.py", line 21, in <module>
    from pip._internal.locations import USER_CACHE_DIR, get_src_prefix
  File "/home/u1/.local/share/python-for-android/build/venv/lib/python3.7/site-packages/pip/_internal/locations.py", line 46, in <module>
    site_packages = sysconfig.get_path("purelib")  # type: Optional[str]
  File "/usr/lib64/python3.7/sysconfig.py", line 506, in get_path
    return get_paths(scheme, vars, expand)[name]
  File "/usr/lib64/python3.7/sysconfig.py", line 496, in get_paths
    return _expand_vars(scheme, vars)
  File "/usr/lib64/python3.7/sysconfig.py", line 165, in _expand_vars
    _extend_dict(vars, get_config_vars())
  File "/usr/lib64/python3.7/sysconfig.py", line 568, in get_config_vars
    srcdir = os.path.dirname(get_makefile_filename())
  File "/usr/lib64/python3.7/sysconfig.py", line 336, in get_makefile_filename
    return os.path.join(get_path('stdlib'), config_dir_name, 'Makefile')
  File "/usr/lib64/python3.7/sysconfig.py", line 506, in get_path
    return get_paths(scheme, vars, expand)[name]
  File "/usr/lib64/python3.7/sysconfig.py", line 496, in get_paths
    return _expand_vars(scheme, vars)
  File "/usr/lib64/python3.7/sysconfig.py", line 170, in _expand_vars
    res[key] = os.path.normpath(_subst_vars(value, vars))
  File "/usr/lib64/python3.7/sysconfig.py", line 151, in _subst_vars
    raise AttributeError('{%s}' % var) from None
AttributeError: {'installed_base'}

@Fak3
Copy link

Fak3 commented Jul 27, 2019

Python error is misleading, actually it fails to find platlibdir when sysconfig.get_path('stdlib') is called. This platlibdir var is supposed to be generated once when python is installed, with python -m sysconfig --generate-posix-vars. But somehow it is not in place... I'm still puzzled how to deal with it.
Running (venv) u1@linux-fdsk:~/.local/share/python-for-android/build/venv> python3 -m sysconfig in the p4a build virtual environment insists it does exist:

        abiflags = "m"
        abs_builddir = "/home/abuild/rpmbuild/BUILD/Python-3.7.3"
        abs_srcdir = "/home/abuild/rpmbuild/BUILD/Python-3.7.3"
        base = "/home/u1/.local/share/python-for-android/build/venv"
        datarootdir = "/usr/share"
        exec_prefix = "/usr"
        installed_base = "/home/u1/.local/share/python-for-android/build/venv"
        installed_platbase = "/home/u1/.local/share/python-for-android/build/venv"
        platbase = "/home/u1/.local/share/python-for-android/build/venv"
        platlibdir = "lib64"
        prefix = "/usr"
        projectbase = "/home/u1/.local/share/python-for-android/build/venv/bin"
        py_version = "3.7.2"
        py_version_nodot = "37"
        py_version_short = "3.7"
        srcdir = "/usr/lib64/python3.7/config-3.7m-x86_64-linux-gnu"
        userbase = "/home/u1/.local"

@Fak3
Copy link

Fak3 commented Jul 27, 2019

Ah, for anyone hitting similar issue - I am on openSUSE, which ships its own version of yet-unmerged cpython patch for better lib64 support: python/cpython#8068

@ghost
Copy link
Author

ghost commented Jul 27, 2019

Wait, and why exactly does that break? 😱 Fascinating, is there something we can do about that?

@Fak3
Copy link

Fak3 commented Jul 28, 2019

When p4a calls pip to install packages in build.py, it provides PYTHONPATH environment variable, containing path: /home/u1/.local/share/python-for-android/build/other_builds/hostpython3/desktop/hostpython3/native-build/build/lib.linux-x86_64-3.7. In this dir there is _sysconfigdata_m_linux_x86_64-linux-gnu.py module, which is different from my system-wide one: it is missing required 'platlibdir': 'lib64'. This variable is required for my system-wide patched cpython to evaluate paths in its patched sysconfig module (namely, stdlib path now defined like this: 'stdlib': '{installed_base}/{platlibdir}/python{py_version_short}')

So the issue is that p4a hostpython is not properly patched to match my system-wide python installation. I am not sure what would be the proper solution for this. Currenly I managed to workaround this by manually adding 'platlibdir': 'lib64' to the /home/u1/.local/share/python-for-android/build/other_builds/hostpython3/desktop/hostpython3/native-build/build/lib.linux-x86_64-3.7/_sysconfigdata_m_linux_x86_64-linux-gnu.py module.

@Fak3
Copy link

Fak3 commented Jul 28, 2019

The issue with startup freeze seems to be fixed.

@ghost ghost changed the title [WIP/don't merge just yet] Bump to dev SDL2 for touch fix & extract .java from SDL2 tarball [WIP/don't merge just yet] Bump to SDL2 2.0.10 & extract .java from SDL2 tarball Jul 28, 2019
@ghost ghost changed the title [WIP/don't merge just yet] Bump to SDL2 2.0.10 & extract .java from SDL2 tarball Bump to SDL2 2.0.10 & extract .java from SDL2 tarball Jul 29, 2019
@ghost ghost removed the WIP label Jul 29, 2019
@misl6
Copy link
Member

misl6 commented Oct 8, 2022

Superseded by #2673

@misl6 misl6 closed this Oct 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants