-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathcheck_python_version.py
More file actions
35 lines (26 loc) · 981 Bytes
/
Copy pathcheck_python_version.py
File metadata and controls
35 lines (26 loc) · 981 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""Simple way to check the Python version at runtime."""
import sys
def print_version_info() -> None:
"""Print detailed Python version information."""
print(f"Python version: {sys.version}")
print(f"Version string: {sys.version.split()[0]}")
print(f"Version info: {sys.version_info}")
info = sys.version_info
print(
f"\nVersion detail:\n"
f" Major: {info.major}\n"
f" Minor: {info.minor}\n"
f" Micro: {info.micro}\n"
f" Release Level: {info.releaselevel}\n"
f" Serial: {info.serial}"
)
def check_minimum_version(major: int = 3, minor: int = 10) -> bool:
"""Return True if the running Python meets the minimum version."""
return sys.version_info >= (major, minor)
if __name__ == "__main__":
print_version_info()
print()
if check_minimum_version(3, 10):
print("Great! You have Python 3.10+. All good.")
else:
print("Sorry, Python 3.10+ is required.")