-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_deployment.py
More file actions
208 lines (171 loc) · 4.53 KB
/
setup_deployment.py
File metadata and controls
208 lines (171 loc) · 4.53 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
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
#!/usr/bin/env python3
"""
Setup script for Options Pricer deployment
Checks all required files and prepares for deployment
"""
import os
import sys
def check_files():
"""Check if all required files exist"""
required_files = [
'streamlit_app.py',
'formulas.py',
'requirements_web.txt',
'README.md'
]
missing_files = []
print("🔍 Checking required files...")
for file in required_files:
if os.path.exists(file):
print(f"✅ {file}")
else:
print(f"❌ {file} - MISSING")
missing_files.append(file)
return missing_files
def check_dependencies():
"""Check if all dependencies are in requirements_web.txt"""
print("\n📦 Checking dependencies...")
if not os.path.exists('requirements_web.txt'):
print("❌ requirements_web.txt not found")
return False
with open('requirements_web.txt', 'r') as f:
requirements = f.read()
required_packages = [
'streamlit',
'numpy',
'scipy',
'plotly'
]
missing_packages = []
for package in required_packages:
if package not in requirements:
missing_packages.append(package)
print(f"❌ {package} not in requirements_web.txt")
else:
print(f"✅ {package}")
return len(missing_packages) == 0
def create_gitignore():
"""Create .gitignore file if it doesn't exist"""
gitignore_content = """# Python
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
# Virtual environments
venv/
env/
ENV/
# IDE
.vscode/
.idea/
*.swp
*.swo
# OS
.DS_Store
Thumbs.db
# Streamlit
.streamlit/
# Environment variables
.env
.env.local
"""
if not os.path.exists('.gitignore'):
with open('.gitignore', 'w') as f:
f.write(gitignore_content)
print("✅ Created .gitignore")
else:
print("✅ .gitignore already exists")
def test_imports():
"""Test if all imports work correctly"""
print("\n🧪 Testing imports...")
try:
import streamlit
print("✅ streamlit")
except ImportError:
print("❌ streamlit - not installed")
return False
try:
import numpy
print("✅ numpy")
except ImportError:
print("❌ numpy - not installed")
return False
try:
import scipy
print("✅ scipy")
except ImportError:
print("❌ scipy - not installed")
return False
try:
import plotly
print("✅ plotly")
except ImportError:
print("❌ plotly - not installed")
return False
try:
from formulas import blackScholes, calculate_implied_volatility
print("✅ formulas module")
except ImportError as e:
print(f"❌ formulas module - {e}")
return False
return True
def main():
"""Main setup function"""
print("🚀 Options Pricer - Deployment Setup")
print("=" * 50)
# Check files
missing_files = check_files()
# Check dependencies
deps_ok = check_dependencies()
# Create .gitignore
create_gitignore()
# Test imports
imports_ok = test_imports()
# Summary
print("\n" + "=" * 50)
print("📋 Setup Summary:")
if missing_files:
print(f"❌ Missing files: {', '.join(missing_files)}")
print(" Please create these files before deployment")
else:
print("✅ All required files present")
if deps_ok:
print("✅ Dependencies configured correctly")
else:
print("❌ Some dependencies missing from requirements_web.txt")
if imports_ok:
print("✅ All imports working correctly")
else:
print("❌ Some imports failed - install missing packages")
# Next steps
print("\n🎯 Next Steps:")
print("1. If any issues above, fix them first")
print("2. Create a GitHub repository")
print("3. Upload your code to GitHub")
print("4. Deploy on Streamlit Cloud")
print("\n📖 See DEPLOYMENT_GUIDE.md for detailed instructions")
if not missing_files and deps_ok and imports_ok:
print("\n🎉 Your project is ready for deployment!")
return True
else:
print("\n⚠️ Please fix the issues above before deploying")
return False
if __name__ == "__main__":
success = main()
sys.exit(0 if success else 1)