-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathVenvSetup.py
41 lines (35 loc) · 1.01 KB
/
VenvSetup.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
# -*- coding: utf-8 -*-
import os
import sys
import json
import platform
from os.path import join
def loadconfig(filepath):
print("loading config file...")
try:
with open(filepath, "r", encoding='utf-8') as load_f:
data = json.load(load_f)
except Exception as error:
print(error)
sys.exit(1)
return data
print("loading has finished.")
def start_venv(systemver):
if systemver == "Windows":
os.system("RD /S /Q .env")
else:
os.system("rm -rf .env")
print("Creating virtual environment...")
os.system("pip3 install virtualenv")
if systemver == "Linux":
os.system("apt-get install python3-venv")
os.system("python3 -m venv .env")
if systemver == "Windows":
os.system(".env\\Scripts\\activate")
else:
os.system("source .env/bin/activate")
print("Virtual environment has been created.")
if __name__=="__main__":
currentpath = os.getcwd()
systemver = platform.system()
start_venv(systemver)