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

Please help building the cffi recipe #1159

Closed
wexi opened this issue Nov 3, 2017 · 3 comments
Closed

Please help building the cffi recipe #1159

wexi opened this issue Nov 3, 2017 · 3 comments

Comments

@wexi
Copy link
Contributor

wexi commented Nov 3, 2017

Hi Python-For-Kivy fellows,

Help would be appreciated in building the cffi package, an essential
pyOpenSSL / cryptography dependency.

Thanks, Enoch.

In class CffiRecipe(CompiledComponentsPythonRecipe) I tried the two
python calling options. The original version 11.4.2 fails identically.

  1. call_hostpython_via_targetpython = True:

     [DEBUG]:        Finished processing dependencies for cffi==1.11.2
     [INFO]:    Rebuilding compiled components in cffi
     [DEBUG]:   -> running hostpython setup.py clean --all
     [DEBUG]:        running clean
     [DEBUG]:        removing 'build/temp.linux-x86_64-2.7' (and everything under it)
     [DEBUG]:        removing 'build/lib.linux-x86_64-2.7' (and everything under it)
     [DEBUG]:        removing 'build/bdist.linux-x86_64' (and everything under it)
     [DEBUG]:        'build/scripts-2.7' does not exist -- can't clean it
     [DEBUG]:        removing 'build'
     [DEBUG]:   -> running hostpython setup.py build_ext -v
     [DEBUG]:        running build_ext
     [DEBUG]:        failed to import Cython: /home/enoch/.local/lib/python2.7/site-packages/Cython/Compiler/Scanning.so: undefined symbol: PyUnicodeUCS4_DecodeUTF8
     [DEBUG]:        error: Cython does not appear to be installed
    
  2. call_hostpython_via_targetpython = False:

     [INFO]:    Building compiled components in cffi
     [INFO]:    -> directory context /home/enoch/.local/share/python-for-android/build/other_builds/libffi/armeabi-v7a/libffi
     [INFO]:    <- directory context /home/enoch/private/gsld
     [INFO]:    -> directory context /home/enoch/.local/share/python-for-android/build/other_builds/cffi-python2/armeabi-v7a/cffi
     [DEBUG]:   -> running hostpython setup.py build_ext -v
     [DEBUG]:        /home/enoch/Android/CrystaX/toolchains/arm-linux-androideabi-5/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/5.3/../../../../arm-linux-androideabi/bin/ld: error: cannot open crtbegin_dynamic.o: No such file or directory
     [DEBUG]:        /home/enoch/Android/CrystaX/toolchains/arm-linux-androideabi-5/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/5.3/../../../../arm-linux-androideabi/bin/ld: error: cannot open crtend_android.o: No such file or directory
     [DEBUG]:        /home/enoch/Android/CrystaX/toolchains/arm-linux-androideabi-5/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/5.3/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lcrystax
     [DEBUG]:        /home/enoch/Android/CrystaX/toolchains/arm-linux-androideabi-5/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/5.3/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lc
     [DEBUG]:        /home/enoch/Android/CrystaX/toolchains/arm-linux-androideabi-5/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/5.3/../../../../arm-linux-androideabi/bin/ld: error: cannot find -ldl
     [DEBUG]:        collect2: error: ld returned 1 exit status
     [DEBUG]:        Note: will not use '__sync_synchronize()' in the C code
     [DEBUG]:        ***** The above error message can be safely ignored.
     [DEBUG]:        
     [DEBUG]:        running build_ext
     [DEBUG]:        building '_cffi_backend' extension
     [DEBUG]:        creating build
     [DEBUG]:        creating build/temp.linux-x86_64-2.7
     [DEBUG]:        creating build/temp.linux-x86_64-2.7/c
     [DEBUG]:        /usr/bin/ccache arm-linux-androideabi-gcc -DANDROID -mandroid -fomit-frame-pointer -D__ANDROID_API__=19 -I/home/enoch/Android/CrystaX/platforms/android-19/arch-arm -isysroot /home/enoch/Android/CrystaX/platforms/android-19/arch-arm -I/home/enoch/.local/share/python-for-android/build/python-installs/gsld/include/python2.7 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -DANDROID -mandroid -fomit-frame-pointer -D__ANDROID_API__=19 -I/home/enoch/Android/CrystaX/platforms/android-19/arch-arm -isysroot /home/enoch/Android/CrystaX/platforms/android-19/arch-arm -I/home/enoch/.local/share/python-for-android/build/python-installs/gsld/include/python2.7 -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -mthumb -I/home/enoch/.local/share/python-for-android/build/other_builds/libffi/armeabi-v7a/libffi/arm-unknown-linux-androideabi/include -fPIC -DUSE__THREAD -I/home/enoch/.local/share/python-for-android/build/other_builds/hostpython2/desktop/hostpython2/Include -I/home/enoch/.local/share/python-for-android/build/other_builds/hostpython2/desktop/hostpython2 -c c/_cffi_backend.c -o build/temp.linux-x86_64-2.7/c/_cffi_backend.o
     [DEBUG]:             ^
     [DEBUG]:        c/_cffi_backend.c: In function 'init_cffi_backend':
     [DEBUG]:        c/_cffi_backend.c:7401:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
     [DEBUG]:             Py_INCREF(&MiniBuffer_Type);
     [DEBUG]:             ^
     [DEBUG]:        creating build/lib.linux-x86_64-2.7
     [DEBUG]:        gcc -pthread -shared -DANDROID -mandroid -fomit-frame-pointer -D__ANDROID_API__=19 -I/home/enoch/Android/CrystaX/platforms/android-19/arch-arm -isysroot /home/enoch/Android/CrystaX/platforms/android-19/arch-arm -I/home/enoch/.local/share/python-for-android/build/python-installs/gsld/include/python2.7 -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -mthumb -I/home/enoch/.local/share/python-for-android/build/other_builds/libffi/armeabi-v7a/libffi/arm-unknown-linux-androideabi/include -L/home/enoch/.local/share/python-for-android/build/libs_collections/gsld/armeabi-v7a -DANDROID -mandroid -fomit-frame-pointer -D__ANDROID_API__=19 -I/home/enoch/Android/CrystaX/platforms/android-19/arch-arm -isysroot /home/enoch/Android/CrystaX/platforms/android-19/arch-arm -I/home/enoch/.local/share/python-for-android/build/python-installs/gsld/include/python2.7 -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -mthumb -I/home/enoch/.local/share/python-for-android/build/other_builds/libffi/armeabi-v7a/libffi/arm-unknown-linux-androideabi/include build/temp.linux-x86_64-2.7/c/_cffi_backend.o -lffi -o build/lib.linux-x86_64-2.7/_cffi_backend.so
     [DEBUG]:        gcc: error: unrecognized command line option '-mfpu=vfp'; did you mean '-mcpu='?
     [DEBUG]:        gcc: error: unrecognized command line option '-mthumb'; did you mean '-mtbm'?
     [DEBUG]:        error: command 'gcc' failed with exit status 1
    
@wexi
Copy link
Contributor Author

wexi commented Nov 13, 2017

This problem with the cffi recipe was solved by defining env['LDSHARED'] to use ARM's gcc.
Should be standard in CompiledComponentsPythonRecipe() just as it is in CppCompiledComponentsPythonRecipe() ... (i.e., should not be a recipe ad hoc fix).
Time for a PR will come when I would finally build the very latest cryptography. No luck yet :-(

@wexi wexi closed this as completed Nov 13, 2017
@AndreMiras
Copy link
Member

Hi @wexi, thanks for reporting, but why closing? This is indeed a bug in CFFI recipe and the bug is still present right?

I came across it and solved in my local recipe a couple of months ago https://github.com/AndreMiras/EtherollApp/blob/v20180531/src/python-for-android/recipes/cffi/__init__.py. So I also created a pull request that solves it and a bunch of other things #1295.

I also think the fix should also be integrated more deeply in recipes parent classes. So feel free to come up with a pull request that also fixes that.

Regarding cryptography, please share your problem I may already have faced and solved it. I would be glad to help, specially if p4a can benefit from it.

@AndreMiras
Copy link
Member

 [DEBUG]:        failed to import Cython: /home/enoch/.local/lib/python2.7/site-packages/Cython/Compiler/Scanning.so: undefined symbol: PyUnicodeUCS4_DecodeUTF8

For reference that error can also come from hostpython2 compilation option. The recipe symbols mismatch with system Python. Compiling hostpython2 recipe with --enable-unicode=ucs4 should fix it. See e72d87d#r29869721 comment and also see how I solved it in a custom local recipe https://github.com/AndreMiras/PyWallet/blob/3e7402a/src/python-for-android/recipes/hostpython2/__init__.py#L51

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

2 participants