Buildozer 无法编译 Cython
Posted
技术标签:
【中文标题】Buildozer 无法编译 Cython【英文标题】:Buildozer can't compile Cython 【发布时间】:2014-11-26 17:43:59 【问题描述】:我正在尝试构建我的 kivy 应用程序,但在运行 buildozer android debug --verbose
之后,我得到的唯一信息是:
[...]
Run prebuild
Call prebuild_hostpython
Call prebuild_python
Call prebuild_sdl
Call prebuild_pygame
Call prebuild_pyjnius
Call prebuild_android
Call prebuild_kivy
Run build
Skipped build_hostpython
Skipped build_python
Skipped build_sdl
Skipped build_pygame
Call build_pyjnius
Entering in ARM environment
Compiler found at /home/michal/.buildozer/android/platform/android-ndk-r9c/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc
/home/michal/Dokumenty/Projekty/Labirynt/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'install_requires'
warnings.warn(msg)
running build_ext
building 'jnius' extension
arm-linux-androideabi-gcc -DANDROID -mandroid -fomit-frame-pointer --sysroot /home/michal/.buildozer/android/platform/android-ndk-r9c/platforms/android-14/arch-arm -DNDEBUG -DANDROID -mandroid -fomit-frame-pointer --sysroot /home/michal/.buildozer/android/platform/android-ndk-r9c/platforms/android-14/arch-arm -fPIC -I/home/michal/Dokumenty/Projekty/Labirynt/.buildozer/android/platform/python-for-android/build/python-install/include/python2.7 -c jnius/jnius.c -o build/temp.linux-x86_64-2.7/jnius/jnius.o
jnius/jnius.c:1:2: error: #error Do not use this file, it is the result of a failed Cython compilation.
#error Do not use this file, it is the result of a failed Cython compilation.
^
error: command 'arm-linux-androideabi-gcc' failed with exit status 1
Error compiling Cython file:
------------------------------------------------------------
...
if py_arg is None:
j_args[index].l = NULL
elif isinstance(py_arg, basestring) and \
argtype in ('Ljava/lang/String;', 'Ljava/lang/Object;'):
j_args[index].l = j_env[0].NewStringUTF(
j_env, <char *><bytes>py_arg.encode('utf-8'))
^
------------------------------------------------------------
jnius/jnius_conversion.pxi:54:31: Casting temporary Python object to non-numeric non-Python type
/home/michal/Dokumenty/Projekty/Labirynt/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'install_requires'
warnings.warn(msg)
running build_ext
building 'jnius' extension
arm-linux-androideabi-gcc -DANDROID -mandroid -fomit-frame-pointer --sysroot /home/michal/.buildozer/android/platform/android-ndk-r9c/platforms/android-14/arch-arm -DNDEBUG -DANDROID -mandroid -fomit-frame-pointer --sysroot /home/michal/.buildozer/android/platform/android-ndk-r9c/platforms/android-14/arch-arm -fPIC -I/home/michal/Dokumenty/Projekty/Labirynt/.buildozer/android/platform/python-for-android/build/python-install/include/python2.7 -c jnius/jnius.c -o build/temp.linux-x86_64-2.7/jnius/jnius.o
jnius/jnius.c:1:2: error: #error Do not use this file, it is the result of a failed Cython compilation.
#error Do not use this file, it is the result of a failed Cython compilation.
^
error: command 'arm-linux-androideabi-gcc' failed with exit status 1
# Command failed: ./distribute.sh -m "kivy" -d "testapp"
我正在使用 Archlinux,64 位,python2 2.7.8-2,和 aur/python2-kivy-git。
当我尝试安装 aur/python2-kivy 时,我得到了
Found GLES 2.0 headers at /usr/include/GLES2/gl2.h
/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'dependency_links'
warnings.warn(msg)
/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'install_requires'
warnings.warn(msg)
running build
running build_py
running build_ext
Build configuration is:
* use_rpi = False
* use_opengl_es2 = True
* use_opengl_debug = False
* use_glew = False
* use_sdl = False
* use_ios = False
* use_mesagl = False
* use_x11 = False
* use_gstreamer = True
* use_avfoundation = False
Generate config.h
Generate config.pxi
Detected compiler is unix
skipping 'kivy/graphics/texture.c' Cython extension (up-to-date)
skipping 'kivy/graphics/vertex.c' Cython extension (up-to-date)
skipping 'kivy/graphics/fbo.c' Cython extension (up-to-date)
skipping 'kivy/graphics/context.c' Cython extension (up-to-date)
skipping 'kivy/properties.c' Cython extension (up-to-date)
skipping 'kivy/graphics/context_instructions.c' Cython extension (up-to-date)
skipping 'kivy/graphics/instructions.c' Cython extension (up-to-date)
skipping 'kivy/graphics/stencil_instructions.c' Cython extension (up-to-date)
skipping 'kivy/graphics/opengl.c' Cython extension (up-to-date)
skipping 'kivy/graphics/transformation.c' Cython extension (up-to-date)
skipping 'kivy/graphics/vbo.c' Cython extension (up-to-date)
skipping 'kivy/graphics/opengl_utils.c' Cython extension (up-to-date)
skipping 'kivy/graphics/c_opengl_debug.c' Cython extension (up-to-date)
skipping 'kivy/graphics/gl_instructions.c' Cython extension (up-to-date)
cythoning kivy/lib/gstplayer/_gstplayer.pyx to kivy/lib/gstplayer/_gstplayer.c
Error compiling Cython file:
------------------------------------------------------------
...
g_object_set_void(self.playbin, 'video-sink', self.fakesink)
# configure playbin
g_object_set_int(self.pipeline, 'async-handling', 1)
c_uri = <bytes>self.uri.encode('utf-8')
^
------------------------------------------------------------
kivy/lib/gstplayer/_gstplayer.pyx:259:16: Storing unsafe C derivative of temporary Python reference
building 'kivy.lib.gstplayer._gstplayer' extension
gcc -pthread -DNDEBUG -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong --param=ssp-buffer-size=4 -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/gstreamer-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/python2.7 -c kivy/lib/gstplayer/_gstplayer.c -o build/temp.linux-x86_64-2.7/kivy/lib/gstplayer/_gstplayer.o
kivy/lib/gstplayer/_gstplayer.c:1:2: error: #error Do not use this file, it is the result of a failed Cython compilation.
#error Do not use this file, it is the result of a failed Cython compilation.
^
error: command 'gcc' failed with exit status 1
我怎样才能让它工作?
【问题讨论】:
我在 ubuntu 14.04 上遇到了完全相同的问题,降级 cython 并没有为我解决问题 @fccoelho 这个问题是针对 Arch 而不是 Ubuntu。 【参考方案1】:这是 Cython 0.21 版和旧代码的问题。最简单的解决方案是将 Cython 降级到 0.20,这很有效。
要使用较新的 Cython,请删除下载的 pyjnius 并让 buildozer 下载最新版本:
rm ~/.buildozer/android/packages/pyjnius-master.zip
但较新的 Cython 也需要较新的 Kivy 代码。在您的 buildozer.spec 中,将要求中的 kivy
更改为 kivy==master
以获取最新的 Kivy 代码。
【讨论】:
以上是关于Buildozer 无法编译 Cython的主要内容,如果未能解决你的问题,请参考以下文章