File size: 1,429 Bytes
1d75522
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
45
46
47
48
49
50
51
#!/usr/bin/env python3

import sys
import pkg_resources
import logging

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

def check_package_version(package_name):
    """Check installed version of a package."""
    try:
        version = pkg_resources.get_distribution(package_name).version
        logger.info(f"{package_name} version: {version}")
        return version
    except pkg_resources.DistributionNotFound:
        logger.error(f"{package_name} is not installed")
        return None

def main():
    """Check versions of key packages."""
    packages = [
        "gradio",
        "torch",
        "transformers",
        "huggingface-hub",
        "pydantic",
        "fastapi",
        "uvicorn"
    ]
    
    logger.info("Checking package versions...")
    for package in packages:
        version = check_package_version(package)
        if version is None:
            sys.exit(1)
    
    # Verify Gradio version specifically
    gradio_version = check_package_version("gradio")
    if gradio_version:
        major, minor, patch = map(int, gradio_version.split("."))
        if major < 4 or (major == 4 and minor < 44):
            logger.error(f"Gradio version {gradio_version} is too old. Please upgrade to 4.44.1 or later")
            sys.exit(1)
    
    logger.info("All package versions verified successfully")
    return 0

if __name__ == "__main__":
    sys.exit(main())