Solved

Installing SWIG python bindings for subversion, trac

Posted on 2008-10-02
14
6,453 Views
Last Modified: 2013-12-06

I have a CentOS 5 machine running Apache 2.2, python 2.5, subversion 1.5.2, and trac 0.11. Originally, the machine came with Python 2.4 and SVN 1.4.2 with the SWIG python bindings:

  python2.4 -c "import svn.repos, sys; print svn.repos.__file__; print sys.version"
  /usr/lib/python2.4/site-packages/svn/repos.pyc
  2.4.3 (#1, Mar 14 2007, 18:51:08)
  [GCC 4.1.1 20070105 (Red Hat 4.1.1-52)]

After installing Python 2.5 and SVN 1.5.2, I have lost the SWIG python bindings:

  python -c "import svn.repos, sys; print svn.repos.__file__; print sys.version"
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
  ImportError: No module named svn.repos

I don't understand this. I installed python 2.5 first, then SVN 1.5.2. Why would SVN put the python bindings into the python 2.4 site-packages area?

  /usr/lib/python2.4/site-packages/libsvn
  /usr/lib/python2.4/site-packages/svn

Trac requires the SWIG python bindings to work. I need to simple, step-by-step instructions on how to get SWIG python bindings installed into the installed python 2.5 site-packages area for an installed subversion package.

Bonus point for any advice on getting mod_python and mod_dav_svn installed as well. I've actually downloaded and configured mod_python for python 2.5, I just haven't run 'make install' yet because I don't know if it's going to mess with my running apache or not.



0
Comment
Question by:rsgalloway
  • 7
  • 6
14 Comments
 
LVL 4

Expert Comment

by:urgoll
Comment Utility
Hello,
the location of the installed swig bindings is determined by swig, not subversion. Most likely, the swig you have was compiled against python 2.4, and therefore is configured to put the bindings into the python 2.4 directory.

After upgrading python to 2.5, you may have to upgrade (or at least recompile) swig to match your new python setup.

I have very little experience with mod_python, but mod_dav_svn is fairly easy. All you have to do when compiling subversion is add this to the ./configure line:
  --with-apxs
assuming the apache apxs binary is in your path.
Then when you 'make install' subversion, the mod_dav_svn will be copied to apache's module directory.
0
 

Author Comment

by:rsgalloway
Comment Utility
Ok, I upgraded SWIG to 1.3.35, but all it did was put a bunch of stuff here:

    /usr/share/swig/1.3.35/python

What does that mean? Do I need to download and install the source tarball and do a custom configuration instead? Then run a make swig-py? What are the specific steps to create the SVN python bindings?

0
 
LVL 4

Expert Comment

by:urgoll
Comment Utility
Of all the software we're talking about (apache, swig, python, svn) which came with CentOS and which did you compile and install manually ?

Did you update swig using yum (centos package) or manually ?
0
 

Author Comment

by:rsgalloway
Comment Utility
Apache 2.2, SWIG, Python 2.4 and SVN 1.4.2 came with the CentOS 5 box.

I installed httpd-devel, SVN 1.5.2 and SWIG 1.3.3 using webmin's rpm package installer, and mod_python, trac 0.11 and Python 2.5 I compiled manually.

yum is offline after I installed Python 2.5. I don't know how to get that working again either, but that's a separate issue.
0
 
LVL 4

Accepted Solution

by:
urgoll earned 250 total points
Comment Utility
You said: I installed httpd-devel, SVN 1.5.2 and SWIG 1.3.3 using webmin's rpm package installer

Are those RPM from CentOS or from a 3rd party ? The issue here is swig. Swig needs to be compiled against a specific version of python. As long as you are using swig as provided by CentOS5, it is compiled against python 2.4, since this is what CentOS5 provides.

Since you compiled python 2.5 manually, you also need to compile swig manually and tel it where to find python (if 2.5 is not /usr/bin/python).

After that is done, you also need to compile svn 1.5 yourself, since it needs to be compiled against your new swig and python libraries.

Hope this helps.
0
 

Author Comment

by:rsgalloway
Comment Utility
Okay, I was afraid of something like that.

The httpd-devel RPM (and associated dependencies) are from CentOS, I believe. The rest are not.

So basically, I need to

1) recompile SWIG with some option like, --with-python=/path/to/python
2) recompile SVN (hoping it will pick up the new SWIG stuff)

Can I do that using the RPMs? Or do I need to download the sources for both of those? Won't it complain that I already have SVN and SWIG installed? Is there a way to UNinstall packages like SVN/SWIG?
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 4

Expert Comment

by:urgoll
Comment Utility
You can remove packages easily, using the rpm command. For example, to remove the SWIG package, you would do:
#  rpm -e swig

Assuming that your python 2.5 is now the default /usr/bin/pyhon on your system, you can do this with RPMs. All you need to do is get the source rpm file (.src.rpm) from the CentOS mirror, and recompile it. This is done with:
#  rpmbuild -bb package.src.rpm
(replace 'package.src.rpm' with the actual source package file name)
It is possible that some -devel packages will be missing, just install those.
The rpmbuild command will compile the package and place it in the /usr/src/redhat/i386 directory (or similar, depending on your computer's architcture). You can then use 'rpm -i package.rpm' to installl it.

So, still assuming that your python 2.5 is the default, you can do:
* remove original svn package
* remove original SWIG package
* rebuild SWIG from source RPM
* install new SWIG rpm
* rebuild SVN from source RPM
* install new SVN rpms

If your python 2.5 is NOT the default /usr/bin/python, then you cannot use the source rpm, as you need to provide the argument '--with-python=/path/to/python' on the ./configure command when building SWIG. However, you should still be able to use the source RPM for SVN.

One BIG not of caution here: you need to keep track of the packages you rebuild, as you must not apply any CentOS-provided upgrade for those packages, as they would revert to using python 2.4 and would break your TRAC installation.

Please let me know how it goes and if you have any further problem.

Regards,
Christophe
0
 

Author Comment

by:rsgalloway
Comment Utility
Making progress. I removed the SWIG and SVN packages, downloaded the source tarballs for each, and installed them.

Output from SWIG config:

checking for Python prefix... /usr/local
checking for Python exec-prefix... /usr/local
checking for Python version... python2.5
checking for Python lib dir... lib
checking for Python header files... -I/usr/local/include/python2.5 -I/usr/local/lib/python2.5/config
checking for Python library... /usr/local/lib/python2.5/config
and the make install put a bunch of stuff here:

Installing /usr/local/share/swig/1.3.36/python/
The SVN config did find python 2.5 and the SWIG bindings:

checking for python... /usr/local/bin/python
...
configure: Configuring python swig binding
checking for Python includes... -I/usr/local/include/python2.5
checking for compiling Python extensions... gcc -pthread -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC
checking for linking Python extensions... gcc -pthread -shared
checking for linking Python libraries...
although there was this:

checking swig version... 1.3.36
configure: WARNING: Detected SWIG version 1.3.36
configure: WARNING: Subversion requires 1.3.24 or later, and is known to work
configure: WARNING: with versions up to 1.3.31
However, the words python or swig did not appear once in the SVN make install output, which seems odd. I would have expected to see something about installing into the python2.5 site-packages area. Also, I still can't import the svn package in python 2.5.

Is there another package I need to download and install? Or, did I leave something out of the SVN ./configure?



0
 

Author Comment

by:rsgalloway
Comment Utility
Update:

I ran these three commands in the SVN source folder:

make swig-py
make check-swig-py
make install-swig-py
and they all completed without error, which is great. I didn't know anything about these commands until a google search. Anyway, it put the SVN python bindings here:

/usr/local/lib/svn-python/libsvn/
/usr/local/lib/svn-python/svn/
which is not where I wanted them, but I guess there are options for that using LIBDIR or LD_LIBRARY_PATH or something. Not really sure how to use those, so I just made a sym link in the python 2.5 site-packages area to the svn libs and it works. I can import svn in python 2.5 now. Unfortunately, it still doens't fix my trac problem. I'm still getting this error:

Unsupported version control system "svn". Check that the Python support libraries for "svn" are correctly installed.
Do I need to recompile trac or something now? Anyone know?

0
 
LVL 4

Expert Comment

by:urgoll
Comment Utility
Are you using TRAC as a CGI or with mod_python ? You need to make sure that TRAC is using python 2.5, not 2.4. If using as CGI, look at the first line of cgi-bin/trac.cgi. If using mod_python, it depends on the version of python mod_python was compiled against.

I haven't used TRAC in a while, but you may have to re-install it. During the installation, the python code is bytecode-compiled, which may or may not be compatible from 2.4 to 2.5, and it probably stores properties such as the location of python.

Just to let you know I'll be out of network access tonight and tomorrow, but will look up this thread tomorrow night see if you've made progress and if I can conjure up some more advise.

Have a great week-end,
Christophe
0
 

Author Comment

by:rsgalloway
Comment Utility
Thanks for the information.

I'm actually running trac with the trac server: tracd, at least until I reinstall mod_python. I have recompiled mod_python with python 2.5, but have not run the make install yet because I was nervous it might break something. I have live sites deployed and no dev/test server. So the tracd server is using python2.5, no doubt.

It's funny because I set up a new trac project and svn repo and that syncs up fine. I just get that error on an existing trac project, so maybe it's a trac project config issue. I will keep playing with it. Thanks for the help, urgoll.
0
 

Author Comment

by:rsgalloway
Comment Utility
Ok, got it! Finally. I just needed to restart the trac daemon to pick up the python svn bindings. Makes sense. Thanks!
0
 
LVL 4

Expert Comment

by:urgoll
Comment Utility
Good, I'm glad it works for you.

Regards,
Christophe
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Here I am using Python IDLE(GUI) to write a simple program and save it, so that we can just execute it in future. Because when we write any program and exit from Python then program that we have written will be lost. So for not losing our program we…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now