gpt4 book ai didi

python - 开发库模块时设置Python路径

转载 作者:太空宇宙 更新时间:2023-11-03 12:22:36 24 4
gpt4 key购买 nike

我正在开发一个库和一个在 Python 2.6 中使用该库的应用程序。我在“site-packages”中放置了一个“mylib.pth”文件,这样我就可以从我的应用程序中import mylib

我正在使用 DVCS,所以当我想修复错误或向库中添加功能时,我创建了存储库的一个分支并在该分支内工作。为了使用我对库所做的更改测试我的应用程序,我编辑“mylib.pth”中的路径以指向新的开发分支。

如果我的图书馆有几个平行的分支同时进行,这会有点乏味。我必须在测试之前继续编辑“mylib.pth”文件,以确保我正在针对我的库的正确版本进行测试。有没有办法在我调用我的应用程序时使用当前路径(即我当前所在的库的开发分支)来设置库路径,而不是使用全局“站点包”中的“mylib.pth”目录?

最佳答案

virtualenv你在找什么?来自描述:

Imagine you have an application that needs version 1 of LibFoo, but another application requires version 2. How can you use both these applications? If you install everything into /usr/lib/python2.4/site-packages (or whatever your platform's standard location is), it's easy to end up in a situation where you unintentionally upgrade an application that shouldn't be upgraded.

关于python - 开发库模块时设置Python路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1889967/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com