MCPcopy Index your code
hub / github.com/github/spec-kit / _get_installed_version

Function _get_installed_version

src/specify_cli/_version.py:53–72  ·  view source on GitHub ↗

Return the installed specify-cli distribution version or 'unknown'. Uses importlib.metadata so the value reflects what was actually installed by pip/uv/pipx — not a value read from pyproject.toml. This is intentional for `specify self check`, which should reason about the installed

()

Source from the content-addressed store, hash-verified

51
52
53def _get_installed_version() -> str:
54 """Return the installed specify-cli distribution version or 'unknown'.
55
56 Uses importlib.metadata so the value reflects what was actually installed
57 by pip/uv/pipx — not a value read from pyproject.toml. This is
58 intentional for `specify self check`, which should reason about the
59 installed distribution rather than a source-tree fallback. Callers must
60 treat the sentinel string 'unknown' as an indeterminate value (see FR-020).
61 """
62 import importlib.metadata
63
64 metadata_errors = [importlib.metadata.PackageNotFoundError]
65 invalid_metadata_error = getattr(importlib.metadata, "InvalidMetadataError", None)
66 if invalid_metadata_error is not None:
67 metadata_errors.append(invalid_metadata_error)
68
69 try:
70 return importlib.metadata.version("specify-cli")
71 except tuple(metadata_errors):
72 return "unknown"
73
74
75def _normalize_tag(tag: str) -> str:

Callers 3

_build_upgrade_planFunction · 0.85
self_checkFunction · 0.85

Calls 1

versionMethod · 0.45