forked from alexlib/pyptv
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_version.py
More file actions
executable file
·44 lines (35 loc) · 1.45 KB
/
check_version.py
File metadata and controls
executable file
·44 lines (35 loc) · 1.45 KB
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
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python
"""
Script to check the installed version of pyptv and warn if it's not the expected version.
"""
import sys
import importlib.metadata
EXPECTED_VERSION = "0.4.3" # The version in the local repository
def check_version():
"""Check if the installed version matches the expected version."""
try:
installed_version = importlib.metadata.version("pyptv")
print(f"Installed pyptv version: {installed_version}")
if installed_version != EXPECTED_VERSION:
print(
f"\nWARNING: The installed version ({installed_version}) does not match "
f"the expected version ({EXPECTED_VERSION})."
)
print("\nPossible reasons:")
if installed_version == "0.4.2":
print("- You installed from PyPI, which has version 0.4.2")
print("- To install the development version (0.4.3), run:")
print(" pip install -e /path/to/pyptv/repository")
else:
print("- You might have a different version installed")
print("- Check your installation source")
return False
else:
print(f"Version check passed: {installed_version}")
return True
except importlib.metadata.PackageNotFoundError:
print("ERROR: pyptv is not installed.")
return False
if __name__ == "__main__":
success = check_version()
sys.exit(0 if success else 1)