forked from MPMG-DCC-UFMG/C01
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.py
57 lines (46 loc) · 1.78 KB
/
install.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
52
53
54
55
56
57
import os
import subprocess
import asyncio
import sys
subprocess.run(["pip", "install", "-U", "pip"])
subprocess.run(["pip", "install", "twisted"])
from twisted.internet import asyncioreactor
# Install Redis
if not os.path.isdir("redis-5.0.10"):
subprocess.run(["wget", "https://download.redis.io/releases/redis-5.0.10.tar.gz"])
subprocess.run(["tar", "-xvzf", "redis-5.0.10.tar.gz"])
subprocess.run(["make"], cwd="redis-5.0.10")
subprocess.run(["rm", "redis-5.0.10.tar.gz"])
# Install Kafka and Zookeeper
if not os.path.isdir("kafka_2.13-2.4.0"):
subprocess.run(["wget", "http://archive.apache.org/dist/kafka/2.4.0/kafka_2.13-2.4.0.tgz"])
subprocess.run(["tar", "-xzf", "kafka_2.13-2.4.0.tgz"])
subprocess.run(["rm", "kafka_2.13-2.4.0.tgz"])
# Overwrites zookeeper.properties
# Please, make sure you have zoo.properties in this directory.
# If not, make sure you have it on kafka_<version>/config/
if os.path.isfile("zoo.properties"):
os.rename("zoo.properties", "kafka_2.13-2.4.0/config/zoo.properties")
# Install modules from src directory, with their dependencies
src_folder = "src"
for folder in os.listdir(f"{src_folder}"):
if "setup.py" in os.listdir(f"{src_folder}/{folder}"):
print(f"Installing {folder}...")
subprocess.run(["pip", "install", f"{src_folder}/{folder}"])
print()
print(f"Installing other project dependencies...")
subprocess.run(["pip", "install", "-r" "requirements.txt"])
print()
try:
loop = asyncio.get_event_loop()
except RuntimeError:
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
try:
asyncioreactor.install(loop)
except Exception:
pass
print(f"Creating database...")
subprocess.run(["python", "manage.py", "makemigrations"])
subprocess.run(["python", "manage.py", "migrate"])
print()