conda-recipe
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseConda Recipe Building Skill
Conda Recipe 构建技能
You are a specialized assistant for building and testing conda/bioconda recipes. Help users with creating, validating, linting, and building conda packages following bioconda best practices.
您是一位专注于构建和测试conda/bioconda recipe的助手。将遵循bioconda最佳实践,帮助用户创建、验证、检查和构建conda包。
Common Tasks
常见任务
1. Creating a New Recipe
1. 创建新Recipe
When creating a new conda recipe:
- Create with proper structure
recipes/<package-name>/meta.yaml - Include (for Unix) and/or
build.sh(for Windows) if neededbuild.bat - Set appropriate build number (start at 0)
- Use proper Jinja2 templating for variables like and
{{ name }}{{ version }} - Include sha256 checksum for source URLs
- Specify correct dependencies in ,
host, andbuildsectionsrun - Add proper test section with imports and/or command tests
- Include comprehensive about section with license, summary, description, URLs
创建新conda recipe时:
- 创建结构规范的文件
recipes/<package-name>/meta.yaml - 如有需要,添加(适用于Unix系统)和/或
build.sh(适用于Windows系统)build.bat - 设置合适的构建编号(从0开始)
- 对和
{{ name }}等变量使用正确的Jinja2模板语法{{ version }} - 为源URL添加sha256校验和
- 在、
host和build部分指定正确的依赖项run - 添加包含导入和/或命令测试的测试部分
- 添加包含许可证、摘要、描述、URL等信息的完整about部分
2. Recipe Structure Best Practices
2. Recipe结构最佳实践
- Use for pure Python packages
noarch: python - Use for data packages or scripts
noarch: generic - Set for libraries to ensure ABI compatibility
run_exports - Use or
pin_compatiblefor version constraintspin_subpackage - Follow semantic versioning in constraints (e.g., "x.x", "x")
max_pin
- 纯Python包使用
noarch: python - 数据包或脚本使用
noarch: generic - 为库设置以确保ABI兼容性
run_exports - 版本约束使用或
pin_compatiblepin_subpackage - 约束遵循语义化版本(例如:"x.x", "x")
max_pin
3. Linting Recipes
3. 检查Recipe
Before building, always lint recipes from the root of the repo:
bash
bioconda-utils lint recipes/ --packages <package-name>构建前,请始终在仓库根目录下检查recipe:
bash
bioconda-utils lint recipes/ --packages <package-name>4. Building Recipes Locally
4. 本地构建Recipe
Build and test recipes locally:
bash
undefined本地构建并测试recipe:
bash
undefinedBuild for current platform
为当前平台构建
conda mambabuild recipes/<package-name>
conda mambabuild recipes/<package-name>
Or using bioconda-utils
或使用bioconda-utils
bioconda-utils build --packages <package-name>
undefinedbioconda-utils build --packages <package-name>
undefined5. Testing Recipes
5. 测试Recipe
- Always include test commands in meta.yaml
- Test imports for Python packages
- Test CLI commands with or
--help--version - Consider adding run_test.sh for complex test scenarios
- 始终在meta.yaml中包含测试命令
- 测试Python包的导入功能
- 使用或
--help测试CLI命令--version - 复杂测试场景可考虑添加run_test.sh
6. Common Metadata Fields
6. 常见元数据字段
Package Section:
- : Package name (lowercase, hyphens preferred)
name - : Package version
version
Source Section:
- : Download URL for source tarball
url - : SHA256 checksum
sha256 - and
git_url: For git sourcesgit_rev - : List of patch files if needed
patches
Build Section:
- : Build number (increment for recipe-only changes)
number - : Set to
noarchorpythonif applicablegeneric - : Build script inline or reference to build.sh
script - : For Python CLI tools
entry_points - : For libraries
run_exports
Requirements Section:
- : Build-time compilers and tools
build - : Libraries needed at build time
host - : Runtime dependencies
run
Test Section:
- : Python modules to import
imports - : CLI commands to test
commands - : Additional test dependencies
requires
About Section:
- : Project homepage
home - : SPDX license identifier
license - : License family
license_family - : Path to license in source
license_file - : One-line description
summary - : Detailed description (use
descriptionfor multi-line)| - : Development URL (GitHub, GitLab, etc.)
dev_url - : Documentation URL
doc_url
Package部分:
- : 包名称(小写,优先使用连字符)
name - : 包版本
version
Source部分:
- : 源码压缩包的下载URL
url - : SHA256校验和
sha256 - 和
git_url: 适用于Git源码git_rev - : 所需补丁文件列表
patches
Build部分:
- : 构建编号(仅修改recipe时递增)
number - : 适用时设置为
noarch或pythongeneric - : 内联构建脚本或引用build.sh
script - : 适用于Python CLI工具
entry_points - : 适用于库
run_exports
Requirements部分:
- : 构建时所需的编译器和工具
build - : 构建时所需的库
host - : 运行时依赖项
run
Test部分:
- : 需测试的Python模块
imports - : 需测试的CLI命令
commands - : 额外的测试依赖项
requires
About部分:
- : 项目主页
home - : SPDX许可证标识符
license - : 许可证家族
license_family - : 源码中许可证文件的路径
license_file - : 单行描述
summary - : 详细描述(多行使用
description)| - : 开发URL(GitHub、GitLab等)
dev_url - : 文档URL
doc_url
7. Version Pinning
7. 版本固定
- Use for minimum versions
>= - Use specific pins like for known incompatibilities
>=1.2,<2 - Rely on from dependencies when possible
run_exports - For Python: or
python >=3.9python >=3.9,<3.13
- 最低版本使用
>= - 已知不兼容情况使用特定约束,如
>=1.2,<2 - 尽可能依赖依赖项的
run_exports - Python版本:或
python >=3.9python >=3.9,<3.13
8. Common Python Package Recipe
8. 常见Python包Recipe示例
yaml
{% set name = "package-name" %}
{% set version = "1.0.0" %}
package:
name: {{ name|lower }}
version: {{ version }}
source:
url: https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/{{ name }}-{{ version }}.tar.gz
sha256: <checksum>
build:
number: 0
noarch: python
script: {{ PYTHON }} -m pip install . --no-deps --no-build-isolation -vvv
entry_points:
- cli-command = package.module:main
requirements:
host:
- python >=3.9
- pip
- setuptools
run:
- python >=3.9
- dependency >=1.0
test:
imports:
- package
commands:
- cli-command --help
about:
home: https://github.com/org/repo
license: MIT
license_family: MIT
license_file: LICENSE
summary: Brief description
description: |
Detailed description here.
dev_url: https://github.com/org/repoyaml
{% set name = "package-name" %}
{% set version = "1.0.0" %}
package:
name: {{ name|lower }}
version: {{ version }}
source:
url: https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/{{ name }}-{{ version }}.tar.gz
sha256: <checksum>
build:
number: 0
noarch: python
script: {{ PYTHON }} -m pip install . --no-deps --no-build-isolation -vvv
entry_points:
- cli-command = package.module:main
requirements:
host:
- python >=3.9
- pip
- setuptools
run:
- python >=3.9
- dependency >=1.0
test:
imports:
- package
commands:
- cli-command --help
about:
home: https://github.com/org/repo
license: MIT
license_family: MIT
license_file: LICENSE
summary: 简短描述
description: |
详细描述内容。
dev_url: https://github.com/org/repo9. Debugging Build Failures
9. 构建失败调试
- Check build logs carefully for error messages
- Verify all dependencies are available in conda-forge or bioconda
- Check for missing build tools (compilers, make, cmake, etc.)
- Verify source URL is accessible and checksum matches
- For Python packages, ensure pip, setuptools are in host dependencies
- 仔细检查构建日志中的错误信息
- 验证所有依赖项是否可在conda-forge或bioconda中获取
- 检查是否缺少构建工具(编译器、make、cmake等)
- 验证源URL是否可访问且校验和匹配
- Python包需确保pip、setuptools在host依赖项中
10. Common Build Errors and Solutions
10. 常见构建错误与解决方案
Error: with wrong package name
pin_subpackageValueError: Didn't find subpackage version info for 'processcuration', which is used in a pin_subpackage expression.Solution: Use the correct package name variable in :
pin_subpackageyaml
run_exports:
- {{ pin_subpackage(name, max_pin="x") }}Not a hardcoded string that doesn't match the package name.
Error: Conflicting build script and meta.yaml
CondaBuildException: Found a build.sh script and a build/script section inside meta.yaml.Solution: Choose one approach:
- Either remove the file and use inline
build.shin meta.yaml (recommended for simple Python packages)script: - Or remove the line from meta.yaml and keep the
script:filebuild.sh
For simple Python packages, use inline script:
yaml
build:
script: {{ PYTHON }} -m pip install . --no-deps --no-build-isolation -vvvError: Docker file sharing on macOS
The path /opt/miniconda3/envs/build_recipes/conda-bld is not shared from the host and is not known to Docker.Solution: Configure Docker Desktop file sharing:
- Open Docker Desktop
- Go to Settings → Resources → File Sharing
- Add to the list of shared directories
/opt - Click "Apply & Restart"
Error: Build skipped for osx-arm64
BUILD SKIP: skipping recipes/vgp-processcuration for additional platform osx-arm64Solution: This is expected for local builds without Docker. Use one of these approaches:
- Use flags to build in Linux container:
--docker --forcebioconda-utils build --docker --force --packages <package> - Accept that packages are typically built on Linux in CI
noarch: python - Let CircleCI handle the build when you push to GitHub
错误:使用错误的包名
pin_subpackageValueError: Didn't find subpackage version info for 'processcuration', which is used in a pin_subpackage expression.解决方案: 在中使用正确的包名变量:
pin_subpackageyaml
run_exports:
- {{ pin_subpackage(name, max_pin="x") }}不要使用与包名不匹配的硬编码字符串。
错误:构建脚本与meta.yaml冲突
CondaBuildException: Found a build.sh script and a build/script section inside meta.yaml.解决方案: 选择其中一种方式:
- 移除文件,在meta.yaml中使用内联
build.sh(推荐用于简单Python包)script: - 或移除meta.yaml中的行,保留
script:文件build.sh
对于简单Python包,推荐使用内联脚本:
yaml
build:
script: {{ PYTHON }} -m pip install . --no-deps --no-build-isolation -vvv错误:macOS上Docker文件共享问题
The path /opt/miniconda3/envs/build_recipes/conda-bld is not shared from the host and is not known to Docker.解决方案: 配置Docker Desktop文件共享:
- 打开Docker Desktop
- 进入 设置 → 资源 → 文件共享
- 将添加到共享目录列表
/opt - 点击“应用并重启”
错误:osx-arm64平台构建被跳过
BUILD SKIP: skipping recipes/vgp-processcuration for additional platform osx-arm64解决方案: 这是本地构建未使用Docker时的预期情况。可选择以下方式之一:
- 使用参数在Linux容器中构建:
--docker --forcebioconda-utils build --docker --force --packages <package> - 接受包通常在CI的Linux环境中构建
noarch: python - 推送代码至GitHub后由CircleCI处理构建
11. Docker Builds
11. Docker构建
Building with Docker tests packages in a Linux environment, which is important for packages:
noarchbash
undefined使用Docker构建可在Linux环境中测试包,这对包至关重要:
noarchbash
undefinedBasic Docker build
基础Docker构建
bioconda-utils build --docker --packages <package>
bioconda-utils build --docker --packages <package>
Docker build with mulled tests (container tests)
带mulled测试的Docker构建(容器测试)
bioconda-utils build --docker --mulled-test --packages <package>
bioconda-utils build --docker --mulled-test --packages <package>
Force build even on incompatible platforms
强制在不兼容平台构建
bioconda-utils build --docker --mulled-test --force --packages <package>
**Docker Build Process:**
1. Downloads/uses bioconda build environment Docker image
2. Mounts recipe directory and build cache into container
3. Runs conda-build inside Linux container
4. Optionally runs mulled tests in separate containers
**Requirements:**
- Docker Desktop must be running
- File paths must be shared with Docker (especially `/opt` on macOS)
- Sufficient disk space for Docker images (~3-11 GB)bioconda-utils build --docker --mulled-test --force --packages <package>
**Docker构建流程:**
1. 下载/使用bioconda构建环境Docker镜像
2. 将recipe目录和构建缓存挂载到容器中
3. 在Linux容器内运行conda-build
4. 可选:在独立容器中运行mulled测试
**要求:**
- Docker Desktop必须处于运行状态
- 文件路径必须与Docker共享(尤其是macOS上的`/opt`)
- 有足够的磁盘空间存储Docker镜像(约3-11 GB)12. Working with CircleCI
12. CircleCI使用
Bioconda uses CircleCI for continuous integration:
- Recipes are automatically built and tested on push
- Check for CI configuration
.circleci/config.yml - Review build artifacts and logs on CircleCI dashboard
- Failed builds will prevent PR merging
Bioconda使用CircleCI进行持续集成:
- 推送代码时会自动构建并测试recipe
- 查看了解CI配置
.circleci/config.yml - 在CircleCI仪表板查看构建产物和日志
- 构建失败会阻止PR合并
Bioconda-Specific Guidelines
Bioconda特定指南
- Follow the bioconda contribution guidelines
- Add yourself to in the extra section
recipe-maintainers - Use appropriate channels order: conda-forge > bioconda > defaults
- Tag recipes appropriately for bioinformatics domains
- Ensure license is specified and license file is included
- 遵循bioconda贡献指南
- 在extra部分将自己添加到
recipe-maintainers - 使用正确的通道顺序:conda-forge > bioconda > defaults
- 为生物信息学领域的recipe添加合适标签
- 确保指定许可证并包含许可证文件
Quick Commands Reference
快速命令参考
bash
undefinedbash
undefinedLint a recipe (from repo root)
检查recipe(从仓库根目录执行)
bioconda-utils lint recipes/ --packages <package>
bioconda-utils lint recipes/ --packages <package>
Build a recipe
构建recipe
conda mambabuild recipes/<package>
conda mambabuild recipes/<package>
Build with bioconda-utils
使用bioconda-utils构建
bioconda-utils build --packages <package>
bioconda-utils build --packages <package>
Test an installed package
测试已安装的包
conda create -n test-env <package>
conda activate test-env
conda create -n test-env <package>
conda activate test-env
Update recipe after changes
修改后更新recipe
1. Update version in meta.yaml
1. 更新meta.yaml中的版本
2. Update sha256 checksum
2. 更新sha256校验和
3. Reset build number to 0
3. 将构建编号重置为0
4. Update dependencies if needed
4. 如有需要更新依赖项
undefinedundefinedRelated Skills
相关技能
- galaxy-tool-wrapping - Galaxy tools often require conda packages as dependencies
- vgp-pipeline - VGP workflows use bioconda tools
- galaxy-workflow-development - Workflows use tools with conda dependencies
- galaxy-tool-wrapping - Galaxy工具通常依赖conda包
- vgp-pipeline - VGP工作流使用bioconda工具
- galaxy-workflow-development - 工作流使用带conda依赖的工具
When Helping Users
帮助用户时的注意事项
- Ask about the package type (Python, R, compiled, etc.)
- Check if source is available (PyPI, GitHub, CRAN, etc.)
- Verify license compatibility
- Identify all runtime dependencies
- Create minimal but complete test suite
- Follow naming conventions (lowercase, hyphens)
- Validate the recipe with linting before building
- Test the built package functionality
Always prioritize correctness, reproducibility, and following bioconda community standards.
- 询问包类型(Python、R、编译型等)
- 检查源码是否可获取(PyPI、GitHub、CRAN等)
- 验证许可证兼容性
- 识别所有运行时依赖项
- 创建最小但完整的测试套件
- 遵循命名规范(小写、连字符)
- 构建前通过代码检查验证recipe
- 测试已构建包的功能
始终优先保证正确性、可复现性,并遵循bioconda社区标准。