Skip to content

Problems in creation of recipe for zbar #854

Closed

Description

@OpenCode

I'm trying to create a recipe for zbar python library. I've created a directory in recipes called zbar. In this one I've created a file called init.py with this code:

from pythonforandroid.toolchain import PythonRecipe


class ZBarRecipe(PythonRecipe):

    name = 'zbar'
    version = '0.10'
    url = 'https://pypi.python.org/packages/33/54/cc5819efc9ee7e34b60b41e1d2d4753b6dd0c26a41c9a552611f66aa106e/zbar-{version}.tar.bz2'
    depends = []
    site_packages_name = 'zbar'
    call_hostpython_via_targetpython = False

recipe = ZBarRecipe()

In my buildozer.spec I've this line

requirements = python2,kivy,unicodecsv,erppeek,zbar

When I run

buildozer android_new debug deploy run logcat

I obtain this error:

[INFO]:    Building zbar for armeabi-v7a
[INFO]:    zbar apparently isn't already in site-packages
[INFO]:    Installing zbar into site-packages
[INFO]:    -> directory context /home/fapruzzese/Projects/Kivy/kivy_demo_app/.buildozer/android/platform/build/build/other_builds/zbar/armeabi-v7a/zbar
[INFO]:    -> running hostpython setup.py install -O2 --root=/home/fapruzzese/Projects/Kivy/kivy_demo_app/.buildozer/android/platform/build/build/python-installs/...(and 49 more)
('name is', 'zbar', <class 'pythonforandroid.recipes.zbar.ZBarRecipe'>)                                                                                                                      
('path is', '/home/fapruzzese/.buildozer/android/platform/android-ndk-r9c/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86/bin/:/home/fapruzzese/.buildozer/android/platform/android-ndk-r9c/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/:/home/fapruzzese/.buildozer/android/platform/android-ndk-r9c:/home/fapruzzese/.buildozer/android/platform/android-sdk-20/tools:/home/fapruzzese/.buildozer/android/platform/apache-ant-1.9.4/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games')
           workinTraceback (most recent call last):                                                                                                                                          
  File "/usr/lib/python2.7/runpy.py", line 162, 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/fapruzzese/Projects/Kivy/kivy_demo_app/.buildozer/android/platform/python-for-android-master/pythonforandroid/toolchain.py", line 792, in <module>
    main()
  File "/home/fapruzzese/Projects/Kivy/kivy_demo_app/.buildozer/android/platform/python-for-android-master/pythonforandroid/toolchain.py", line 789, in main
    ToolchainCL()
  File "/home/fapruzzese/Projects/Kivy/kivy_demo_app/.buildozer/android/platform/python-for-android-master/pythonforandroid/toolchain.py", line 464, in __init__
    getattr(self, args.subparser_name.replace('-', '_'))(args)
  File "/home/fapruzzese/Projects/Kivy/kivy_demo_app/.buildozer/android/platform/python-for-android-master/pythonforandroid/toolchain.py", line 145, in wrapper_func
    build_dist_from_args(ctx, dist, args)
  File "/home/fapruzzese/Projects/Kivy/kivy_demo_app/.buildozer/android/platform/python-for-android-master/pythonforandroid/toolchain.py", line 188, in build_dist_from_args
    build_recipes(build_order, python_modules, ctx)
  File "pythonforandroid/build.py", line 561, in build_recipes
  File "pythonforandroid/recipe.py", line 788, in build_arch
  File "pythonforandroid/recipe.py", line 842, in install_python_package
  File "pythonforandroid/logger.py", line 173, in shprint
  File "/usr/local/lib/python2.7/dist-packages/sh.py", line 565, in next
    self.wait()
  File "/usr/local/lib/python2.7/dist-packages/sh.py", line 500, in wait
    self.handle_command_exit_code(exit_code)
  File "/usr/local/lib/python2.7/dist-packages/sh.py", line 516, in handle_command_exit_code
    raise exc(self.ran, self.process.stdout, self.process.stderr)
sh.ErrorReturnCode_1: 

  RAN: '/home/fapruzzese/Projects/Kivy/kivy_demo_app/.buildozer/android/platform/build/build/other_builds/hostpython2/desktop/hostpython2/hostpython setup.py install -O2 --root=/home/fapruzzese/Projects/Kivy/kivy_demo_app/.buildozer/android/platform/build/build/python-installs/OdooApp --install-lib=lib/python2.7/site-packages'

  STDOUT:
running install
running build
running build_ext
building 'zbar' extension
arm-linux-androideabi-gcc -DANDROID -mandroid -fomit-frame-pointer --sysroot /home/fapruzzese/.buildozer/android/platform/android-ndk-r9c/platforms/android-19/arch-arm -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -DANDROID -mandroid -fomit-frame-pointer --sysroot /home/fapruzzese/.buildozer/android/platform/android-ndk-r9c/platforms/android-19/arch-arm -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -mthumb -fPIC -I/home/fapruzzese/Projects/Kivy/kivy_demo_app/.buildozer/android/platform/build/build/other_builds/hostpython2/desktop/hostpython2/Include -I/home/fapruzzese/Projects/Kivy/kivy_demo_app/.buildozer/android/platform/build/build/other_builds/hostpython2/desktop/hostpython2 -c zbarmodule.c -o build/temp.linux-x86_64-2.7/zbarmodule.o
In file included from /home/fapruzzese/Projects/Kivy/kivy_demo_app/.buildozer/android/platform/build/build/other_builds/hostpython2/desktop/hostpython2/Include/Python.h:58:0,
                 from zbarmodule.h:24,
                 from zbarmodule.c:24:
/home/fapruzzese/Projects/Kivy/kivy_demo_app/.buildozer/android/platform/build/build/other_builds/hostpython2/desktop/hostpython2/Include/pyport.h:849:2: error: #error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)."
 #error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)."
  ^
In file included from /home/fapruzzese/Projects/Kivy/kivy_demo_app/.buildozer/android/platform/build/build/other_builds/hostpython2/desktop/hostpython2/Include/Python.h:126:0,
                 from zbarmodule.h:24,
                 from zbarmodule.c:24:
/home/fapruzzese/Projects/Kivy/kivy_demo_app/.buildozer/android/platform/build/build/other_builds/hostpython2/desktop/hostpython2/Include/modsupport.h:27:1: warning: 'PyArg_ParseTuple' is an unrecognized format function type [-Wformat=]
 PyAPI_FUNC(int) PyArg_ParseTuple(PyObject *, const char *, ...) Py_FORMAT_PARSETUPLE(PyArg_ParseTuple, 2, 3);
 ^
In file included from zbarmodule.c:24:0:
zbarmodule.h:26:18: fatal error: zbar.h: No such file or directory
 #include <zbar.h>
                  ^
compilation terminated.
error: command 'arm-linux-androideabi-gcc' failed with exit status 1


  STDERR:

# Command failed: python -m pythonforandroid.toolchain --color=always --storage-dir=/home/fapruzzese/Projects/Kivy/kivy_demo_app/.buildozer/android/platform/build create --dist_name=OdooApp --bootstrap=sdl2 --requirements=python2,kivy,unicodecsv,erppeek,zbar --arch armeabi-v7a --copy-libs
# 
# 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

In desktop environment this problem is solved by installation of libzbar-dev from system repository.

Can anyone help me, please? Thanks

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Activity

  1. inclement commented on Jul 27, 2016

    @inclement
    Member

    This will need to be a compiled components recipe, probably CompiledComponentsPythonRecipe (class ZBarRecipe(CompiledComponentsPythonRecipe): ...), because this recipe type knows how to build its external dependencies.

    There could be additional problems, but that's the first thing to try.

  2. OpenCode commented on Jul 28, 2016

    @OpenCode
    Author

    Doesn't work. Some problem.

  3. nmz787 commented on Aug 29, 2016

    @nmz787

    Any update on this? I have an 'test kivy' project that I am trying to get some .so libs added to. Even though I added the libs to my test project folder libs/android-v7 and used this buildozer.spec syntax android.add_libs_armeabi_v7a = libs/android-v7/*.so but my program still fails. Someone elsewhere (kivy/buildozer#63) said to try adding android.arch=armeabi-v7a to buildozer.spec but that had no effect. Even if I use the android_new command to try building... I get the same basic error message as the previous poster:

    [INFO]:    # Building recipes
    [INFO]:    Building python2 for armeabi-v7a
    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/nathan/Projects/kivy_test/.buildozer/android/platform/python-for-android-master/pythonforandroid/toolchain.py", line 792, in <module>
        main()
      File "/home/nathan/Projects/kivy_test/.buildozer/android/platform/python-for-android-master/pythonforandroid/toolchain.py", line 789, in main
        ToolchainCL()
      File "/home/nathan/Projects/kivy_test/.buildozer/android/platform/python-for-android-master/pythonforandroid/toolchain.py", line 464, in __init__
        getattr(self, args.subparser_name.replace('-', '_'))(args)
      File "/home/nathan/Projects/kivy_test/.buildozer/android/platform/python-for-android-master/pythonforandroid/toolchain.py", line 145, in wrapper_func
        build_dist_from_args(ctx, dist, args)
      File "/home/nathan/Projects/kivy_test/.buildozer/android/platform/python-for-android-master/pythonforandroid/toolchain.py", line 188, in build_dist_from_args
        build_recipes(build_order, python_modules, ctx)
      File "pythonforandroid/build.py", line 561, in build_recipes
        recipe.build_arch(arch)
      File "/home/nathan/Projects/kivy_test/.buildozer/android/platform/python-for-android-master/pythonforandroid/recipes/python2/__init__.py", line 44, in build_arch
        self.do_python_build(arch)
      File "/home/nathan/Projects/kivy_test/.buildozer/android/platform/python-for-android-master/pythonforandroid/recipes/python2/__init__.py", line 73, in do_python_build
        shprint(sh.cp, self.ctx.hostpython, self.get_build_dir(arch.arch))
    AttributeError: 'Context' object has no attribute 'hostpython'
    # Command failed: python -m pythonforandroid.toolchain --color=always --storage-dir=/home/nathan/Projects/kivy_test/.buildozer/android/platform/build create --dist_name=myapp --bootstrap=sdl2 --requirements=kivy,plyer --arch armeabi-v7a --copy-libs
    
    
  4. nmz787 commented on Aug 29, 2016

    @nmz787

    Well it seems my last posted issue was solved with adding python2 to the requirements in buildozer.spec. Solution found here:
    http://stackoverflow.com/a/36647373/253127

  5. OpenCode commented on Aug 29, 2016

    @OpenCode
    Author

    @nmz787 I've python2 in my requirements, yet

  6. AndreMiras commented on Oct 18, 2017

    @AndreMiras
    Member

    I would love to work on that one when I get time :)

  7. AndreMiras commented on Oct 19, 2017

    @AndreMiras
    Member

    It's ready #1145 :)

  8. added a commit that references this issue on Nov 13, 2017
  9. AndreMiras commented on Nov 13, 2017

    @AndreMiras
    Member

    @OpenCode or someone can close that issue since #1145 was merged.

  10. KeyWeeUsr commented on Nov 13, 2017

    @KeyWeeUsr
    Contributor

    Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions