上传和安装 conda 软件包#
要使用 conda 包,您必须使用相应的子域https://conda.anaconda.org
.从用户安装 conda 包travis
,例如,使用存储库 URLhttps://conda.anaconda.org/travis
.
上传 conda 包#
此示例 Anaconda.org 演示如何使用conda build
.
打开 Anaconda Prompt(macOS/Linux 上的终端)。
如有必要,请安装
anaconda-client
和conda-build
packages 的 Packages 中: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.org
anaconda upload
命令: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 Prompt(macOS/Linux 上的终端)。
由于 conda 知道如何与 Anaconda.org 交互,因此指定通道
sean
,例如,翻译成 https://anaconda.org/sean:conda config --add channels sean
您现在可以从 Sean 的 Anaconda.org 帐户安装公有 conda 软件包。尝试安装
testci
https://anaconda.org/sean/testci 的软件包:conda install testci
专用频道#
您可以从具有Token和标签的专用频道安装包:
# 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>
仅当频道是私有的时,才需要Token。
查找上传包的帮助#
您可以获取上传选项的完整列表,包括:
Package 频道。
标签。
对其他用户的可用性。
元数据。
要列出选项,请在 Anaconda Prompt(macOS/Linux 上的终端)中运行以下命令:
anaconda upload -h