Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I'm trying to install libgit2 on OSX, and I keep running into issues. Ultimately I'm trying to get pygit2 installed, which fails because it doesn't recognize libgit2 being installed.

libgit2's instructions are the following according to their github page:

$ mkdir build && cd build
$ cmake .. 
$ cmake --build .

They then say that in order to build the universal binary for OSX, you can use the following when configuring:

-DCMAKE_OSX_ARCHITECTURES="i386;x86_64"

To me that means do the following:

$ mkdir build && cd build
$ cmake .. -DCMAKE_OSX_ARCHITECTURES="i386;x86_64"
$ cmake --build .

However, that doesn't appear to work. I still have pygit2 bomb out when I try and install it through pip.

$ pip install pygit2

This is the error I get:

In file included from src/pygit2.c:32:

include/pygit2/types.h:60: error: expected specifier-qualifier-list before ‘git_diff_list’

src/pygit2.c: In function ‘moduleinit’:

src/pygit2.c:231: error: ‘GIT_STATUS_CURRENT’ undeclared (first use in this function)

src/pygit2.c:231: error: (Each undeclared identifier is reported only once

src/pygit2.c:231: error: for each function it appears in.)

*snip*

Command /Users/HOMEDIR/VIRTUALENVPATH/bin/python -c "import setuptools;__file__='/Users/HOMEDIR/VIRTUALENVPATH/build/pygit2/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/3v/7q7kyp3x4js3j0hvhmfkt6fw0000gn/T/pip-Sbr_Q3-record/install-record.txt --single-version-externally-managed --install-headers /Users/HOMEDIR/VIRTUALENVPATH/bin/../include/site/python2.7 failed with error code 1 in /Users/HOMEDIR/VIRTUALENVPATH/build/pygit2

Has anyone been through this rodeo before and can help out?

share|improve this question
add comment

1 Answer 1

up vote 4 down vote accepted

I coul not install pygit2 using pip. However, it worked fine using the latest version available on Github:

$ git clone git://github.com/libgit2/pygit2.git
$ cd pygit2
$ python setup.py install

The problem here I think is that you're trying to use a two month old pygit2 release with the cutting edge version of libgit2. If using pip is an absolute necessity, you should try installing an older version of libgit2 too (like this one).

You only have to use the -DCMAKE_OSX_ARCHITECTURES="i386;x86_64" flag if you're targeting "old" Macs without 64 bits capable processors (before Core 2 x, with Snow Leopard or older).

You should also run

$ cmake --build . --target install

after your

$ cmake --build .

command. Without this, libgit2 headers (*.h) and libraries (*.dylib) will not be installed in your /usr/local/{include,lib} directories and will not be available to others softwares (hence your compilations errors).

share|improve this answer
    
This answer is a beautiful thing. Thanks man. –  hisnameisjimmy Nov 26 '12 at 19:40
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.