Spaces:
Runtime error
Runtime error
File size: 5,150 Bytes
e4423e9 | 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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | # 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() |