Version 2 (modified by 12 years ago) ( diff ) | ,
---|
Improving performance for Trac's git support
Using python bindings for git rather than the git command-line
This could be an alternative backend that would avoid the cost of spawning git executables and parsing their standard output.
The trade-offs could be the following, bindings vs. command-line:
- (+) faster (but how much?)
- (?) robustness
- (+) no pipe handling and dangling processes (is this still problematic?)
- (-) crashes?
- (-) memory usage (risk of memory leaks?)
Peter Stuge started a conversion of the backend, see his early work in his pygit2wip branch.
Note that the final form of the support for these bindings will have to come as a Trac plugin, much like TracMercurial is, as pygit2
is licensed under the GPL.
Installation
First you'll need to install the git bindings for Python:
And for building libgit2
, you'll need cmake.
Windows build instructions, for Python 2.6 or 2.7 with VC9
$ git clone https://github.com/libgit2/libgit2.git $ cd libgit2
Now set the LIBGIT2
environment variable to the place you want to install libgit2
(this environment variable is expected to be set by pygit2
):
$ export LIBGIT2=C:/Dev/libgit2-vc9
if you live in a msysgit bash shell, or:
> set LIBGIT2=C:/Dev/libgit2-vc9
if you're forced to use a cmd.exe…
Then download the libgit2-msvc9.diff patch, apply it, build and install libgit2
like this:
$ patch -p1 < libgit2-msvc9.diff $ mkdir build-msvc9 $ cd build-msvc9 $ cmake -G "Visual Studio 9 2008" .. -DCMAKE_INSTALL_PREFIX=$LIBGIT2 -- Check for working C compiler using: Visual Studio 9 2008 -- Check for working C compiler using: Visual Studio 9 2008 -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Found PythonInterp: C:/Dev/Python272/python.exe (found version "2.7.2") -- Configuring done -- Generating done -- Build files have been written to: C:/Workspace/src/git/libgit2/build-msvc9 $ cmake --config Release --build . --target install
(replace $LIBGIT2
with %LIBGIT2%
if you're in a cmd.exe
)
At this point you're ready to build the bindings themselves. First download pygit2-msvc9.diff, then:
$ git clone https://github.com/libgit2/pygit2 $ cd pygit2 $ patch -p1 < pygit2-msvc9.diff $ ls $LIBGIT2 bin include lib $ python setup.py install
Note about the tests:
$ python setup.py test --args\ -v
with 0.17, I get one error (test_read_tree
) and … several crashes (test_new_repo
, test_write
, test_status
, and nearly all tests in test_diff.py
).
Attachments (2)
-
libgit2-msvc9.diff
(1.3 KB
) - added by 12 years ago.
patch for libgit2, needed when building with msvc9 so that pygit2 can link to it (see #741)
-
pygit2-msvc9.diff
(1.7 KB
) - added by 12 years ago.
patch for pygit2, needed to build with msvc9 (see #60)
Download all attachments as: .zip