-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinteractive_setup.py
51 lines (38 loc) · 1.44 KB
/
interactive_setup.py
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
import sys
import venv
import os
import subprocess
import questionary
def create_virtual_environment():
venv_dir = os.path.join(os.getcwd(), 'venv')
venv.create(venv_dir, with_pip=True)
activate_script = os.path.join(venv_dir, 'bin', 'activate')
return activate_script
def install_dependencies():
subprocess.run([sys.executable, '-m', 'pip', 'install',
'-r', 'requirements.txt'], check=True)
def global_installation():
subprocess.run([sys.executable, '-m', 'pip', 'install', '.'], check=True)
def docker_setup():
subprocess.run(['/usr/local/bin/docker', 'build', '-t',
'strava-to-trainingpeaks', '.'], check=True)
subprocess.run(['/usr/local/bin/docker', 'run', '-it', '--rm',
'strava-to-trainingpeaks'], check=True)
def main():
setup_method = questionary.select(
"Choose your preferred setup method:",
choices=["Global installation", "Virtual environment", "Docker"]
).ask()
if setup_method == "Global installation":
global_installation()
elif setup_method == "Virtual environment":
activate_script = create_virtual_environment()
install_dependencies()
print(
f"Virtual environment created. Activate it using 'source {activate_script}'")
elif setup_method == "Docker":
docker_setup()
else:
print("Invalid setup method selected.")
if __name__ == "__main__":
main()