How to install libgit2/pygit2 into virtualenv? (Ubuntu)

1.8k Views Asked by At

I have tried dulwich, and GitPython - neither of which seem mature. Now I am trying to install libgit2/pygit2. I have successfully installed them into the host packages environment, but now I need to get them installed in the virtualenv of the app I am building.

Python 2.7.3 (default, Sep 26 2013, 20:03:06)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygit2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/pygit2/__init__.py", line 32, in <module>
    import _pygit2
ImportError: libgit2.so.0: cannot open shared object file: No such file or directory
>>>

As you can see the current issue seems to be that the globally installed libgit2.so.0 cannot be found from within the virtualenv. Fair enough, that is what virtualenv is about after all,, sandboxing. So how do I go about linking/symlinking/building a version/copy of the libgit2.so for the virtualenv ?

1

There are 1 best solutions below

1
On

I found the following script in a Gist that - when run while logged into a virtualenv -- will install the current libgit2/pygit2 together there in the venv.

https://gist.github.com/olivier-m/5755638

One note of caution, update the version numbers for both libraries to the same most recent version ( 0.20.0 at this time of writing ).