如何在chaquopy中更改内置库文件?

huangapple go评论57阅读模式
英文:

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&gt;

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.

huangapple
  • 本文由 发表于 2023年5月25日 01:50:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/76326219.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定