Spaces:
Sleeping
Sleeping
| #!/usr/bin/env python3 | |
| """ | |
| Setup checker for WikiFit application. | |
| This script verifies that all required dependencies are installed and the app structure is correct. | |
| """ | |
| import importlib | |
| import os | |
| import sys | |
| import subprocess | |
| def check_imports(): | |
| """Check that all required packages can be imported""" | |
| required_packages = ['streamlit', 'requests', 'PIL'] | |
| missing_packages = [] | |
| print("Checking required packages...") | |
| for package in required_packages: | |
| try: | |
| if package == 'PIL': | |
| # Special case for PIL/Pillow | |
| importlib.import_module('PIL') | |
| print(f"β {package} (Pillow) is installed") | |
| else: | |
| importlib.import_module(package) | |
| print(f"β {package} is installed") | |
| except ImportError: | |
| missing_packages.append(package) | |
| print(f"β {package} is missing") | |
| return missing_packages | |
| def check_file_structure(): | |
| """Check that all required files exist""" | |
| required_files = [ | |
| 'app.py', | |
| 'requirements.txt', | |
| 'pages/__init__.py', | |
| 'pages/home.py', | |
| 'pages/search.py', | |
| 'pages/quiz.py', | |
| 'pages/workout_plans.py', | |
| 'pages/remedies.py', | |
| 'services/__init__.py', | |
| 'services/wiki_service.py', | |
| 'services/ai_service.py' | |
| ] | |
| missing_files = [] | |
| print("\nChecking file structure...") | |
| for file_path in required_files: | |
| if os.path.exists(file_path): | |
| print(f"β {file_path} exists") | |
| else: | |
| missing_files.append(file_path) | |
| print(f"β {file_path} is missing") | |
| return missing_files | |
| def install_missing_packages(missing_packages): | |
| """Install missing packages using pip""" | |
| if not missing_packages: | |
| return | |
| print("\nAttempting to install missing packages...") | |
| for package in missing_packages: | |
| if package == 'PIL': | |
| package = 'pillow' # PIL is installed via pillow | |
| try: | |
| subprocess.check_call([sys.executable, '-m', 'pip', 'install', package]) | |
| print(f"β Successfully installed {package}") | |
| except subprocess.CalledProcessError: | |
| print(f"β Failed to install {package}") | |
| def main(): | |
| """Run all checks""" | |
| print("WikiFit Setup Checker") | |
| print("=====================") | |
| # Check imports | |
| missing_packages = check_imports() | |
| # Check file structure | |
| missing_files = check_file_structure() | |
| # Summary | |
| print("\nCheck Summary:") | |
| if not missing_packages and not missing_files: | |
| print("β All checks passed! Your WikiFit installation looks good.") | |
| print("\nYou can run the app with: streamlit run app.py") | |
| else: | |
| if missing_packages: | |
| print(f"β Missing packages: {', '.join(missing_packages)}") | |
| install_missing_packages(missing_packages) | |
| if missing_files: | |
| print(f"β Missing files: {', '.join(missing_files)}") | |
| print("Please make sure all required files are in place.") | |
| if __name__ == "__main__": | |
| main() | |