Spaces:
Runtime error
Runtime error
#!/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()) | |