funcaptcha / check-versions.py
doniramdani820's picture
Upload 12 files
ecb8e64 verified
#!/usr/bin/env python3
"""
πŸ” Package Version Checker for HF Spaces Deployment
Script untuk check available versions dari required packages
"""
import subprocess
import sys
import json
from typing import List, Dict
def check_package_versions(package: str, show_all: bool = False) -> List[str]:
"""Check available versions untuk package tertentu"""
try:
result = subprocess.run(
[sys.executable, "-m", "pip", "index", "versions", package],
capture_output=True,
text=True,
timeout=30
)
if result.returncode == 0:
lines = result.stdout.strip().split('\n')
versions = []
for line in lines:
if 'Available versions:' in line:
# Extract versions dari output
version_part = line.split('Available versions:')[1].strip()
versions = [v.strip() for v in version_part.split(',')]
break
if show_all:
return versions
else:
return versions[:10] # Show first 10 most recent
else:
print(f"❌ Error checking {package}: {result.stderr}")
return []
except subprocess.TimeoutExpired:
print(f"⏰ Timeout checking {package}")
return []
except Exception as e:
print(f"❌ Exception checking {package}: {e}")
return []
def main():
"""Main function untuk check semua packages"""
print("πŸ” Checking package versions untuk HF Spaces deployment...")
print("=" * 60)
# Packages yang perlu di-check
packages = [
"fastapi",
"uvicorn",
"onnxruntime",
"opencv-python-headless",
"numpy",
"pillow",
"pyyaml",
"python-multipart",
"python-jose"
]
results = {}
for package in packages:
print(f"πŸ” Checking {package}...")
versions = check_package_versions(package, show_all=False)
if versions:
print(f"βœ… {package}: {', '.join(versions[:5])}...")
results[package] = versions
else:
print(f"❌ {package}: Could not retrieve versions")
results[package] = []
print("\n" + "=" * 60)
print("πŸ“‹ RECOMMENDED requirements.txt:")
print("=" * 60)
# Generate recommended versions
recommendations = {
"fastapi": "0.104.1",
"uvicorn[standard]": "0.24.0",
"onnxruntime": "1.15.1",
"opencv-python-headless": "4.8.0.76", # From error log
"numpy": "1.24.3",
"pillow": "10.0.1",
"pyyaml": "6.0.1",
"python-multipart": "0.0.6",
"python-jose[cryptography]": "3.3.0"
}
for package, version in recommendations.items():
print(f"{package}=={version}")
print("\n" + "=" * 60)
print("πŸ’‘ FLEXIBLE requirements.txt (ranges):")
print("=" * 60)
flexible = {
"fastapi": ">=0.100.0,<0.110.0",
"uvicorn[standard]": ">=0.20.0,<0.30.0",
"onnxruntime": ">=1.15.0,<1.16.0",
"opencv-python-headless": ">=4.7.0,<4.9.0",
"numpy": ">=1.21.0,<1.26.0",
"pillow": ">=9.0.0,<11.0.0",
"pyyaml": ">=6.0",
"python-multipart": ">=0.0.5"
}
for package, version in flexible.items():
print(f"{package}{version}")
print("\n🎯 Use exact versions for production, ranges for development!")
if __name__ == "__main__":
main()