-
Notifications
You must be signed in to change notification settings - Fork 2
/
setup_venv.bat
76 lines (58 loc) · 1.88 KB
/
setup_venv.bat
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
@ECHO OFF
SET PYTHON_EXECUTABLE=notfound
@REM LOOP test
FOR %%P IN ("python") DO (
%%~P --version
IF NOT ERRORLEVEL 1 (
SET PYTHON_EXECUTABLE=%%~P
echo Using python command: %%~P
GOTO :start_django_project
)
)
IF PYTHON_EXECUTABLE=notfound (
echo Couldn't find a valid python command, please install python 3.8 or higher.
PAUSE
EXIT
)
:start_django_project
@REM Check for existing virtual environment
IF NOT EXIST venv\Scripts\activate.bat (
ECHO Creating venv ... This may take a while
%PYTHON_EXECUTABLE% -m venv venv
)
@REM Install requirements if not already installed
IF NOT EXIST venv\req_installed (
ECHO Installing requirements
"venv\Scripts\python" -m pip install --upgrade pip
"venv\Scripts\python" -m pip install -r requirements.txt
COPY NUL venv\req_installed
) ELSE (
ECHO Requirements are already installed
)
@REM Initialise Django
COPY "example_env.txt" ".env"
if EXIST teams_source/manage.py (
ECHO Making migrations
"venv\Scripts\python" teams_source/manage.py makemigrations
ECHO Running migrations
"venv\Scripts\python" teams_source/manage.py migrate
ECHO Loading fixtures
@REM LOOP through all fixtures in the fixtures folder in a for loop and load them one by one
for %%f in (teams_source\teams_app\fixtures\*.*) do (
ECHO Loading fixture %%f
"venv\Scripts\python" teams_source/manage.py loaddata %%f
)
IF NOT EXIST venv\user_created (
ECHO
ECHO Create an admin user
COPY NUL venv\user_created
"venv\Scripts\python" teams_source/manage.py createsuperuser
) ELSE (
ECHO Super User already created
)
@REM ECHO Collecting static files
@REM "venv\Scripts\python" teams_source/manage.py collectstatic --noinput
ECHO This process has successfully finished
ECHO Don't forget to activate virtual environment before running manage.py
)
PAUSE