File tree Expand file tree Collapse file tree 1 file changed +19
-3
lines changed
src/agentscope_runtime/engine/deployers/utils Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -305,13 +305,29 @@ def _parse_pyproject_toml(pyproject_path: Path) -> List[str]:
305305
306306def _get_package_version () -> str :
307307 """
308- Get the package version from pyproject.toml file.
308+ Get the package version.
309+
310+ Tries multiple methods in order:
311+ 1. Import from agentscope_runtime.version module
312+ 2. Fallback to parsing pyproject.toml (for development)
309313
310314 Returns:
311315 str: The version string, or empty string if not found
312316 """
313- # Try to find pyproject.toml in the current directory and parent
314- # directories
317+ # Method 1: Try importing from version module directly
318+ try :
319+ from agentscope_runtime .version import __version__
320+
321+ if __version__ :
322+ # Remove 'v' prefix if present (e.g., "v1.1.0b3" -> "1.1.0b3")
323+ return __version__ .lstrip ("v" )
324+ except ImportError :
325+ pass
326+
327+ # Method 2: Fallback to pyproject.toml (for development from source)
328+ if tomllib is None :
329+ return ""
330+
315331 current_dir = Path (__file__ ).parent
316332 for _ in range (6 ): # Look up to 6 levels up
317333 pyproject_path = current_dir / "pyproject.toml"
You can’t perform that action at this time.
0 commit comments