![](/img/trans.png)
[英]Python Packaging: Creating a dependency on a `conda-forge` package in `conda` `meta.yaml` file
[英]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_files
, requires
,以及一些其他鍵的正確格式化的測試環境。 我認為,鑒於您的問題描述:
對於我的軟件包,我想運行一個存在於我的軟件包中的測試腳本,該腳本取決於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.