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()