Python Subversion包装库
在Subversion中有一个从Python使用Subversion的示例Python Subversion包装库,python,svn,easy-install,Python,Svn,Easy Install,在Subversion中有一个从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 DIR
#!/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
那么,我如何安装这个库呢?本文档中提到的库是基于SWIG的包装器,它是与Subversion一起构建和发布的。因此,如果您的操作系统的包是
subversion
,那么请寻找与之配套的subversion python
包。如果您是从源代码构建subversion,那么您需要使用--with python
配置选项来配置要并行构建的绑定
另一种选择(使用完全不同的API)是。这些都有更好的文档记录,并且更易于使用,但在运行时性能方面效率也较低(它们没有实现所有的连接重用功能以及文档不足的“官方”绑定)。您需要安装subversion python才能导入类 就我而言(软呢帽)
sudo-yum安装subversion-python
Apt get应该有或多或少相同的它抱怨
svn.core
而不是svn.fs
(后者在导入列表中排在第一位),这不是有点奇怪吗?你抓到我了,我在交互式Promptals上复制并粘贴了运行import svn.core
时的错误,我的操作系统现在是Windows,它没有包管理器。如果您能将我链接到该文档,我很乐意使用pysvn
。@MattHickford更新了一个到pysvn的链接。感谢您找到了难以理解的文档,说明库pysvn很棒,并且做了我想要的
$ pip install svn
Downloading/unpacking svn
Could not find any downloads that satisfy the requirement svn
No distributions at all found for svn