6

我正在尝试让 conda-forge 托管我创建的已经在 PyPI 上的 python 包:https ://pypi.org/project/ludoSim-jaib1/

我已经阅读了关于贡献包的 conda- forge文档和关于通过meta.yaml配方文件定义元数据的conda文档

我向conda-forge/staged-recipesrepo提交的 pull request 在这里。我的meta.yaml文件可以在该拉取请求中找到,但我也会在此处以文本形式发布:

{% set name = "ludoSim-jaib1" %}
{% set version = "0.0.1" %}

 package:
  name: {{ name|lower }}
  version: {{ version }}

 source:
  url: https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/{{ name }}-{{ version }}.tar.gz
  sha256: 3342abcd52a6a18e1d4b0e2e626c051f24133187647c6618c0f81d7add28d543

 build: 
  number: 0
  script: python -m pip install . --no-deps -vv 
  skip: true  # [py<30]

 requirements:
  host:
    - python
    - pip
  run:
    - python

 test:
  source_files:
    tests/test_ludo.py
    tests/runTest.py
  imports:
    - ludoSim
    - pytest

 about:
  home: http://github.com/jaib1/ludoSim
  license: GPL-3.0
  license_family: GPL
  license_file: LICENSE.md
  summary: A simple ludo simulator
  description: See the package README.md for more information.

 extra:
  recipe-maintainers:
    - jaib1

我认为我在食谱中做错了一些简单的事情meta.yaml,但由于这是我第一次向 conda-forge 提交包,我不确定到底是什么。阅读文档时,我对配方文件中的部分感到困惑test:我不完全了解该test部分中的信息如何用于运行构建测试:对于我的包,我想运行我的包中存在的测试脚本包,取决于 pytest 包,需要在我的包所在位置的父目录中运行。

我能否获得有关如何修复我的meta.yaml配方文件以及如何test为我的场景对该文件中的部分进行建模的信息?

4

1 回答 1

6

以下文档是我在下面重复的所有内容的规范参考:

https://docs.conda.io/projects/conda-build/en/stable/resources/define-metadata.html#test-section

创建 conda 配方时,有(AFAIK)三种方法来定义将被执行的测试:

  • 在配方目录中创建run_test.[py,pl,sh,bat](这是由conda-build
  • includetest/imports测试是否可以导入 python 模块
  • 包括test/commands运行任意 shell 命令

这些可以通过 、 和许多其他键来补充source_filesrequires以正确格式化测试环境。我认为,鉴于您的问题描述:

对于我的包,我想运行一个测试脚本,它存在于我的包中,取决于 pytest 包,并且需要在我的包所在位置的父目录中运行

你可能想要这样的东西:

test:
  imports:
    - ludoSim
  source_files:
    - tests/test_ludo.py
    - tests/runTest.py
  requires:
    - pytest
  commands:
    - pytest tests/

这应该将给定source_files的源文件夹中的内容复制到测试目录中,然后安装pytest,然后运行pytest tests/。我不确定我是否正确解释了您的目录要求,但您test/commands可以包含任意数量的呼叫pushd或类似呼叫,以移动到您需要的位置。

于 2019-07-16T09:07:37.803 回答