You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 24, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Feb 24, 2023. It is now read-only.
In trying to figure out issues I'm having on older devices running 6.0.1, I'm wondering if some of my issues are that I had to change how I import the library. In looking back at my fork, the dynamic library has an SONAME, the current version coming from this fork are not. In looking back at Issue 18 I noticed that my errors was showing the windows style path, and I wonder if it's causing some of my issues. As described here
On a side note, I also see that Python 3.9b5 is available. I tried adding a similar path to the configure.ac, but I didn't have much luck.
Adding SONAME requires some non-trivial patches to setup.py and/or distutils. I'd like a self-contained App to test before investing time into SONAME stuffs.
Also, I really suggest you to build static library libpython.a and link your JNI library to libpython.a so to get rid of all the issues around dynamic linking.
I played around and added the following patch to configure.ac. I realize this is hard coded, but this added the SONAME to my dynamic library, and fixed some of my issues.
I have tried to get the static library to work, but I have not had much luck. Any chance you can point me in the right direction if you recommend that, or update my test app to show how that would work?
Sorry, but I don't have much time recently for testing it. Mind to share error messages you've got? (I'm not asking for a complete example this time - I know preparing it is very time consuming :P)
I think after rebuilding python3-android as static libraries and remove loadLibrary("python3.9") are first steps?
CMake Error at CMakeLists.txt:21 (target_link_libraries):
Cannot specify link libraries for target "python39" which is not built by
this project.
I've tried to just change what is currently in the CMakesList.txt and use STATIC instead of SHARED and .a instead of .o. The app then compiles, but crashes at runtime with
CMakeLists
2020-09-17 10:23:49.568 29855-29855/com.example.pythontest E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.pythontest, PID: 29855
java.lang.UnsatisfiedLinkError: dlopen failed: library "libpython3.9.so" not found
At this point I feel I need to create a fork of your project that has my hack in configure.ac so I can at least get back to that if needed. Maybe we can get a static build working, but other then a requests library input failing on my 32 bit 6.0.1 device, everything works with this SONAME patch.
As an added note. I'm pretty much giving up on the 1 device that doesn't run this. I tracked it down to the requests library (https://requests.readthedocs.io/en/master/) It appears to fail in urllib3 when trying to make the following import
from __future__ import absolute_import
I tried removing these imports, but it only created other issues. Just sharing for the sake of sharing, not sure it helps anyone understand my issues.
java.lang.UnsatisfiedLinkError: dlopen failed: library "libpython3.9.so" not found
Hmm, that's strange. If you want to continue the state library approach, could you check if readelf -d libpythonthread.so still has libpython3.9.so (it shouldn't now), and the System.loadLibrary("python3.9"); has been removed from Java files?
It appears to fail in urllib3 when trying to make the following import
Yet another strange stuff... absolute_import is enabled by default on Python 3.x.
Activity
yan12125 commentedon Sep 4, 2020
Adding SONAME requires some non-trivial patches to setup.py and/or distutils. I'd like a self-contained App to test before investing time into SONAME stuffs.
Also, I really suggest you to build static library libpython.a and link your JNI library to libpython.a so to get rid of all the issues around dynamic linking.
GRRedWings commentedon Sep 4, 2020
I played around and added the following patch to configure.ac. I realize this is hard coded, but this added the SONAME to my dynamic library, and fixed some of my issues.
`diff --git a/configure.ac b/configure.ac
index 73ee71c6d2..a62edaebae 100644
--- a/configure.ac 2020-09-03 13:02:27.847717033 -0700
+++ b/configure.ac 2020-09-03 13:14:11.101958236 -0700
@@ -890,8 +890,9 @@
AC_SUBST(MULTIARCH_CPPFLAGS)
AC_MSG_CHECKING([for -Wl,--no-as-needed])
+LDFLAGS="$LDFLAGS -Wl,-soname,libpython3.9.so"
save_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS -Wl,--no-as-needed"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
[NO_AS_NEEDED="-Wl,--no-as-needed"
AC_MSG_RESULT([yes])],
`
GRRedWings commentedon Sep 11, 2020
I have tried to get the static library to work, but I have not had much luck. Any chance you can point me in the right direction if you recommend that, or update my test app to show how that would work?
yan12125 commentedon Sep 16, 2020
Sorry, but I don't have much time recently for testing it. Mind to share error messages you've got? (I'm not asking for a complete example this time - I know preparing it is very time consuming :P)
I think after rebuilding python3-android as static libraries and remove loadLibrary("python3.9") are first steps?
GRRedWings commentedon Sep 17, 2020
I feel I'm doing something wrong. I've tried adding these lines to CMakeLists
but get this error
I've tried to just change what is currently in the CMakesList.txt and use STATIC instead of SHARED and .a instead of .o. The app then compiles, but crashes at runtime with
CMakeLists
Runtime Output
At this point I feel I need to create a fork of your project that has my hack in configure.ac so I can at least get back to that if needed. Maybe we can get a static build working, but other then a requests library input failing on my 32 bit 6.0.1 device, everything works with this SONAME patch.
GRRedWings commentedon Sep 17, 2020
As an added note. I'm pretty much giving up on the 1 device that doesn't run this. I tracked it down to the requests library (https://requests.readthedocs.io/en/master/) It appears to fail in urllib3 when trying to make the following import
from __future__ import absolute_importI tried removing these imports, but it only created other issues. Just sharing for the sake of sharing, not sure it helps anyone understand my issues.
yan12125 commentedon Sep 20, 2020
Hmm, that's strange. If you want to continue the state library approach, could you check if
readelf -d libpythonthread.sostill haslibpython3.9.so(it shouldn't now), and theSystem.loadLibrary("python3.9");has been removed from Java files?Yet another strange stuff...
absolute_importis enabled by default on Python 3.x.