Skip to content

Commit 89372fc

Browse files
authored
core[patch]: Update sys info information (#16297)
Update information collected in sys info. python -m langchain_core.sys_info System Information ------------------ > OS: Linux > OS Version: #14~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Nov 20 18:15:30 UTC 2 > Python Version: 3.11.4 (main, Sep 25 2023, 10:06:23) [GCC 11.4.0] Package Information ------------------- > langchain_core: 0.1.10 > langchain: 0.1.0 > langchain_community: 0.0.11 > langchain_cli: 0.0.20 > langchain_experimental: 0.0.36 > langchain_openai: 0.0.2 > langchainhub: 0.1.14 > langserve: 0.0.19 Packages not installed (Not Necessarily a Problem) -------------------------------------------------- The following packages were not found: > langgraph
1 parent 5396604 commit 89372fc

File tree

1 file changed

+35
-8
lines changed

1 file changed

+35
-8
lines changed

libs/core/langchain_core/sys_info.py

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,32 @@
44

55
def print_sys_info(*, additional_pkgs: Sequence[str] = tuple()) -> None:
66
"""Print information about the environment for debugging purposes."""
7+
import pkgutil
78
import platform
89
import sys
910
from importlib import metadata, util
1011

11-
packages = [
12-
"langchain_core",
13-
"langchain",
14-
"langchain_community",
12+
# Packages that do not start with "langchain" prefix.
13+
other_langchain_packages = [
1514
"langserve",
16-
] + list(additional_pkgs)
15+
"langgraph",
16+
]
17+
18+
langchain_pkgs = [
19+
name for _, name, _ in pkgutil.iter_modules() if name.startswith("langchain")
20+
]
21+
22+
all_packages = sorted(
23+
set(langchain_pkgs + other_langchain_packages + list(additional_pkgs))
24+
)
25+
26+
# Always surface these packages to the top
27+
order_by = ["langchain_core", "langchain", "langchain_community"]
28+
29+
for pkg in reversed(order_by):
30+
if pkg in all_packages:
31+
all_packages.remove(pkg)
32+
all_packages = [pkg] + list(all_packages)
1733

1834
system_info = {
1935
"OS": platform.system(),
@@ -32,13 +48,15 @@ def print_sys_info(*, additional_pkgs: Sequence[str] = tuple()) -> None:
3248
print("Package Information")
3349
print("-------------------")
3450

35-
for pkg in packages:
51+
not_installed = []
52+
53+
for pkg in all_packages:
3654
try:
3755
found_package = util.find_spec(pkg)
3856
except Exception:
3957
found_package = None
4058
if found_package is None:
41-
print(f"> {pkg}: Not Found")
59+
not_installed.append(pkg)
4260
continue
4361

4462
# Package version
@@ -51,7 +69,16 @@ def print_sys_info(*, additional_pkgs: Sequence[str] = tuple()) -> None:
5169
if package_version is not None:
5270
print(f"> {pkg}: {package_version}")
5371
else:
54-
print(f"> {pkg}: Found")
72+
print(f"> {pkg}: Installed. No version info available.")
73+
74+
if not_installed:
75+
print()
76+
print("Packages not installed (Not Necessarily a Problem)")
77+
print("--------------------------------------------------")
78+
print("The following packages were not found:")
79+
print()
80+
for pkg in not_installed:
81+
print(f"> {pkg}")
5582

5683

5784
if __name__ == "__main__":

0 commit comments

Comments
 (0)