Enhance package management in checker.py by implementing version control for required packages. Added warnings filter to suppress warning messages. The script now checks for specific package versions and installs them accordingly, improving dependency management and ensuring compatibility. This change enhances the robustness of the environment setup for the checker process.

This commit is contained in:
vvzvlad 2025-01-19 11:32:51 +03:00
parent da56ef57f0
commit c062ad8e66

View File

@ -3,6 +3,9 @@
# pylance: disable=reportMissingImports, reportMissingModuleSource, reportGeneralTypeIssues # pylance: disable=reportMissingImports, reportMissingModuleSource, reportGeneralTypeIssues
# type: ignore # type: ignore
import warnings
warnings.filterwarnings("ignore", category=Warning)
import re import re
from datetime import datetime, timedelta, timezone from datetime import datetime, timedelta, timezone
import subprocess import subprocess
@ -14,12 +17,23 @@ import pkg_resources
import requests import requests
import json import json
from collections import deque from collections import deque
required_packages = ['grist-api', 'colorama']
installed_packages = [pkg.key for pkg in pkg_resources.working_set]
for package in required_packages: required_packages = {
if package not in installed_packages: 'grist-api': 'latest',
subprocess.check_call([sys.executable, '-m', 'pip', 'install', package, '--break-system-packages']) 'colorama': 'latest',
'requests': '2.31.0',
'urllib3': '2.0.7',
'charset-normalizer': '3.3.2'
}
installed_packages = {pkg.key: pkg.version for pkg in pkg_resources.working_set}
for package, version in required_packages.items():
if package not in installed_packages or (version != 'latest' and installed_packages[package] != version):
if version == 'latest':
subprocess.check_call([sys.executable, '-m', 'pip', 'install', package, '--break-system-packages'])
else:
subprocess.check_call([sys.executable, '-m', 'pip', 'install', f"{package}=={version}", '--break-system-packages'])
from grist_api import GristDocAPI from grist_api import GristDocAPI
import colorama import colorama