Skip to content

Instantly share code, notes, and snippets.

@YellowSharkMT
Forked from olivier-m/pygit2.sh
Created March 12, 2014 16:53
Show Gist options
  • Save YellowSharkMT/9511208 to your computer and use it in GitHub Desktop.
Save YellowSharkMT/9511208 to your computer and use it in GitHub Desktop.
Install LibGit2 & PyGit2 to a Virtual Environment (venv must be activated before executing this script). Tested on Ubuntu 12.04.4.
#!/bin/sh
set -e
if [ "${VIRTUAL_ENV}" = "" ]; then
echo "Error: Not in a virtual env"
exit 1
fi
OS=$(uname -s)
set -u
SRC="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/_tmp"
TARGET=${VIRTUAL_ENV}
test -d ${SRC} || mkdir ${SRC}
cd ${SRC}
test -d libgit2 || git clone git://github.com/libgit2/libgit2.git
test -d pygit2 || git clone git://github.com/libgit2/pygit2.git
# Building libgit2
cd ${SRC}/libgit2
rm -rf build && mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=${TARGET}
cmake --build . --target install
# Building pygit2
cd ${SRC}/pygit2
LIBGIT2=${TARGET} python setup.py build_ext -R ${TARGET}/lib
python setup.py build
if [ "${OS}" = "Darwin" ]; then
install_name_tool -add_rpath ${TARGET}/lib $(find build -name '_pygit2.so')
install_name_tool -change libgit2.0.dylib @rpath/libgit2.0.dylib $(find build -name '_pygit2.so')
fi
python setup.py install
rm -rf ${SRC}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment