首页 文章

从git repo分支安装pip

提问于
浏览
483

试图 pip 安装一个repo的特定分支 . 谷歌告诉我

pip install 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 .

我该如何安装这个分支?

4 回答

  • 239

    前缀为url前缀 git+ (参见VCS Support):

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

    并指定不带前导 / 的分支名称 .

  • 24

    使用带有git的pip克隆存储库可能非常慢(例如,使用_749741进行测试,需要几分钟) . 我发现的最快的东西是GitHub和BitBucket,它是:

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

    成为django大师:

    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
    

    这里,主分支通常被命名为default . 这将使您的requirements.txt安装更快 .

    其他一些答案提到了将要安装的软件包放入 requirements.txt 时所需的变化 . 请注意,使用此归档语法,不需要前导 -e 和尾随 #egg=blah-blah ,您只需粘贴URL,因此您的requirements.txt如下所示:

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

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

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

    它虽然会被保存为鸡蛋 .

  • 38

    使用 ssh credentials 从私人仓库安装的说明 .

    For usage:

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

    For development:

    $ git clone git@github.com/myuser/foo.git@my_version
    $ pip install --editable ./
    

相关问题