python-for-android icon indicating copy to clipboard operation
python-for-android copied to clipboard

Enhancement request: add documentation that your venv must not be in the project folder

Open nhansendev opened this issue 2 years ago • 1 comments

I had encountered a mysterious issue where my project would appear to build cleanly, but python packages would sometimes go missing while trying to run the app.

Specifically, the app would crash during launch and any number of ModuleNotFoundErrors would appear in the logcat. E.g. ModuleNotFoundError: No module named 'paramiko'

This behavior only appeared when certain packages were added, which made it more confusing. Using just python, kivy, and numpy, for example, caused no problems. (Might be related to things with recipes? Hard to tell)

This happened even when the various suggestions in the troubleshooting guide were followed, such as completely wiping the build and starting over, explicitly adding the full dependency tree(s) to the .spec requirements, ensuring nothing would cause non-deterministic behavior, etc.

What finally solved the issue was the realization that having my virtual environment folder within the project folder caused some kind of interference with the process (even though it was supposedly being ignored via the source.exclude_dirs parameter in the .spec file) .

Summary

Please add documentation that including your virtual environment folder within your project's folder (where it will be seen by buildozer/p4a) can/will prevent the app from running even if it builds without obvious issues.

nhansendev avatar Jul 04 '23 05:07 nhansendev

The core issue here is I think the interaction between including/excluding exts and excluding directories is fundamentally ambiguous (without reading the Buildozer code) .

Reading the Buildozer code tells us that exts has priority over directories, which means that exclude_dirs does not necessarily exclude a directory as one might think it should (without reading all the other options and considering the interactions).

This led the user to reasonably but incorrectly assume they could create a non-app subdirectory and exclude it (in this case a venv dir). (because the .spec says "#source.exclude_dirs = tests, bin, venv")

RobertFlatt avatar Jul 05 '23 07:07 RobertFlatt