lukasmvv
lukasmvv

Reputation: 31

How to create custom recipes for p4a in Python?

So I am trying to use the SpeechRecognition package with my Kivy app. I am using buildozer to build and deploy, but I need to create a custom recipe for the SpeechRecognition package.

So far I have downloaded the p4a folder with all the recipes and created a new folder 'speech_recognition'. When building the app buildozer tries to download the package but then fails. I guess I need help with how to exactly setup my recipe file.

I have looked at a bunch of example recipes available here.

Here is my speech_recognition/__init__.py

from pythonforandroid.recipe import CppCompiledComponentsPythonRecipe
class SRRecipe(CppCompiledComponentsPythonRecipe):
    version = '3.8.1'
    url = 'https://github.com/Uberi/speech_recognition/archive/{version}.zip'
    site_packages_name = 'speech_recognition'
    #depends = ['setuptools']
recipe = SRRecipe()

Here is the console output:

[INFO]:    -> running mkdir -p /home/lukas/Documents...(and 86 more)
[INFO]:    -> directory context /home/lukas/Documents/SpeechRecog/.buildozer/android/platform/build-armeabi-v7a/packages/speech_recognition
[INFO]:    -> running basename https://github.com/Ube...(and 31 more)
[INFO]:    -> running rm speech_recognition-3.8.1.zip
[INFO]:    -> running rm -f .mark-speech_recognition-3.8.1.zip
[INFO]:    Downloading speech_recognition from https://github.com/Uberi/speech_recognition-3.8.1.zip
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 "/home/lukas/Documents/SpeechRecog/python-for-android/pythonforandroid/toolchain.py", line 1196, in <module>
    main()
  File "/home/lukas/Documents/SpeechRecog/python-for-android/pythonforandroid/entrypoints.py", line 18, in main
    ToolchainCL()
  File "/home/lukas/Documents/SpeechRecog/python-for-android/pythonforandroid/toolchain.py", line 671, in __init__
    getattr(self, args.subparser_name.replace('-', '_'))(args)
  File "/home/lukas/Documents/SpeechRecog/python-for-android/pythonforandroid/toolchain.py", line 155, in wrapper_func
    build_dist_from_args(ctx, dist, args)
  File "/home/lukas/Documents/SpeechRecog/python-for-android/pythonforandroid/toolchain.py", line 209, in build_dist_from_args
    args, "ignore_setup_py", False
  File "/home/lukas/Documents/SpeechRecog/python-for-android/pythonforandroid/build.py", line 558, in build_recipes
    recipe.download_if_necessary()
  File "/home/lukas/Documents/SpeechRecog/python-for-android/pythonforandroid/recipe.py", line 356, in download_if_necessary
    self.download()
  File "/home/lukas/Documents/SpeechRecog/python-for-android/pythonforandroid/recipe.py", line 402, in download
    self.download_file(self.versioned_url, filename)
  File "/home/lukas/Documents/SpeechRecog/python-for-android/pythonforandroid/recipe.py", line 217, in download_file
    urlretrieve(url, target, report_hook)
  File "/usr/lib/python3.6/urllib/request.py", line 1819, in retrieve
    block = fp.read(bs)
  File "/home/lukas/kivy_venv/lib/python3.6/tempfile.py", line 624, in func_wrapper
    return func(*args, **kwargs)
ValueError: read of closed file

What is strange to me is that the url in the output is not the same as the url i specify? Any help would be appreciated.

Upvotes: 3

Views: 931

Answers (0)

Related Questions