Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/353.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在特定日期从github进行pip安装_Python_Git_Github - Fatal编程技术网

Python 如何在特定日期从github进行pip安装

Python 如何在特定日期从github进行pip安装,python,git,github,Python,Git,Github,我需要从git hub使用pip进行安装,但希望从5月4日开始使用存储库。有人能帮我吗 例如,如果我想pip安装repo的特定分支,我可以使用以下命令: pip install https://github.com/user/repo.git@branch 但是除了分支机构名称之外,不知道如何按日期获取它?您可以克隆repo,在本地签出所需的日期,并在开发模式下安装pip: git clone https://github.com/user/repo.git cd repo git check

我需要从git hub使用pip进行安装,但希望从5月4日开始使用存储库。有人能帮我吗

例如,如果我想
pip安装
repo的特定分支,我可以使用以下命令:

pip install https://github.com/user/repo.git@branch

但是除了分支机构名称之外,不知道如何按日期获取它?

您可以克隆repo,在本地签出所需的日期,并在开发模式下安装pip:

git clone https://github.com/user/repo.git
cd repo
git checkout `git rev-list -n 1 --before="2016-03-03 13:37" master`
pip install -e

那么,您可以使用所需的提交来替换
。我刚和bpython核对过:

$ pip install --upgrade --user git+https://github.com/bpython/bpython.git@f2014dbae31313571cc9c26f51a14f4fda09d138
Collecting git+https://github.com/bpython/bpython.git@f2014dbae31313571cc9c26f51a14f4fda09d138
  Cloning https://github.com/bpython/bpython.git (to f2014dbae31313571cc9c26f51a14f4fda09d138) to /tmp/.private/alex/pip-tQcJmV-build
  Could not find a tag or branch 'f2014dbae31313571cc9c26f51a14f4fda09d138', assuming commit.
...
另一个问题是如何获得给定日期的提交

第一个选项是打开浏览器,找到适当的提交,并手动为
pip安装
形成适当的URL。实际上,我在上面的例子中使用了这种方法

但你可能想让事情自动化。我会从github制作给定回购协议的本地浅拷贝:

git clone --depth 10 --single-branch --branch master https://github.com/bpython/bpython.git
(仅从
bpython
official repo的主分支机构获得最后10次承诺)

然后,确定哪些提交满足日期限制:

COMMITID=$(git rev-list -n 1 --before '2016/04/07 16:36:15 2016 +0000' HEAD)
然后,在
pip install
命令中使用提交id:

pip install --upgrade --user git+file:///tmp/.private/alex/bpython@${COMMITID}

作弊!:)但是,肯定+1我会诚实地依赖于指定提交的sha的本机pip机制。有什么区别?你必须克隆回购协议才能获得日期