如果我理解正确,你的第一个问题是如果你已经有 setup.py,如何为 python 创建 conda 包。答案很常见,google一下就知道了。一个有用的参考:https ://docs.conda.io/projects/conda-build/en/latest/user-guide/tutorials/build-pkgs.html
非常简短(不一定是通用方式)是:
conda install conda-build
mkdir conda-recipe && pushd conda-recipe
echo "python setup.py install --single-version-externally-managed" > build.sh
touch meta.yaml # populate meta.yaml with proper config. Something to start with: https://docs.conda.io/projects/conda-build/en/latest/_downloads/d42b166defebcb482accb83c6edec8c9/meta.yaml
# with <CWD> being your current working directory.
popd && conda-build <CWD>/conda-recipe -croot build --output-folder <CWD>/dist/conda
对于第二个问题,咨询https://docs.conda.io/projects/conda-build/en/latest/resources/define-metadata.html#implicit-metapackages,一种方法是通过outputs
配置定义不同的子包。
您的情况的粗略配置:
package:
name: my_package
requirements:
host:
- python
run:
- my_package-the_subpackage1
- my_package-the_subpackage2
outputs:
- name: my_package.the_subpackage1
requirements:
- some-dep
script: some_build_script.sh
- name: my_package.the_subpackage2
requirements:
- some-other-dep
script: some_other_build_script.sh
这将创建 3 个包(2 个子包和一个依赖于子包的父元包。要安装它们,您可以执行以下操作:
conda install my_package
得到整件事或
conda install my_package.the_subpackage1
只安装第一个子包。