openbench-cli 0.0.1__py3-none-macosx_11_0_arm64.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.
Files changed (111) hide show
  1. ds_cli_bin/__init__.py +426 -0
  2. ds_cli_bin/bin/_internal/attrs-26.1.0.dist-info/INSTALLER +1 -0
  3. ds_cli_bin/bin/_internal/attrs-26.1.0.dist-info/METADATA +199 -0
  4. ds_cli_bin/bin/_internal/attrs-26.1.0.dist-info/RECORD +55 -0
  5. ds_cli_bin/bin/_internal/attrs-26.1.0.dist-info/WHEEL +4 -0
  6. ds_cli_bin/bin/_internal/attrs-26.1.0.dist-info/licenses/LICENSE +21 -0
  7. ds_cli_bin/bin/_internal/base_library.zip +0 -0
  8. ds_cli_bin/bin/_internal/certifi/cacert.pem +3959 -0
  9. ds_cli_bin/bin/_internal/certifi/py.typed +0 -0
  10. ds_cli_bin/bin/_internal/charset_normalizer/cd.cpython-312-darwin.so +0 -0
  11. ds_cli_bin/bin/_internal/charset_normalizer/md.cpython-312-darwin.so +0 -0
  12. ds_cli_bin/bin/_internal/jsonschema/benchmarks/issue232/issue.json +2653 -0
  13. ds_cli_bin/bin/_internal/jsonschema-4.26.0.dist-info/INSTALLER +1 -0
  14. ds_cli_bin/bin/_internal/jsonschema-4.26.0.dist-info/METADATA +170 -0
  15. ds_cli_bin/bin/_internal/jsonschema-4.26.0.dist-info/RECORD +83 -0
  16. ds_cli_bin/bin/_internal/jsonschema-4.26.0.dist-info/REQUESTED +0 -0
  17. ds_cli_bin/bin/_internal/jsonschema-4.26.0.dist-info/WHEEL +4 -0
  18. ds_cli_bin/bin/_internal/jsonschema-4.26.0.dist-info/entry_points.txt +2 -0
  19. ds_cli_bin/bin/_internal/jsonschema-4.26.0.dist-info/licenses/COPYING +19 -0
  20. ds_cli_bin/bin/_internal/jsonschema_specifications/schemas/draft201909/metaschema.json +42 -0
  21. ds_cli_bin/bin/_internal/jsonschema_specifications/schemas/draft201909/vocabularies/applicator +56 -0
  22. ds_cli_bin/bin/_internal/jsonschema_specifications/schemas/draft201909/vocabularies/content +17 -0
  23. ds_cli_bin/bin/_internal/jsonschema_specifications/schemas/draft201909/vocabularies/core +57 -0
  24. ds_cli_bin/bin/_internal/jsonschema_specifications/schemas/draft201909/vocabularies/format +14 -0
  25. ds_cli_bin/bin/_internal/jsonschema_specifications/schemas/draft201909/vocabularies/meta-data +37 -0
  26. ds_cli_bin/bin/_internal/jsonschema_specifications/schemas/draft201909/vocabularies/validation +98 -0
  27. ds_cli_bin/bin/_internal/jsonschema_specifications/schemas/draft202012/metaschema.json +58 -0
  28. ds_cli_bin/bin/_internal/jsonschema_specifications/schemas/draft202012/vocabularies/applicator +48 -0
  29. ds_cli_bin/bin/_internal/jsonschema_specifications/schemas/draft202012/vocabularies/content +17 -0
  30. ds_cli_bin/bin/_internal/jsonschema_specifications/schemas/draft202012/vocabularies/core +51 -0
  31. ds_cli_bin/bin/_internal/jsonschema_specifications/schemas/draft202012/vocabularies/format-annotation +14 -0
  32. ds_cli_bin/bin/_internal/jsonschema_specifications/schemas/draft202012/vocabularies/format-assertion +14 -0
  33. ds_cli_bin/bin/_internal/jsonschema_specifications/schemas/draft202012/vocabularies/meta-data +37 -0
  34. ds_cli_bin/bin/_internal/jsonschema_specifications/schemas/draft202012/vocabularies/unevaluated +15 -0
  35. ds_cli_bin/bin/_internal/jsonschema_specifications/schemas/draft202012/vocabularies/validation +98 -0
  36. ds_cli_bin/bin/_internal/jsonschema_specifications/schemas/draft3/metaschema.json +172 -0
  37. ds_cli_bin/bin/_internal/jsonschema_specifications/schemas/draft4/metaschema.json +149 -0
  38. ds_cli_bin/bin/_internal/jsonschema_specifications/schemas/draft6/metaschema.json +153 -0
  39. ds_cli_bin/bin/_internal/jsonschema_specifications/schemas/draft7/metaschema.json +166 -0
  40. ds_cli_bin/bin/_internal/libb2.1.dylib +0 -0
  41. ds_cli_bin/bin/_internal/libcrypto.3.dylib +0 -0
  42. ds_cli_bin/bin/_internal/libintl.8.dylib +0 -0
  43. ds_cli_bin/bin/_internal/liblzma.5.dylib +0 -0
  44. ds_cli_bin/bin/_internal/libpython3.12.dylib +0 -0
  45. ds_cli_bin/bin/_internal/libreadline.8.dylib +0 -0
  46. ds_cli_bin/bin/_internal/libssl.3.dylib +0 -0
  47. ds_cli_bin/bin/_internal/orjson/orjson.cpython-312-darwin.so +0 -0
  48. ds_cli_bin/bin/_internal/psutil/_psutil_osx.abi3.so +0 -0
  49. ds_cli_bin/bin/_internal/python3.12/lib-dynload/_asyncio.cpython-312-darwin.so +0 -0
  50. ds_cli_bin/bin/_internal/python3.12/lib-dynload/_bisect.cpython-312-darwin.so +0 -0
  51. ds_cli_bin/bin/_internal/python3.12/lib-dynload/_blake2.cpython-312-darwin.so +0 -0
  52. ds_cli_bin/bin/_internal/python3.12/lib-dynload/_bz2.cpython-312-darwin.so +0 -0
  53. ds_cli_bin/bin/_internal/python3.12/lib-dynload/_codecs_cn.cpython-312-darwin.so +0 -0
  54. ds_cli_bin/bin/_internal/python3.12/lib-dynload/_codecs_hk.cpython-312-darwin.so +0 -0
  55. ds_cli_bin/bin/_internal/python3.12/lib-dynload/_codecs_iso2022.cpython-312-darwin.so +0 -0
  56. ds_cli_bin/bin/_internal/python3.12/lib-dynload/_codecs_jp.cpython-312-darwin.so +0 -0
  57. ds_cli_bin/bin/_internal/python3.12/lib-dynload/_codecs_kr.cpython-312-darwin.so +0 -0
  58. ds_cli_bin/bin/_internal/python3.12/lib-dynload/_codecs_tw.cpython-312-darwin.so +0 -0
  59. ds_cli_bin/bin/_internal/python3.12/lib-dynload/_contextvars.cpython-312-darwin.so +0 -0
  60. ds_cli_bin/bin/_internal/python3.12/lib-dynload/_csv.cpython-312-darwin.so +0 -0
  61. ds_cli_bin/bin/_internal/python3.12/lib-dynload/_ctypes.cpython-312-darwin.so +0 -0
  62. ds_cli_bin/bin/_internal/python3.12/lib-dynload/_datetime.cpython-312-darwin.so +0 -0
  63. ds_cli_bin/bin/_internal/python3.12/lib-dynload/_decimal.cpython-312-darwin.so +0 -0
  64. ds_cli_bin/bin/_internal/python3.12/lib-dynload/_hashlib.cpython-312-darwin.so +0 -0
  65. ds_cli_bin/bin/_internal/python3.12/lib-dynload/_heapq.cpython-312-darwin.so +0 -0
  66. ds_cli_bin/bin/_internal/python3.12/lib-dynload/_json.cpython-312-darwin.so +0 -0
  67. ds_cli_bin/bin/_internal/python3.12/lib-dynload/_lzma.cpython-312-darwin.so +0 -0
  68. ds_cli_bin/bin/_internal/python3.12/lib-dynload/_md5.cpython-312-darwin.so +0 -0
  69. ds_cli_bin/bin/_internal/python3.12/lib-dynload/_multibytecodec.cpython-312-darwin.so +0 -0
  70. ds_cli_bin/bin/_internal/python3.12/lib-dynload/_multiprocessing.cpython-312-darwin.so +0 -0
  71. ds_cli_bin/bin/_internal/python3.12/lib-dynload/_opcode.cpython-312-darwin.so +0 -0
  72. ds_cli_bin/bin/_internal/python3.12/lib-dynload/_pickle.cpython-312-darwin.so +0 -0
  73. ds_cli_bin/bin/_internal/python3.12/lib-dynload/_posixshmem.cpython-312-darwin.so +0 -0
  74. ds_cli_bin/bin/_internal/python3.12/lib-dynload/_posixsubprocess.cpython-312-darwin.so +0 -0
  75. ds_cli_bin/bin/_internal/python3.12/lib-dynload/_queue.cpython-312-darwin.so +0 -0
  76. ds_cli_bin/bin/_internal/python3.12/lib-dynload/_random.cpython-312-darwin.so +0 -0
  77. ds_cli_bin/bin/_internal/python3.12/lib-dynload/_scproxy.cpython-312-darwin.so +0 -0
  78. ds_cli_bin/bin/_internal/python3.12/lib-dynload/_sha1.cpython-312-darwin.so +0 -0
  79. ds_cli_bin/bin/_internal/python3.12/lib-dynload/_sha2.cpython-312-darwin.so +0 -0
  80. ds_cli_bin/bin/_internal/python3.12/lib-dynload/_sha3.cpython-312-darwin.so +0 -0
  81. ds_cli_bin/bin/_internal/python3.12/lib-dynload/_socket.cpython-312-darwin.so +0 -0
  82. ds_cli_bin/bin/_internal/python3.12/lib-dynload/_ssl.cpython-312-darwin.so +0 -0
  83. ds_cli_bin/bin/_internal/python3.12/lib-dynload/_statistics.cpython-312-darwin.so +0 -0
  84. ds_cli_bin/bin/_internal/python3.12/lib-dynload/_struct.cpython-312-darwin.so +0 -0
  85. ds_cli_bin/bin/_internal/python3.12/lib-dynload/_uuid.cpython-312-darwin.so +0 -0
  86. ds_cli_bin/bin/_internal/python3.12/lib-dynload/_zoneinfo.cpython-312-darwin.so +0 -0
  87. ds_cli_bin/bin/_internal/python3.12/lib-dynload/array.cpython-312-darwin.so +0 -0
  88. ds_cli_bin/bin/_internal/python3.12/lib-dynload/audioop.cpython-312-darwin.so +0 -0
  89. ds_cli_bin/bin/_internal/python3.12/lib-dynload/binascii.cpython-312-darwin.so +0 -0
  90. ds_cli_bin/bin/_internal/python3.12/lib-dynload/fcntl.cpython-312-darwin.so +0 -0
  91. ds_cli_bin/bin/_internal/python3.12/lib-dynload/grp.cpython-312-darwin.so +0 -0
  92. ds_cli_bin/bin/_internal/python3.12/lib-dynload/math.cpython-312-darwin.so +0 -0
  93. ds_cli_bin/bin/_internal/python3.12/lib-dynload/mmap.cpython-312-darwin.so +0 -0
  94. ds_cli_bin/bin/_internal/python3.12/lib-dynload/pyexpat.cpython-312-darwin.so +0 -0
  95. ds_cli_bin/bin/_internal/python3.12/lib-dynload/readline.cpython-312-darwin.so +0 -0
  96. ds_cli_bin/bin/_internal/python3.12/lib-dynload/resource.cpython-312-darwin.so +0 -0
  97. ds_cli_bin/bin/_internal/python3.12/lib-dynload/select.cpython-312-darwin.so +0 -0
  98. ds_cli_bin/bin/_internal/python3.12/lib-dynload/syslog.cpython-312-darwin.so +0 -0
  99. ds_cli_bin/bin/_internal/python3.12/lib-dynload/termios.cpython-312-darwin.so +0 -0
  100. ds_cli_bin/bin/_internal/python3.12/lib-dynload/unicodedata.cpython-312-darwin.so +0 -0
  101. ds_cli_bin/bin/_internal/python3.12/lib-dynload/zlib.cpython-312-darwin.so +0 -0
  102. ds_cli_bin/bin/_internal/rpds/rpds.cpython-312-darwin.so +0 -0
  103. ds_cli_bin/bin/_internal/setuptools/_vendor/jaraco/text/Lorem ipsum.txt +2 -0
  104. ds_cli_bin/bin/_internal/yaml/_yaml.cpython-312-darwin.so +0 -0
  105. ds_cli_bin/bin/ob +0 -0
  106. ds_cli_bin/release_config.py +5 -0
  107. openbench_cli-0.0.1.dist-info/METADATA +9 -0
  108. openbench_cli-0.0.1.dist-info/RECORD +111 -0
  109. openbench_cli-0.0.1.dist-info/WHEEL +5 -0
  110. openbench_cli-0.0.1.dist-info/entry_points.txt +2 -0
  111. openbench_cli-0.0.1.dist-info/top_level.txt +1 -0
ds_cli_bin/__init__.py ADDED
@@ -0,0 +1,426 @@
1
+ import json
2
+ import os
3
+ import shlex
4
+ import subprocess
5
+ import sys
6
+ import time
7
+ from importlib.metadata import version
8
+ from importlib.resources import files
9
+ from pathlib import Path
10
+ from urllib.request import urlopen
11
+
12
+
13
+ PACKAGE_NAME = "openbench-cli"
14
+ DEFAULT_CHECK_INTERVAL_SECONDS = 0
15
+ try:
16
+ from .release_config import DEFAULT_PIP_INDEX_ARGS, DEFAULT_PYPI_JSON_URL
17
+ except Exception:
18
+ DEFAULT_PYPI_JSON_URL = f"https://pypi.org/pypi/{PACKAGE_NAME}/json"
19
+ DEFAULT_PIP_INDEX_ARGS = [
20
+ "-i",
21
+ "https://pypi.org/simple",
22
+ ]
23
+
24
+
25
+ def _cache_path():
26
+ cache_name = os.getenv("DS_CLI_FLAT_UPDATE_CACHE", "update-check.json")
27
+ return Path.home() / ".ob-flat" / cache_name
28
+
29
+
30
+ def _pypi_json_url():
31
+ return os.getenv("DS_CLI_FLAT_UPDATE_JSON_URL", DEFAULT_PYPI_JSON_URL)
32
+
33
+
34
+ def _pip_index_args():
35
+ override = os.getenv("DS_CLI_FLAT_PIP_INDEX_ARGS")
36
+ if override:
37
+ return override.split()
38
+ return list(DEFAULT_PIP_INDEX_ARGS)
39
+
40
+
41
+ def _check_interval_seconds():
42
+ try:
43
+ return max(0, int(os.getenv("DS_CLI_FLAT_UPDATE_CACHE_SECONDS", DEFAULT_CHECK_INTERVAL_SECONDS)))
44
+ except ValueError:
45
+ return DEFAULT_CHECK_INTERVAL_SECONDS
46
+
47
+
48
+ def _load_cached_latest():
49
+ path = _cache_path()
50
+ if not path.exists():
51
+ return None
52
+
53
+ try:
54
+ data = json.loads(path.read_text(encoding="utf-8"))
55
+ checked_at = data.get("checked_at", 0)
56
+ if time.time() - checked_at > _check_interval_seconds():
57
+ return None
58
+ return data.get("latest")
59
+ except Exception:
60
+ return None
61
+
62
+
63
+ def _save_cached_latest(latest):
64
+ path = _cache_path()
65
+ path.parent.mkdir(parents=True, exist_ok=True)
66
+ path.write_text(
67
+ json.dumps({"checked_at": time.time(), "latest": latest}),
68
+ encoding="utf-8",
69
+ )
70
+
71
+
72
+ def _fetch_latest_version(version_cls):
73
+ with urlopen(_pypi_json_url(), timeout=2) as response:
74
+ data = json.loads(response.read().decode("utf-8"))
75
+
76
+ versions = []
77
+ for raw_version, files_info in data.get("releases", {}).items():
78
+ parsed = version_cls(raw_version)
79
+ if parsed.is_prerelease:
80
+ continue
81
+ if files_info and all(item.get("yanked", False) for item in files_info):
82
+ continue
83
+ versions.append(parsed)
84
+
85
+ if not versions:
86
+ return None
87
+
88
+ return str(max(versions))
89
+
90
+
91
+ def _upgrade_command():
92
+ base = [_python_executable(), "-m", "pip", "install", "-U"]
93
+ base.extend(_pip_index_args())
94
+ base.append(PACKAGE_NAME)
95
+ return base
96
+
97
+
98
+ def _python_executable():
99
+ executable = Path(sys.executable)
100
+ if os.name == "nt" and executable.name.lower() == "ob.exe":
101
+ candidate = Path(sys.prefix) / "Scripts" / "python.exe"
102
+ if candidate.exists():
103
+ return str(candidate)
104
+ return sys.executable
105
+
106
+
107
+ def _format_command(args):
108
+ if os.name == "nt":
109
+ return subprocess.list2cmdline(args)
110
+ return " ".join(shlex.quote(arg) for arg in args)
111
+
112
+
113
+ def _run_upgrade_after_exit(command):
114
+ updater_path = Path.home() / ".ob" / f"self-update-{os.getpid()}.py"
115
+ updater_path.parent.mkdir(parents=True, exist_ok=True)
116
+ updater_path.write_text(
117
+ """
118
+ import ctypes
119
+ import json
120
+ import os
121
+ import subprocess
122
+ import sys
123
+ import time
124
+
125
+
126
+ def wait_for_parent(pid, timeout_seconds=60):
127
+ if os.name == "nt":
128
+ handle = ctypes.windll.kernel32.OpenProcess(0x00100000, False, pid)
129
+ if handle:
130
+ try:
131
+ ctypes.windll.kernel32.WaitForSingleObject(handle, int(timeout_seconds * 1000))
132
+ finally:
133
+ ctypes.windll.kernel32.CloseHandle(handle)
134
+ return
135
+
136
+ deadline = time.time() + timeout_seconds
137
+ while time.time() < deadline:
138
+ try:
139
+ os.kill(pid, 0)
140
+ except OSError:
141
+ return
142
+ time.sleep(0.2)
143
+
144
+
145
+ def format_command(command):
146
+ if os.name == "nt":
147
+ return subprocess.list2cmdline(command)
148
+ return " ".join(command)
149
+
150
+
151
+ def restore_prompt():
152
+ if os.name != "nt" or os.getenv("DS_CLI_RESTORE_PROMPT", "1") == "0":
153
+ return
154
+
155
+ try:
156
+ from ctypes import wintypes
157
+
158
+ STD_INPUT_HANDLE = -10
159
+ KEY_EVENT = 0x0001
160
+ VK_RETURN = 0x0D
161
+
162
+ class KEY_EVENT_RECORD(ctypes.Structure):
163
+ _fields_ = [
164
+ ("bKeyDown", wintypes.BOOL),
165
+ ("wRepeatCount", wintypes.WORD),
166
+ ("wVirtualKeyCode", wintypes.WORD),
167
+ ("wVirtualScanCode", wintypes.WORD),
168
+ ("uChar", wintypes.WCHAR),
169
+ ("dwControlKeyState", wintypes.DWORD),
170
+ ]
171
+
172
+ class INPUT_RECORD(ctypes.Structure):
173
+ _fields_ = [
174
+ ("EventType", wintypes.WORD),
175
+ ("KeyEvent", KEY_EVENT_RECORD),
176
+ ]
177
+
178
+ records = (INPUT_RECORD * 2)()
179
+ records[0].EventType = KEY_EVENT
180
+ records[0].KeyEvent = KEY_EVENT_RECORD(True, 1, VK_RETURN, 0, "\\r", 0)
181
+ records[1].EventType = KEY_EVENT
182
+ records[1].KeyEvent = KEY_EVENT_RECORD(False, 1, VK_RETURN, 0, "\\r", 0)
183
+
184
+ written = wintypes.DWORD()
185
+ handle = ctypes.windll.kernel32.GetStdHandle(STD_INPUT_HANDLE)
186
+ ctypes.windll.kernel32.WriteConsoleInputW(handle, records, 2, ctypes.byref(written))
187
+ except Exception:
188
+ pass
189
+
190
+
191
+ def main():
192
+ parent_pid = int(sys.argv[1])
193
+ command = json.loads(sys.argv[2])
194
+ wait_for_parent(parent_pid)
195
+ time.sleep(0.5)
196
+ print("[ob] Running update command:")
197
+ print(" " + format_command(command))
198
+ rc = subprocess.call(command)
199
+ if rc == 0:
200
+ print("[ob] Update completed. Please run your command again.")
201
+ else:
202
+ print("[ob] Update failed. Please run the update command manually.", file=sys.stderr)
203
+ sys.stdout.flush()
204
+ sys.stderr.flush()
205
+ restore_prompt()
206
+ try:
207
+ os.remove(__file__)
208
+ except OSError:
209
+ pass
210
+ return rc
211
+
212
+
213
+ if __name__ == "__main__":
214
+ raise SystemExit(main())
215
+ """.lstrip(),
216
+ encoding="utf-8",
217
+ )
218
+
219
+ subprocess.Popen(
220
+ [_python_executable(), str(updater_path), str(os.getpid()), json.dumps(command)],
221
+ close_fds=False,
222
+ )
223
+ print("[ob] 已启动自动升级进程,当前命令将退出。")
224
+ print("[ob] Auto-update has started. The current command will exit.")
225
+ return 2
226
+
227
+
228
+ def _can_update_in_current_process():
229
+ return os.name != "nt"
230
+
231
+
232
+ def _run_upgrade():
233
+ command = _upgrade_command()
234
+ print("[ob] 正在升级,请稍候...")
235
+ print("[ob] Updating, please wait...")
236
+ if not _can_update_in_current_process():
237
+ return _run_upgrade_after_exit(command)
238
+
239
+ result = subprocess.run(command)
240
+ if result.returncode == 0:
241
+ print("[ob] 升级完成,请重新执行命令。")
242
+ print("[ob] Update completed. Please run your command again.")
243
+ else:
244
+ print(
245
+ f"[ob] 升级失败,请手动执行:\n"
246
+ f" {_format_command(command)}\n"
247
+ f"[ob] Update failed. Please run manually:\n"
248
+ f" {_format_command(command)}",
249
+ file=sys.stderr,
250
+ )
251
+ return result.returncode or 2
252
+
253
+
254
+ def _confirm_upgrade():
255
+ if not sys.stdin.isatty():
256
+ return False
257
+ try:
258
+ answer = input("[ob] 是否现在自动升级?输入 y 继续,其他输入退出 / Update now? Enter y to continue: ")
259
+ except (EOFError, KeyboardInterrupt):
260
+ return False
261
+ return answer.strip().lower() == "y"
262
+
263
+
264
+ def _ensure_latest_version():
265
+ try:
266
+ from packaging.version import Version
267
+
268
+ current = Version(version(PACKAGE_NAME))
269
+
270
+ latest = _load_cached_latest()
271
+ if latest is None:
272
+ latest = _fetch_latest_version(Version)
273
+ if latest:
274
+ _save_cached_latest(latest)
275
+
276
+ if latest and Version(latest) > current:
277
+ command = _upgrade_command()
278
+ print(
279
+ f"[ob] 当前工具版本过低,请升级。\n"
280
+ f"[ob] 当前版本:{current},最新版本:{latest}。\n"
281
+ f"[ob] The current tool version is too old. Please upgrade. "
282
+ f"Current version: {current}; latest version: {latest}.\n"
283
+ f"[ob] 升级命令 / Upgrade command:\n"
284
+ f" {_format_command(command)}",
285
+ file=sys.stderr,
286
+ flush=True,
287
+ )
288
+ if os.getenv("DS_CLI_AUTO_UPDATE") == "1" or _confirm_upgrade():
289
+ return _run_upgrade()
290
+ return 2
291
+ except Exception as exc:
292
+ command = _upgrade_command()
293
+ print(
294
+ f"[ob] 无法校验最新版本,命令不能继续执行。\n"
295
+ f"[ob] Failed to verify latest version, so the command cannot continue.\n"
296
+ f"[ob] 原因 / Reason: {exc}\n"
297
+ f"[ob] 可先尝试升级 / Try updating first:\n"
298
+ f" {_format_command(command)}",
299
+ file=sys.stderr,
300
+ flush=True,
301
+ )
302
+ return 3
303
+
304
+ return 0
305
+
306
+
307
+ def _heal_stale_modules():
308
+ """清理打包目录内不属于「当前 wheel」的旧版本残留编译文件(自愈)。
309
+
310
+ 老用户先装过旧版本(如非 flat 的 `aispeech-ds-cli` 或更早的 feature_flat 构建),
311
+ 其编译模块(如 ``_internal/psutil/_psutil_osx.cpython-312-darwin.so``)会残留在
312
+ ``bin/_internal/`` 下。pip 覆盖安装新 wheel 时只按新 RECORD 写入/覆盖文件,
313
+ 不会删除这些不属于新 wheel 的残留文件,导致 Python 加载到旧版本缺少
314
+ ``getpagesize`` 的 ``_psutil_osx`` 而报 ``AttributeError``。
315
+
316
+ 这里以「当前安装的 RECORD(importlib.metadata.files)」为准,把 ``bin/_internal``
317
+ 下不属于本安装的编译模块(``.so`` / ``.pyd`` / ``.dylib`` / ``.dll``)删除,
318
+ 使老用户升级后运行一次即恢复,无需手动卸载重装。
319
+ """
320
+ # 以「当前运行包所在 site-packages」为准,只在本位置下找
321
+ # openbench_cli-*.dist-info(避免全局扫描误选到其它环境/残留的同名包),
322
+ # 并取版本最高的那一份(即最新安装),再校验其 RECORD 必须包含当前 launcher 自身。
323
+ site_root = Path(__file__).resolve().parent.parent # site-packages
324
+ norm_name = PACKAGE_NAME.lower().replace("-", "_")
325
+ prefix = norm_name + "-"
326
+
327
+ def _version_key(version_str):
328
+ parts = []
329
+ for chunk in (version_str or "0").split("."):
330
+ digits = ""
331
+ for ch in chunk:
332
+ if ch.isdigit():
333
+ digits += ch
334
+ else:
335
+ break
336
+ parts.append(int(digits) if digits else 0)
337
+ return tuple(parts)
338
+
339
+ try:
340
+ dist_infos = [
341
+ d for d in site_root.glob("*.dist-info")
342
+ if d.name.lower().startswith(prefix)
343
+ ]
344
+ except Exception:
345
+ return
346
+ if not dist_infos:
347
+ return
348
+
349
+ dist_infos = sorted(
350
+ dist_infos,
351
+ key=lambda d: _version_key(d.name[len(prefix):].removesuffix(".dist-info")),
352
+ reverse=True,
353
+ )
354
+
355
+ owned = set()
356
+ found_self = False
357
+ for dist_info in dist_infos:
358
+ record = dist_info / "RECORD"
359
+ if not record.is_file():
360
+ continue
361
+ current_owned = set()
362
+ try:
363
+ for line in record.read_text(encoding="utf-8").splitlines():
364
+ if not line.strip():
365
+ continue
366
+ rel = line.split(",", 1)[0]
367
+ current_owned.add(str((site_root / rel).resolve()))
368
+ except Exception:
369
+ continue
370
+ # 必须包含当前 launcher 自身,否则不是本包(或旧残留),跳过以免误删
371
+ if str(Path(__file__).resolve()) not in current_owned:
372
+ continue
373
+ owned = current_owned
374
+ found_self = True
375
+ break
376
+
377
+ if not found_self or not owned:
378
+ return
379
+
380
+ try:
381
+ internal = Path(str(files(__package__).joinpath("bin", "_internal")))
382
+ except Exception:
383
+ return
384
+ if not internal.is_dir():
385
+ return
386
+
387
+ extensions = (".so", ".pyd", ".dylib", ".dll")
388
+ removed = []
389
+ for path in internal.rglob("*"):
390
+ if not path.is_file():
391
+ continue
392
+ if path.suffix not in extensions:
393
+ continue
394
+ if str(path.resolve()) in owned:
395
+ continue
396
+ try:
397
+ path.unlink()
398
+ removed.append(path.name)
399
+ except OSError:
400
+ continue
401
+
402
+ if removed:
403
+ print(f"[ob] 检测到 {len(removed)} 个旧版本残留文件,已自动清理:{', '.join(sorted(removed))}")
404
+ # 清理后如果没有子文件了,顺带移除空目录(尽力而为,失败不处理)
405
+ for d in sorted((p for p in internal.rglob("*") if p.is_dir()), key=lambda p: len(str(p)), reverse=True):
406
+ try:
407
+ d.rmdir()
408
+ except OSError:
409
+ pass
410
+
411
+
412
+ def main():
413
+ # 该包以 wheel 方式分发(未必发布到 PyPI),默认不做版本自检/自动升级,
414
+ # 以保证在无网络或未发布时命令仍可运行。需要自检时用 DS_CLI_FLAT_UPDATE_CHECK=1。
415
+ if os.getenv("DS_CLI_FLAT_UPDATE_CHECK") == "1":
416
+ update_status = _ensure_latest_version()
417
+ if update_status != 0:
418
+ return update_status
419
+
420
+ # 升级覆盖安装后,先清理旧版本残留的编译模块,避免加载到旧 .so 出错
421
+ _heal_stale_modules()
422
+
423
+ exe_name = "ob.exe" if sys.platform.startswith("win") else "ob"
424
+ exe = files(__package__).joinpath("bin", exe_name)
425
+ result = subprocess.run([str(exe), *sys.argv[1:]])
426
+ return result.returncode
@@ -0,0 +1,199 @@
1
+ Metadata-Version: 2.4
2
+ Name: attrs
3
+ Version: 26.1.0
4
+ Summary: Classes Without Boilerplate
5
+ Project-URL: Documentation, https://www.attrs.org/
6
+ Project-URL: Changelog, https://www.attrs.org/en/stable/changelog.html
7
+ Project-URL: GitHub, https://github.com/python-attrs/attrs
8
+ Project-URL: Funding, https://github.com/sponsors/hynek
9
+ Project-URL: Tidelift, https://tidelift.com/subscription/pkg/pypi-attrs?utm_source=pypi-attrs&utm_medium=pypi
10
+ Author-email: Hynek Schlawack <hs@ox.cx>
11
+ License-Expression: MIT
12
+ License-File: LICENSE
13
+ Keywords: attribute,boilerplate,class
14
+ Classifier: Development Status :: 5 - Production/Stable
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Programming Language :: Python :: 3.14
21
+ Classifier: Programming Language :: Python :: Implementation :: CPython
22
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
23
+ Classifier: Typing :: Typed
24
+ Requires-Python: >=3.9
25
+ Description-Content-Type: text/markdown
26
+
27
+ <p align="center">
28
+ <a href="https://www.attrs.org/">
29
+ <img src="https://raw.githubusercontent.com/python-attrs/attrs/main/docs/_static/attrs_logo.svg" width="35%" alt="attrs" />
30
+ </a>
31
+ </p>
32
+
33
+
34
+ *attrs* is the Python package that will bring back the **joy** of **writing classes** by relieving you from the drudgery of implementing object protocols (aka [dunder methods](https://www.attrs.org/en/latest/glossary.html#term-dunder-methods)).
35
+ Trusted by NASA for [Mars missions since 2020](https://github.com/readme/featured/nasa-ingenuity-helicopter)!
36
+
37
+ Its main goal is to help you to write **concise** and **correct** software without slowing down your code.
38
+
39
+
40
+ ## Sponsors
41
+
42
+ *attrs* would not be possible without our [amazing sponsors](https://github.com/sponsors/hynek).
43
+ Especially those generously supporting us at the *The Organization* tier and higher:
44
+
45
+ <!-- sponsor-break-begin -->
46
+
47
+ <p align="center">
48
+
49
+ <!-- [[[cog
50
+ import pathlib, tomllib
51
+
52
+ for sponsor in tomllib.loads(pathlib.Path("pyproject.toml").read_text())["tool"]["sponcon"]["sponsors"]:
53
+ print(f'<a href="{sponsor["url"]}"><img title="{sponsor["title"]}" src="https://www.attrs.org/en/26.1.0/_static/sponsors/{sponsor["img"]}" width="190" /></a>')
54
+ ]]] -->
55
+ <a href="https://www.variomedia.de/"><img title="Variomedia AG" src="https://www.attrs.org/en/26.1.0/_static/sponsors/Variomedia.svg" width="190" /></a>
56
+ <a href="https://tidelift.com/?utm_source=lifter&utm_medium=referral&utm_campaign=hynek"><img title="Tidelift" src="https://www.attrs.org/en/26.1.0/_static/sponsors/Tidelift.svg" width="190" /></a>
57
+ <a href="https://kraken.tech/"><img title="Kraken Tech" src="https://www.attrs.org/en/26.1.0/_static/sponsors/Kraken.svg" width="190" /></a>
58
+ <a href="https://privacy-solutions.org/"><img title="Privacy Solutions" src="https://www.attrs.org/en/26.1.0/_static/sponsors/Privacy-Solutions.svg" width="190" /></a>
59
+ <a href="https://filepreviews.io/"><img title="FilePreviews" src="https://www.attrs.org/en/26.1.0/_static/sponsors/FilePreviews.svg" width="190" /></a>
60
+ <a href="https://www.testmuai.com/?utm_medium=sponsor&utm_source=structlog"><img title="TestMu AI" src="https://www.attrs.org/en/26.1.0/_static/sponsors/TestMu-AI.svg" width="190" /></a>
61
+ <a href="https://polar.sh/"><img title="Polar" src="https://www.attrs.org/en/26.1.0/_static/sponsors/Polar.svg" width="190" /></a>
62
+ <!-- [[[end]]] -->
63
+
64
+ </p>
65
+
66
+ <!-- sponsor-break-end -->
67
+
68
+ <p align="center">
69
+ <strong>Please consider <a href="https://github.com/sponsors/hynek">joining them</a> to help make <em>attrs</em>’s maintenance more sustainable!</strong>
70
+ </p>
71
+
72
+ <!-- teaser-end -->
73
+
74
+ ## Example
75
+
76
+ *attrs* gives you a class decorator and a way to declaratively define the attributes on that class:
77
+
78
+ <!-- code-begin -->
79
+
80
+ ```pycon
81
+ >>> from attrs import asdict, define, make_class, Factory
82
+
83
+ >>> @define
84
+ ... class SomeClass:
85
+ ... a_number: int = 42
86
+ ... list_of_numbers: list[int] = Factory(list)
87
+ ...
88
+ ... def hard_math(self, another_number):
89
+ ... return self.a_number + sum(self.list_of_numbers) * another_number
90
+
91
+
92
+ >>> sc = SomeClass(1, [1, 2, 3])
93
+ >>> sc
94
+ SomeClass(a_number=1, list_of_numbers=[1, 2, 3])
95
+
96
+ >>> sc.hard_math(3)
97
+ 19
98
+ >>> sc == SomeClass(1, [1, 2, 3])
99
+ True
100
+ >>> sc != SomeClass(2, [3, 2, 1])
101
+ True
102
+
103
+ >>> asdict(sc)
104
+ {'a_number': 1, 'list_of_numbers': [1, 2, 3]}
105
+
106
+ >>> SomeClass()
107
+ SomeClass(a_number=42, list_of_numbers=[])
108
+
109
+ >>> C = make_class("C", ["a", "b"])
110
+ >>> C("foo", "bar")
111
+ C(a='foo', b='bar')
112
+ ```
113
+
114
+ After *declaring* your attributes, *attrs* gives you:
115
+
116
+ - a concise and explicit overview of the class's attributes,
117
+ - a nice human-readable `__repr__`,
118
+ - equality-checking methods,
119
+ - an initializer,
120
+ - and much more,
121
+
122
+ *without* writing dull boilerplate code again and again and *without* runtime performance penalties.
123
+
124
+ ---
125
+
126
+ This example uses *attrs*'s modern APIs that have been introduced in version 20.1.0, and the *attrs* package import name that has been added in version 21.3.0.
127
+ The classic APIs (`@attr.s`, `attr.ib`, plus their serious-business aliases) and the `attr` package import name will remain **indefinitely**.
128
+
129
+ Check out [*On The Core API Names*](https://www.attrs.org/en/latest/names.html) for an in-depth explanation!
130
+
131
+
132
+ ### Hate Type Annotations!?
133
+
134
+ No problem!
135
+ Types are entirely **optional** with *attrs*.
136
+ Simply assign `attrs.field()` to the attributes instead of annotating them with types:
137
+
138
+ ```python
139
+ from attrs import define, field
140
+
141
+ @define
142
+ class SomeClass:
143
+ a_number = field(default=42)
144
+ list_of_numbers = field(factory=list)
145
+ ```
146
+
147
+
148
+ ## Data Classes
149
+
150
+ On the tin, *attrs* might remind you of `dataclasses` (and indeed, `dataclasses` [are a descendant](https://hynek.me/articles/import-attrs/) of *attrs*).
151
+ In practice it does a lot more and is more flexible.
152
+ For instance, it allows you to define [special handling of NumPy arrays for equality checks](https://www.attrs.org/en/stable/comparison.html#customization), allows more ways to [plug into the initialization process](https://www.attrs.org/en/stable/init.html#hooking-yourself-into-initialization), has a replacement for `__init_subclass__`, and allows for stepping through the generated methods using a debugger.
153
+
154
+ For more details, please refer to our [comparison page](https://www.attrs.org/en/stable/why.html#data-classes), but generally speaking, we are more likely to commit crimes against nature to make things work that one would expect to work, but that are quite complicated in practice.
155
+
156
+
157
+ ## Project Information
158
+
159
+ - [**Changelog**](https://www.attrs.org/en/stable/changelog.html)
160
+ - [**Documentation**](https://www.attrs.org/)
161
+ - [**PyPI**](https://pypi.org/project/attrs/)
162
+ - [**Source Code**](https://github.com/python-attrs/attrs)
163
+ - [**Contributing**](https://github.com/python-attrs/attrs/blob/main/.github/CONTRIBUTING.md)
164
+ - [**Third-party Extensions**](https://github.com/python-attrs/attrs/wiki/Extensions-to-attrs)
165
+ - **Get Help**: use the `python-attrs` tag on [Stack Overflow](https://stackoverflow.com/questions/tagged/python-attrs)
166
+
167
+
168
+ ### *attrs* for Enterprise
169
+
170
+ Available as part of the [Tidelift Subscription](https://tidelift.com/?utm_source=lifter&utm_medium=referral&utm_campaign=hynek).
171
+
172
+ The maintainers of *attrs* and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source packages you use to build your applications.
173
+ Save time, reduce risk, and improve code health, while paying the maintainers of the exact packages you use.
174
+
175
+ ## Release Information
176
+
177
+ ### Backwards-incompatible Changes
178
+
179
+ - Field aliases are now resolved *before* calling `field_transformer`, so transformers receive fully populated `Attribute` objects with usable `alias` values instead of `None`.
180
+ The new `Attribute.alias_is_default` flag indicates whether the alias was auto-generated (`True`) or explicitly set by the user (`False`).
181
+ [#1509](https://github.com/python-attrs/attrs/issues/1509)
182
+
183
+
184
+ ### Changes
185
+
186
+ - Fix type annotations for `attrs.validators.optional()`, so it no longer rejects tuples with more than one validator.
187
+ [#1496](https://github.com/python-attrs/attrs/issues/1496)
188
+ - The `attrs.validators.disabled()` contextmanager can now be nested.
189
+ [#1513](https://github.com/python-attrs/attrs/issues/1513)
190
+ - Frozen classes can set `on_setattr=attrs.setters.NO_OP` in addition to `None`.
191
+ [#1515](https://github.com/python-attrs/attrs/issues/1515)
192
+ - It's now possible to pass *attrs* **instances** in addition to *attrs* **classes** to `attrs.fields()`.
193
+ [#1529](https://github.com/python-attrs/attrs/issues/1529)
194
+
195
+
196
+
197
+ ---
198
+
199
+ [Full changelog →](https://www.attrs.org/en/stable/changelog.html)
@@ -0,0 +1,55 @@
1
+ attr/__init__.py,sha256=fOYIvt1eGSqQre4uCS3sJWKZ0mwAuC8UD6qba5OS9_U,2057
2
+ attr/__init__.pyi,sha256=pVGImAUVovq2_TYl_r_HIYnGlyOaoCuEhxo-EvsnnSc,11325
3
+ attr/__pycache__/__init__.cpython-312.pyc,,
4
+ attr/__pycache__/_cmp.cpython-312.pyc,,
5
+ attr/__pycache__/_compat.cpython-312.pyc,,
6
+ attr/__pycache__/_config.cpython-312.pyc,,
7
+ attr/__pycache__/_funcs.cpython-312.pyc,,
8
+ attr/__pycache__/_make.cpython-312.pyc,,
9
+ attr/__pycache__/_next_gen.cpython-312.pyc,,
10
+ attr/__pycache__/_version_info.cpython-312.pyc,,
11
+ attr/__pycache__/converters.cpython-312.pyc,,
12
+ attr/__pycache__/exceptions.cpython-312.pyc,,
13
+ attr/__pycache__/filters.cpython-312.pyc,,
14
+ attr/__pycache__/setters.cpython-312.pyc,,
15
+ attr/__pycache__/validators.cpython-312.pyc,,
16
+ attr/_cmp.py,sha256=3Nn1TjxllUYiX_nJoVnEkXoDk0hM1DYKj5DE7GZe4i0,4117
17
+ attr/_cmp.pyi,sha256=U-_RU_UZOyPUEQzXE6RMYQQcjkZRY25wTH99sN0s7MM,368
18
+ attr/_compat.py,sha256=x0g7iEUOnBVJC72zyFCgb1eKqyxS-7f2LGnNyZ_r95s,2829
19
+ attr/_config.py,sha256=dGq3xR6fgZEF6UBt_L0T-eUHIB4i43kRmH0P28sJVw8,843
20
+ attr/_funcs.py,sha256=Ix5IETTfz5F01F-12MF_CSFomIn2h8b67EVVz2gCtBE,16479
21
+ attr/_make.py,sha256=H7OH2eWS5CnBzLUjNFE1WymfPrmF1r8fv2RPdt9MuYA,106129
22
+ attr/_next_gen.py,sha256=BQtCUlzwg2gWHTYXBQvrEYBnzBUrDvO57u0Py6UCPhc,26274
23
+ attr/_typing_compat.pyi,sha256=XDP54TUn-ZKhD62TOQebmzrwFyomhUCoGRpclb6alRA,469
24
+ attr/_version_info.py,sha256=w4R-FYC3NK_kMkGUWJlYP4cVAlH9HRaC-um3fcjYkHM,2222
25
+ attr/_version_info.pyi,sha256=x_M3L3WuB7r_ULXAWjx959udKQ4HLB8l-hsc1FDGNvk,209
26
+ attr/converters.py,sha256=GlDeOzPeTFgeBBLbj9G57Ez5lAk68uhSALRYJ_exe84,3861
27
+ attr/converters.pyi,sha256=orU2bff-VjQa2kMDyvnMQV73oJT2WRyQuw4ZR1ym1bE,643
28
+ attr/exceptions.py,sha256=b4vMbnoQ3VpwWZhqrYi_ssXVCK8o2c4HQSS09cSUM9o,1990
29
+ attr/exceptions.pyi,sha256=zZq8bCUnKAy9mDtBEw42ZhPhAUIHoTKedDQInJD883M,539
30
+ attr/filters.py,sha256=ZBiKWLp3R0LfCZsq7X11pn9WX8NslS2wXM4jsnLOGc8,1795
31
+ attr/filters.pyi,sha256=3J5BG-dTxltBk1_-RuNRUHrv2qu1v8v4aDNAQ7_mifA,208
32
+ attr/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
33
+ attr/setters.py,sha256=5-dcT63GQK35ONEzSgfXCkbB7pPkaR-qv15mm4PVSzQ,1617
34
+ attr/setters.pyi,sha256=NnVkaFU1BB4JB8E4JuXyrzTUgvtMpj8p3wBdJY7uix4,584
35
+ attr/validators.py,sha256=m3QRzZTANr4f2C4eVdUoFg11NgXWak8Wat4qQTGhvcs,21553
36
+ attr/validators.pyi,sha256=gM1ZmHaBckyYWI2EirpRNzqm3B19cw5Iq6B4Kno9YCM,4087
37
+ attrs-26.1.0.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
38
+ attrs-26.1.0.dist-info/METADATA,sha256=TNQOaQ8jvzfLytNO_WdY4GLfHfB8hoM_fjzpW_H6OMw,8754
39
+ attrs-26.1.0.dist-info/RECORD,,
40
+ attrs-26.1.0.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
41
+ attrs-26.1.0.dist-info/licenses/LICENSE,sha256=iCEVyV38KvHutnFPjsbVy8q_Znyv-HKfQkINpj9xTp8,1109
42
+ attrs/__init__.py,sha256=RxaAZNwYiEh-fcvHLZNpQ_DWKni73M_jxEPEftiq1Zc,1183
43
+ attrs/__init__.pyi,sha256=2gV79g9UxJppGSM48hAZJ6h_MHb70dZoJL31ZNJeZYI,9416
44
+ attrs/__pycache__/__init__.cpython-312.pyc,,
45
+ attrs/__pycache__/converters.cpython-312.pyc,,
46
+ attrs/__pycache__/exceptions.cpython-312.pyc,,
47
+ attrs/__pycache__/filters.cpython-312.pyc,,
48
+ attrs/__pycache__/setters.cpython-312.pyc,,
49
+ attrs/__pycache__/validators.cpython-312.pyc,,
50
+ attrs/converters.py,sha256=8kQljrVwfSTRu8INwEk8SI0eGrzmWftsT7rM0EqyohM,76
51
+ attrs/exceptions.py,sha256=ACCCmg19-vDFaDPY9vFl199SPXCQMN_bENs4DALjzms,76
52
+ attrs/filters.py,sha256=VOUMZug9uEU6dUuA0dF1jInUK0PL3fLgP0VBS5d-CDE,73
53
+ attrs/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
54
+ attrs/setters.py,sha256=eL1YidYQV3T2h9_SYIZSZR1FAcHGb1TuCTy0E0Lv2SU,73
55
+ attrs/validators.py,sha256=xcy6wD5TtTkdCG1f4XWbocPSO0faBjk5IfVJfP6SUj0,76
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.29.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any