Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

subversion python bindings documentation? [closed]

Where can I find a good introduction to using the subversion python bindings?

I found one section in the svnbook that talks about it; and some basic examples from 1.3.

Is there something a bit more thorough and up-to-date?

like image 397
retracile Avatar asked Sep 19 '09 16:09

retracile


3 Answers

Just wanted to add a little clarification here.

Thanks to the above two answers (@BenjaminWohlwend and @Logan), I became aware there are more than one set of Python bindings/interfaces for Subversion; I did this on my Ubuntu 11.04 box:

$ apt-cache search '[Ss]vn|[Ss]ubversion' | grep -i python
python-svn - A(nother) Python interface to Subversion
python-svn-dbg - A(nother) Python interface to Subversion (debug extension)
python-subversion - Python bindings for Subversion
python-subversion-dbg - Python bindings for Subversion (debug extension)
python-opster - a python command line parsing speedster
python-py - Advanced Python testing tool and networking lib
python-rope - Python refactoring library
python-subvertpy - Alternative Python bindings for Subversion

One can look at the Debian package filelist, to determine which libraries these refer to; so we have:

  • python-subversion - or SWIG bindings (or libsvn, libsvn_swig_py) filelist
    • Examples: http://svn.apache.org/repos/asf/subversion/trunk/tools/examples/ , http://svn.apache.org/repos/asf/subversion/trunk/subversion/bindings/swig/python/tests/
    • import svn.core, svn.client ; from svn import fs, core, repos
  • python-svn - or pysvn filelist
    • Examples: http://sourcecodebrowser.com/pysvn/1.4.1/dir_cd55444703d7fb2488815f1970d01a75.html , http://pysvn.tigris.org/docs/pysvn_prog_guide.html
    • import pysvn
  • python-subvertpy - or subvertpy filelist
    • Examples: http://sourcecodebrowser.com/subvertpy/0.7.2/dir_22b88615bda8eebb370e96884c00fb89.html
    • from subvertpy import delta, repos , from subvertpy.ra import RemoteAccess, Auth

... and I also found another in the repository:

  • ctypes-python - or csvn source
    • Examples: http://svn.apache.org/repos/asf/subversion/trunk/subversion/bindings/ctypes-python/examples/
    • import csvn.core , from csvn.repos import *

The link http://svn.apache.org/repos/asf/subversion (which I got from @BenjaminWohlwend) is apparently the Apache Software Foundation (asf?) Subversion repository for Subversion source code itself.

The OP's quest for documentation seems related to python-subversion (or SWIG bindings (or libsvn); whose build-from-source instructions are in @Logan's post. I couldn't find much better documentation source from the svn.developer: Using the APIs already referred in the OP, except for the bindings/swig/python/README; it explains how SWIG generates Python interfaces from C:

TRANSLATING PARAMETER LISTS

The argument-reductions laws of the SWIG bindings something go like
this:

- The module prefix can be omitted.  o:  

     void *some_C_function = svn_client_foo;  

  becomes:  

     import svn.client  
     func = svn.client.foo  

[...]

Then, one could look in, say, svn/core.py, and find functions (and "Symbols defined explicitly") like svn_mergeinfo_merge; noting that core.py imports libsvn.core - where libsvn probably refers to the shared object (.so) files built from the C file libsvn_swig_py/swigutil_py.c.

Then, we can look up svn_mergeinfo_merge, and find a commit message like SVNSearch: Subversion (commit 23570 05.03.2007), which refers to that function, and a svn_mergeinfo.h; looking up that file further, we find it in the ASF repository: svn_mergeinfo.h, which indeed contains:

/** Like svn_mergeinfo_merge2, but uses only one pool.
 *
 * @deprecated Provided for backward compatibility with the 1.5 API.
 */
SVN_DEPRECATED
svn_error_t *
svn_mergeinfo_merge(svn_mergeinfo_t mergeinfo,
                    svn_mergeinfo_t changes,
                    apr_pool_t *pool);

Seeing DEPRECATED there, it's probably good here to refer to svn commit: r1175903 (Mon Sep 26 2011):

  • subversion/libsvn_subr/mergeinfo.c

    (svn_mergeinfo_merge2): New.

    (svn_mergeinfo_merge): Move to deprecated.c.

    (svn_mergeinfo_catalog_merge): Use the new API.

That is - that particular function has been deprecated in 2011 - so hopefully, one's Python SVN bindings and SVN installation should be matching...

like image 138
sdaau Avatar answered Nov 04 '22 00:11

sdaau


If you build Subversion from source the Subversion Python bindings aren't automatically included. You have to specifically build and include them. Luckily, you can do this after you've installed Subversion. The source for the bindings is included within the Subversion source code.

These instructions are for Subversion 1.5.9 and Python 2.4.3 on Red Hat Enterprise Linux, but they should be easily hackable for recent versions of Subversion and Python and generic unix installs.

First, download swig from http://downloads.sourceforge.net/swig

tar -xvf swig-<version>.tar.gz
cd swig-<version>

At this point you have to make a decision. You can install swig for all supported languages or you can install for just what you need. 'make check' can take up to an hour to run and may fail due to errors from languages you aren't concerned with.

If you want to use all supported languages run:

./configure 

If you want to scope down to just python, run:

./configure --with-python=/usr/local/bin/python2.4 --without-perl --without-ruby --without-php4

Next, run:

make

If you opted for the full install, run:

make -k check

If you scoped down to just python you only need to run the python tests:

make check-python-examples
make check-python-test-suite

If everything's OK, you're ready to install swig:

make install

From here, installing the subversion python bindings should be fairly straightforward:

tar -xvf subversion-1.5.9.tar.gz --gzip 
cd subversion-1.5.9
make swig-py
make install-swig-py
touch /usr/lib64/python2.4/site-packages/svn-python.pth
echo /usr/local/lib/svn-python > /usr/lib64/python2.4/site-packages/svn-python.pth

As always, your mileage may vary depending on your specific versions and architecture. Good luck.

like image 2
Logan Avatar answered Nov 04 '22 00:11

Logan


This looks like a pretty complete documentation:

http://pysvn.tigris.org/docs/pysvn_prog_ref.html

And here are a couple examples:

http://svn.apache.org/repos/asf/subversion/trunk/tools/examples/

like image 1
Benjamin Wohlwend Avatar answered Nov 03 '22 23:11

Benjamin Wohlwend