英文:
How to make changes in a built-in library file in chaquopy?
问题
我面临一个问题,我需要更改一个特定库(使用pip安装)中内置文件中的一行。我已经找到了文件位置在
app\build\pip\debug\common<library folder>
但每次我运行Gradle(用于安装或创建APK),整个文件夹都会重新创建,因此文件仍然与以前相同。
有没有办法使更改保持永久?
英文:
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?
答案1
得分: 1
如David K Hess在评论中提到的,猴子补丁可能是最简单的解决方案。
如果猴子补丁不适用于您的问题,假设该库是纯Python的,您可以从PyPI下载它,编辑您的本地副本,然后从中安装:
-
例如,您可以下载一个.whl文件,编辑其中的文件,然后添加一个指向.whl文件的
install
行。 -
或者您可以下载一个sdist(.tar.gz文件),将其提取到一个目录中,编辑其中的文件,然后添加一个指向该目录的
install
行。
在这两种情况下,install
行可能应该放在要求列表的开头,位于可能依赖于该库的任何其他内容之前。
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论