pip install from git repo branch

前端 未结 6 2241
醉酒成梦
醉酒成梦 2020-11-22 02:58

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

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

The

相关标签:
6条回答
  • 2020-11-22 03:19

    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

    0 讨论(0)
  • 2020-11-22 03:31

    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.

    0 讨论(0)
  • 2020-11-22 03:34

    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
    
    0 讨论(0)
  • 2020-11-22 03:35

    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 /.

    0 讨论(0)
  • 2020-11-22 03:36

    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.

    0 讨论(0)
  • 2020-11-22 03:41

    Instructions to install from private repo using ssh credentials:

    $ pip install git+ssh://git@github.com/myuser/foo.git@my_version
    
    0 讨论(0)
提交回复
热议问题