系统环境

# cat /etc/redhat-release 
CentOS release 6.6 (Final)
# uname -m
x86_64

svn 版本

# svnversion --version
svnversion,版本 1.8.16 (r1740329)

python版本

# python -V
Python 2.7.8

安装

# cd /data
# wget http://tigris.org/files/documents/1233/49509/pysvn-1.9.0.tar.gz
# tar -xf pysvn-1.9.0.tar.gz 
# cd pysvn-1.9.0/Source
# python setup.py configure


错误:('Error:', 'Cannot find SVN include svn_client.h - use --svn-inc-dir')
解决:yum -y install subversion-devel
错误:('Error:', 'Cannot find APR include apr.h - use --apr-inc-dir')
解决:yum -y install apr-devel
错误:('Error:', 'Cannot find APR include apu.h - use --apu-inc-dir')
解决:yum -y install apr-util-devel




# python setup.py configure    
Info: Configure for python 2.7.8 in exec_prefix /usr/local
Info: Found  PyCXX include in /data/pysvn-1.9.0/Import/pycxx-6.2.7
Info: Found  PyCXX include in /data/pysvn-1.9.0/Import/pycxx-6.2.7
Info: Found   PyCXX Source in /data/pysvn-1.9.0/Import/pycxx-6.2.7/Src
Info: Found    SVN include in /usr/include/subversion-1
Info: Found    SVN library in /usr/lib64
Info: Found        SVN bin in /usr/bin
Info: Found    APR include in /usr/include/apr-1
Info: Found    APR include in /usr/include/apr-1
Info: Found    APR library in /usr/lib64
Info: Building against SVN 1.8.16
Info: Found  PyCXX include in /data/pysvn-1.9.0/Import/pycxx-6.2.7
Info: Found  PyCXX include in /data/pysvn-1.9.0/Import/pycxx-6.2.7
Info: Found   PyCXX Source in /data/pysvn-1.9.0/Import/pycxx-6.2.7/Src
Info: Found    SVN include in /usr/include/subversion-1
Info: Found    SVN library in /usr/lib64
Info: Found        SVN bin in /usr/bin
Info: Found    APR include in /usr/include/apr-1
Info: Found    APR include in /usr/include/apr-1
Info: Found    APR library in /usr/lib64
Info: Building against SVN 1.8.16
Info: Using tool chain LinuxCompilerGCC
Info: Creating Makefile for Sources
Info: Creating Makefile for Tests
Info: svn testcase 10 skipped - svn version too old
# make
Info: Make generate_svn_error_codes.hpp
/usr/local/bin/python -u generate_svn_error_codes/create_svn_error_codes_hpp.py /usr/include/subversion-1
Compile: generate_svn_error_codes/generate_svn_error_codes.cpp into generate_svn_error_codes.o
make: g++:命令未找到
make: *** [generate_svn_error_codes.o] 错误 127
处理:yum -y install gcc-c++
再make

创建pysvn目录

mkdir -p /usr/local/lib/python2.7/site-packages/pysvn

拷贝

cp pysvn/__init__.py /usr/local/lib/python2.7/site-packages/pysvn
cp pysvn/_pysvn_2_7.so /usr/local/lib/python2.7/site-packages/pysvn

测试:

vim test.py
import pysvn

path="/data/trunk" 
client = pysvn.Client()
entry = client.info(path)
print entry.url                    #获取svn url
print client.log(entry.url)         #获取提交历史记录

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