Colonel Panic
Colonel Panic

Reputation: 137574

Python Subversion wrapper library

In Subversion's documentation there's an example of using Subversion from Python

#!/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)

When I run this code I get an import error:

$ 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

This means I'm missing the library svn. I tried to install the package, but the Python package manager can't find it.

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

So, how do I install this library?

Upvotes: 6

Views: 22626

Answers (2)

Rudi Strydom
Rudi Strydom

Reputation: 4597

You need to install subversion-python in order to be able to import the classes.

In my case (Fedora)

sudo yum install subversion-python

Apt-get should have more or less the same

Upvotes: 2

Charles Duffy
Charles Duffy

Reputation: 295403

The library referred to by this documentation is the SWIG-based wrappers which build and ship with Subversion itself. Thus -- if your operating system's package is subversion, look for a subversion-python package to ship alongside it. If you're building subversion from source, you'll want to use the --with-python configure option for the bindings to be built alongside.

An alternative (with a quite different API) is the 3rd-party wrapper pysvn. These are better-documented and are easier to use, but are also less efficient in terms of runtime performance (they don't implement all the connection reuse capabilities and such of the underdocumented "official" bindings).

Upvotes: 9

Related Questions