简体   繁体   English

将git分支作为参数传递给conda environment.yml以获取pip包

[英]Pass git branch as parameter to conda environment.yml for pip package

For my Python project I am using a conda environment file to ensure a similar environment for all developers and deployment. 对于我的Python项目,我正在使用conda环境文件来确保所有开发人员和部署都使用类似的环境。 My project requires a specific version of a private repo to be included in the environment. 我的项目要求环境中包含特定版本的专用存储库。 For deployment on my development server, the package should be installed from the development branch of the repo. 为了在我的开发服务器上进行部署,应该从仓库的开发分支中安装该软件包。 For deployment on production, the master branch should be used. 为了在生产上进行部署,应使用master分支。 Since they run on the same server, the environments need to have different names as well. 由于它们在同一服务器上运行,因此环境也需要具有不同的名称。

So what I want: 所以我想要的是:

  • environment named 'master_env' which installs private package from @master branch 名为“ master_env”的环境,该环境从@master分支安装私有软件包
  • environment named 'development_env' which installs private package from @development branch 名为“ development_env”的环境,该环境从@development分支安装私有软件包

Given the following environment file, is there I way to achieve that? 给定以下环境文件,我有办法实现吗? I figured if I could be passign arguments/variables when installing this environment that would be a solution, but I can't find if/how that works. 我确定在安装此环境时是否可以通过passign参数/变量,这是一个解决方案,但是我找不到它是否/如何工作。

Environment.yml: Environment.yml:

name: conda_env
channels:
  - conda-forge
dependencies:
  - python==3.6.4
  - pandas==0.22.0
  - pip:
    - git+https://url.com/private_repo.git@development

What is the best practice in this situation? 在这种情况下,最佳做法是什么?

git+ https://url.com/private_repo.git@development . git + https://url.com/private_repo.git@development

The format mentioned in your question is one of the pip standards for VCS. 您的问题中提到的格式是VCS的pip标准之一。 It will work for installing from a specific branch of a project. 它可以从项目的特定分支进行安装。 You can see the other standard formats here: https://pip.pypa.io/en/stable/reference/pip_install/#git 您可以在此处查看其他标准格式: https : //pip.pypa.io/en/stable/reference/pip_install/#git

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM