pip从GitHub安装最新版本



我知道我可以用安装主分支

pip install git+https://github.com/USER/REPO

我也知道我可以安装一个特定的版本:

pip install git+https://github.com/USER/REPO@RELEASE

但是有没有办法安装最新版本(GitHub返回的版本https://github.com/USER/REPO/releases/latest)?我试过以下几种:

pip install git+https://github.com/USER/REPO@latest

但它失败了:

ERROR: Command errored out with exit status 1: git checkout -q latest

EDIT:这个问题不是Pip的重复。Pip没有安装最新版本的GitHub。后者是关于如何安装特定版本和/或从master分支安装,但不是从最新版本安装。

您可以使用github API。类似的东西

pip install "git+https://github.com/USER/REPO@$(curl -s https://api.github.com/repos/USER/REPO/releases/latest | jq -r ".tag_name")"

可能对你有用。如果你不想安装jq,这里有以下要点。

这可能是个坏主意,但你可以从GitHub的其余API获取最新的tarball url:

pip install 
$(python3 -c "import urllib.request, json, sys; 
u=json.loads(urllib.request.urlopen('https://api.github.com/repos/USER/REPO/releases/latest').read().decode()).get('tarball_url', False);
print(u) if u else sys.exit(1);")

使用命令替换$(..)将其放入pip install

应该有几个可用的选项,tarball_urlzipball_url以及pip应该能够下载这些选项。

相关内容

最新更新