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

Prebuilt python does not contain binaries for any architecture. #1254

Closed
Abysselene opened this issue Apr 6, 2018 · 6 comments
Closed

Prebuilt python does not contain binaries for any architecture. #1254

Abysselene opened this issue Apr 6, 2018 · 6 comments

Comments

@Abysselene
Copy link

Hello, I have a problem and I can't find a solution on internet BUT I may have found why I got this problem and wish to know your thoughts.

First I explain shortly what I'm doing and why:
I need to build a python/kivy app for android with ssl activated and python3.
To make my app I followed the kivy guide and installed crystax Ndk but their version of python has not been built after ssl so even if I add openssl as a requirement it still doesn't exists in python.

I found on a forum someone saying that the last non official versions of crystax https://dl.crystax.net/ have ssl integrated so I gave it a try.
Unfortunately I always get the error :

[INFO]:    # Building recipes
[INFO]:    Building hostpython3crystax for armeabi-v7a
[INFO]:    Building openssl for armeabi-v7a
[INFO]:    -> directory context /media/axel/reste/buildozer/.buildozer/android/platform/build/build/other_builds/openssl/armeabi-v7a/openssl
[INFO]:    -> running perl Configure shared no-dso no-krb5 android-armv7
           working: *** Because of configuration changes, you MUST do the following before                 [INFO]:    Applying patch disable-sover.patch                                
[INFO]:    -> running patch -t -d /media/axel/reste/buildozer/.buildozer/android/platform/build/build/other_builds/openssl/armeabi-v7a/openssl -p1 -i /media/...(and 134 more)
[INFO]:    Applying patch rename-shared-lib.patch
[INFO]:    -> running patch -t -d /media/axel/reste/buildozer/.buildozer/android/platform/build/build/other_builds/openssl/armeabi-v7a/openssl -p1 -i /media/...(and 138 more)
[INFO]:    -> running make build_libs                                                                                                                                                   
           working: make[3]: Leaving directory '/media/axel/reste/buildoz[INFO]:    -> running cp libssl1.0.2h.so libcrypto1.0.2h.so /media/axel/reste/buildozer/.buildozer/android/platform/build/build/libs_collections/medmanip/armeabi-v7a
[INFO]:    <- directory context /media/axel/reste/buildozer/.buildozer/android/platform/python-for-android-new-toolchain
[INFO]:    Building sdl2_image for armeabi-v7a
[INFO]:    Building sdl2_mixer for armeabi-v7a
[INFO]:    Building sdl2_ttf for armeabi-v7a
[INFO]:    Building python3crystax for armeabi-v7a
[ERROR]:   The prebuilt Python for version 3.5 does not contain binaries for your chosen architecture "armeabi-v7a".

I need armeabi-v7a for my phone but whatever I was frustrated to have nothing working and decided to try the other archs.
I have the same error for each arch as if none was present. I looked for the error on internet and found this page:
https://github.com/kivy/python-for-android/blob/master/pythonforandroid/recipes/python3crystax/__init__.py
and if we look how the code searches for the archs, it goes to
crystax-ndk-10.3.2/sources/python/3.5/libs
but in the beta versions of crystax I can see that it's different, the folders are in
crystax-ndk-10.3.2/sources/python/3.5/shared
If I compare the android.mk of those 2 versions, the offi and the beta we can see the difference:
Offi:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE := python_shared
LOCAL_SRC_FILES := libs/$(TARGET_ARCH_ABI)/libpython3.5m.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include/python
include $(PREBUILT_SHARED_LIBRARY)

Beta:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE := python_shared
LOCAL_SRC_FILES := shared/$(TARGET_ARCH_ABI)/libs/libpython3.5m.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include/python
include $(PREBUILT_SHARED_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := python_static
LOCAL_SRC_FILES := static/libs/$(TARGET_ARCH_ABI)/libpython3.5m.a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include/python
include $(PREBUILT_STATIC_LIBRARY)

For now I intend to give it a try by moving the files and renaming folders in the beta version to get it to build but I was wondering if there is somewhere a p4a version which works with this different structure when looking for an architecture given python3.5 binaries, I found nothing yet.
Maybe it could be interesting to edit the __init__.py file to have it looking for an other structure/other folders if it doesn't find what it's looking for?

I'm looking for your thoughts about this problem.

@inclement
Copy link
Member

So the actual issue is that you're using a beta crystax NDK whose folder structure is different to the released version, and is not understood by p4a?

@Abysselene
Copy link
Author

Abysselene commented Apr 6, 2018

Yep, the last non beta release of crystax ndk (10.3.2) date is august 2016 and doesn't support ssl with python3.
Here someone says to use the last one available which was the 10.3.2 b919 (mars 2017) if I compare the post date and the last one available at that date. crystax/android-platform-ndk#19

Honestly I'm kind of lost, I'm not even sure if I should post here.
I'm trying to find a way to have kivy works with python3 and ssl but it seems it necessitates a beta of crystax and I don't know why but they changed the folder structure and since I didn't find anything in the p4a source code indicating a verification of the structure I wonder if it will be done or are beta releases of crystax ignored?

@inclement
Copy link
Member

python-for-android does not currently support the beta versions of the crystax NDK, although it probably wouldn't be hard to add this support.

There's a PR at #1195 that adds openssl for python3 by building it ourselves.

@Abysselene
Copy link
Author

Abysselene commented Apr 6, 2018

I saw this one and thought I would try it if the rest doesn't work.
Thanks for the tip, now I know what to do :-)

By the way, if someone wonders what happens when reorganizing the structure folder of b917 to have it working with p4a when building python3.5. The building seems to work, the app is made and launched on the phone but it crashes with a fatal signal 11 sigsegv error, it seems sdl2 has a problem, maybe an other bootstrap like pygame could work, I didn't try.

EDIT: Let me kiss you!!!!! I followed your advice and it finally works, Crystax offi 10.3.2 with 3 files modded to get ssl working with python3. I've been on it for 3 days!

@userlabs
Copy link

userlabs commented Apr 6, 2018

@Abysselene could you elaborate on the 3 files that needed modification. Thanks in advance. Are you referring to the #1195 posted above by @inclement.

@Abysselene
Copy link
Author

Abysselene commented Apr 11, 2018

Yes, I didn't do it neatly by pulling this or that because there were few changes and I was afraid to mess with git commands so what I did is this:
I used the latest official crystax ndk 10.3.2
About buildozer.spec I have:
requirements = python3crystax,kivy, openssl
then it will automatically download the latest stable branch of p4a in a subfolder /.buildozer/android/platform/python-for-android-new-toolchain when building
Once done on the prompt you can interrupt the build, it's no use to let it continue. I copied the new toolchain directory to another location and edited buildozer.spec accordingly:
p4a.source_dir = /whatever/buildozer/p4aCustom/python-for-android-new-toolchain_modded
Then in this copy I changed the 3 files to have them this way : https://github.com/kivy/python-for-android/pull/1195/files
So there are 2 init files to edit and patch_python3.6.patch to add but I doubt the patch file is needed, maybe it's only useful if you have the last master or stable branch.
Now you can build and it will use the modded p4a which is able to add ssl when building python 3+

EDIT: In requirements, openssl no longer necessary. I tried and did a clean, no problem since p4a compiles py3crystax correctly with ssl included now.

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