11

I am experiencing an odd problem every time I try the set-up of pygit2. Below is what I run and the error generated.

$ python3 setup.py install
running install
running build
running build_py
running build_ext
building '_pygit2' extension
/usr/bin/clang -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Os -w -pipe -march=native -Qunused-arguments -mmacosx-version-min=10.7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk -isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/include -L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/lib -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/include -I/usr/local/include -Iinclude -I/usr/local/Cellar/python3/3.2.3/include/python3.2m -c src/pygit2.c -o build/temp.macosx-10.7-x86_64-3.2/src/pygit2.o
In file included from src/pygit2.c:32:
include/pygit2/error.h:6:10: fatal error: 'git2.h' file not found
#include <git2.h>
         ^
1 error generated.
error: command '/usr/bin/clang' failed with exit status 1

I think I have successfully installed libgit2 (the build and make finished fine). Maybe it is a path issue? I have set LIBGIT2 environment variable to the src directory in the libgit2 folder. Is that the right place?

Seanny123
  • 8,776
  • 13
  • 68
  • 124
nzaccardi
  • 354
  • 1
  • 3
  • 11

4 Answers4

5

I never installed libgit2, but the following might help:

If your distro's repository contains libgit2, I'll advice to remove what you have compiled before and install libgit2 (binaries) and libgit2-dev (headers etc.) packages from the repo. This will place binaries and sources to the right directories.

Otherwise, try symlinking git2.h to /usr/local/include

dmytro
  • 1,293
  • 9
  • 21
3

Following step worked for me:

brew install libgit2 
2

It doesn't look like the LIBGIT2 variable took (could you show how you set the variable?) as the extra include directive uses /usr/local/include (which is the default).

The LIBGIT2 env var needs to be set to the prefix where the library was installed, typically /usr or /usr/local. It doesn't look like the library was installed to /usr/local as the compiler can't find it, so maybe you need export LIBGIT2=/usr before running setup.py.

Carlos Martín Nieto
  • 5,207
  • 1
  • 15
  • 16
0

You must be on macOS. Here is how I solved the problem:

brew install libgit2

If that isn't working because of Permission denied @ dir_s_mkdir, just run the following command

 sudo chown -R $(whoiam) $(brew --prefix)/*
Laurel
  • 5,965
  • 14
  • 31
  • 57