ReMe/reme/utils/web_static.py
jinliyl ef3f99f019
refactor(packaging): reorganize published packages (#495)
* refactor(packaging): reorganize published packages

* fix(packaging): install AgentScope extra in wheel smoke

* docs: align package guides and documentation site

* ci(workflow): add core dependency verification step in Python package build

- Add a workflow step to verify released core dependencies by installing the wheel with core extras
- Assert the presence of the static index.html file to ensure proper package contents
- Create and use a temporary virtual environment for isolation during verification
- Keep existing artifacts upload step intact and conditional on inputs.upload_artifacts flag

* fix(ci): update package installation dependencies in Windows workflow

- Change pip install from editable reme_studio and core to only dev and as extras
- Remove installation of reme_studio and core to streamline dependency setup
- Ensure Windows CI uses the correct extras for testing environment

* fix(tests): add missing commas in toml file reads in package version tests

- Added trailing commas in the tomllib.loads calls for auto-fin and daily_paper configs
- Ensured consistent syntax to prevent potential tuple misinterpretation
- Improved readability and correctness of the test setup code

* fix(packaging): protect qwenpaw releases and test Studio health
2026-08-27 14:02:09 +08:00

49 lines
1.5 KiB
Python

"""Resolve the optional ReMe workspace frontend build."""
from __future__ import annotations
import os
from pathlib import Path
REME_WEB_STATIC_DIR = "REME_WEB_STATIC_DIR"
def _packaged_studio_dir() -> Path | None:
"""Return the static directory supplied by the optional Studio package."""
try:
from reme_studio import static_dir
except ImportError:
return None
return static_dir()
def resolve_web_static_dir(configured_dir: str | None = None) -> Path | None:
"""Return the first directory containing a built workspace ``index.html``."""
package_dir = Path(__file__).resolve().parent.parent
repository_dir = package_dir.parent
cwd = Path.cwd()
explicit_candidates = [
configured_dir,
os.getenv(REME_WEB_STATIC_DIR),
]
for candidate in explicit_candidates:
if not candidate:
continue
path = Path(candidate).expanduser().resolve()
if path.is_dir() and (path / "index.html").is_file():
return path
fallback_candidates = [
_packaged_studio_dir(),
package_dir / "web",
repository_dir / "reme_studio" / "dist-static",
cwd / "reme_studio" / "dist-static",
cwd / "web_dist",
]
for candidate in fallback_candidates:
if not candidate:
continue
path = Path(candidate).expanduser().resolve()
if path.is_dir() and (path / "index.html").is_file():
return path
return None