在构建器中编译 Cython 文件时出错



我使用 kivy 构建了一个 android 应用程序,当我编译它以使用 buildozer 构建 apk 时,弹出了以下错误;

[INFO]:    -> directory context /home/himanshu/helplineapp/.buildozer/android/platform/build/build/other_builds/pyjnius-python2-sdl2/armeabi-v7a/pyjnius
[INFO]:    -> running python.host -c import sys; print(sys.path)
working: ['', '/home/himanshu/helplineapp/.buildozer/android/platform/build/build/python-instal[INFO]:    Trying first build of pyjnius to get cython files: this is expected to fail
[INFO]:    -> running python.host setup.py build_ext -v
('cwd is', '/home/himanshu/helplineapp/.buildozer/android/platform/build/build/other_builds/pyjnius-python2-sdl2/armeabi-v7a/pyjnius')               
working:  #error Do not use this file, it is the result of a failed Cython compilatiException in thread background thread for pid 3379:   
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
File "/home/himanshu/.local/lib/python2.7/site-packages/sh.py", line 1540, in wrap
fn(*args, **kwargs)
File "/home/himanshu/.local/lib/python2.7/site-packages/sh.py", line 2455, in background_thread
handle_exit_code(exit_code)
File "/home/himanshu/.local/lib/python2.7/site-packages/sh.py", line 2153, in fn
return self.command.handle_command_exit_code(exit_code)
File "/home/himanshu/.local/lib/python2.7/site-packages/sh.py", line 815, in handle_command_exit_code
raise exc
ErrorReturnCode_1: 
RAN: /home/himanshu/helplineapp/.buildozer/android/platform/build/build/python-installs/myapp/bin/python.host setup.py build_ext -v
STDOUT:
/home/himanshu/helplineapp/.buildozer/android/platform/build/build/python-installs/myapp/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'install_requires'
warnings.warn(msg)
running build_ext
building 'jnius' extension
/usr/bin/ccache arm-linux-androideabi-gcc -DANDROID -mandroid -fomit-frame-pointer -D__ANDROID_API__=19 -I/home/himanshu/.buildozer/android/platform/android-ndk-r9c/platforms/android-19/arch-arm -isysroot /home/himanshu/.buildozer/android/platform/android-ndk-r9c/platforms/android-19/arch-arm -I/home/himanshu/helplineapp/.buildozer/android/platform/build/build/python-installs/myapp/include/python2.7 -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -DANDROID -mandroid -fomit-frame-pointer -D__ANDROID_API__=19 -I/home/himanshu/.buildozer/android/platform/android-ndk-r9c/platforms/android-19/arch-arm -isysroot /home/himanshu/.buildozer/android/platform/android-ndk-r9c/platforms/android-19/arch-arm -I/home/himanshu/helplineapp/.buildozer/android/platform/build/build/python-installs/myapp/include/python2.7 -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -mthumb -fPIC -I/home/himanshu/helplineapp/.buildozer/android/platform/build/build/python-installs/myapp/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 '/usr/bin/ccache' failed with exit status 1

STDERR:

[INFO]:    pyjnius first build failed (as expected)
[INFO]:    Running cython where appropriate
[INFO]:    Cythonize jnius/jnius.pyx
[INFO]:    -> running cython ./jnius/jnius.pyx
()                                                                                                                                                   
working:             for interface in getattr(value, '__javainterfaces__', []):     Exception in thread background thread for pid 3389:   
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
File "/home/himanshu/.local/lib/python2.7/site-packages/sh.py", line 1540, in wrap
fn(*args, **kwargs)
File "/home/himanshu/.local/lib/python2.7/site-packages/sh.py", line 2455, in background_thread
handle_exit_code(exit_code)
File "/home/himanshu/.local/lib/python2.7/site-packages/sh.py", line 2153, in fn
return self.command.handle_command_exit_code(exit_code)
File "/home/himanshu/.local/lib/python2.7/site-packages/sh.py", line 815, in handle_command_exit_code
raise exc
ErrorReturnCode_1: 
RAN: /usr/local/bin/cython ./jnius/jnius.pyx
STDOUT:
Error compiling Cython file:
------------------------------------------------------------
...
if jcs is not None:
obj = jcs.j_cls
if NULL == obj:
for interface in getattr(value, '__javainterfaces__', []):
obj = j_env[0].FindClass(j_env, str_for_c(interface))
^
------------------------------------------------------------
jnius/jnius_export_class.pxi:133:57: Obtaining 'char *' from temporary Python value

STDERR:

Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/home/himanshu/helplineapp/.buildozer/android/platform/python-for-android-new-toolchain/pythonforandroid/toolchain.py", line 978, in <module>
main()
File "/home/himanshu/helplineapp/.buildozer/android/platform/python-for-android-new-toolchain/pythonforandroid/toolchain.py", line 975, in main
ToolchainCL()
File "/home/himanshu/helplineapp/.buildozer/android/platform/python-for-android-new-toolchain/pythonforandroid/toolchain.py", line 512, in __init__
getattr(self, args.subparser_name.replace('-', '_'))(args)
File "/home/himanshu/helplineapp/.buildozer/android/platform/python-for-android-new-toolchain/pythonforandroid/toolchain.py", line 149, in wrapper_func
build_dist_from_args(ctx, dist, args)
File "/home/himanshu/helplineapp/.buildozer/android/platform/python-for-android-new-toolchain/pythonforandroid/toolchain.py", line 193, in build_dist_from_args
build_recipes(build_order, python_modules, ctx)
File "pythonforandroid/build.py", line 573, in build_recipes
File "pythonforandroid/recipe.py", line 928, in build_arch
File "pythonforandroid/recipe.py", line 963, in build_cython_components
File "pythonforandroid/recipe.py", line 1008, in cythonize_build
File "pythonforandroid/recipe.py", line 999, in cythonize_file
File "pythonforandroid/logger.py", line 175, in shprint
File "/home/himanshu/.local/lib/python2.7/site-packages/sh.py", line 863, in next
self.wait()
File "/home/himanshu/.local/lib/python2.7/site-packages/sh.py", line 792, in wait
self.handle_command_exit_code(exit_code)
File "/home/himanshu/.local/lib/python2.7/site-packages/sh.py", line 815, in handle_command_exit_code
raise exc
sh.ErrorReturnCode_1: 
RAN: /usr/local/bin/cython ./jnius/jnius.pyx
STDOUT:
Error compiling Cython file:
------------------------------------------------------------
...
if jcs is not None:
obj = jcs.j_cls
if NULL == obj:
for interface in getattr(value, '__javainterfaces__', []):
obj = j_env[0].FindClass(j_env, str_for_c(interface))
^
------------------------------------------------------------
jnius/jnius_export_class.pxi:133:57: Obtaining 'char *' from temporary Python value

STDERR:
# Command failed: /usr/bin/python -m pythonforandroid.toolchain create --dist_name=myapp --bootstrap=sdl2 --requirements=kivy --arch armeabi-v7a --copy-libs --color=always --storage-dir=/home/himanshu/helplineapp/.buildozer/android/platform/build
# 
# Buildozer failed to execute the last command
# The error might be hidden in the log above this error
# Please read the full log, and search for it before
# raising an issue with buildozer itself.
# In case of a bug report, please add a full log with log_level = 2

我知道最新版本的cython存在一些问题,所以我降级到cython==0.20,但没有运气,仍然是相同的错误。我已经通过降级cython来使用buildozer编译了另外两个程序,但是现在,在这种情况下,我不知道发生了什么。这里的其他一些答案说,在buildozer.spec文件中提高日志级别2将澄清错误的细节,但我是buildozer的新手。我不知道该怎么做。

此外,此过程在下载 SDK 工具时花费的时间太长,因此我的资源有限。我谦卑地请求帮助我摆脱这个错误。

提前感谢!

我在cython版本方面有一些非常相似的东西。我只设法让我的构建器与cython 0.23一起工作。花了好几个小时和多次重新安装才弄清楚......

也许给 cython 0.23 一个尝试。我个人可以确认它适用于构建器 0.34.dev0。

最新更新