Python Subversion 包装器库

标签 python svn easy-install

在 Subversion 的 documentation 中有一个从 Python 使用 Subversion 的例子

#!/usr/bin/python
import svn.fs, svn.core, svn.repos

def crawl_filesystem_dir(root, directory):
    """Recursively crawl DIRECTORY under ROOT in the filesystem, and return a list of all the paths at or below DIRECTORY."""

    # Get the directory entries for DIRECTORY.
    entries = svn.fs.svn_fs_dir_entries(root, directory)

当我运行此代码时出现导入错误:

$ python crawl.py
Traceback (most recent call last):
  File "crawl.py", line 7, in <module>
    import svn.fs, svn.core, svn.repos
ImportError: No module named svn.fs

这意味着我缺少库 svn。我尝试安装该包,但 Python 包管理器找不到它。

$ pip install svn
Downloading/unpacking svn
  Could not find any downloads that satisfy the requirement svn
No distributions at all found for svn

那么,我该如何安装这个库呢?

最佳答案

本文档引用的库是基于 SWIG 的包装器,它与 Subversion 本身一起构建和发布。因此——如果您的操作系统的包是 subversion,请寻找一个 subversion-python 包与它一起发布。如果您从源代码构建颠覆,您需要使用 --with-python 配置选项来同时构建绑定(bind)。

另一种选择(具有完全不同的 API)是 the 3rd-party wrapper pysvn .它们有更好的文档记录并且更易于使用,但在运行时性能方面效率也较低(它们没有实现所有连接重用功能以及文档不足的“官方”绑定(bind))。

关于Python Subversion 包装器库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10582469/

相关文章:

.net - JIRA Studio 适合 .NET 开发吗?

python - 升级后pip坏了

python - 定时器的暂停/恢复功能

python - Pandas DataFrame 构造函数对行进行排序,即使使用 OrderedDict 作为输入

python - Action 插件和 Ansible 模块之间有什么关系?

python - 配置文件中的语法错误 - 未定义 future 功能 unicode_literals (Python、Django、Sphinx)

python - 'easy_install' 期间发出的警告

python - 使窗口关闭特定值(python)

sql - 用于SQL Server Management Studio 2005的SVN客户端

svn - SVN历史中带星号(*)的粗体是什么意思?