When I try to install gitpython via pip normally under python 2.7, it fails telling me python 3.x is required.
This particular script/process has worked until this morning.
$ sudo pip install gitpython
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting gitpython
Using cached https://www.piwheels.org/simple/gitpython/GitPython-2.1.12-py2.py3-none-any.whl
GitPython requires Python '>=3.0, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*' but the running Python is 2.7.16
I am running Python 2.7.16
$ python --version
Python 2.7.16
When I check the current documentation I see that Python 2.7 or newer is listed as a requirement. What am I missing?
Turns out the documentation was lagging, and Python 2.7 support was dropped in dac619e.
Assuming other folks are procrastinating as I am in getting to Python 3, I've created a fork of GitPython which is current with 2.1.12 and reverts only those changes which eliminated stated compatibility for Python 2.7. My fork is expected to remain static with the 0.2.12a release and otherwise even with mainline GitPython 2.1.12.
I've created a small batch file for folks who may want/need to automate the installation process of this fork:
#!/bin/bash
gitpython() {
local cwd repo pipList found
pipList=$(pip list)
found=$(grep -o "GitPython" <<< "$pipList" | wc -l)
repo="https://github.com/lbussy/GitPython.git"
if [ "$found" -eq "0" ]; then
echo -e "\nDownloading and installing GitPython for Python 2.7."
cwd=$(pwd)
git clone "$repo" "$HOME/git-python" &>/dev/null || die "$@"
cd "$HOME/git-python" || die "$@"
eval "python setup.py install" &>/dev/null || die "$@"
cd "$cwd" || die "$@"
rm -fr "$HOME/git-python"
echo -e "\nGitPython for Python 2.7 install complete."
else
echo -e "\nGitPython for Python 2.7 already installed."
fi
}
function die
{
local message=$1
[ -z "$message" ] && message="Died"
echo "${BASH_SOURCE[1]}: line ${BASH_LINENO[0]}: ${FUNCNAME[1]}: $message." >&2
exit 1
}
main() {
gitpython "$@"
}
main "$?" && exit 0
Installed in this manner, it is still able to be managed by pip going forward.