-
Notifications
You must be signed in to change notification settings - Fork 83
/
init_repo.py
45 lines (29 loc) · 1.07 KB
/
init_repo.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
import os
import subprocess # nosec
import sys
def log(message: str) -> None:
print(f"[init_repo] {message}")
def check_python_version() -> bool:
version_info = sys.version_info
if version_info.major != 3:
return False
if version_info.minor < 6 or version_info.minor > 8:
return False
return True
def main() -> None:
if check_python_version():
log("Creating virtual environment")
subprocess.run("python -m venv .venv") # nosec
log("Installing python packages")
py_path = os.path.join(".venv", "Scripts", "python")
if not sys.platform.startswith("win"):
py_path = os.path.join(".venv", "bin", "python")
subprocess.run(f"{py_path} -m pip install --upgrade pip", shell=True) # nosec
# install packages
subprocess.run(f"{py_path} -m pip install -r requirements.txt", shell=True) # nosec
log("Python packages installed successfully")
log("DONE!")
else:
log("Supported python versions are 3.6-3.8")
if __name__ == "__main__":
main()