开发者

How do I include and link pysvn with my python script?

开发者 https://www.devze.com 2023-03-22 22:20 出处:网络
I am working on a tool that uses pysvn. The previous writer of the tool included pysvn1.4 with it, so that it could be used on any machine that had python, without needing to download or install pysvn

I am working on a tool that uses pysvn. The previous writer of the tool included pysvn1.4 with it, so that it could be used on any machine that had python, without needing to download or install pysvn.

I would like to update the tool to use pysvn 1.6.

What I have done so far is installed pysvn1.6 on my machine, and moved the pysvn folder from my /usr/lib/python/site-package/pysvn directory into the directory of my source files, as it seems like that is how the previous author did it.

The current filesystem structure is as follows:

assorted.py files
assorted.pyc files
pysvn folder that includes old version of pysvn
    __init__.py
    __init__.pyc
    __pysvn.so

However, when I run the program, I get this error:

Traceback (most recent call last):
  File "slocmine.py", line 195, in ?
    sys.exit(main(sys.argv[0:]))
  File "slocmine.py", line 113, in main
    logjsonstr = pyslocd_svn_log.doit(svn, url)
  File "/users/users1/chindes/newsloc/svn/lib/python2.4/pyslocd_svn_log.py", line 114, in doit
    revision=pysvn_rev_head, depth=pysvn.depth.empty)
AttributeError: 'module' object has no attribute 'empty'

which originates from this (previously valid) code:

repoinfo = svn.info2(repoPathUrl,
    revision=pysvn_rev_head, depth=pysvn.depth.empty)

This suggests to me that I have not imported the module correctly, although I may be wrong.

Edit: It seems that I have version 1.6.2 of pysvn and version 1.6.1开发者_C百科5 of subversion which are apparently not compatible.


pysvn is definitely one of the stranger modules to build. This is how I have succesfully built and used pysvn. The environment variable TARG is set to the Python install directory.

cd ~
wget http://pysvn.barrys-emacs.org/source_kits/pysvn-1.7.5.tar.gz
tar zxvf pysvn-1.7.5.tar.gz
cd pysvn-1.7.5/Source
python setup.py backport
python setup.py configure --apr-inc-dir=/usr/include/apr-1
make
cd ../Tests
make
cd ../Sources
mkdir -p $TARG/lib/python2.7/site-packages/pysvn
cp pysvn/__init__.py $TARG/lib/python2.7/site-packages/pysvn
cp pysvn/_pysvn_2_7.so $TARG/lib/python2.7/site-packages/pysvn
cd ~

If you still have the old module available, why not try running it again, but add some debugging statements at the same spot in the file which raised the exception. You can use diff to find the right spot in the context since the code may have changed. On the other hand, you could just try the latest version (see script above) since it may be a library bug.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号