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

AttributeError: 'Context' object has no attribute 'hostpython' #620

Closed
cbenhagen opened this issue Feb 3, 2016 · 11 comments
Closed

AttributeError: 'Context' object has no attribute 'hostpython' #620

cbenhagen opened this issue Feb 3, 2016 · 11 comments

Comments

@cbenhagen
Copy link
Contributor

Running this on OS X 10.11.3
p4a apk --requirements=kivysdl2 --private /tmp/test --package=org.test.test--name="test" --version=0.1 --bootstrap=sdl2 --android_api 19

I get the following error:

[INFO]:    This python-for-android revamp is an experimental alpha release!
[INFO]:    It should work (mostly), but you may experience missing features or bugs.
[INFO]:    Will compile for the following archs: armeabi
[INFO]:    Found possible SDK dirs in buildozer dir: android-sdk-20, android-sdk-21
[INFO]:    Will attempt to use SDK at /Users/ben/.buildozer/android/platform/android-sdk-20
[WARNING]: This SDK lookup is intended for debug only, if you use python-for-android much you should probably maintain your own SDK download.
[INFO]:    Getting Android API version from user argument
[INFO]:    Available Android APIs are (19)
[INFO]:    Requested API target 19 is available, continuing.
[INFO]:    Found possible NDK dirs in buildozer dir: android-ndk-r9c, android-ndk-r9c-darwin-x86_64.tar.bz2
[INFO]:    Will attempt to use NDK at /Users/ben/.buildozer/android/platform/android-ndk-r9c
[WARNING]: This NDK lookup is intended for debug only, if you use python-for-android much you should probably maintain your own NDK download.
[INFO]:    Got NDK version from $ANDROIDNDKVER
[INFO]:    Got Android NDK version from the NDK dir: it is r9c
[INFO]:    Using Google NDK r9c
[INFO]:    Found virtualenv at /usr/local/bin/virtualenv-2.7
[INFO]:    ccache is missing, the build will not be optimized in the future.
[INFO]:    Found the following toolchain versions: ['4.6', '4.8', 'clang3.3']
[INFO]:    Picking the latest gcc toolchain, here 4.8
[WARNING]: Missing executable: libtoolize is not installed
[INFO]:    No existing dists meet the given requirements!
[INFO]:    No dist exists that meets your requirements, so one will be built.
[INFO]:    Bootstrap requires recipes ['sdl2', ('python2', 'python3crystax')]
[INFO]:    No recipe named kivysdl2; will attempt to install with pip
[INFO]:    Loaded recipe sdl2 (depends on [('python2', 'python3crystax'), 'sdl2_image', 'sdl2_mixer', 'sdl2_ttf'], conflicts ['sdl', 'pygame', 'pygame_bootstrap_components'])
[INFO]:    Loaded recipe sdl2_image (depends on [])
[INFO]:    Loaded recipe sdl2_mixer (depends on [])
[INFO]:    Loaded recipe sdl2_ttf (depends on [])
[INFO]:    Found multiple valid recipe sets:
[INFO]:        ['sdl2_image', 'sdl2_mixer', 'python2', 'sdl2_ttf', 'sdl2']
[INFO]:        ['sdl2_image', 'sdl2_mixer', 'python3crystax', 'sdl2_ttf', 'sdl2']
[INFO]:    Using the first of these: ['sdl2_image', 'sdl2_mixer', 'python2', 'sdl2_ttf', 'sdl2']
[INFO]:    The selected bootstrap is sdl2
[INFO]:    # Creating dist with sdl2 bootstrap
[INFO]:    Dist will have name unnamed_dist_3 and recipes (kivysdl2)
[INFO]:    -> running cp -r /usr/local/lib/python2.7/site-packages/pythonforandroid/bootstraps/sdl2/build /Users/ben/Libra...(and 77 more)
[INFO]:    -> directory context /Users/ben/Library/Application Support/python-for-android/build/bootstrap_builds/sdl2-python2
[INFO]:    <- directory context /private/tmp/test
[INFO]:    Recipe build order is ['python2', 'sdl2_image', 'sdl2_mixer', 'sdl2_ttf', 'sdl2']
[INFO]:    The requirements (kivysdl2) were not found as recipes, they will be installed with pip.
[INFO]:    # Downloading recipes
[INFO]:    Downloading python2
[INFO]:    -> running mkdir -p /Users/ben/Library/Application Support/python-for-android/packages/python2
[INFO]:    -> directory context /Users/ben/Library/Application Support/python-for-android/packages/python2
[INFO]:    -> running basename http://python.org/ftp/python/2.7.2/Python-2.7.2.tar.bz2
[INFO]:    python2 download already cached, skipping
[WARNING]: Should check headers here! Skipping for now.
[INFO]:    <- directory context /private/tmp/test
[INFO]:    Downloading sdl2_image
[INFO]:    -> running mkdir -p /Users/ben/Library/Application Support/python-for-android/packages/sdl2_image
[INFO]:    -> directory context /Users/ben/Library/Application Support/python-for-android/packages/sdl2_image
[INFO]:    -> running basename https://www.libsdl.org/projects/SDL_image/release/SDL2_image-2.0.0.tar.gz
[INFO]:    sdl2_image download already cached, skipping
[WARNING]: Should check headers here! Skipping for now.
[INFO]:    <- directory context /private/tmp/test
[INFO]:    Downloading sdl2_mixer
[INFO]:    -> running mkdir -p /Users/ben/Library/Application Support/python-for-android/packages/sdl2_mixer
[INFO]:    -> directory context /Users/ben/Library/Application Support/python-for-android/packages/sdl2_mixer
[INFO]:    -> running basename https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-2.0.0.tar.gz
[INFO]:    sdl2_mixer download already cached, skipping
[WARNING]: Should check headers here! Skipping for now.
[INFO]:    <- directory context /private/tmp/test
[INFO]:    Downloading sdl2_ttf
[INFO]:    -> running mkdir -p /Users/ben/Library/Application Support/python-for-android/packages/sdl2_ttf
[INFO]:    -> directory context /Users/ben/Library/Application Support/python-for-android/packages/sdl2_ttf
[INFO]:    -> running basename https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-2.0.12.tar.gz
[INFO]:    sdl2_ttf download already cached, skipping
[WARNING]: Should check headers here! Skipping for now.
[INFO]:    <- directory context /private/tmp/test
[INFO]:    Downloading sdl2
[INFO]:    -> running mkdir -p /Users/ben/Library/Application Support/python-for-android/packages/sdl2
[INFO]:    -> directory context /Users/ben/Library/Application Support/python-for-android/packages/sdl2
[INFO]:    -> running basename https://www.libsdl.org/release/SDL2-2.0.3.tar.gz
[INFO]:    sdl2 download already cached, skipping
[WARNING]: Should check headers here! Skipping for now.
[INFO]:    <- directory context /private/tmp/test
[INFO]:    # Building all recipes for arch armeabi
[INFO]:    # Unpacking recipes
[INFO]:    Unpacking python2 for armeabi
[INFO]:    -> running basename http://python.org/ftp/python/2.7.2/Python-2.7.2.tar.bz2
[INFO]:    -> directory context /Users/ben/Library/Application Support/python-for-android/build/other_builds/python2/armeabi
[INFO]:    python2 is already unpacked, skipping
[INFO]:    <- directory context /private/tmp/test
[INFO]:    Unpacking sdl2_image for armeabi
[INFO]:    -> running basename https://www.libsdl.org/projects/SDL_image/release/SDL2_image-2.0.0.tar.gz
[INFO]:    -> directory context /Users/ben/Library/Application Support/python-for-android/build/bootstrap_builds/sdl2-python2/jni
[INFO]:    sdl2_image is already unpacked, skipping
[INFO]:    <- directory context /private/tmp/test
[INFO]:    Unpacking sdl2_mixer for armeabi
[INFO]:    -> running basename https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-2.0.0.tar.gz
[INFO]:    -> directory context /Users/ben/Library/Application Support/python-for-android/build/bootstrap_builds/sdl2-python2/jni
[INFO]:    sdl2_mixer is already unpacked, skipping
[INFO]:    <- directory context /private/tmp/test
[INFO]:    Unpacking sdl2_ttf for armeabi
[INFO]:    -> running basename https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-2.0.12.tar.gz
[INFO]:    -> directory context /Users/ben/Library/Application Support/python-for-android/build/bootstrap_builds/sdl2-python2/jni
[INFO]:    sdl2_ttf is already unpacked, skipping
[INFO]:    <- directory context /private/tmp/test
[INFO]:    Unpacking sdl2 for armeabi
[INFO]:    -> running basename https://www.libsdl.org/release/SDL2-2.0.3.tar.gz
[INFO]:    -> directory context /Users/ben/Library/Application Support/python-for-android/build/bootstrap_builds/sdl2-python2/jni
[INFO]:    sdl2 is already unpacked, skipping
[INFO]:    <- directory context /private/tmp/test
[INFO]:    # Prebuilding recipes
[INFO]:    Prebuilding python2 for armeabi
[INFO]:    python2 has no prebuild_armeabi, skipping
[INFO]:    Applying patches for python2[armeabi]
[INFO]:    python2 already patched, skipping
[INFO]:    Prebuilding sdl2_image for armeabi
[INFO]:    sdl2_image has no prebuild_armeabi, skipping
[INFO]:    Applying patches for sdl2_image[armeabi]
[INFO]:    sdl2_image already patched, skipping
[INFO]:    Prebuilding sdl2_mixer for armeabi
[INFO]:    sdl2_mixer has no prebuild_armeabi, skipping
[INFO]:    Applying patches for sdl2_mixer[armeabi]
[INFO]:    sdl2_mixer already patched, skipping
[INFO]:    Prebuilding sdl2_ttf for armeabi
[INFO]:    sdl2_ttf has no prebuild_armeabi, skipping
[INFO]:    Prebuilding sdl2 for armeabi
[INFO]:    sdl2 has no prebuild_armeabi, skipping
[INFO]:    Applying patches for sdl2[armeabi]
[INFO]:    sdl2 already patched, skipping
[INFO]:    # Building recipes
[INFO]:    Building python2 for armeabi
Traceback (most recent call last):
  File "/usr/local/bin/p4a", line 9, in <module>
    load_entry_point('python-for-android==0.3', 'console_scripts', 'p4a')()
  File "/usr/local/lib/python2.7/site-packages/pythonforandroid/toolchain.py", line 708, in main
    ToolchainCL()
  File "/usr/local/lib/python2.7/site-packages/pythonforandroid/toolchain.py", line 323, in __init__
    getattr(self, args.command)(unknown)
  File "/usr/local/lib/python2.7/site-packages/pythonforandroid/toolchain.py", line 105, in wrapper_func
    build_dist_from_args(ctx, dist, dist_args)
  File "/usr/local/lib/python2.7/site-packages/pythonforandroid/toolchain.py", line 142, in build_dist_from_args
    build_recipes(build_order, python_modules, ctx)
  File "/usr/local/lib/python2.7/site-packages/pythonforandroid/build.py", line 551, in build_recipes
    recipe.build_arch(arch)
  File "/usr/local/lib/python2.7/site-packages/pythonforandroid/recipes/python2/__init__.py", line 44, in build_arch
    self.do_python_build(arch)
  File "/usr/local/lib/python2.7/site-packages/pythonforandroid/recipes/python2/__init__.py", line 76, in do_python_build
    shprint(sh.cp, self.ctx.hostpython, self.get_build_dir(arch.arch))
AttributeError: 'Context' object has no attribute 'hostpython'
@inclement
Copy link
Member

I think this relates to a known bug where the hostpython recipe is not included. You can work around it by adding hostpython2 to the requirements.

Also, don't use kivysdl2 recipe, the name is just kivy.

@cbenhagen
Copy link
Contributor Author

Thank you! :) Is there a bug open for this already which i missed? Or should we leave this one open until this gets fixed?

@kived kived closed this as completed in a8973ee Feb 3, 2016
@cbenhagen
Copy link
Contributor Author

@kived can you reopen this issue if it is not a duplicate?

@kived
Copy link
Contributor

kived commented Feb 3, 2016

Sorry, thought this was caused by using kivysdl2 which isn't a recipe. Looks like the real issue is that the dependencies of a recipe in a dependency group are not processed after the recipe is selected from the group. In other words, the sdl2 recipe depends on either python2 or python3crystax, but after selecting one it doesn't seem to process the dependencies of the selected recipe.

@Zen-CODE
Copy link
Member

Can confirm that adding 'hostpython2' in requirements solved this for me.

@inclement
Copy link
Member

Should be fixed by #641

@kiok46
Copy link

kiok46 commented Sep 4, 2016

@inclement this occurred again, on OSX 10.11.5

@inclement
Copy link
Member

Thanks, I'm aware of the problem appearing again. If you have an example, would you be able to open a new issue with the log if there isn't one already - it would be useful to have a test case.

@kiok46
Copy link

kiok46 commented Sep 4, 2016

@inclement sure.

@YodaEmbedding
Copy link

YodaEmbedding commented Jun 2, 2017

EDIT: Welp, I manually added hostpython2 to requirements as suggested and it works.


Still breaks on a clean install on Arch.

sudo pip install buildozer
buildozer init

I edit buildozer.spec slightly, with the following changes:

title = Flow Rate App
package.name = flowrateapp
package.domain = com.mulhaq.flowrateapp
log_level = 2

Then, I run:

buildozer android debug

It fails and tells me to install API level 19:

# Cwd /media/hdd/code/flow-rate-app/flowRateAppKivy/.buildozer/android/platform/python-for-android-master
[INFO]:    Will compile for the following archs: armeabi-v7a
[INFO]:    Found Android API target in $ANDROIDAPI
[INFO]:    Available Android APIs are ()
[WARNING]: Requested API target 19 is not available, install it with the SDK android tool.
[WARNING]: Exiting.
# Command failed: /usr/bin/python2 -m pythonforandroid.toolchain create --dist_name=flowrateapp --bootstrap=sdl2 --requirements=kivy --arch armeabi-v7a --copy-libs --color=always --storage-dir=/media/hdd/code/flow-rate-app/flowRateAppKivy/.buildozer/android/platform/build

I install the necessary build tools and SDK using the SDK manager tool ~/.buildozer/android/platform/android-sdk-20/tools/android, as described here.

Rerunning buildozer android debug gives:

[...]
[INFO]:    # Building recipes
[INFO]:    Building python2 for armeabi-v7a
Traceback (most recent call last):
  File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/media/hdd/code/flow-rate-app/flowRateAppKivy/.buildozer/android/platform/python-for-android-master/pythonforandroid/toolchain.py", line 905, in <module>
    main()
  File "/media/hdd/code/flow-rate-app/flowRateAppKivy/.buildozer/android/platform/python-for-android-master/pythonforandroid/toolchain.py", line 902, in main
    ToolchainCL()
  File "/media/hdd/code/flow-rate-app/flowRateAppKivy/.buildozer/android/platform/python-for-android-master/pythonforandroid/toolchain.py", line 508, in __init__
    getattr(self, args.subparser_name.replace('-', '_'))(args)
  File "/media/hdd/code/flow-rate-app/flowRateAppKivy/.buildozer/android/platform/python-for-android-master/pythonforandroid/toolchain.py", line 147, in wrapper_func
    build_dist_from_args(ctx, dist, args)
  File "/media/hdd/code/flow-rate-app/flowRateAppKivy/.buildozer/android/platform/python-for-android-master/pythonforandroid/toolchain.py", line 190, in build_dist_from_args
    build_recipes(build_order, python_modules, ctx)
  File "/media/hdd/code/flow-rate-app/flowRateAppKivy/.buildozer/android/platform/python-for-android-master/pythonforandroid/build.py", line 565, in build_recipes
    recipe.build_arch(arch)
  File "/media/hdd/code/flow-rate-app/flowRateAppKivy/.buildozer/android/platform/python-for-android-master/pythonforandroid/recipes/python2/__init__.py", line 44, in build_arch
    self.do_python_build(arch)
  File "/media/hdd/code/flow-rate-app/flowRateAppKivy/.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: /usr/bin/python -m pythonforandroid.toolchain create --dist_name=flowrateapp --bootstrap=sdl2 --requirements=kivy --arch armeabi-v7a --copy-libs --color=always --storage-dir=/media/hdd/code/flow-rate-app/flowRateAppKivy/.buildozer/android/platform/build

@Zen-CODE
Copy link
Member

Zen-CODE commented Aug 13, 2018 via email

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

6 participants