Spaces:
Runtime error
Runtime error
Download smart_setup.py from deepakkumar00/MatchHire: direct link, hf CLI and curl.
- Browser
- Download file 5.15 kB
-
https://huggingface.co/spaces/deepakkumar00/MatchHire/resolve/main/smart_setup.py
- Command line
-
hf download hf://spaces/deepakkumar00/MatchHire/smart_setup.py
-
curl -L -o smart_setup.py https://huggingface.co/spaces/deepakkumar00/MatchHire/resolve/main/smart_setup.py
5.15 kB
| # smart_setup.py - Intelligent installation script | |
| import subprocess | |
| import sys | |
| import os | |
| def install_package(package_name): | |
| """Install a package using pip""" | |
| try: | |
| subprocess.check_call([sys.executable, "-m", "pip", "install", package_name]) | |
| return True | |
| except subprocess.CalledProcessError: | |
| return False | |
| def test_pdf_libraries(): | |
| """Test which PDF library works""" | |
| pdf_libraries = [ | |
| ("PyPDF2==3.0.1", "PyPDF2", "from PyPDF2 import PdfReader"), | |
| ("pypdf==4.0.1", "pypdf", "import pypdf"), | |
| ("PyMuPDF==1.23.8", "PyMuPDF/fitz", "import fitz") | |
| ] | |
| for package, name, test_import in pdf_libraries: | |
| print(f"π Trying {name}...") | |
| # Install the package | |
| if install_package(package): | |
| # Test if it imports successfully | |
| try: | |
| exec(test_import) | |
| print(f"β {name} installed and working!") | |
| return name | |
| except ImportError as e: | |
| print(f"β {name} installed but not working: {e}") | |
| continue | |
| else: | |
| print(f"β Failed to install {name}") | |
| return None | |
| def main(): | |
| print("π Smart Resume Relevance System Setup") | |
| print("=" * 50) | |
| # Core packages that should always work | |
| core_packages = [ | |
| "fastapi==0.104.1", | |
| "uvicorn==0.24.0", | |
| "sqlalchemy==2.0.23", | |
| "python-multipart==0.0.6", | |
| "python-docx==1.1.0", | |
| "sentence-transformers==2.2.2", | |
| "scikit-learn==1.3.2", | |
| "python-dotenv==1.0.0", | |
| "pydantic==2.5.0", | |
| "aiofiles==23.2.1" | |
| ] | |
| print("π¦ Installing core packages...") | |
| failed_packages = [] | |
| for package in core_packages: | |
| package_name = package.split('==')[0] | |
| print(f" Installing {package_name}...") | |
| if install_package(package): | |
| print(f" β {package_name} installed successfully") | |
| else: | |
| print(f" β Failed to install {package_name}") | |
| failed_packages.append(package_name) | |
| print(f"\nπ Installing PDF processing library...") | |
| pdf_library = test_pdf_libraries() | |
| # Optional packages | |
| print(f"\nπ― Installing optional packages...") | |
| optional_packages = [ | |
| ("spacy", "Better NLP processing (optional)") | |
| ] | |
| for package, description in optional_packages: | |
| print(f" Installing {package} - {description}") | |
| if install_package(package): | |
| print(f" β {package} installed") | |
| # Install spacy model if spacy was installed | |
| if package == "spacy": | |
| print(" π Installing spaCy English model...") | |
| try: | |
| subprocess.check_call([sys.executable, "-m", "spacy", "download", "en_core_web_sm"]) | |
| print(" β spaCy model installed") | |
| except subprocess.CalledProcessError: | |
| print(" β οΈ spaCy model installation failed (optional)") | |
| else: | |
| print(f" β οΈ {package} installation failed (optional)") | |
| # Summary | |
| print(f"\nπ Setup Summary") | |
| print("=" * 30) | |
| if failed_packages: | |
| print(f"β Failed core packages: {', '.join(failed_packages)}") | |
| print("β οΈ System may not work properly without these packages") | |
| else: | |
| print("β All core packages installed successfully") | |
| if pdf_library: | |
| print(f"β PDF support: {pdf_library}") | |
| else: | |
| print("β No PDF library could be installed") | |
| print("π You can still use DOCX and TXT files") | |
| print(f"\nπ Next steps:") | |
| if not failed_packages and pdf_library: | |
| print("1. Run: python run.py") | |
| print("2. Open frontend/index.html in your browser") | |
| print("3. Upload some resumes and job descriptions!") | |
| else: | |
| print("1. Fix any failed package installations") | |
| print("2. For PDF issues, try installing Visual Studio Build Tools") | |
| print("3. Alternatively, use DOCX format for documents") | |
| # Create a status file | |
| status = { | |
| "core_packages_ok": len(failed_packages) == 0, | |
| "pdf_library": pdf_library, | |
| "ready_to_run": len(failed_packages) == 0, | |
| "supported_formats": ["DOCX", "TXT"] + (["PDF"] if pdf_library else []) | |
| } | |
| print(f"\nπΎ Installation status saved to setup_status.txt") | |
| with open("setup_status.txt", "w") as f: | |
| f.write("Resume Relevance System Setup Status\n") | |
| f.write("=" * 40 + "\n") | |
| f.write(f"Core packages: {'β OK' if status['core_packages_ok'] else 'β Failed'}\n") | |
| f.write(f"PDF support: {'β ' + pdf_library if pdf_library else 'β None'}\n") | |
| f.write(f"Ready to run: {'β Yes' if status['ready_to_run'] else 'β No'}\n") | |
| f.write(f"Supported formats: {', '.join(status['supported_formats'])}\n") | |
| if __name__ == "__main__": | |
| main() |