1{ stdenv
2, lib
3, buildPythonPackage
4, fetchurl
5, isPy3k
6, python
7, apr
8, aprutil
9, bash
10, e2fsprogs
11, expat
12, gcc
13, glibcLocales
14, neon
15, openssl
16, pycxx
17, subversion
18}:
19
20buildPythonPackage rec {
21 pname = "pysvn";
22 version = "1.9.12";
23 format = "other";
24
25 src = fetchurl {
26 url = "https://pysvn.barrys-emacs.org/source_kits/${pname}-${version}.tar.gz";
27 sha256 = "sRPa4wNyjDmGdF1gTOgLS0pnrdyZwkkH4/9UCdh/R9Q=";
28 };
29
30 buildInputs = [ bash subversion apr aprutil expat neon openssl ]
31 ++ lib.optionals stdenv.isLinux [ e2fsprogs ]
32 ++ lib.optionals stdenv.isDarwin [ gcc ];
33
34 postPatch = ''
35 sed -i "117s|append(|insert(0, |" Tests/benchmark_diff.py
36 '';
37
38 preConfigure = ''
39 cd Source
40 ${python.interpreter} setup.py backport
41 ${python.interpreter} setup.py configure \
42 --apr-inc-dir=${apr.dev}/include \
43 --apu-inc-dir=${aprutil.dev}/include \
44 --pycxx-dir=${pycxx.dev}/include \
45 --svn-inc-dir=${subversion.dev}/include/subversion-1 \
46 --pycxx-src-dir=${pycxx.dev}/src \
47 --apr-lib-dir=${apr.out}/lib \
48 --svn-lib-dir=${subversion.out}/lib \
49 --svn-bin-dir=${subversion.out}/bin
50 '' + (lib.optionalString (stdenv.isDarwin && !isPy3k) ''
51 sed -i -e 's|libpython2.7.dylib|lib/libpython2.7.dylib|' Makefile
52 '');
53
54 checkInputs = [ glibcLocales ];
55 checkPhase = ''
56 runHook preCheck
57
58 # It is not only shebangs, some tests also write scripts dynamically
59 # so it is easier to simply search and replace
60 sed -i "s|/bin/bash|${bash}/bin/bash|" ../Tests/test-*.sh
61 make -C ../Tests
62
63 ${python.interpreter} -c "import pysvn"
64
65 runHook postCheck
66 '';
67
68 installPhase = ''
69 dest=$(toPythonPath $out)/pysvn
70 mkdir -p $dest
71 cp pysvn/__init__.py $dest/
72 cp pysvn/_pysvn*.so $dest/
73 mkdir -p $out/share/doc
74 mv -v ../Docs $out/share/doc/pysvn-${version}
75 rm -v $out/share/doc/pysvn-${version}/generate_cpp_docs_from_html_docs.py
76 '';
77
78 meta = with lib; {
79 description = "Python bindings for Subversion";
80 homepage = "http://pysvn.tigris.org/";
81 license = licenses.asl20;
82 # g++: command not found
83 broken = stdenv.isDarwin;
84 };
85}