pysvn安裝

系統環境

# 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


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章