问题:从git repo分支安装pip

尝试pip安装仓库的特定分支。Google告诉我

点安装git + https://github.com/user/repo.git@branch

分支的名称是issue/34/oscar-0.6我这样做的,pip install https://github.com/tangentlabs/django-oscar-paypal.git@/issue/34/oscar-0.6但是它返回了404。

如何安装此分支?

Trying to pip install a repo’s specific branch. Google tells me to

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

The branch’s name is issue/34/oscar-0.6 so I did pip install https://github.com/tangentlabs/django-oscar-paypal.git@/issue/34/oscar-0.6 but its returning a 404.

How do I install this branch?


回答 0

在url前缀之前git+(请参阅VCS支持):

pip install git+https://github.com/tangentlabs/django-oscar-paypal.git@issue/34/oscar-0.6

并指定分支名称,但不要以/。开头。

Prepend the url prefix git+ (See VCS Support):

pip install git+https://github.com/tangentlabs/django-oscar-paypal.git@issue/34/oscar-0.6

And specify the branch name without the leading /.


回答 1

将git +与pip一起使用来克隆存储库可能非常慢(例如,使用https://github.com/django/django@stable/1.6.x进行测试,这将需要几分钟的时间)。我发现与GitHub和BitBucket兼容的最快的东西是:

pip install https://github.com/user/repository/archive/branch.zip

成为django master的对象:

pip install https://github.com/django/django/archive/master.zip

对于django stable / 1.7.x:

pip install https://github.com/django/django/archive/stable/1.7.x.zip

使用BitBucket,它具有相同的可预测模式:

pip install https://bitbucket.org/izi/django-admin-tools/get/default.zip

在这里,master分支通常被命名为default。这将使您的requirements.txt安装速度更快。

其他一些答案提到将要安装的软件包放入您的时所需的变体requirements.txt。请注意,这个档案的语法,领先-e和落后#egg=blah-blah不是必需的,你可以只是简单粘贴URL,所以你requirements.txt的样子:

https://github.com/user/repository/archive/branch.zip

Using pip with git+ to clone a repository can be extremely slow (test with https://github.com/django/django@stable/1.6.x for example, it will take a few minutes). The fastest thing I’ve found, which works with GitHub and BitBucket, is:

pip install https://github.com/user/repository/archive/branch.zip

which becomes for django master:

pip install https://github.com/django/django/archive/master.zip

for django stable/1.7.x:

pip install https://github.com/django/django/archive/stable/1.7.x.zip

With BitBucket it’s about the same predictable pattern:

pip install https://bitbucket.org/izi/django-admin-tools/get/default.zip

Here, the master branch is generally named default. This will make your requirements.txt installing much faster.

Some other answers mention variations required when placing the package to be installed into your requirements.txt. Note that with this archive syntax, the leading -e and trailing #egg=blah-blah are not required, and you can just simply paste the URL, so your requirements.txt looks like:

https://github.com/user/repository/archive/branch.zip

回答 2

使用ssh凭证从专用存储库安装的说明:

$ pip install git+ssh://git@github.com/myuser/foo.git@my_version

Instructions to install from private repo using ssh credentials:

$ pip install git+ssh://git@github.com/myuser/foo.git@my_version

回答 3

只是要添加一个额外的内容,如果要在pip文件中安装它,可以这样添加:

-e git+https://github.com/tangentlabs/django-oscar-paypal.git@issue/34/oscar-0.6#egg=django-oscar-paypal

但是它将被保存为鸡蛋。

Just to add an extra, if you want to install it in your pip file it can be added like this:

-e git+https://github.com/tangentlabs/django-oscar-paypal.git@issue/34/oscar-0.6#egg=django-oscar-paypal

It will be saved as an egg though.


回答 4

您使用了egg文件的安装过程。该程序支持安装了gitgit+httpgit+httpsgit+sshgit+gitgit+file。其中提到了一些。

可以使用分支,标签或哈希值进行安装是很好的。

@Steve_K指出,使用“ git +”安装可能会很慢,并建议通过zip文件进行安装:

pip install https://github.com/user/repository/archive/branch.zip

或者,建议您使用该.whl文件(如果存在)进行安装。

pip install https://github.com/user/repository/archive/branch.whl

这是一种非常新的格式,比egg文件更新。它需要wheel和setuptools> = 0.8软件包。您可以在这里找到更多。

You used the egg files install procedure. This procedure supports installing over git, git+http, git+https, git+ssh, git+git and git+file. Some of these are mentioned.

It’s good you can use branches, tags, or hashes to install.

@Steve_K noted it can be slow to install with “git+” and proposed installing via zip file:

pip install https://github.com/user/repository/archive/branch.zip

Alternatively, I suggest you may install using the .whl file if this exists.

pip install https://github.com/user/repository/archive/branch.whl

It’s pretty new format, newer than egg files. It requires wheel and setuptools>=0.8 packages. You can find more in here.


回答 5

这就像魅力一样工作:

pip3 install git+https://github.com/deepak1725/fabric8-analytics-worker.git@develop

哪里:

发展:分支

fabric8-analytics-worker.git:回购

deepak1725:用户

This worked like charm:

pip3 install git+https://github.com/deepak1725/fabric8-analytics-worker.git@develop

Where :

develop: Branch

fabric8-analytics-worker.git : Repo

deepak1725: user


声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。