Skip to main content
 首页 » 编程设计

python之Django : Which approach is better [ virtualenv + pip ] vs [manually carrying packages in svn]

2025年05月04日22duanxz

我有一个使用大量第 3 方应用程序的 Django 项目,所以想从这两种方法中做出决定来管理我的情况:

<醇>
  • 我可以使用 [virtualenv + pip ] 和 pip freeze 作为需求文件来管理我的项目依赖项。

    I don't have to worry about the apps, but can't have that committed with my code to svn.

  • 我可以在我的 svn 结构中有一个 lib 文件夹,让我的应用程序放在那里并将其添加到 sys.path
  • 这样,我的依赖项可以提交给 svn,但我必须管理 sys.path

    我应该采用哪种方式?

    每种方法的优缺点是什么?

    更新:

    Method1 Disadvantage : Difficult to work with appengine.

    请您参考如下方法:

    到目前为止,这是一个没有答案的问题(至少对我而言)。最近有一些关于这个的讨论:-

    https://plus.google.com/u/0/104537541227697934010/posts/a4kJ9e1UUqE

    Ian Bicking 在评论中这样说:-

    I do think we can do something that incorporates both systems. I posted a recipe for handling this earlier, for instance (I suppose I should clean it up and repost it). You can handle libraries in a very similar way in Python, while still using the tools we have to manage those libraries. You can do that, but it's not at all obvious how to do that, so people tend to rely on things like reinstalling packages at deploy time.

    http://tarekziade.wordpress.com/2012/02/10/defining-a-wsgi-app-deployment-standard/

    第一种方法似乎在 Python 开发人员中最为常见。当我第一次开始在 Django 中进行开发时,感觉有点奇怪,因为在使用 PHP 时,将第三方 lib 检查到项目 repo 中是很常见的,但正如 Ian Bicking 在链接帖子中所说,PHP 样式部署遗漏了这样的非-可移植图书馆。您不想将诸如 mysqldb 或 PIL 之类的东西打包到您的项目中,而这些东西最好由 Pip 或 distribute 等工具处理。