上传和安装conda包#
要使用conda包,您必须使用相应的子域https://conda.anaconda.org
。例如,要从用户travis
安装conda包,请使用仓库URLhttps://conda.anaconda.org/travis
。
上传conda包#
这个例子展示了如何使用conda build
构建并上传一个conda包到Anaconda.org。
打开Anaconda提示符(在macOS/Linux上是终端)。
如有必要,通过运行以下命令安装
anaconda-client
和conda-build
包:conda install anaconda-client conda-build
选择您想要构建包的仓库。在这个例子中,我们使用了一个小的公共conda测试包:
# Replace <PACKAGE> with the package name git clone https://github.com/Anaconda-Platform/anaconda-client cd anaconda-client/<PACKAGE>/conda/
在这个目录中,有两个必需的文件,meta.yaml 和 build.sh。
macOS 和 Linux 系统是 Unix 系统。为 Unix 系统构建的包需要一个
build.sh
文件,为 Windows 构建的包需要一个bld.bat
文件,而为 Windows 和 Unix 系统构建的包则需要同时具备build.sh
文件和bld.bat
文件。所有包都需要一个meta.yaml
文件。要构建包,请关闭自动客户端上传,然后运行
conda build
命令:conda config --set anaconda_upload no conda build .
所有以这种方式构建的包都放置在Anaconda的
conda-bld
目录的子目录中。提示
您可以通过添加
--output
选项来检查生成的文件被放置在何处:conda build . --output
通过运行
anaconda upload
命令将测试包上传到Anaconda.org:anaconda login # Replace </PATH/TO/PACKAGE_NAME> with the correct file path and package name # Packages can be uploaded with .tar.bz2 or .conda compression formats anaconda upload </PATH/TO/PACKAGE_NAME>.tar.bz2 anaconda upload </PATH/TO/PACKAGE_NAME>.conda
有关.conda
格式的更多信息,请参阅使用.conda压缩格式。
有关conda整体构建框架的更多信息,请查看我们关于构建conda包的文章。
安装conda包#
您可以通过向您的conda配置添加频道来从Anaconda.org安装conda包。
公共频道#
打开Anaconda提示符(在macOS/Linux上是终端)。
因为conda知道如何与Anaconda.org交互,例如,指定通道
sean
,会转换为https://anaconda.org/sean:conda config --add channels sean
您现在可以从Sean的Anaconda.org账户安装公共conda包。尝试在https://anaconda.org/sean/testci安装
testci
包:conda install testci
私有频道#
您可以使用令牌和标签从私有渠道安装包:
# Replace <TOKEN> with the provided token
# Replace <CHANNEL> with a user channel
# Replace <LABEL_NAME> with the label name
# Replace <PACKAGE> with the name of the package you want to install
conda install --channel https://conda.anaconda.org/t/<TOKEN>/<CHANNEL>/label/<LABEL_NAME> <PACKAGE>
只有在频道是私有的情况下才需要令牌。
寻找上传包的帮助#
您可以获取上传选项的完整列表,包括:
包通道。
标签。
对其他用户的可用性。
元数据。
要列出选项,请在Anaconda Prompt(在macOS/Linux上为终端)中运行以下命令:
anaconda upload -h