Skip to content

UnboundLocalError: local variable 'toolchain_version' referenced before assignment #2190

@AndreMiras

Description

@AndreMiras

Versions

  • Python: 3.8
  • OS: Linux Arch
  • Kivy: N/A
  • Cython: Cython==0.28.6

Description

Building a the apps (in this case testapps/on_device_unit_tests) fails with a UnboundLocalError when the NDK directory doesn't exist.

Exact command used was:

python setup.py apk --sdk-dir ~/.buildozer/android/platform/android-sdk --ndk-dir ~/.buildozer/android/platform/android-ndk --requirements libffi,sdl2,pyjnius,kivy,python3,openssl,requests,sqlite3,setuptools,numpy

Logs

python setup.py apk --sdk-dir ~/.buildozer/android/platform/android-sdk --ndk-dir ~/.buildozer/android/platform/android-ndk --requirements libffi,sdl2,pyjnius,kivy,python3,openssl,requests,sq
lite3,setuptools,numpy
found requirements
running apk
WARNING: You did not supply an Android package identifier, trying org.test.unit_tests_app instead.
         This may fail if this is not a valid identifier
Including test_app/app_flask.py
Including test_app/app_kivy.py
Including test_app/main.py
Including test_app/tools.py
Including test_app/widgets.py
Including test_app/constants.py
Including test_app/app_service.py
Including test_app/screen_service.kv
Including test_app/screen_unittests.kv
Including test_app/widgets.kv
Including test_app/screen_orientation.kv
Including test_app/screen_keyboard.kv
Including test_app/app_requirements.txt
Including test_app/static/colours.png
Including test_app/static/coloursinv.png
Including test_app/static/flask.css
Including test_app/static/Blanka-Regular.otf
Including test_app/templates/index.html
Including test_app/templates/page2.html
Including test_app/templates/base.html
Including test_app/templates/unittests.html
Including test_app/tests/__init__.py
Including test_app/tests/test_requirements.py
Including test_app/tests/mixin.py
[INFO]:    Will compile for the following archs: armeabi-v7a
[INFO]:    Getting Android API version from user argument: 27
[INFO]:    Available Android APIs are (27)
[INFO]:    Requested API target 27 is available, continuing.
[INFO]:    Getting NDK dir from from user argument
[INFO]:    Could not determine NDK version, no source.properties in the NDK dir.
[WARNING]: Unable to read the NDK version from the given directory /home/andre/.buildozer/android/platform/android-ndk.
[WARNING]: Make sure your NDK version is greater than 19. If you get build errors, download the recommended NDK 19c from https://developer.android.com/ndk/downloads/.
[INFO]:    Getting NDK API version (i.e. minimum supported API) from user argument
[INFO]:    ccache is missing, the build will not be optimized in the future.
/home/andre/workspace/python-for-android/venv/bin/python3: No module named cython
[WARNING]: Cython for python3 missing. If you are building for  a python 3 target (which is the default) then THINGS WILL BREAK.
[WARNING]: ndk_platform doesn't exist: /home/andre/.buildozer/android/platform/android-ndk/platforms/android-21/arch-arm
[WARNING]: Could not find toolchain subdirectory!
[WARNING]: Could not find any toolchain for arm-linux-androideabi!
Traceback (most recent call last):
  File "setup.py", line 79, in <module>
    setup(
  File "/usr/lib/python3.8/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/usr/lib/python3.8/distutils/dist.py", line 966, in run_commands
    self.run_command(cmd)
  File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/home/andre/workspace/python-for-android/pythonforandroid/bdistapk.py", line 79, in run
    main()
  File "/home/andre/workspace/python-for-android/pythonforandroid/entrypoints.py", line 18, in main
    ToolchainCL()
  File "/home/andre/workspace/python-for-android/pythonforandroid/toolchain.py", line 688, in __init__
    getattr(self, command)(args)
  File "/home/andre/workspace/python-for-android/pythonforandroid/toolchain.py", line 144, in wrapper_func
    ctx.prepare_build_environment(user_sdk_dir=self.sdk_dir,
  File "/home/andre/workspace/python-for-android/pythonforandroid/build.py", line 407, in prepare_build_environment
    self.toolchain_version = toolchain_version
UnboundLocalError: local variable 'toolchain_version' referenced before assignment

The fix is actually simple, but I would like it to be cover tested

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions