INNER CODE UNIT · Python

_provide

Priivacy-ai/spec-kitty · packages/spec-kitty-services/spec_kitty_services/__init__.py:59

def _provide(service: str) -> str | None:
    package = _package_dir()
    manifest_path = package / MANIFEST_NAME
    if not manifest_path.is_file():
        return None  # a source checkout or an editable install: nothing is bundled
    try:
        manifest = parse_manifest(manifest_path.read_bytes())
    except (OSError, ManifestError):
        return None
    if manifest.target is None or manifest.cli_version != _installed_cli_version():
        return None  # the fallback wheel, or a version skew: the CLI fetches its own pinned build
    if manifest.target != _host_target():
        return None  # a wheel forced onto another platform
    binary = manifest.binary_for(service)
    if binary is None or binary.sha256 != _pinned_sha256(service, manifest.target):
        return None  # a build the CLI does not pin: step aside rather than have the CLI refuse it
    path = package / BIN_DIR / binary.asset
    return str(path) if path.is_file() and not path.is_symlink() else None

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…