Skip to content

The agent engineering platform.

fix(core): don't print package if no version found (#33347)

Mason Daugherty4c38157ee0e6
diff --git a/libs/core/langchain_core/sys_info.py b/libs/core/langchain_core/sys_info.py
index dcd0a178bf..57a0877906 100644
--- a/libs/core/langchain_core/sys_info.py
+++ b/libs/core/langchain_core/sys_info.py
@@ -6,6 +6,7 @@ debugging purposes.
import pkgutil
import platform
+import re
import sys
from collections.abc import Sequence
from importlib import metadata, util
@@ -26,9 +27,12 @@ def _get_sub_deps(packages: Sequence[str]) -> list[str]:
continue
for req in required:
- cleaned_req = req.split(" ")[0]
- if cleaned_req.replace("-", "_") not in underscored_packages:
- sub_deps.add(cleaned_req)
+ # Extract package name (e.g., "httpx<1,>=0.23.0" -> "httpx")
+ match = re.match(r"^([a-zA-Z0-9_.-]+)", req)
+ if match:
+ pkg_name = match.group(1)
+ if pkg_name.replace("-", "_") not in underscored_packages:
+ sub_deps.add(pkg_name)
return sorted(sub_deps, key=lambda x: x.lower())
@@ -107,8 +111,6 @@ def print_sys_info(*, additional_pkgs: Sequence[str] = ()) -> None:
# Print package with version
if package_version is not None:
print(f"> {pkg}: {package_version}") # noqa: T201
- else:
- print(f"> {pkg}: Installed. No version info available.") # noqa: T201
if not_installed:
print() # noqa: T201