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?
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).
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With