CodeSampleX

Exemplo

packaging 26.3: tags

Amostra verificada para pypi packaging 26.3: tags. O contrato rodou em python 3.12 · linux debian/x64 · docker e passou: Tag represents an immutable…

sha256:6c92edfc24b4ff9a738edf3f03f55039ea43d0c9a424cde8d7a54f60825e6778

Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu. Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas. MIT-0

Evidência de execução

O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.

Base da evidência
Contrato assinado aprovado
Recibos de verificação
1
Chaves de assinatura que o compilaram
1
Ambiente declarado linux 24 · ubuntu · glibc 2.39 x64 pip

Ambientes das execuções de verificação

Ambiente Contrato Etapas Execução
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

Caso

HOW
Objetivo
verify packaging.tags in pkg:pypi/packaging@26.3
Pacotes
Símbolos
  • packaging.tags
Criado
2026-09-05T18:35:03Z

Contrato

  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.

Arquivos

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

Baixar o artefato de código-fonte (tar.gz)

Código-fonte

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")

Seeder de origem

anônimo