fix version parsing: prefer tomllib and tolerate BOM/CRLF so UI shows pyproject version

This commit is contained in:
rookiestar28
2026-02-09 19:02:05 +08:00
parent 387782a165
commit 2b1141cb41
3 changed files with 21 additions and 5 deletions
+17 -1
View File
@@ -25,10 +25,26 @@ def _read_pyproject_version() -> Optional[str]:
with open(pyproject_path, "r", encoding="utf-8") as f:
text = f.read()
# Prefer stdlib TOML parser if available (Python 3.11+), then fallback to regex.
try:
from tomllib import loads as _toml_loads # type: ignore
except Exception:
_toml_loads = None
if _toml_loads:
try:
data = _toml_loads(text)
ver = data.get("project", {}).get("version")
if ver:
return str(ver).strip() or None
except Exception:
pass
# Find the [project] section and parse `version = "..."` within it.
# IMPORTANT: tolerate BOM/CRLF so the UI version does not silently fall back to 0.1.0.
# This is intentionally conservative to avoid false matches in other sections.
m = re.search(
r"(?ms)^\\[project\\]\\s*(?:[^\\[]*?)^version\\s*=\\s*\"([^\"]+)\"\\s*$",
r"(?ms)^\ufeff?\\[project\\]\\s*(?:[^\\[]*?)^version\\s*=\\s*[\"']([^\"']+)[\"']\\s*$",
text,
)
if not m:
+3 -3
View File
@@ -43,15 +43,15 @@ server {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
# Security: Forward real IP for Rate Limiting
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# Timeouts for long generations
proxy_read_timeout 600s;
}
# Block sensitive paths
location /openclaw/logs {
deny all;
+1 -1
View File
@@ -1,7 +1,7 @@
[project]
name = "comfyui-openclaw"
description = "Your own personal AIGC Factory. Any picture. Any reel. The Comfy way.©️"
version = "0.1.8"
version = "0.1.9"
license = {text = "MIT"}
readme = "README.md"
requires-python = ">=3.10"