kivy / kivy-ios

Toolchain for compiling Python / Kivy / other libraries for iOS
https://kivy.org/docs/guide/packaging-ios.html
MIT License
780 stars 240 forks source link

Custom recipe list does not persist between toolchain commands #675

Open RobertFlatt opened 2 years ago

RobertFlatt commented 2 years ago

Versions

Describe the bug

kivy-ios command toolchain build... fails on a custom recipe build, when that recipe depends on a previously built custom recipe. The error generated by second_custom_recipe build is: [INFO ] Using the bundled version for recipe 'first_custom_recipe'

The error message interpreted as the second_custom_recipe is looking for the first_custom_recipe as a bundled recipe, which it is not.

To Reproduce Use two custom recipes with the second depending on the first

toolchain distclean
toolchain build python3 kivy
toolchain build first_custom_recipe --add-custom-recipe recipes/first_custom_recipe
toolchain build second_custom_recipe --add-custom-recipe recipes/second_custom_recipe

Expected behavior https://github.com/kivy/kivy-ios#create-the-xcode-project where it says "Then click on Play, and enjoy"

Logs

Build first custom recipe:

robert@Air ex % toolchain build pybind11 --add-custom-recipe recipes/pybind11
[INFO    ] Adding recipes/pybind11 to custom recipes paths
[INFO    ] Building with 8 processes, where supported
[INFO    ] Want to build ['pybind11']
[INFO    ] A custom version for recipe 'pybind11' found in folder recipes/pybind11
[INFO    ] Loaded recipe pybind11 (depends of [], optional are [])
[INFO    ] Build order is ['pybind11']
[INFO    ] A custom version for recipe 'pybind11' found in folder recipes/pybind11
[INFO    ] Recipe order is ['pybind11']
[DEBUG   ] Cached result: Download pybind11. Ignoring
[DEBUG   ] Cached result: Extract pybind11. Ignoring
[DEBUG   ] Cached result: Install_hostpython_prerequisites pybind11. Ignoring
[DEBUG   ] Cached result: Build_all pybind11. Ignoring

Build second custom recipe

robert@Air ex % toolchain build tflite-runtime --add-custom-recipe recipes/tflite-runtime
[INFO    ] Adding recipes/tflite-runtime to custom recipes paths
[INFO    ] Building with 8 processes, where supported
[INFO    ] Want to build ['tflite-runtime']
[INFO    ] A custom version for recipe 'tflite-runtime' found in folder recipes/tflite-runtime
[INFO    ] Loaded recipe tflite-runtime (depends of ['pybind11', 'numpy'], optional are [])
[INFO    ] Using the bundled version for recipe 'pybind11'
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.9/bin/toolchain", line 8, in <module>
    sys.exit(main())
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/kivy_ios/toolchain.py", line 1555, in main
    ToolchainCL()
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/kivy_ios/toolchain.py", line 1299, in __init__
    getattr(self, args.command)()
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/kivy_ios/toolchain.py", line 1368, in build
    build_recipes(args.recipe, ctx)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/kivy_ios/toolchain.py", line 1112, in build_recipes
    recipe = Recipe.get_recipe(name, ctx)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/kivy_ios/toolchain.py", line 989, in get_recipe
    mod = importlib.import_module(f"kivy_ios.recipes.{name}")
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'kivy_ios.recipes.pybind11'
robert@Air ex % 

Additional context Add any other context about the problem here.

RobertFlatt commented 2 years ago

The issue occurs because the internal list of custom recipes ctx.custom_recipes_paths does not persist between toolchain build occurrences.

The workaround is to build both custom recipes with the same toolchain build:

toolchain build first_custom_recipe second_custom_recipe --add-custom-recipe recipes/first_custom_recipe  --add-custom-recipe recipes/second_custom_recipe

For the same reason this will also fail:

toolchain clean first_custom_recipe
RobertFlatt commented 2 years ago

For the same reason toolchain status does not list custom recipes.

The missing functionality could be implemented with a .db mapping built custom recipes to their directory.

misl6 commented 2 years ago

Yeah. Absolutely agree. Marking as feature-request. Thank you for the detailed report.