Пример
packaging 26.3: tags.sys_tags
Проверенный пример — pypi packaging 26.3: tags.sys_tags. Контракт выполнен на python 3.12 · linux debian/x64 · docker и пройден.
sha256:fa9d059949d5cd13644123edf91e56a190a414a8f1943c4863082144463f44d6
Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла.
Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди.
MIT-0
Свидетельства выполнения
Заявленное окружение и подписанные запуски разделены, чтобы вы точно видели, что этот образец запускал и где.
- Основа свидетельства
- Подписанный контракт пройден
- Квитанции проверки
- 1
- Ключи подписи, собравшие его
- 1
Заявленная среда
linux 24 · ubuntu · glibc 2.39 x64 pip
Среды запусков проверки
| Окружение | Контракт | Этапы | Запуск |
|---|---|---|---|
| python 3.12 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · python@1python:3.12-slim@sha256:09f7da3bc104… |
2026-09-02 |
Кейс
HOW- Цель
- verify packaging.tags.sys_tags in pkg:pypi/packaging@26.3
- Пакеты
- Символы
-
- packaging.tags.sys_tags
- Создан
- 2026-09-02T13:38:32Z
Контракт
- assert sys_tags returns an iterator of Tag instances with interpreter, abi, and platform string attributes
- assert sys_tags yields tags ordered from specific platform tags to universal py3-none-any fallback tags
- assert sys_tags accepts warn boolean parameter and yields non-empty sequence of valid Tag objects
- assert Tag objects from sys_tags support string formatting, hashability, and equality with reconstructable Tag instances
Файлы
- PROMPT.md
- csx.json
- pyproject.toml
- requirements.txt
- sample.py
- spec.json
- test/contract.py
Исходный код
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify packaging.tags.sys_tags in pkg:pypi/packaging@26.3
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:pypi/packaging@26.3
Demonstrate these symbols/APIs:
- packaging.tags.sys_tags
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:f428d9b44ff2a25c0a5bec6c13a60081577f70a18c37a7099c164f98e2599daf","contract":["assert sys_tags returns an iterator of Tag instances with interpreter, abi, and platform string attributes","assert sys_tags yields tags ordered from specific platform tags to universal py3-none-any fallback tags","assert sys_tags accepts warn boolean parameter and yields non-empty sequence of valid Tag objects","assert Tag objects from sys_tags support string formatting, hashability, and equality with reconstructable Tag instances"],"goal":"verify packaging.tags.sys_tags in pkg:pypi/packaging@26.3","kind":"HOW","packages":["pkg:pypi/packaging@26.3"],"schemaVersion":1,"symbols":["packaging.tags.sys_tags"]},"contractCommand":["python","test/contract.py"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"pypi","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"pip","schemaVersion":1},"license":"MIT-0","packages":["pkg:pypi/packaging@26.3"],"schemaVersion":1,"subject":"pkg:pypi/packaging@26.3","symbols":["packaging.tags.sys_tags"],"verifierAdapter":"python@1"}
[project]
name = "verify-packaging-tags"
version = "0.1.0"
dependencies = [
"packaging==26.3",
]
packaging==26.3
"""Demonstration of retrieving and inspecting system compatibility tags with packaging.tags."""
from typing import Iterator, List, Optional
import packaging.tags as tags
def get_current_system_tags(warn: bool = False) -> Iterator[tags.Tag]:
"""Return the sequence of compatibility tag triples for the running interpreter."""
return tags.sys_tags(warn=warn)
def get_most_specific_tag() -> Optional[tags.Tag]:
"""Return the most specific compatibility tag supported by current environment."""
for tag in tags.sys_tags():
return tag
return None
def get_platform_tags() -> List[str]:
"""Return list of string representations of all platform tags supported by current environment."""
return [str(tag) for tag in tags.sys_tags()]
{
"schemaVersion": 1,
"goal": "verify packaging.tags.sys_tags in pkg:pypi/packaging@26.3",
"kind": "HOW",
"packages": [
"pkg:pypi/packaging@26.3"
],
"symbols": [
"packaging.tags.sys_tags"
]
}
"""Contract verification test for packaging.tags.sys_tags in pkg:pypi/packaging@26.3."""
import os
import sys
# Ensure project root is on sys.path for local module imports
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import packaging.tags as tags
from sample import get_current_system_tags, get_most_specific_tag, get_platform_tags
def test_sys_tags_returns_tag_instances() -> None:
"""Assertion 1: assert sys_tags returns an iterator of Tag instances with interpreter, abi, and platform string attributes."""
tag_iter = tags.sys_tags()
tag_list = list(tag_iter)
assert len(tag_list) > 0, "sys_tags() must yield at least one tag"
first = tag_list[0]
assert isinstance(first, tags.Tag), f"Expected Tag instance, got {type(first)}"
assert isinstance(first.interpreter, str), "Tag.interpreter must be a str"
assert isinstance(first.abi, str), "Tag.abi must be a str"
assert isinstance(first.platform, str), "Tag.platform must be a str"
sample_first = get_most_specific_tag()
assert sample_first is not None
assert sample_first == first
def test_sys_tags_universal_fallback() -> None:
"""Assertion 2: assert sys_tags yields tags ordered from specific platform tags to universal py3-none-any fallback tags."""
tag_list = list(tags.sys_tags())
assert len(tag_list) > 0
fallback_tags = [
t for t in tag_list
if t.interpreter.startswith("py") and t.abi == "none" and t.platform == "any"
]
assert len(fallback_tags) > 0, "sys_tags() must contain universal pure-python fallback tags"
first_tag = tag_list[0]
last_fallback = fallback_tags[-1]
first_index = tag_list.index(first_tag)
last_index = tag_list.index(last_fallback)
assert first_index <= last_index
def test_sys_tags_warn_parameter() -> None:
"""Assertion 3: assert sys_tags accepts warn boolean parameter and yields non-empty sequence of valid Tag objects."""
tags_warn_false = list(get_current_system_tags(warn=False))
tags_warn_true = list(get_current_system_tags(warn=True))
assert len(tags_warn_false) > 0
assert len(tags_warn_true) > 0
assert all(isinstance(t, tags.Tag) for t in tags_warn_true)
assert tags_warn_false == list(tags.sys_tags(warn=False))
def test_tag_formatting_hash_and_equality() -> None:
"""Assertion 4: assert Tag objects from sys_tags support string formatting, hashability, and equality with reconstructable Tag instances."""
tag_list = list(tags.sys_tags())
sample_tag = tag_list[0]
expected_str = f"{sample_tag.interpreter}-{sample_tag.abi}-{sample_tag.platform}"
assert str(sample_tag) == expected_str
formatted_list = get_platform_tags()
assert formatted_list[0] == expected_str
reconstructed = tags.Tag(sample_tag.interpreter, sample_tag.abi, sample_tag.platform)
assert sample_tag == reconstructed
assert hash(sample_tag) == hash(reconstructed)
assert sample_tag in set(tag_list)
def main() -> None:
test_sys_tags_returns_tag_instances()
test_sys_tags_universal_fallback()
test_sys_tags_warn_parameter()
test_tag_formatting_hash_and_equality()
print("All contract assertions passed.")
if __name__ == "__main__":
main()
Исходный сидер
аноним