forked from harvard-edge/cs249r_book
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
executable file
·48 lines (39 loc) · 1.57 KB
/
setup.py
File metadata and controls
executable file
·48 lines (39 loc) · 1.57 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
#!/usr/bin/env python3
"""
Setup script to install binder CLI in virtual environment
This allows using 'binder' command without './' when venv is active
"""
import os
import sys
import subprocess
from pathlib import Path
def main():
"""Install binder CLI in development mode"""
project_root = Path(__file__).parent.parent # Go up from book/ to repo root
print("🔧 Setting up binder CLI in virtual environment...")
# Check if we're in a virtual environment
if not hasattr(sys, 'real_prefix') and not (hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix):
print("⚠️ Warning: Not in a virtual environment")
print(" Consider activating your venv first: source .venv/bin/activate")
response = input(" Continue anyway? (y/N): ")
if response.lower() != 'y':
print("❌ Setup cancelled")
return 1
try:
# Install in development mode
subprocess.run([
sys.executable, "-m", "pip", "install", "-e", "."
], cwd=project_root, check=True)
print("✅ Binder CLI installed successfully!")
print()
print("📋 You can now use:")
print(" binder help # Global command (when venv active)")
print(" ./binder help # Local script (always works)")
print()
print("🎯 Both commands do the same thing - use whichever you prefer!")
return 0
except subprocess.CalledProcessError as e:
print(f"❌ Installation failed: {e}")
return 1
if __name__ == "__main__":
sys.exit(main())