-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
103 lines (89 loc) · 3.41 KB
/
setup.py
File metadata and controls
103 lines (89 loc) · 3.41 KB
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
#!/usr/bin/env python3
"""
Setup script for JobAppsMailTracker
Helps with initial project setup and dependency installation
"""
import subprocess
import sys
import os
def run_command(command, description):
"""Run a command and handle errors"""
print(f"\n{description}...")
try:
result = subprocess.run(command, shell=True, check=True, capture_output=True, text=True)
print(f"✓ {description} completed successfully")
return True
except subprocess.CalledProcessError as e:
print(f"✗ {description} failed:")
print(f" Error: {e.stderr}")
return False
def check_python_version():
"""Check if Python version is compatible"""
version = sys.version_info
if version.major < 3 or (version.major == 3 and version.minor < 7):
print("✗ Python 3.7 or higher is required")
print(f" Current version: {version.major}.{version.minor}.{version.micro}")
return False
print(f"✓ Python version {version.major}.{version.minor}.{version.micro} is compatible")
return True
def install_dependencies():
"""Install required Python packages"""
return run_command(
"pip install -r requirements.txt",
"Installing Python dependencies"
)
def create_virtual_environment():
"""Create a virtual environment"""
if os.path.exists("venv"):
print("✓ Virtual environment already exists")
return True
return run_command(
"python -m venv venv",
"Creating virtual environment"
)
def check_credentials():
"""Check if credentials.json exists"""
if os.path.exists("credentials.json"):
print("✓ credentials.json found")
return True
else:
print("✗ credentials.json not found")
print(" Please download your OAuth 2.0 credentials from Google Cloud Console")
print(" and save them as 'credentials.json' in the project root directory")
return False
def main():
"""Main setup function"""
print("=== JobAppsMailTracker Setup ===\n")
# Check Python version
if not check_python_version():
sys.exit(1)
# Create virtual environment
if not create_virtual_environment():
print("\nPlease create a virtual environment manually:")
print(" python -m venv venv")
print(" source venv/bin/activate # On Windows: venv\\Scripts\\activate")
sys.exit(1)
# Install dependencies
if not install_dependencies():
print("\nPlease install dependencies manually:")
print(" pip install -r requirements.txt")
sys.exit(1)
# Check credentials
if not check_credentials():
print("\nSetup incomplete. Please:")
print("1. Go to Google Cloud Console")
print("2. Enable Gmail API and Google Sheets API")
print("3. Create OAuth 2.0 credentials for Desktop Application")
print("4. Download credentials.json and place in project root")
sys.exit(1)
print("\n=== Setup Complete! ===")
print("\nNext steps:")
print("1. Activate your virtual environment:")
print(" source venv/bin/activate # On Windows: venv\\Scripts\\activate")
print("2. Create a Gmail label called 'Job Applications'")
print("3. Apply this label to job-related emails")
print("4. Run the tracker:")
print(" python job_tracker.py")
print("\nFor detailed instructions, see README.md")
if __name__ == "__main__":
main()