robovast-client 2.1.0__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.
@@ -0,0 +1,17 @@
1
+ # Copyright (C) 2026 Frederik Pasch
2
+ # SPDX-License-Identifier: Apache-2.0
3
+
4
+ """What a client needs to talk to a robovast-service, and nothing else.
5
+
6
+ These modules were under :mod:`robovast.common`, which cannot host them once the client
7
+ ships as its own distribution: ``common/__init__.py`` carries the lazy re-export map, so
8
+ the package is a regular one and its contents cannot be split across two distributions.
9
+ ``robovast.client`` is a package of its own for exactly that reason.
10
+
11
+ The rule for what belongs here is the install it has to survive in: ``pydantic``,
12
+ ``click`` and ``requests``, with no simulator, no Kubernetes client and no array library.
13
+ Anything reaching further belongs in the core.
14
+
15
+ Deliberately kept empty of re-exports. The parent it came from cost 528 modules to touch
16
+ because its ``__init__`` imported eagerly; repeating that here would undo the point.
17
+ """
@@ -0,0 +1,65 @@
1
+ # Copyright (C) 2026 Frederik Pasch
2
+ # SPDX-License-Identifier: Apache-2.0
3
+
4
+ """The version of the code *this process is running*.
5
+
6
+ Lives here rather than beside the in-process service because both sides of the version
7
+ handshake need it: the HTTP client reports its own version, the service reports the one it
8
+ loaded. Keeping it in ``local_transport`` meant a client could not ask "what am I running?"
9
+ without importing the whole in-process server.
10
+ """
11
+
12
+ from importlib.metadata import PackageNotFoundError
13
+ from importlib.metadata import version as _pkg_version
14
+
15
+
16
+ def running_version() -> str:
17
+ """The running code's version: git revision if available, else package metadata.
18
+
19
+ The preference is the point. A service is long-lived and loads its code once, so a
20
+ client needs to tell "the fix I just made is loaded" from "this process predates it".
21
+ The packaged version alone cannot — it stays ``2.0.0`` across every edit.
22
+
23
+ Never raises. The git-revision path needs ``robovast.common.execution``, which a
24
+ client-only install does not have, so the import is inside the ``try`` with everything
25
+ else: a version string is diagnostic, and failing to produce one must not break the
26
+ handshake it is part of.
27
+
28
+ The distributions are tried in order of how much they say about the running code:
29
+ ``robovast`` when it is installed, then ``robovast-client``, which is installed in
30
+ *every* case and so is the last answer that is still a fact. ``0.0.0+unknown`` remains
31
+ only for a source tree with no metadata at all — reported by a perfectly good
32
+ client-only install, it would read as a broken install rather than a small one.
33
+ """
34
+ try:
35
+ from robovast.common.execution import \
36
+ get_app_version # pylint: disable=import-outside-toplevel
37
+ return get_app_version()
38
+ except Exception: # noqa: BLE001 - version reporting must never break the handshake
39
+ for dist in ("robovast", "robovast-client"):
40
+ try:
41
+ return _pkg_version(dist)
42
+ except PackageNotFoundError:
43
+ continue
44
+ return "0.0.0+unknown" # a source tree with no metadata
45
+
46
+
47
+ def running_revision() -> str:
48
+ """The running code's git revision, or ``""`` when it cannot be determined.
49
+
50
+ The strict half of :func:`running_version`, and the reason both exist: a *version* is
51
+ allowed to fall back to package metadata, because "which robovast am I?" always has an
52
+ answer worth printing. A *revision* is not, because the only question it is asked is
53
+ "is this the same code as over there?" -- and a semver that stays ``2.0.0`` across every
54
+ edit answers that with a confident wrong yes.
55
+
56
+ ``""`` therefore means "no comparison is possible here", which a caller can act on by
57
+ saying so. Two cases produce it and neither is an error: a client-only install (no
58
+ ``robovast.common.execution`` to ask) and a non-git install of the full package.
59
+ """
60
+ try:
61
+ from robovast.common.execution import \
62
+ code_revision # pylint: disable=import-outside-toplevel
63
+ return code_revision()
64
+ except Exception: # noqa: BLE001 - a diagnostic must not raise; "" is the honest answer
65
+ return ""