藉由葛雷堡的力量... 我擁有 Conda 食譜了!
骷髏王的n主要目標是征服葛雷堡。
簡介
玩笑話說完,新專案 grayskull 的創建意圖是生成更好的 Conda 食譜,以便正確打包在不同管道(例如 PyPI、CRAN、Conan、GitHub 註冊表、GitHub 儲存庫等等)中可用的專案。最重要的是,Grayskull 也正在開發以協助 conda-forge 更新食譜。
目前狀態
目前,Grayskull(版本 0.2.1
)能夠僅透過在 PyPI 上尋找套件來生成食譜,並且在 PyPI 和 conda-forge 上可用。此套件的 GitHub 儲存庫為:marcelotrevisani/grayskull。
在 Grayskull 之前,我們只有 conda-build skeleton
可以為 PyPI 上的 Python 套件生成食譜。在所有其他方面,與 conda-build skeleton
和 grayskull
相比,生成食譜的品質差異以及花費的時間都有很大的差距。Grayskull 生成食譜時會考慮平台、可用的 Python 版本、選擇器、編譯器(Fortran、C 和 C++)、套件約束、許可證類型、許可證檔案等等。它使用來自多個來源的中繼資料,盡力創建最佳的食譜。
安裝
您可以使用 pip
或 conda
安裝 grayskull
。Grayskull
不依賴 conda
執行,並且可以用最少的依賴項生成食譜。
使用 conda
Grayskull 在 conda-forge 管道上可用。
conda install -c conda-forge grayskull
使用 pip
pip install grayskull
Grayskull vs conda-build skeleton
grayskull
和 conda skeleton
生成的食譜有一些差異。以 pytest
食譜為例,它具有平台選擇器、Python 版本約束,並且還有幾個套件約束。
Grayskull (0.2.1) - 花費 4 秒生成食譜
{% set name = "pytest" %}
{% set version = "5.3.5" %}
package:
name: {{ name|lower }}
version: {{ version }}
source:
url: https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/{{ name }}-{{ version }}.tar.gz
sha256: 0d5fe9189a148acc3c3eb2ac8e1ac0742cb7618c084f3d228baaec0c254b318d
build:
number: 0
skip: true # [py2k]
entry_points:
- pytest=pytest:main
- py.test=pytest:main
script: {{ PYTHON }} -m pip install . -vv
requirements:
host:
- pip
- python
- setuptools >=40.0
- setuptools_scm
run:
- atomicwrites >=1.0 # [win]
- attrs >=17.4.0
- colorama # [win]
- importlib-metadata >=0.12 # [py<38]
- more-itertools >=4.0.0
- packaging
- pathlib2 >=2.2.0 # [py<36]
- pluggy <1.0,>=0.12
- py >=1.5.0
- python
- wcwidth
test:
imports:
- pytest
commands:
- pip check
- pytest --help
- py.test --help
requires:
- pip
about:
home: https://pypi.org/project/pytest/
summary: 'pytest: simple powerful testing with Python'
dev_url: https://github.com/pytest-dev/pytest
license: MIT
license_file: LICENSE
extra:
recipe-maintainers:
- marcelotrevisani
Skeleton (3.18.11) - 花費 31 秒生成食譜
{% set name = "pytest" %}
{% set version = "5.3.5" %}
package:
name: "{{ name|lower }}"
version: "{{ version }}"
source:
url: "https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/{{ name }}-{{ version }}.tar.gz"
sha256: 0d5fe9189a148acc3c3eb2ac8e1ac0742cb7618c084f3d228baaec0c254b318d
build:
number: 0
script: "{{ PYTHON }} -m pip install . -vv"
requirements:
host:
- atomicwrites >=1.0
- attrs >=17.4.0
- colorama;sys_platform =="win32"
- importlib-metadata >=0.12
- more-itertools >=4.0.0
- packaging
- pathlib2 >=2.2.0
- pip
- pluggy >=0.12,<1.0
- py >=1.5.0
- python
- wcwidth
run:
- atomicwrites >=1.0
- attrs >=17.4.0
- colorama;sys_platform =="win32"
- importlib-metadata >=0.12
- more-itertools >=4.0.0
- packaging
- pathlib2 >=2.2.0
- pluggy >=0.12,<1.0
- py >=1.5.0
- python
- wcwidth
about:
home: The package home page
license: MIT
license_family: MIT
license_file:
summary: "pytest: simple powerful testing with Python"
doc_url:
dev_url:
extra:
recipe-maintainers:
- your-github-id-here
conda-forge
上 pytest 5.3.5
的原始食譜
{% set version = "5.3.5" %}
package:
name: pytest
version: {{ version }}
source:
url: https://pypi.io/packages/source/p/pytest/pytest-{{ version }}.tar.gz
sha256: 0d5fe9189a148acc3c3eb2ac8e1ac0742cb7618c084f3d228baaec0c254b318d
build:
skip: True # [py27]
number: 1
script: "{{ PYTHON }} setup.py install --single-version-externally-managed --record record.txt"
entry_points:
- py.test = py.test:main
- pytest = py.test:main
requirements:
host:
- pip
- python
- setuptools >=40.0
- setuptools_scm
run:
- atomicwrites >=1.0 # [win]
- attrs >=17.4.0
- colorama # [win]
- importlib_metadata >=0.12 # [py<38]
- more-itertools >=4.0
- packaging
- pathlib2 >=2.2.0 # [py<36]
- pluggy >=0.12,<1.0
- py >=1.5.0
- python
- setuptools >=40.0
- wcwidth
run_constrained:
# pytest-faulthandler 2 is a dummy package.
# if an older version of fault-handler is installed, it will conflict with pytest >=5.
- pytest-faulthandler >=2
test:
commands:
- pytest -h
imports:
- pytest
about:
home: https://pytest.dev.org.tw/en/latest/
license: MIT
license_file: LICENSE
summary: 'Simple and powerful testing with Python.'
description: |
The pytest framework makes it easy to write small tests, yet scales to
support complex functional testing for applications and libraries.
doc_url: https://pytest.dev.org.tw/en/latest/
dev_url: https://github.com/pytest-dev/pytest/
extra:
recipe-maintainers:
- flub
- goanpeca
- nicoddemus
- ocefpaf
- mingwandroid
主要差異
屬性 | Grayskull (0.2.1) | Skeleton (3.18.11) |
---|---|---|
指令 | ✅ grayskull pypi pytest | ✅ conda skeleton pypi pytest |
時間 | ✅ 4 秒 | ❌ 31 秒 |
許可證 | ✅ 正確新增許可證檔案和許可證類型 | ❗️ 僅新增許可證類型 |
Host 需求 | ✅ 正確新增所有 host 需求 | ❌ 未正確新增 host 依賴項。它新增了不必要的依賴項,並且缺少建置套件所需的許多依賴項 |
Run 需求 | ✅ 僅缺少 host 需求中的 setuptools(但此依賴項未在 pytest 套件上定義) | ❌ 為專案新增了不正確的依賴項 |
選擇器 | ✅ 正確跳過 Python 2 並為 windows 和 python 版本新增選擇器 | ❌ 它沒有新增任何關於選擇器的資訊。實際上,conda-build 新增了錯誤的資訊,這將導致食譜損壞。例如,新增了 'sys_platform == win32',這是 conda 食譜的錯誤格式 |
Entry points | ✅ 正確新增所有 entry points | ❌ 沒有 entry points |
是否可以建置? | ✅ 是 | ❌ 否 |
在 noarch: python
的情況下,Grayskull 足夠聰明,可以偵測到食譜何時支援它,而 Skeleton 則沒有做到。重要的是要強調 Skeleton 也沒有偵測到編譯器。然而,Grayskull 總是嘗試偵測它。
Grayskull (0.2.1) 的用法
專案選項
$ grayskull --help
usage: grayskull [-h] [--version] {pypi} ...
Grayskull - Conda recipe generator
positional arguments:
{pypi} Options to generate PyPI recipes
pypi Generate recipes based on PyPI
optional arguments:
-h, --help show this help message and exit
--version, -v Print Grayskull version and exit
$ grayskull pypi --help
usage: grayskull pypi [-h] [--maintainers MAINTAINERS [MAINTAINERS...]]
[--output OUTPUT]
pypi_packages [pypi_packages ...]
positional arguments:
pypi_packages Specify the PyPI package name.
optional arguments:
-h, --help show this help message and exit
--maintainers MAINTAINERS [MAINTAINERS ...], -m MAINTAINERS [MAINTAINERS...] List of maintainers which will be added to the recipe.
--output OUTPUT, -o OUTPUT Path to where the recipe will be created
要生成食譜,您只需呼叫 grayskull
並傳遞管道(就目前而言,我們僅支援 PyPI,它應該是 pypi)和套件名稱。您還應該使用選項 --output
或 -o
指定輸出資料夾,它將在其中創建套件資料夾和食譜。重要的是要注意,使用者可以使用選項 --maintainers
指定維護者列表,這些維護者將被新增到食譜中。
pytest 的範例
如果您需要指定套件版本,您可以將等號放在套件名稱之後,版本緊隨其後。範例
grayskull pypi requests=2.21.0
或
grayskull pypi requests==2.21.0
如果您想生成多個食譜,只需傳遞套件列表,例如
grayskul pypi pytest requests=2.21.0 colorama
未來計畫
- 對於下一個主要版本 (1.0.0),計畫新增能夠載入食譜並僅更新部分的功能;
- 使用 CRAN (R) 管道 (2.0.0) 生成 Conda 食譜;
- 使用 Conan (C++) 管道 (3.0.0) 生成 Conda 食譜;
問題
如有任何問題、疑問、建議,請隨時在儲存庫上開啟 issue。
非常歡迎貢獻! :)
這項工作感謝 NumFOCUS 小型開發補助計畫才得以實現。