Pysvn使用手记--安装篇

PySVN提供了Python语言环境下进行Subversion操作的语言支持,比官方的python语言绑定有更好的API。项目包括了pysvn 和WorkBench ,这两个简单的区分是workbench是带有GUI的功能更加强大的工具。pysvn的目的就是为了方便我们这些pythoner,能够使用python去操作subversion。由于对workbench的需求不是很大,所以这里主要介绍pysvn Extension。 目前pysvn Extension的版本号是1.7.5,能够在windows,unix/linux,mac os上,windows和MAC OS上提供了安装包,在unix/linux上可以使用: Ubuntu
  • sudo apt-get install python-svn
  • sudo apt-get install svn-workbench
Fedora packages pysvn
  • yum install pysvn
另外就是可以选择编译源码安装。windows和unix/linux(mac os)上都可以选择自己编译源码的方式,这里可以参考提供的安装文档的方式进行:

Prerequisites

To build pysvn you will require:
  • Python 2.2 or later with these options:
    • Python runtime package
    • Python development package
    • Python pyexpat package
  • subversion 1.5.x or 1.6.x with these options:
    • Subversion client package
    • Subversion development package
  • PyCXX V6.2.2 to build against Python 2 or Python 3 which is included in the pysvn source kit.
Some distributions will split python and subversion into more the one package. You will need to find all the packages that give you the options listed above.

Building on win32

These instructions assume you have Microsoft Visual C++ 6.0 to compile the code and INNO 4.0.10 to create the installation kit. Note: You must build with MSVC 6.0 as python 2.3 and earlier was built with that version. Note: You must build with MSVC 2003.NET for python 2.4 or Python 2.5. Note: You must build with MSVC 2008 (9.0) for Python 2.6 or later and python 3.0 or later.
  1. Build subversion (tested with SVN 1.5.6 and svn 1.6.15)
  2. Fetch and expand the pysvn source code into extdir
  3. Expand pycxx-6.2.1.tar.gz into extdir\Import if not using a source kit
  4. Edit Builder\builder_custom_init.cmd to match the locations of the sources.
  5. cd Builder
  6. builder_custom_init.cmd
  7. nmake -f win32.mak build
To install the built kit
  1. Uninstall any previous kit (control panel's Add/Remove programs)
  2. nmake -f win32.mak install

Building on unix and Mac OS X systems.

  1. Install subversion. When installing from packages you will need to install the devel packages as well. For example on Fedora/Redhat subversion-devel, apr-devel, apr-util-devel and their dependancies.
  2. Get the pysvn source code
  3. For Python 2 or Python 3 builds: tar xzf pycxx-6.2.1.tar.gz into extdir/Import if not using a source kit
  4. cd Source
  5. For Python 2 builds: backport the PySVN code using python setup.py backport
  6. Create the Makefile using python setup.py configure
  7. make
  8. cd Tests
  9. Test pysvn by running make
Install pysvn by copying the following from Extension/Source to python site-specific directory.
  • mkdir python-libdir/site-packages/pysvn
  • cp pysvn/__init__.py python-libdir/site-packages/pysvn
  • cp pysvn/_pysvn*.so python-libdir/site-packages/pysvn
       

问题:centos上的python以及subversion的版本太老,这样会造成编译pysvn的问题,经常会出现某些动态文件以及.h文件不存在的信息。