簡體   English   中英

如何添加適當的“ meta.yaml”配方文件以創建conda-forge軟件包分發? 特別是配方文件中的“測試”部分?

[英]How to add a proper 'meta.yaml' recipe file for creating a conda-forge package distribution? Particularly `test` section in recipe file?

我正在嘗試讓conda-forge托管我創建的python程序包,該程序包已經在PyPI上: https ://pypi.org/project/ludoSim-jaib1/

我在此處閱讀了有關貢獻軟件包的meta.yaml文檔,並在此處閱讀了有關通過meta.yaml配方文件定義元數據的meta.yaml文檔

我向conda-forge/staged-recipes提交的拉取請求在此處 我的meta.yaml文件可以在該pull請求中找到,但我也會在此處以文本形式發布:

{% 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食譜中肯定有一些簡單的事情我做錯了,但是由於這是我第一次向meta.yaml提交軟件包,所以我不確定到底是什么。 在閱讀文檔時,我對配方文件中的test部分感到困惑:我不完全了解test部分中的信息如何用於運行構建測試:對於我的軟件包,我想運行一個存在的測試腳本在我的軟件包中,取決於pytest軟件包,並且哪個軟件包需要在我的軟件包所在位置的父目錄中運行。

我能否獲得有關如何修復我的meta.yaml配方文件以及如何為我的方案對該文件中的test部分建模的信息?

以下文檔是我在下面重復的所有內容的規范參考:

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

創建conda配方時,有(AFAIK)三種方法來定義將要執行的測試:

  • 在配方目錄中創建run_test.[py,pl,sh,bat] (這是conda-build自動發現的
  • 包括test/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從您的源文件夾復制到test目錄,然后安裝pytest ,然后運行pytest tests/ 我不確定我是否正確理解了您的目錄要求,但是您的test/commands可以包含任意數量的pushd或類似調用,以移動到您需要的位置。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM