Search code examples
pythonandroidandroid-studiopipchaquopy

How to make changes in a built-in library file in chaquopy?


I am facing a problem where I have to change a line in a built-in file in a particular library (installed using pip). I have located the file in

app\build\pip\debug\common\<library folder>

But every time I run the Gradle (for installing or creating APK), the entire folder is recreated, and hence, the file is again the same as previous.

Is there any way to make the change permanent?


Solution

  • As mentioned in the comment by David K Hess, monkey patching may be the easiest solution.

    If monkey patching isn't suitable for your issue, then assuming the library is pure-Python, you can download it from PyPI, edit your local copy, and then install from that:

    • For example, you could download a .whl file, edit the file inside it, and then add an install line pointing to the .whl.

    • Or you could download an sdist (.tar.gz file), extract it to a directory, edit the file inside it, and then add an install line pointing to the directory.

    In both cases, the install line should probably come first in the requirements list, before anything else which may depend on the library.