首页 > 解决方案 > 当使用 conda-build 构建 conda 包并且我的代码使用纯 python 库时,我需要在 meta.yaml 文件中的 build/host/run 中放入什么?

问题描述

假设我有一个使用 pandas、numpy 和 matplotlib 的 python 包。如果我查看他们的 meta.yaml 文件,我会在需求部分看到很多依赖项。例如像make这样的编译器。我是否还需要在我自己的 meta.yaml 包中命名来自 build 和 host 部分的所有这些依赖项,或者如果我只写以下内容就足够了:

Requirements:
Host: 
- python 3.8
Build: 
- python 3.8
Run:
- pandas
- numpy
- matplotlib

标签: pythonconda-build

解决方案


你可以只指定你的包的 python 依赖项。这是 conda-forge 的一个例子。

这是一个虚构的例子:

package:
  name: foobar
  version: 0.1

source:
  git_url: https://github.com/greenfish/foobar
  git_tag: v0.1

build:
  number: 0
  noarch: python
  script: {{ PYTHON }} -m pip install . --no-deps -vv

requirements:
  host:
    - python
    - pip
  run:
    - python
    - pandas >=1.0
    - numpy

test:
  imports:
    - foobar

about:
  home: http://greenfish-foobar.org
  license: BSD-3-Clause
  license_file: LICENSE.txt
  summary: This package is for all your foobar needs

推荐阅读