ruyi 0.42.0b20251015__tar.gz → 0.43.0a20251017__tar.gz

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.
Files changed (102) hide show
  1. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/PKG-INFO +1 -2
  2. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/pyproject.toml +1 -2
  3. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/__main__.py +4 -0
  4. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/cli/main.py +6 -1
  5. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/cli/oobe.py +1 -1
  6. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/pluginhost/api.py +1 -1
  7. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/telemetry/aggregate.py +1 -1
  8. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/telemetry/provider.py +1 -1
  9. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/telemetry/store.py +2 -2
  10. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/utils/global_mode.py +1 -1
  11. {ruyi-0.42.0b20251015/ruyi/telemetry → ruyi-0.43.0a20251017/ruyi/utils}/node_info.py +52 -1
  12. ruyi-0.43.0a20251017/ruyi/version.py +20 -0
  13. ruyi-0.42.0b20251015/ruyi/version.py +0 -67
  14. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/LICENSE-Apache.txt +0 -0
  15. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/README.md +0 -0
  16. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/__init__.py +0 -0
  17. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/cli/__init__.py +0 -0
  18. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/cli/builtin_commands.py +0 -0
  19. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/cli/cmd.py +0 -0
  20. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/cli/completer.py +0 -0
  21. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/cli/completion.py +0 -0
  22. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/cli/config_cli.py +0 -0
  23. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/cli/self_cli.py +0 -0
  24. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/cli/user_input.py +0 -0
  25. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/cli/version_cli.py +0 -0
  26. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/config/__init__.py +0 -0
  27. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/config/editor.py +0 -0
  28. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/config/errors.py +0 -0
  29. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/config/news.py +0 -0
  30. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/config/schema.py +0 -0
  31. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/device/__init__.py +0 -0
  32. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/device/provision.py +0 -0
  33. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/device/provision_cli.py +0 -0
  34. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/log/__init__.py +0 -0
  35. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/mux/__init__.py +0 -0
  36. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/mux/runtime.py +0 -0
  37. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/mux/venv/__init__.py +0 -0
  38. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/mux/venv/emulator_cfg.py +0 -0
  39. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/mux/venv/maker.py +0 -0
  40. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/mux/venv/venv_cli.py +0 -0
  41. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/mux/venv_cfg.py +0 -0
  42. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/pluginhost/__init__.py +0 -0
  43. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/pluginhost/ctx.py +0 -0
  44. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/pluginhost/paths.py +0 -0
  45. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/pluginhost/plugin_cli.py +0 -0
  46. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/pluginhost/unsandboxed.py +0 -0
  47. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/py.typed +0 -0
  48. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/resource_bundle/__init__.py +0 -0
  49. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/resource_bundle/__main__.py +0 -0
  50. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/resource_bundle/data.py +0 -0
  51. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/ruyipkg/__init__.py +0 -0
  52. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/ruyipkg/admin_checksum.py +0 -0
  53. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/ruyipkg/admin_cli.py +0 -0
  54. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/ruyipkg/atom.py +0 -0
  55. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/ruyipkg/augmented_pkg.py +0 -0
  56. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/ruyipkg/canonical_dump.py +0 -0
  57. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/ruyipkg/checksum.py +0 -0
  58. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/ruyipkg/cli_completion.py +0 -0
  59. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/ruyipkg/distfile.py +0 -0
  60. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/ruyipkg/entity.py +0 -0
  61. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/ruyipkg/entity_cli.py +0 -0
  62. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/ruyipkg/entity_provider.py +0 -0
  63. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/ruyipkg/fetcher.py +0 -0
  64. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/ruyipkg/host.py +0 -0
  65. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/ruyipkg/install.py +0 -0
  66. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/ruyipkg/install_cli.py +0 -0
  67. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/ruyipkg/list.py +0 -0
  68. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/ruyipkg/list_cli.py +0 -0
  69. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/ruyipkg/list_filter.py +0 -0
  70. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/ruyipkg/msg.py +0 -0
  71. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/ruyipkg/news.py +0 -0
  72. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/ruyipkg/news_cli.py +0 -0
  73. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/ruyipkg/news_store.py +0 -0
  74. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/ruyipkg/pkg_manifest.py +0 -0
  75. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/ruyipkg/profile.py +0 -0
  76. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/ruyipkg/profile_cli.py +0 -0
  77. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/ruyipkg/protocols.py +0 -0
  78. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/ruyipkg/repo.py +0 -0
  79. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/ruyipkg/state.py +0 -0
  80. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/ruyipkg/unpack.py +0 -0
  81. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/ruyipkg/unpack_method.py +0 -0
  82. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/ruyipkg/update_cli.py +0 -0
  83. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/telemetry/__init__.py +0 -0
  84. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/telemetry/event.py +0 -0
  85. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/telemetry/scope.py +0 -0
  86. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/telemetry/telemetry_cli.py +0 -0
  87. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/utils/__init__.py +0 -0
  88. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/utils/ar.py +0 -0
  89. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/utils/ci.py +0 -0
  90. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/utils/frontmatter.py +0 -0
  91. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/utils/git.py +0 -0
  92. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/utils/l10n.py +0 -0
  93. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/utils/markdown.py +0 -0
  94. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/utils/mounts.py +0 -0
  95. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/utils/nuitka.py +0 -0
  96. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/utils/porcelain.py +0 -0
  97. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/utils/prereqs.py +0 -0
  98. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/utils/ssl_patch.py +0 -0
  99. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/utils/templating.py +0 -0
  100. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/utils/toml.py +0 -0
  101. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/utils/url.py +0 -0
  102. {ruyi-0.42.0b20251015 → ruyi-0.43.0a20251017}/ruyi/utils/xdg_basedir.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ruyi
3
- Version: 0.42.0b20251015
3
+ Version: 0.43.0a20251017
4
4
  Summary: Package manager for RuyiSDK
5
5
  License: Apache License
6
6
  Version 2.0, January 2004
@@ -225,7 +225,6 @@ Requires-Dist: argcomplete (>=2.0.0)
225
225
  Requires-Dist: arpy
226
226
  Requires-Dist: fastjsonschema (>=2.15.1)
227
227
  Requires-Dist: jinja2 (>=3,<4)
228
- Requires-Dist: packaging (>=21)
229
228
  Requires-Dist: pygit2 (>=1.6)
230
229
  Requires-Dist: pyyaml (>=5.4)
231
230
  Requires-Dist: requests (>=2,<3)
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
4
4
 
5
5
  [project]
6
6
  name = "ruyi"
7
- version = "0.42.0-beta.20251015"
7
+ version = "0.43.0-alpha.20251017"
8
8
  description = "Package manager for RuyiSDK"
9
9
  keywords = ["ruyi", "ruyisdk"]
10
10
  license = { file = "LICENSE-Apache.txt" }
@@ -33,7 +33,6 @@ dependencies = [
33
33
  "arpy",
34
34
  "fastjsonschema>=2.15.1",
35
35
  "jinja2 (>=3, <4)",
36
- "packaging>=21",
37
36
  "pygit2>=1.6",
38
37
  "pyyaml>=5.4",
39
38
  "requests (>=2, <3)",
@@ -11,6 +11,7 @@ from ruyi.utils.global_mode import (
11
11
  TRUTHY_ENV_VAR_VALUES,
12
12
  is_env_var_truthy,
13
13
  )
14
+ from ruyi.utils.node_info import probe_for_container_runtime
14
15
 
15
16
  # NOTE: no imports that directly or indirectly pull in pygit2 should go here,
16
17
  # because import of pygit2 will fail if done before ssl_patch. Notably this
@@ -32,6 +33,9 @@ def _is_allowed_to_run_as_root() -> bool:
32
33
  # CI environments are usually considered to be controlled, and safe
33
34
  # for root usage.
34
35
  return True
36
+ if probe_for_container_runtime(os.environ) != "unknown":
37
+ # So are container environments.
38
+ return True
35
39
  return False
36
40
 
37
41
 
@@ -6,6 +6,7 @@ from typing import Final, TYPE_CHECKING
6
6
  from ..config import GlobalConfig
7
7
  from ..telemetry.scope import TelemetryScope
8
8
  from ..utils.global_mode import GlobalModeProvider
9
+ from ..version import RUYI_SEMVER
9
10
  from . import RUYI_ENTRYPOINT_NAME
10
11
  from .oobe import OOBE
11
12
 
@@ -22,7 +23,11 @@ def is_called_as_ruyi(argv0: str) -> bool:
22
23
 
23
24
 
24
25
  def should_prompt_for_renaming(argv0: str) -> bool:
25
- return os.path.basename(argv0).lower().startswith(f"{RUYI_ENTRYPOINT_NAME}-")
26
+ # We need to allow things like "ruyi-qemu" through, to not break our mux.
27
+ # Only consider filenames starting with both our name *and* version to be
28
+ # un-renamed onefile artifacts that warrant a rename prompt.
29
+ likely_artifact_name_prefix = f"{RUYI_ENTRYPOINT_NAME}-{RUYI_SEMVER}."
30
+ return os.path.basename(argv0).lower().startswith(likely_artifact_name_prefix)
26
31
 
27
32
 
28
33
  def main(gm: GlobalModeProvider, gc: GlobalConfig, argv: list[str]) -> int:
@@ -65,7 +65,7 @@ class OOBE:
65
65
  handler()
66
66
 
67
67
  def _builtin_shell_completion_tip(self) -> None:
68
- from ..telemetry.node_info import probe_for_shell
68
+ from ..utils.node_info import probe_for_shell
69
69
  from .completion import SUPPORTED_SHELLS
70
70
 
71
71
  # Only show the tip if we're not externally managed by a package manager,
@@ -44,7 +44,7 @@ class RuyiHostAPI:
44
44
 
45
45
  @property
46
46
  def ruyi_version(self) -> str:
47
- return str(RUYI_SEMVER)
47
+ return RUYI_SEMVER
48
48
 
49
49
  @property
50
50
  def ruyi_plugin_api_rev(self) -> int:
@@ -3,8 +3,8 @@ from typing import Iterable, TypeAlias, TypedDict, TYPE_CHECKING
3
3
  if TYPE_CHECKING:
4
4
  from typing_extensions import NotRequired
5
5
 
6
+ from ..utils.node_info import NodeInfo
6
7
  from .event import TelemetryEvent
7
- from .node_info import NodeInfo
8
8
 
9
9
 
10
10
  class AggregatedTelemetryEvent(TypedDict):
@@ -8,7 +8,7 @@ from typing import Callable, TYPE_CHECKING, cast
8
8
  import uuid
9
9
 
10
10
  from ..log import RuyiLogger
11
- from .node_info import NodeInfo, gather_node_info
11
+ from ..utils.node_info import NodeInfo, gather_node_info
12
12
  from .scope import TelemetryScope
13
13
  from .store import TelemetryStore
14
14
 
@@ -8,10 +8,10 @@ from typing import Callable, Final, Iterable
8
8
  import uuid
9
9
 
10
10
  from ..log import RuyiLogger
11
+ from ..utils.node_info import NodeInfo
11
12
  from ..utils.url import urljoin_for_sure
12
13
  from .aggregate import UploadPayload, aggregate_events
13
14
  from .event import TelemetryEvent, is_telemetry_event
14
- from .node_info import NodeInfo
15
15
  from .scope import TelemetryScope
16
16
 
17
17
  # e.g. "run.202410201845.d06ca5d668e64fec833ed3e6eb926a2c.ndjson"
@@ -165,7 +165,7 @@ class TelemetryStore:
165
165
  payload: UploadPayload = {
166
166
  "fmt": 1,
167
167
  "nonce": payload_nonce,
168
- "ruyi_version": str(RUYI_SEMVER),
168
+ "ruyi_version": RUYI_SEMVER,
169
169
  "events": aggregate_data,
170
170
  }
171
171
  if installation_data is not None:
@@ -143,7 +143,7 @@ def _probe_cli_autocomplete(env: Mapping[str, str], argv: list[str]) -> bool:
143
143
  if arg.startswith("--output-completion-script"):
144
144
  return True
145
145
 
146
- return "_ARGCOMPLETE" in os.environ
146
+ return "_ARGCOMPLETE" in env
147
147
 
148
148
 
149
149
  class EnvGlobalModeProvider(GlobalModeProvider):
@@ -1,5 +1,6 @@
1
1
  import glob
2
2
  import os
3
+ import pathlib
3
4
  import platform
4
5
  import re
5
6
  import subprocess
@@ -10,7 +11,7 @@ import uuid
10
11
  if TYPE_CHECKING:
11
12
  from typing_extensions import NotRequired
12
13
 
13
- from ..utils.ci import probe_for_ci
14
+ from .ci import probe_for_ci
14
15
 
15
16
 
16
17
  class NodeInfo(TypedDict):
@@ -161,6 +162,56 @@ def probe_for_shell(os_environ: Mapping[str, str]) -> str:
161
162
  return "unknown"
162
163
 
163
164
 
165
+ def probe_for_container_runtime(os_environ: Mapping[str, str]) -> str:
166
+ """Check if we are likely running in a container. Probes FS and environment
167
+ for signatures of known container runtimes."""
168
+
169
+ # check environment markers first
170
+
171
+ if "KUBERNETES_SERVICE_HOST" in os_environ:
172
+ return "kubernetes"
173
+
174
+ if "container" in os_environ:
175
+ v = os_environ["container"].lower()
176
+ if v == "oci":
177
+ return "other-oci-compliant"
178
+ # could be e.g. "lxc", "lxc-libvirt", "systemd-nspawn", etc.
179
+ return v
180
+
181
+ # check for filesystem markers
182
+
183
+ if os.path.exists("/run/.containerenv"):
184
+ return "podman"
185
+ # Docker must be checked after Podman
186
+ if os.path.exists("/.dockerenv"):
187
+ return "docker"
188
+
189
+ try:
190
+ v = pathlib.Path("/run/systemd/container").read_text(encoding="utf-8").strip()
191
+ if v:
192
+ return v.lower()
193
+ except Exception:
194
+ pass
195
+
196
+ if _probe_for_wsl():
197
+ return "wsl"
198
+
199
+ return "unknown"
200
+
201
+
202
+ def _probe_for_wsl() -> bool:
203
+ if sys.platform != "linux":
204
+ return False
205
+ # http://github.com/Microsoft/WSL/issues/423#issuecomment-221627364
206
+ for path in ("/proc/sys/kernel/osrelease", "/proc/version"):
207
+ try:
208
+ ver = pathlib.Path(path).read_text(encoding="utf-8")
209
+ except Exception:
210
+ continue
211
+ return "Microsoft" in ver or "WSL" in ver
212
+ return False
213
+
214
+
164
215
  def gather_node_info(report_uuid: uuid.UUID | None = None) -> NodeInfo:
165
216
  arch = platform.machine()
166
217
  libc = probe_for_libc()
@@ -0,0 +1,20 @@
1
+ from typing import Final
2
+
3
+ RUYI_SEMVER: Final = "0.43.0-alpha.20251017"
4
+ RUYI_USER_AGENT: Final = f"ruyi/{RUYI_SEMVER}"
5
+
6
+ COPYRIGHT_NOTICE: Final = """\
7
+ Copyright (C) Institute of Software, Chinese Academy of Sciences (ISCAS).
8
+ All rights reserved.
9
+ License: Apache-2.0 <https://www.apache.org/licenses/LICENSE-2.0>
10
+ \
11
+ """
12
+
13
+ MPL_REDIST_NOTICE: Final = """\
14
+ This distribution of ruyi contains code licensed under the Mozilla Public
15
+ License 2.0 (https://mozilla.org/MPL/2.0/). You can get the respective
16
+ project's sources from the project's official website:
17
+
18
+ * certifi: https://github.com/certifi/python-certifi
19
+ \
20
+ """
@@ -1,67 +0,0 @@
1
- import importlib.metadata
2
- from typing import Final, TYPE_CHECKING
3
-
4
- import packaging.version
5
-
6
- if TYPE_CHECKING:
7
- # pyright only works with semver 3.x
8
- from semver.version import Version
9
- else:
10
- try:
11
- from semver.version import Version # type: ignore[import-untyped,unused-ignore]
12
- except ModuleNotFoundError:
13
- # semver 2.x
14
- from semver import VersionInfo as Version # type: ignore[import-untyped,unused-ignore]
15
-
16
- # NOTE: one cannot print logs in the version helpers, because the version info
17
- # is initialized so early (before argparse can look at argv because --version
18
- # requires version info to be ready) that the porcelain status is not yet
19
- # available.
20
-
21
- _PYPI_PRERELEASE_KINDS_MAP: Final = {
22
- "a": "alpha",
23
- "b": "beta",
24
- "rc": "rc",
25
- }
26
-
27
-
28
- # based on https://python-semver.readthedocs.io/en/3.0.2/advanced/convert-pypi-to-semver.html
29
- def _convert2semver(ver: packaging.version.Version) -> Version:
30
- if ver.epoch:
31
- raise ValueError("Can't convert an epoch to semver")
32
- if ver.post:
33
- raise ValueError("Can't convert a post part to semver")
34
-
35
- pre: str | None = None
36
- if ver.pre:
37
- kind, val = ver.pre
38
- pre = f"{_PYPI_PRERELEASE_KINDS_MAP.get(kind, kind)}.{val}"
39
-
40
- maj, min, pat = ver.release[:3]
41
- return Version(maj, min, pat, prerelease=pre, build=ver.dev)
42
-
43
-
44
- def _init_pkg_semver() -> Version:
45
- pkg_pypi_ver = packaging.version.Version(importlib.metadata.version("ruyi"))
46
- # log.D(f"PyPI-style version of ruyi: {pkg_pypi_ver}")
47
- return _convert2semver(pkg_pypi_ver)
48
-
49
-
50
- RUYI_SEMVER: Final = _init_pkg_semver()
51
- RUYI_USER_AGENT: Final = f"ruyi/{RUYI_SEMVER}"
52
-
53
- COPYRIGHT_NOTICE: Final = """\
54
- Copyright (C) Institute of Software, Chinese Academy of Sciences (ISCAS).
55
- All rights reserved.
56
- License: Apache-2.0 <https://www.apache.org/licenses/LICENSE-2.0>
57
- \
58
- """
59
-
60
- MPL_REDIST_NOTICE: Final = """\
61
- This distribution of ruyi contains code licensed under the Mozilla Public
62
- License 2.0 (https://mozilla.org/MPL/2.0/). You can get the respective
63
- project's sources from the project's official website:
64
-
65
- * certifi: https://github.com/certifi/python-certifi
66
- \
67
- """
File without changes