Skip to content

Commit 01af72b

Browse files
committed
Better check-versions ouptut
1 parent 7965c3b commit 01af72b

File tree

1 file changed

+93
-68
lines changed

1 file changed

+93
-68
lines changed

relenv/pyversions.py

Lines changed: 93 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,78 +1003,103 @@ def main(args: argparse.Namespace) -> None:
10031003

10041004
# Handle dependency operations
10051005
if args.check_deps:
1006-
print("Checking for new dependency versions...")
1007-
1008-
print("\nOpenSSL:")
1009-
openssl_versions = detect_openssl_versions()
1010-
if openssl_versions:
1011-
print(f" Latest: {openssl_versions[0]}")
1012-
1013-
print("\nSQLite:")
1014-
sqlite_versions = detect_sqlite_versions()
1015-
if sqlite_versions:
1016-
latest_ver, latest_sql = sqlite_versions[0]
1017-
print(f" Latest: {latest_ver}")
1018-
1019-
print("\nXZ:")
1020-
xz_versions = detect_xz_versions()
1021-
if xz_versions:
1022-
print(f" Latest: {xz_versions[0]}")
1023-
1024-
print("\nlibffi:")
1025-
libffi_versions = detect_libffi_versions()
1026-
if libffi_versions:
1027-
print(f" Latest: {libffi_versions[0]}")
1028-
1029-
print("\nzlib:")
1030-
zlib_versions = detect_zlib_versions()
1031-
if zlib_versions:
1032-
print(f" Latest: {zlib_versions[0]}")
1033-
1034-
print("\nncurses:")
1035-
ncurses_versions = detect_ncurses_versions()
1036-
if ncurses_versions:
1037-
print(f" Latest: {ncurses_versions[0]}")
1038-
1039-
print("\nreadline:")
1040-
readline_versions = detect_readline_versions()
1041-
if readline_versions:
1042-
print(f" Latest: {readline_versions[0]}")
1043-
1044-
print("\ngdbm:")
1045-
gdbm_versions = detect_gdbm_versions()
1046-
if gdbm_versions:
1047-
print(f" Latest: {gdbm_versions[0]}")
1048-
1049-
print("\nlibxcrypt:")
1050-
libxcrypt_versions = detect_libxcrypt_versions()
1051-
if libxcrypt_versions:
1052-
print(f" Latest: {libxcrypt_versions[0]}")
1053-
1054-
print("\nkrb5:")
1055-
krb5_versions = detect_krb5_versions()
1056-
if krb5_versions:
1057-
print(f" Latest: {krb5_versions[0]}")
1006+
print("Checking for new dependency versions...\n")
1007+
1008+
# Load current versions from JSON
1009+
with open(packaged) as f:
1010+
data = json.load(f)
1011+
1012+
current_deps = data.get("dependencies", {})
1013+
updates_available = []
1014+
up_to_date = []
1015+
1016+
# Detect terminal capabilities for fancy vs ASCII output
1017+
use_unicode = True
1018+
if sys.platform == "win32":
1019+
# Check if we're in a modern terminal that supports Unicode
1020+
import os
1021+
1022+
# Windows Terminal and modern PowerShell support Unicode
1023+
wt_session = os.environ.get("WT_SESSION")
1024+
term_program = os.environ.get("TERM_PROGRAM")
1025+
if not wt_session and not term_program:
1026+
# Likely cmd.exe or old PowerShell, use ASCII
1027+
use_unicode = False
1028+
1029+
if use_unicode:
1030+
ok_symbol = "✓"
1031+
update_symbol = "⚠"
1032+
new_symbol = "✗"
1033+
arrow = "→"
1034+
else:
1035+
ok_symbol = "[OK] "
1036+
update_symbol = "[UPDATE]"
1037+
new_symbol = "[NEW] "
1038+
arrow = "->"
1039+
1040+
# Check each dependency
1041+
checks = [
1042+
("openssl", "OpenSSL", detect_openssl_versions),
1043+
("sqlite", "SQLite", detect_sqlite_versions),
1044+
("xz", "XZ", detect_xz_versions),
1045+
("libffi", "libffi", detect_libffi_versions),
1046+
("zlib", "zlib", detect_zlib_versions),
1047+
("ncurses", "ncurses", detect_ncurses_versions),
1048+
("readline", "readline", detect_readline_versions),
1049+
("gdbm", "gdbm", detect_gdbm_versions),
1050+
("libxcrypt", "libxcrypt", detect_libxcrypt_versions),
1051+
("krb5", "krb5", detect_krb5_versions),
1052+
("bzip2", "bzip2", detect_bzip2_versions),
1053+
("uuid", "uuid", detect_uuid_versions),
1054+
("tirpc", "tirpc", detect_tirpc_versions),
1055+
("expat", "expat", detect_expat_versions),
1056+
]
10581057

1059-
print("\nbzip2:")
1060-
bzip2_versions = detect_bzip2_versions()
1061-
if bzip2_versions:
1062-
print(f" Latest: {bzip2_versions[0]}")
1058+
for dep_key, dep_name, detect_func in checks:
1059+
detected = detect_func()
1060+
if not detected:
1061+
continue
10631062

1064-
print("\nuuid:")
1065-
uuid_versions = detect_uuid_versions()
1066-
if uuid_versions:
1067-
print(f" Latest: {uuid_versions[0]}")
1063+
# Handle SQLite's tuple return
1064+
if dep_key == "sqlite":
1065+
latest_version = detected[0][0] # type: ignore[index]
1066+
else:
1067+
latest_version = detected[0] # type: ignore[index]
1068+
1069+
# Get current version from JSON
1070+
current_version = None
1071+
if dep_key in current_deps:
1072+
versions = sorted(current_deps[dep_key].keys(), reverse=True)
1073+
if versions:
1074+
current_version = versions[0]
1075+
1076+
# Compare versions
1077+
if current_version == latest_version:
1078+
print(
1079+
f"{ok_symbol} {dep_name:12} {current_version:15} " f"(up-to-date)"
1080+
)
1081+
up_to_date.append(dep_name)
1082+
elif current_version:
1083+
print(
1084+
f"{update_symbol} {dep_name:12} {current_version:15} "
1085+
f"{arrow} {latest_version} (update available)"
1086+
)
1087+
updates_available.append((dep_name, current_version, latest_version))
1088+
else:
1089+
print(
1090+
f"{new_symbol} {dep_name:12} {'(not tracked)':15} "
1091+
f"{arrow} {latest_version}"
1092+
)
1093+
updates_available.append((dep_name, None, latest_version))
10681094

1069-
print("\ntirpc:")
1070-
tirpc_versions = detect_tirpc_versions()
1071-
if tirpc_versions:
1072-
print(f" Latest: {tirpc_versions[0]}")
1095+
# Summary
1096+
print(f"\n{'=' * 60}")
1097+
print(f"Summary: {len(up_to_date)} up-to-date, ", end="")
1098+
print(f"{len(updates_available)} updates available")
10731099

1074-
print("\nexpat:")
1075-
expat_versions = detect_expat_versions()
1076-
if expat_versions:
1077-
print(f" Latest: {expat_versions[0]}")
1100+
if updates_available:
1101+
print("\nTo update dependencies, run:")
1102+
print(" python3 -m relenv versions --update-deps")
10781103

10791104
sys.exit(0)
10801105

0 commit comments

Comments
 (0)