-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
578 lines (489 loc) · 19 KB
/
setup.py
File metadata and controls
578 lines (489 loc) · 19 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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
#!/usr/bin/env python3
"""
10X Content Expert - Setup Script
Run this ONCE before using the skills.
Creates a virtual environment to keep your system Python clean.
Usage:
python setup.py
python setup.py --force # Force reinstall even if already set up
"""
import subprocess
import sys
import os
from pathlib import Path
# Configuration
BASE_DIR = Path(__file__).parent
VENV_DIR = BASE_DIR / '.venv'
SETUP_MARKER_FILE = BASE_DIR / '.setup_complete'
def is_setup_complete():
"""Check if setup has already been completed"""
return SETUP_MARKER_FILE.exists() and VENV_DIR.exists()
def mark_setup_complete():
"""Create marker file to indicate setup is complete"""
# Get venv python path for reference
if sys.platform == 'win32':
venv_python = VENV_DIR / 'Scripts' / 'python.exe'
else:
venv_python = VENV_DIR / 'bin' / 'python'
SETUP_MARKER_FILE.write_text(
f"Setup completed successfully.\n"
f"Virtual environment: {VENV_DIR}\n"
f"Python: {venv_python}\n"
f"\n"
f"Delete this file to force reinstallation.\n"
f"Or run: python setup.py --force\n"
)
print(f"\n[OK] Created setup marker: {SETUP_MARKER_FILE.name}")
def check_python_version():
"""Check Python version"""
version = sys.version_info
if version.major < 3 or (version.major == 3 and version.minor < 9):
print(f"[X] Python 3.9+ required. You have Python {version.major}.{version.minor}")
return False
print(f"[OK] Python {version.major}.{version.minor}.{version.micro} detected")
return True
def create_virtual_environment():
"""Create virtual environment"""
print("\n[*] Creating virtual environment...")
if VENV_DIR.exists():
print(f" Virtual environment already exists at: {VENV_DIR}")
return True
try:
subprocess.check_call([
sys.executable, '-m', 'venv', str(VENV_DIR)
])
print(f"[OK] Virtual environment created at: {VENV_DIR}")
return True
except subprocess.CalledProcessError as e:
print(f"[X] Failed to create virtual environment: {e}")
return False
def get_venv_python():
"""Get path to Python in virtual environment"""
if sys.platform == 'win32':
return VENV_DIR / 'Scripts' / 'python.exe'
else:
return VENV_DIR / 'bin' / 'python'
def get_venv_pip():
"""Get path to pip in virtual environment"""
if sys.platform == 'win32':
return VENV_DIR / 'Scripts' / 'pip.exe'
else:
return VENV_DIR / 'bin' / 'pip'
def install_requirements():
"""Install required packages into virtual environment"""
print("\n[*] Installing Python dependencies into virtual environment...")
print("-" * 50)
requirements_file = BASE_DIR / 'requirements.txt'
if not requirements_file.exists():
print("[X] requirements.txt not found!")
return False
venv_pip = get_venv_pip()
if not venv_pip.exists():
print("[X] Virtual environment pip not found!")
return False
try:
# Upgrade pip first (ignore errors as venv pip works fine)
subprocess.run(
[str(venv_pip), 'install', '--upgrade', 'pip'],
capture_output=True
)
# Install requirements
result = subprocess.run(
[str(venv_pip), 'install', '-r', str(requirements_file)],
capture_output=False
)
if result.returncode == 0:
print("\n[OK] All dependencies installed successfully!")
return True
else:
print("\n[X] Some packages failed to install")
return False
except Exception as e:
print(f"\n[X] Failed to install dependencies: {e}")
return False
def create_directories():
"""Create necessary directories"""
print("\n[*] Creating directories...")
directories = [
# Input/Output
BASE_DIR / 'input',
BASE_DIR / 'output' / 'working',
BASE_DIR / 'output' / 'content' / 'emails',
BASE_DIR / 'output' / 'content' / 'social' / 'linkedin',
BASE_DIR / 'output' / 'content' / 'social' / 'twitter',
BASE_DIR / 'output' / 'content' / 'presentations',
BASE_DIR / 'output' / 'content' / 'blogs',
BASE_DIR / 'output' / 'content' / 'sequences',
BASE_DIR / 'output' / 'content' / 'hooks',
BASE_DIR / 'output' / 'analysis',
BASE_DIR / 'output' / 'plans',
BASE_DIR / 'output' / 'logs',
# Local file editing outputs
BASE_DIR / 'output' / 'pdf',
BASE_DIR / 'output' / 'pptx',
BASE_DIR / 'output' / 'docx',
BASE_DIR / 'output' / 'xlsx',
# References
BASE_DIR / 'references' / 'transcripts' / 'training',
BASE_DIR / 'references' / 'transcripts' / 'webinars',
BASE_DIR / 'references' / 'transcripts' / 'interviews',
BASE_DIR / 'references' / 'transcripts' / 'podcasts',
BASE_DIR / 'references' / 'examples' / 'emails' / 'welcome',
BASE_DIR / 'references' / 'examples' / 'emails' / 'sales',
BASE_DIR / 'references' / 'examples' / 'emails' / 'newsletters',
BASE_DIR / 'references' / 'examples' / 'social' / 'linkedin',
BASE_DIR / 'references' / 'examples' / 'social' / 'twitter',
BASE_DIR / 'references' / 'examples' / 'social' / 'instagram',
BASE_DIR / 'references' / 'examples' / 'presentations',
BASE_DIR / 'references' / 'examples' / 'blogs',
BASE_DIR / 'references' / 'brand-voice',
BASE_DIR / 'references' / 'templates' / 'email',
BASE_DIR / 'references' / 'templates' / 'social',
BASE_DIR / 'references' / 'templates' / 'ppt',
BASE_DIR / 'references' / 'templates' / 'blog',
# Transcription outputs
BASE_DIR / 'references' / 'transcripts' / 'auto-transcribed',
# MEGA downloads
BASE_DIR / 'output' / 'mega-downloads',
# Transcription outputs
BASE_DIR / 'output' / 'transcripts',
# Canvas outputs
BASE_DIR / 'output' / 'canvas',
# TLDraw canvas app
BASE_DIR / 'tldraw-canvas',
]
for dir_path in directories:
dir_path.mkdir(parents=True, exist_ok=True)
print("[OK] Directories created!")
return True
def verify_installation():
"""Verify key packages are installed in virtual environment"""
print("\n[*] Verifying installation...")
venv_python = get_venv_python()
packages = [
('PyPDF2', 'PDF editing'),
('pptx', 'PowerPoint editing'),
('docx', 'Word editing'),
('openpyxl', 'Excel editing'),
('PIL', 'Image processing'),
('rich', 'Console output'),
]
# Optional packages that don't block setup
optional_packages = [
('whisper', 'Audio transcription (optional)'),
]
all_good = True
for package, purpose in packages:
try:
result = subprocess.run(
[str(venv_python), '-c', f'import {package}'],
capture_output=True,
text=True
)
if result.returncode == 0:
print(f" [OK] {package} ({purpose})")
else:
print(f" [X] {package} ({purpose}) - NOT INSTALLED")
all_good = False
except Exception:
print(f" [X] {package} ({purpose}) - CHECK FAILED")
all_good = False
for package, purpose in optional_packages:
try:
result = subprocess.run(
[str(venv_python), '-c', f'import {package}'],
capture_output=True,
text=True
)
if result.returncode == 0:
print(f" [OK] {package} ({purpose})")
else:
print(f" [--] {package} ({purpose}) - not installed (optional)")
except Exception:
print(f" [--] {package} ({purpose}) - not installed (optional)")
return all_good
def create_run_script():
"""Create helper scripts to run Python with venv"""
# Windows batch file
if sys.platform == 'win32':
bat_content = f'''@echo off
"{VENV_DIR}\\Scripts\\python.exe" %*
'''
bat_file = BASE_DIR / 'run_python.bat'
bat_file.write_text(bat_content)
print(f"[OK] Created {bat_file.name} - use this to run Python scripts")
def check_docker():
"""Check if Docker Desktop is installed and running"""
try:
result = subprocess.run(
['docker', 'info'],
capture_output=True, text=True, timeout=10
)
if result.returncode == 0:
print(" [OK] Docker Desktop is installed and running")
return True
else:
print(" [--] Docker installed but not running")
return False
except (FileNotFoundError, subprocess.TimeoutExpired):
print(" [--] Docker not found (optional)")
return False
def check_ffmpeg():
"""Check if FFmpeg is available on PATH"""
try:
result = subprocess.run(
['ffmpeg', '-version'],
capture_output=True, text=True, timeout=10
)
if result.returncode == 0:
version_line = result.stdout.split('\n')[0]
print(f" [OK] {version_line}")
return True
except (FileNotFoundError, subprocess.TimeoutExpired):
pass
print(" [--] FFmpeg not found (needed for local Whisper transcription)")
if sys.platform == 'win32':
print(" → winget install Gyan.FFmpeg")
elif sys.platform == 'darwin':
print(" → brew install ffmpeg")
else:
print(" → sudo apt-get install -y ffmpeg")
return False
def check_node():
"""Check if Node.js is installed (for tldraw-canvas)"""
try:
result = subprocess.run(
['node', '--version'],
capture_output=True, text=True, timeout=10
)
if result.returncode == 0:
ver = result.stdout.strip()
major = int(ver.replace('v', '').split('.')[0])
if major >= 18:
print(f" [OK] Node.js {ver} (>= 18)")
return True
else:
print(f" [!] Node.js {ver} found but >= 18 recommended")
return False
except (FileNotFoundError, subprocess.TimeoutExpired):
pass
print(" [--] Node.js not found (needed for tldraw-canvas)")
if sys.platform == 'win32':
print(" → winget install OpenJS.NodeJS.LTS")
elif sys.platform == 'darwin':
print(" → brew install node@18")
else:
print(" → curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -")
return False
def setup_optional_features():
"""Interactive optional feature setup"""
print("\n" + "=" * 60)
print("OPTIONAL FEATURES")
print("=" * 60)
# --- Docker ---
print("\n[*] Checking Docker...")
has_docker = check_docker()
# --- FFmpeg ---
print("\n[*] Checking FFmpeg...")
has_ffmpeg = check_ffmpeg()
# --- Node.js ---
print("\n[*] Checking Node.js...")
has_node = check_node()
# --- Whisper ---
print("\n[*] Checking Whisper transcription...")
venv_python = get_venv_python()
has_whisper = False
try:
result = subprocess.run(
[str(venv_python), '-c', 'import whisper; print(whisper.__version__)'],
capture_output=True, text=True, timeout=10
)
if result.returncode == 0:
print(f" [OK] Whisper {result.stdout.strip()} installed")
has_whisper = True
else:
print(" [--] Whisper not installed")
except Exception:
print(" [--] Whisper not installed")
# --- OpenAI API ---
print("\n[*] Checking OpenAI API...")
env_file = BASE_DIR / '.env'
has_openai_key = False
if env_file.exists():
env_content = env_file.read_text()
if 'OPENAI_API_KEY=sk-' in env_content:
print(" [OK] OpenAI API key configured")
has_openai_key = True
else:
print(" [--] No OpenAI API key (can use cloud transcription)")
# --- Canva ---
print("\n[*] Checking Canva API...")
has_canva = False
if env_file.exists():
env_content = env_file.read_text()
if 'CANVA_CLIENT_ID=' in env_content and 'your_client_id_here' not in env_content:
print(" [OK] Canva API credentials configured")
has_canva = True
else:
print(" [--] Canva API not configured (optional — for design creation)")
print(" → Get credentials at https://www.canva.com/developers/")
# --- Summary ---
print("\n" + "-" * 60)
print("OPTIONAL FEATURE SUMMARY:")
features = [
("Docker Desktop", has_docker, "Container-based Whisper (no local install)"),
("FFmpeg", has_ffmpeg, "Audio/video processing for Whisper"),
("Node.js 18+", has_node, "TLDraw interactive canvas"),
("Whisper (local)", has_whisper, "Local audio transcription"),
("OpenAI API", has_openai_key, "Cloud transcription (no local Whisper needed)"),
("Canva API", has_canva, "Design creation and editing"),
]
for name, installed, purpose in features:
status = "✓" if installed else "–"
print(f" [{status}] {name:20s} → {purpose}")
# --- Offer to install Whisper ---
if not has_whisper and (has_ffmpeg or has_docker):
print("\n")
try:
answer = input("Install Whisper for local transcription? (y/N): ").strip().lower()
if answer == 'y':
if has_docker and not has_ffmpeg:
print("\n[*] Docker detected. You can use Docker-based Whisper instead.")
print(" Set USE_DOCKER_WHISPER=true in .env")
print(" Docker image: onerahmet/openai-whisper-asr-webservice")
else:
print("\n[*] Installing Whisper (this may take a while, ~2GB)...")
venv_pip = get_venv_pip()
subprocess.run(
[str(venv_pip), 'install', 'openai-whisper', 'ffmpeg-python'],
capture_output=False
)
print("[OK] Whisper installed!")
except (EOFError, KeyboardInterrupt):
print("\n Skipped.")
# --- Offer to install canvas deps ---
canvas_modules = BASE_DIR / 'tldraw-canvas' / 'node_modules'
if has_node and not canvas_modules.exists():
print("\n")
try:
answer = input("Install TLDraw canvas dependencies? (y/N): ").strip().lower()
if answer == 'y':
print("\n[*] Installing tldraw-canvas dependencies...")
subprocess.run(
['npm', 'install'],
cwd=str(BASE_DIR / 'tldraw-canvas'),
capture_output=False
)
print("[OK] Canvas dependencies installed!")
except (EOFError, KeyboardInterrupt):
print("\n Skipped.")
return {
'docker': has_docker,
'ffmpeg': has_ffmpeg,
'node': has_node,
'whisper': has_whisper,
'openai': has_openai_key,
'canva': has_canva,
}
def main():
# Check for --force flag
force_reinstall = '--force' in sys.argv or '-f' in sys.argv
# Check if setup already done
if is_setup_complete() and not force_reinstall:
print("=" * 60)
print("10X CONTENT EXPERT - ALREADY SET UP")
print("=" * 60)
print("\nSetup has already been completed.")
print(f"Virtual environment: {VENV_DIR}")
print("\nAll dependencies are installed and ready to use.")
print("\nTo force reinstallation, run:")
print(" python setup.py --force")
print("\nOr delete the .setup_complete file and run again.")
return
print("=" * 60)
print("10X CONTENT EXPERT - SETUP")
print("=" * 60)
if force_reinstall:
print("\n[FORCE MODE] Reinstalling all dependencies...\n")
else:
print("\nThis script will set up everything you need to use the Content Expert.")
print("A virtual environment will be created to keep your system clean.\n")
# Check Python version
if not check_python_version():
sys.exit(1)
# Create virtual environment
if not create_virtual_environment():
print("\n[X] Failed to create virtual environment")
sys.exit(1)
# Install requirements
if not install_requirements():
print("\n[!] Some packages failed to install.")
print("Try running manually:")
print(f" {get_venv_pip()} install -r requirements.txt")
# Create directories
create_directories()
# Create helper scripts
create_run_script()
# Verify installation
if verify_installation():
# Mark setup as complete only if verification passes
mark_setup_complete()
# Optional features
optional = setup_optional_features()
print("\n" + "=" * 60)
print("SETUP COMPLETE!")
print("=" * 60)
# Platform-specific instructions
if sys.platform == 'win32':
activate_cmd = f".venv\\Scripts\\activate"
python_cmd = ".venv\\Scripts\\python.exe"
ffmpeg_hint = "winget install Gyan.FFmpeg"
elif sys.platform == 'darwin':
activate_cmd = "source .venv/bin/activate"
python_cmd = ".venv/bin/python"
ffmpeg_hint = "brew install ffmpeg"
else:
activate_cmd = "source .venv/bin/activate"
python_cmd = ".venv/bin/python"
ffmpeg_hint = "sudo apt-get install -y ffmpeg"
print(f"""
Virtual Environment Created!
----------------------------
Location: {VENV_DIR}
To run scripts manually:
{python_cmd} scripts/script_name.py
Or activate the environment first:
{activate_cmd}
Next Steps:
-----------
1. Add your reference materials (RECOMMENDED):
- Add transcripts to: references/transcripts/
- Add content examples to: references/examples/
- Fill out brand voice guide: references/brand-voice/
2. Start Claude Code in this folder:
- The skills will be automatically available
- Use /content to access all features
3. Try these commands:
- "Write a LinkedIn post about [topic]"
- "Create an email sequence for [goal]"
- "Analyze my transcripts for content ideas"
- "Generate headlines for my blog post"
Local file editing also available:
- "Edit my presentation.pptx"
- "Update my document.docx"
Note: Your system Python packages remain UNCHANGED.
All dependencies are isolated in the .venv folder.
Optional Features:
------------------
Transcription (choose one):
a) OpenAI API (cloud): Set OPENAI_API_KEY in .env — no local install
b) Local Whisper: pip install openai-whisper torch (needs FFmpeg + ~2GB)
c) Docker Whisper: Set USE_DOCKER_WHISPER=true in .env (needs Docker Desktop)
Other optional tools:
- MEGA CMD: Install from https://mega.io/cmd for /mega commands
- Node.js 18+: For TLDraw canvas → cd tldraw-canvas && npm install
- Canva API: Configure CANVA_CLIENT_ID in .env for design automation
- FFmpeg: For audio/video processing → {ffmpeg_hint}
""")
if __name__ == '__main__':
main()