問題描述
我有幾個相互依賴的 python 項目.我對每個項目都有不同的發布版本,不同的項目可能依賴于特定項目的不同發布版本.我想在內部服務器上創建自己的 conda 存儲庫,我可以將這些項目的版本作為 conda 包推送,其他項目可以從那里安裝所需的版本.這可能嗎?如果有怎么辦?
I have a few python projects that are dependent on each other. I have different release versions for each project and different projects might be dependent on different release versions of a particular project. I would like to create my own conda repository on an internal server where I can push the releases of these projects as conda packages and the other projects can install the required version from there. Is this possible? If so how?
推薦答案
你可以使用 conda 自定義頻道 作為您的私人倉庫.基本步驟是使用conda build"創建一個 conda 包,然后將該包復制到您的自定義頻道(一個目錄)中,然后在該目錄上運行 conda index.然后,您可以使用conda install -c"從該頻道安裝軟件包.
You can use a conda custom channel as your private repo. The essential steps are to use "conda build" to create a conda package, then copy that package into your custom channel (a directory), and now run conda index on that directory. You can then install packages from this channel by using the "conda install -c ".
一個例子,更詳細地說,假設 linux-64:
An example, in more detail, let's assume linux-64:
- 創建頻道:
mkdir -p/tmp/my-conda-channel/linux-64
現在假設您有一個名為abc"的項目,其中包含 meta.yaml 和 build.sh,其中包含某個版本 X.現在您構建它:
- Create the channel:
mkdir -p /tmp/my-conda-channel/linux-64
Now assuming you have some project named "abc" with a meta.yaml and build.sh with some version X. Now you build it:
conda build abc
這將在您的 conda-bld 目錄中構建一個 tar.bz2 文件.例如:~/miniconda3/conda-bld/linux-64/abc-X-py35_0.tar.bz2.將該文件復制到您的頻道:
This will build a tar.bz2 file in your conda-bld directory. For example: ~/miniconda3/conda-bld/linux-64/abc-X-py35_0.tar.bz2. Copy that file to your channel:
cp ~/miniconda3/conda-bld/linux-64/abc-X-py35_0.tar.bz2/tmp/my-conda-channel/linux-64/
現在索引它:
conda 索引/tmp/my-conda-channel/linux-64/
您現在已將該軟件包上傳到您的自定義頻道.您可以通過以下方式將其安裝在任何 conda 環境中:
You've now uploaded that package to your custom channel. You can install it in any of your conda environments by doing:
conda install -c file://tmp/my-conda-channel/ abc=X
回想一下,X 是版本,因此,一旦您在頻道中放置了更多版本,您就可以安裝特定版本.
Where, recall, the X is the version so, once you've placed more versions in your channel, you can install specific versions.
如果您有一個項目依賴于abc"的 X 版本,那么我們只需將其添加到該項目的 meta.yaml 中.示例:
If you have a project that depends on the X version of "abc" then we simply add it to that projects meta.yaml. Example:
package:
name: some-other-project
version: 0.1
requirements:
build:
- abc X
...
創建此頻道后,最好將其添加到您的 .condarc 文件,以便自動搜索.例如:
Once you have created this channel it's probably a good idea to add it to your .condarc file so that it will get automatically searched. For example:
channels:
- file://tmp/my-conda-channel/
- defaults
這篇關于如何托管我自己的私有 conda 存儲庫?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!