CodeSampleX

Пример

packaging 26.3: tags

Проверенный пример — pypi packaging 26.3: tags. Контракт выполнен на python 3.12 · linux debian/x64 · docker и пройден: Tag represents an immutable, hashable…

sha256:6c92edfc24b4ff9a738edf3f03f55039ea43d0c9a424cde8d7a54f60825e6778

Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла. Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди. 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-05

Кейс

HOW
Цель
verify packaging.tags in pkg:pypi/packaging@26.3
Пакеты
Символы
  • packaging.tags
Создан
2026-09-05T18:35:03Z

Контракт

  1. Tag represents an immutable, hashable PEP 425 wheel tag triple with interpreter, abi, and platform attributes.
  2. parse_tag parses single and compressed tag strings into a frozenset of Tag instances.
  3. sys_tags yields an iterator of Tag triples prioritized for the running interpreter.
  4. cpython_tags yields compatible CPython tags for given python_version, abis, and platforms.
  5. compatible_tags yields fallback compatibility tags for a target interpreter and platform.
  6. interpreter_name and interpreter_version return non-empty string identifiers for the current runtime.
  7. parse_tag raises ValueError when tag strings do not contain exactly three components.

Файлы

  • NOTES.md
  • PROMPT.md
  • csx.json
  • requirements.txt
  • spec.json
  • test/contract.py

Скачать артефакт с исходным кодом (tar.gz)

Исходный код

NOTES.md
# packaging.tags wheel tag handling

This sample pins `packaging` 26.3 and verifies `packaging.tags` for PEP 425 wheel tags generation and parsing.

The contract verifies:
- `Tag` represents an immutable, hashable PEP 425 wheel tag triple with interpreter, abi, and platform attributes.
- `parse_tag` parses single and compressed tag strings into a frozenset of `Tag` instances.
- `sys_tags` yields an iterator of `Tag` triples prioritized for the running interpreter.
- `cpython_tags` yields compatible CPython tags for given python_version, abis, and platforms.
- `compatible_tags` yields fallback compatibility tags for a target interpreter and platform.
- `interpreter_name` and `interpreter_version` return non-empty string identifiers for the current runtime.
- `parse_tag` raises `ValueError` when tag strings do not contain exactly three components.
PROMPT.md
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 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

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.
csx.json
{"case":{"caseId":"case:sha256:96fe3ca518c8af6b6f5c7928301a1627b7f7218d8b3c2bd4317aba32104738f3","contract":["Tag represents an immutable, hashable PEP 425 wheel tag triple with interpreter, abi, and platform attributes.","parse_tag parses single and compressed tag strings into a frozenset of Tag instances.","sys_tags yields an iterator of Tag triples prioritized for the running interpreter.","cpython_tags yields compatible CPython tags for given python_version, abis, and platforms.","compatible_tags yields fallback compatibility tags for a target interpreter and platform.","interpreter_name and interpreter_version return non-empty string identifiers for the current runtime.","parse_tag raises ValueError when tag strings do not contain exactly three components."],"goal":"verify packaging.tags in pkg:pypi/packaging@26.3","kind":"HOW","packages":["pkg:pypi/packaging@26.3"],"schemaVersion":1,"symbols":["packaging.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"],"verifierAdapter":"python@1"}
requirements.txt
packaging==26.3
spec.json
{
  "schemaVersion": 1,
  "goal": "verify packaging.tags in pkg:pypi/packaging@26.3",
  "kind": "HOW",
  "packages": [
    "pkg:pypi/packaging@26.3"
  ],
  "symbols": [
    "packaging.tags"
  ]
}
test/contract.py
from packaging.tags import (
    Tag,
    compatible_tags,
    cpython_tags,
    interpreter_name,
    interpreter_version,
    parse_tag,
    sys_tags,
)

# 1. Tag represents an immutable, hashable PEP 425 wheel tag triple with interpreter, abi, and platform attributes.
t = Tag("py3", "none", "any")
assert t.interpreter == "py3"
assert t.abi == "none"
assert t.platform == "any"
assert str(t) == "py3-none-any"
assert hash(t) == hash(Tag("py3", "none", "any"))
assert t == Tag("py3", "none", "any")
assert t != Tag("py2", "none", "any")

# 2. parse_tag parses single and compressed tag strings into a frozenset of Tag instances.
parsed_single = parse_tag("py3-none-any")
assert isinstance(parsed_single, frozenset)
assert len(parsed_single) == 1
assert t in parsed_single

parsed_multi = parse_tag("py2.py3-none-any")
assert isinstance(parsed_multi, frozenset)
assert len(parsed_multi) == 2
assert Tag("py2", "none", "any") in parsed_multi
assert Tag("py3", "none", "any") in parsed_multi

# 3. sys_tags yields an iterator of Tag triples prioritized for the running interpreter.
tags_list = list(sys_tags())
assert len(tags_list) > 0
assert all(isinstance(x, Tag) for x in tags_list)
assert Tag("py3", "none", "any") in tags_list

# 4. cpython_tags yields compatible CPython tags for given python_version, abis, and platforms.
cp_tags = list(cpython_tags(python_version=(3, 11), abis=["cp311"], platforms=["linux_x86_64"]))
assert len(cp_tags) > 0
assert any(x.interpreter == "cp311" and x.abi == "cp311" and x.platform == "linux_x86_64" for x in cp_tags)
assert any(x.interpreter == "cp311" and x.abi == "abi3" and x.platform == "linux_x86_64" for x in cp_tags)
assert any(x.interpreter == "cp311" and x.abi == "none" and x.platform == "linux_x86_64" for x in cp_tags)

# 5. compatible_tags yields fallback compatibility tags for a target interpreter and platform.
compat = list(compatible_tags(python_version=(3, 11), interpreter="cp311", platforms=["linux_x86_64"]))
assert len(compat) > 0
assert any(x.interpreter == "cp311" and x.abi == "none" and x.platform == "any" for x in compat)
assert any(x.interpreter == "py3" and x.abi == "none" and x.platform == "any" for x in compat)

# 6. interpreter_name and interpreter_version return non-empty string identifiers for the current runtime.
name = interpreter_name()
version = interpreter_version()
assert isinstance(name, str) and len(name) > 0
assert isinstance(version, str) and len(version) > 0

# 7. parse_tag raises ValueError when tag strings do not contain exactly three components.
for invalid in ["", "single", "two-parts", "one-two-three-four"]:
    try:
        parse_tag(invalid)
        raise AssertionError(f"Expected ValueError for invalid tag: {invalid}")
    except ValueError:
        pass

print("CONTRACT PASS: packaging.tags verified offline")

Исходный сидер

аноним