pip install gitpython 因 python 3.x 要求而失败

pip install gitpython fails with python 3.x requirement

当我尝试在 python 2.7 下正常通过 pip 安装 gitpython 时,它没有告诉我 python 3.x 是必需的。

这个特殊的 script/process 一直工作到今天早上。

 $ 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

我是运行Python2.7.16

$ python --version
Python 2.7.16

当我检查当前的 documentation 时,我发现 Python 2.7 或更高版本被列为要求。我错过了什么?

原来 documentation was lagging, and Python 2.7 support was dropped in dac619e

假设其他人像我一样拖延 Python 3,我创建了 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

我已经为可能 want/need 自动安装此分支的人创建了一个小批处理文件:

#!/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=
    [ -z "$message" ] && message="Died"
    echo "${BASH_SOURCE[1]}: line ${BASH_LINENO[0]}: ${FUNCNAME[1]}: $message." >&2
    exit 1
}

main() {
    gitpython "$@"
}

main "$?" && exit 0

以这种方式安装,它仍然可以通过 pip 进行管理。