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

Python3 doesn't work on Android #484

Closed
inclement opened this issue Nov 1, 2015 · 7 comments
Closed

Python3 doesn't work on Android #484

inclement opened this issue Nov 1, 2015 · 7 comments

Comments

@inclement
Copy link
Member

I'm posting this issue so that anyone looking can see the current state of things.

Right now, p4a has a python3 recipe using some sl4a patches for python 3.4. These allow it to compile, but python crashes during Py_Initialize on the device. The reason could be some problem with these patches, or something in our extra patches to change how libs are loaded (I haven't tried without these, this might be worth looking at).

I'm currently investigating this by starting to redirect python's internal logging to logcat (as this crash happens before we can do this globally for python-level logs). Another option would be to use remote gdb, but this is fiddly.

Any input or testing from others is welcome here - I don't really know what's wrong, and don't have a lot of ideas for how to continue.

@haricot
Copy link

haricot commented Nov 3, 2015

I do not know if this is related but hostpython3 does not seem to work properly

hostpython2
~.local/share/python-for-android/build/python-installs/testproject2/bin$ ./python.host
Python 2.7.2 (default, Nov 3 2015, 13:34:46)
[GCC 5.2.1 20151010] on linux4
Type "help", "copyright", "credits" or "license" for more information.

import time

hostpython3
~/.local/share/python-for-android/build/python-install/bin$ ./python.host
Python 3.4.2 (default, Nov 3 2015, 13:26:17)
[GCC 5.2.1 20151010] on linux
Type "help", "copyright", "credits" or "license" for more information.

import time
Traceback (most recent call last):
File "", line 1, in
ImportError: /home/dhcddx/.local/share/python-for-android/build/python-instal
l/lib/python3.4/lib-dynload/time.cpython-34m.so: wrong ELF class: ELFCLASS32

@inclement
Copy link
Member Author

This is expected, the python.host binary is in the arm-python folder, so
it tries to import the arm libraries and fails. It's only used here to
install stuff that doesn't need this import, and actually some of the
recipes have to use a different method because they hit the same problem
that you've discovered.

I guess the hostpython should work correctly if run from
build/other_builds/hostpython3/armeabi/whateverthefolderiscalled - this
is where it's actually built properly for x86.

On 03/11/15 14:12, Nicolas wrote:

I do not know if this is related but hostpython3 does not seem to work
properly

hostpython2
~.local/share/python-for-android/build/python-installs/testproject2/bin$
./python.host
Python 2.7.2 (default, Nov 3 2015, 13:34:46)
[GCC 5.2.1 20151010] on linux4
Type "help", "copyright", "credits" or "license" for more information.

        import time

hostpython3
~/.local/share/python-for-android/build/python-install/bin$ ./python.host
Python 3.4.2 (default, Nov 3 2015, 13:26:17)
[GCC 5.2.1 20151010] on linux
Type "help", "copyright", "credits" or "license" for more information.

        import time
        Traceback (most recent call last):
        File "", line 1, in
        ImportError:
        /home/dhcddx/.local/share/python-for-android/build/python-instal\
        l/lib/python3.4/lib-dynload/time.cpython-34m.so: wrong ELF
        class: ELFCLASS32


Reply to this email directly or view it on GitHub
#484 (comment).

@inclement
Copy link
Member Author

Actually, it's an interesting observation that the hostpython2 will run from the arm-python dir but hostpython3 won't, but I think this is probably just some difference between py2 and py3 (it's not impossible it could be important though).

I've actually narrowed down the first failure of python3 on android to the calculate_path function in which python finds its prefix and exec_prefix internal variables. Since it runs this far, I don't think the main issue can be a hostpython problem, but I'll keep it in mind - thanks!

@haricot
Copy link

haricot commented Nov 3, 2015

Thank you for your explanations and the test result.
I hope this is not off topic but with the previous test I have not managed to make it work with any folders but it looks work with a different fork host python-for-android.
https://github.com/kuri65536/python-for-android
~/sources/kuri/python-for-android/python3-alpha/host/bin$ ./python3.4
Python 3.4.3 (default, Nov 3 2015, 23:25:19)
[GCC 5.2.1 20151010] on linux
Type "help", "copyright", "credits" or "license" for more information.

import time

@inclement
Copy link
Member Author

I've got it working using the new python for android builds from CrystaX, though cross compiling cython etc is still a bit of a pain, and it'll need some thought to integrate this new method into the p4a build process.

@wannaphong
Copy link

it finally works! https://github.com/kivy/python-for-android/tree/python3_support
Thank you. 👍

@inclement
Copy link
Member Author

Added by #546.

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

No branches or pull requests

3 participants