Skip to content

Commit d89c0e4

Browse files
authored
Use metadata to detect version of package (#4782)
Signed-off-by: Kebe <[email protected]>
1 parent fa3c9e0 commit d89c0e4

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

python/sglang/check_env.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Check environment configurations and dependency versions."""
22

3-
import importlib
3+
import importlib.metadata
44
import os
55
import resource
66
import subprocess
@@ -59,9 +59,8 @@ def get_package_versions(packages):
5959
for package in packages:
6060
package_name = package.split("==")[0].split(">=")[0].split("<=")[0]
6161
try:
62-
module = importlib.import_module(package_name)
63-
if hasattr(module, "__version__"):
64-
versions[package_name] = module.__version__
62+
version = importlib.metadata.version(package_name)
63+
versions[package_name] = version
6564
except ModuleNotFoundError:
6665
versions[package_name] = "Module Not Found"
6766
return versions

0 commit comments

Comments
 (0)