Hi folks! I am releasing into the wild a script I hacked together to help ease my
compile-install-run-debug cycle for python-for-android/kivy apps.
https://gist.github.com/kamathln/9e3ea07309e79e90fb6009429510348d/edit
This script is shared in the hopes that you will customize it for your environment as some commands and paths may differ. It is also an ugly hackish script I wrote for myself, so anyone craving more quality is most welcome to improve it or re-implement it in python .
First customize it for your environment and project by copying the ENVIRONMENT variables below to your "$HOME/.p4a-build.conf" and "$project folder/p4a-build.conf"(note the dots). It is highly recommended that the sources which actually go into the app (like main.py, assets folder, etc.) to be in 'src' folder under your project folder. Make sure your p4a-build.conf , blacklist.txt and requirements.txt are in the project folder.
$ vim p4a-build.conf
$ p4a-build my_nice_project 3.2 src
c to Compile
l to list private.mp3 contents from unshake2-3.3-debug.apk
i to install unshake2-3.3-debug.apk to phone
r to run installed app
d to run logcat
q to quit
>
$ vim requirements.txt
$ vim src/main.py # Keep editing and saving..
.. Lots of compile related messages here. But if any py file in src does not compile, it will fail immediately and give you a big red error.
After this, you usually end up using the i for install, and r for run and if needed d for debug.. Then the edit-[alt-tab]c->i->r->d cycle repeats.
compile-install-run-debug cycle for python-for-android/kivy apps.
https://gist.github.com/kamathln/9e3ea07309e79e90fb6009429510348d/edit
This script is shared in the hopes that you will customize it for your environment as some commands and paths may differ. It is also an ugly hackish script I wrote for myself, so anyone craving more quality is most welcome to improve it or re-implement it in python .
Features:
- Checks for compilation errors of files under src using the compileall module, and stops there if it finds errors. (Compilation by p4a generally ignores and carries on)
- Lists the generated apk files with size after compile
- Lists the files in private.mp3 with 1 key command
- installation to phone using adb(replaces existing app)
- runs the app using adb shell am start
How to use:
First customize it for your environment and project by copying the ENVIRONMENT variables below to your "$HOME/.p4a-build.conf" and "$project folder/p4a-build.conf"(note the dots). It is highly recommended that the sources which actually go into the app (like main.py, assets folder, etc.) to be in 'src' folder under your project folder. Make sure your p4a-build.conf , blacklist.txt and requirements.txt are in the project folder.
Typical way to run the script
In terminal 1
$ cd my_nice_project_folder$ vim p4a-build.conf
$ p4a-build my_nice_project 3.2 src
c to Compile
l to list private.mp3 contents from unshake2-3.3-debug.apk
i to install unshake2-3.3-debug.apk to phone
r to run installed app
d to run logcat
q to quit
>
In Terminal 2
$ vim blacklist.txt$ vim requirements.txt
$ vim src/main.py # Keep editing and saving..
In Terminal 1
> c.. Lots of compile related messages here. But if any py file in src does not compile, it will fail immediately and give you a big red error.
After this, you usually end up using the i for install, and r for run and if needed d for debug.. Then the edit-[alt-tab]c->i->r->d cycle repeats.
Improvable areas
- Single command for compile-install-run (currently they are seperate), with error detection.
- Convert to python for better and cleaner code. And cleaner config management : Currently, if any changes in config are required, we need to exit the script, edit the config files and enter the script again. With python, we must be able to cleanly list, edit and save home config and project wise config. Also clean recipes/build/dists/etc easily by hooking directly to p4a modules
- Once converted to Python, use advanced Android techniques to push changes quickly to awaiting deamon in the debug version of the app.
No comments:
Post a Comment