Reputation: 2365
I've got the pysvn module working great in Python 2.7.1, but it refuses to import in Python 3.2. It was installed with apt-get, so I figured it should work for both.
xxxxx:~$ python
Python 2.7.1+ (r271:86832, Sep 27 2012, 21:12:17)
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pysvn
>>> exit()
xxxxx:~$ python3
Python 3.2 (r32:88445, Oct 20 2012, 14:09:29)
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pysvn
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named pysvn
>>> exit()
edit: I've tried installing the 3.2 version through pip as well, here's the results
xxxxx:~$ sudo pip-3.2 install http://pysvn.barrys-emacs.org/source_kits/pysvn-1.7.8.tar.gz Downloading/unpacking http://pysvn.barrys-emacs.org/source_kits/pysvn-1.7.8.tar.gz
Downloading pysvn-1.7.8.tar.gz (347kB): 347kB downloaded
Running setup.py egg_info for package from http://pysvn.barrys-emacs.org/source_kits/pysvn-1.7.8.tar.gz
Cleaning up...
xxxxx:~$ python3
Python 3.2 (r32:88445, Oct 20 2012, 14:09:29)
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pysvn
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named pysvn
Upvotes: 2
Views: 2518
Reputation: 7112
python3-svn has been included into Ubuntu distribution only since 16.10 Yakkety. For those having older Ubuntu versions the information below may help.
This is how I built and installed pysvn for Python3 on Ubuntu 14.04 32-bit (and later on Ubuntu 16.04 64-bit):
sudo apt-get install libsvn-dev
. This will also install libapr1-dev.'../Import/pycxx-%d.%d.%d' % pycxx_version,
to '../Import/pycxx-6.2.8',
in the unpacked setup_configure.py file, so that it pointed to the unpacked pycxx directory. The --pycxx-dir
parameter not worked for me, hence the brute hardcoding. It may work for your case, though, so you may want to try it first (see the comment from @djangonaut).Run
python3 setup.py configure \
--svn-lib-dir=/usr/lib/i386-linux-gnu/ \
--apr-lib-dir=/usr/lib/i386-linux-gnu/ \
--verbose
The two additional dir parameters point to the directory where libsvn_client-1.so and libapr-1.so are. On 64-bit system it's gonna be /usr/lib/x86_64-linux-gnu/
.
make
to actually build the library.cd ../Tests
, make
.Installed the built library:
cd ../Source
sudo mkdir /usr/lib/python3/dist-packages/pysvn
sudo cp pysvn/__init__.py /usr/lib/python3/dist-packages/pysvn/
sudo cp pysvn/*.so /usr/lib/python3/dist-packages/pysvn/
Done.
This is mostly what is described in the INSTALL.html file from the pysvn sources, with some tweaks.
Upvotes: 3
Reputation: 554
Cannot add comment to leave a link, so put it here:
My way on linux:
Get sources from here
tar -zxf pysvn-1.9.10.tar.gz
apt-get install subversion libsvn1 libsvn-dev make g++
cd pysvn-1.9.10/Source
python setup.py configure --pycxx-dir=/pysvn-1.9.10/Import/pycxx-7.1.3/
make
Here i've got errors below:
Compile: /pysvn-1.9.10/Import/pycxx-7.1.3/Src/cxxsupport.cxx into cxxsupport.o
/pysvn-1.9.10/Import/pycxx-7.1.3/Src/cxxsupport.cxx:42:10: fatal error: Src/Python3/cxxsupport.cxx: No such file or directory
#include "Src/Python3/cxxsupport.cxx"
Compile: /pysvn-1.9.10/Import/pycxx-7.1.3/Src/cxxextensions.c into cxxextensions.o
/pysvn-1.9.10/Import/pycxx-7.1.3/Src/cxxextensions.c:42:10: fatal error: Src/Python3/cxxextensions.c: No such file or directory
#include "Src/Python3/cxxextensions.c"
It is needed to edit that files:
vi /pysvn-1.9.10/Import/pycxx-7.1.3/Src/cxxsupport.cxx
change #include "Src/Python3/cxxsupport.cxx" to
#include "Python3/cxxsupport.cxx"
and same on second file. Than make
again:
make clean && make
...
Compile: /code/pysvn-1.9.10/Import/pycxx-7.1.3/Src/cxxextensions.c into cxxextensions.o
Compile: /code/pysvn-1.9.10/Import/pycxx-7.1.3/Src/IndirectPythonInterface.cxx into IndirectPythonInterface.o
Compile: /code/pysvn-1.9.10/Import/pycxx-7.1.3/Src/cxx_exceptions.cxx into cxx_exceptions.o
Link pysvn/_pysvn_3_7.so
Then just copy it to the site-packages (change to yours directory):
mkdir /usr/local/lib/python3.7/site-packages/pysvn
cp /code/pysvn-1.9.10/Sources/pysvn/__init__.py /usr/local/lib/python3.7/site-packages/
cp /code/pysvn-1.9.10/Sources/pysvn/_pysvn*.so /usr/local/lib/python3.7/site-packages/
Upvotes: 1
Reputation: 4079
Ubuntu distributes the packages for Python 2 and Python 3 separately as different source code has to be used for the two major versions of Python. Typically the Python 3 package is prefixed with python3
instead of python
. No Python 3 pysvn package seems to exist in Ubuntu though pysvn supports Python 3.
Upvotes: -1