mini-code-cli 0.1.0.4__py3-none-any.whl → 0.1.1.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
mini_code_cli/__init__.py CHANGED
@@ -1,2 +1,40 @@
1
- from importlib.metadata import version
2
- __version__ = version("mini-code-cli")
1
+ """mini_code_cli -- package metadata (the version shown in the welcome banner).
2
+
3
+ The version is read from ``pyproject.toml`` first: that file is the source of
4
+ truth when running from a checkout, and the *installed* metadata is often stale
5
+ (a plain ``pip install -e .`` keeps the version it was installed at, so bumping
6
+ ``pyproject.toml`` would leave the banner reporting an old number). If the file
7
+ cannot be read, fall back to the installed distribution's metadata and finally
8
+ to ``"unknown"`` so importing the package can never fail over a version lookup.
9
+ """
10
+
11
+ __all__ = ["__version__"]
12
+
13
+
14
+ def _read_version():
15
+ """Best-effort package version: pyproject.toml, then installed metadata."""
16
+ try:
17
+ from pathlib import Path
18
+
19
+ pyproject = Path(__file__).resolve().parent.parent / "pyproject.toml"
20
+ try:
21
+ import tomllib # Python >= 3.11
22
+ except ImportError: # pragma: no cover - older interpreters
23
+ tomllib = None
24
+ if tomllib is not None:
25
+ try:
26
+ with open(pyproject, "rb") as f:
27
+ return str(tomllib.load(f)["project"]["version"])
28
+ except Exception:
29
+ pass
30
+ except Exception:
31
+ pass
32
+ try:
33
+ from importlib.metadata import version as _dist_version
34
+
35
+ return _dist_version("mini-code-cli")
36
+ except Exception:
37
+ return "unknown"
38
+
39
+
40
+ __version__ = _read_version()